This commit declares DRM_BRIDGE_OP_HPD for the analogix_dp bridge, adds the hpd_enable/hpd_disable bridge callbacks and reports the hotplug events through drm_bridge_hpd_notify() with the status read from the HPD GPIO pin or the controller registers.
The DRM_BRIDGE_OP_HPD capability is declared only for the platforms which support hotplug detection (the GPIO HPD mode, or the native HPD mode on RK3576 and RK3588), since the drm core stops polling the connector once DRM_BRIDGE_OP_HPD is declared. Signed-off-by: Damon Ding <[email protected]> --- Changes in v6: - Declare DRM_BRIDGE_OP_HPD only for the platforms which support hotplug detection, since the drm core stops polling the connector once DRM_BRIDGE_OP_HPD is declared. (Sashiko) - Add Tested-by tag. Changes in v7: - Set the bridge ops after the chain is attached, as the DRM_BRIDGE_OP_HPD declaration previously preceded the force_connected_mode initialization, leaving the hotplug detection broken on fixed panels with a wired HPD GPIO. (Sashiko) - Drop the Tested-by tags, as the design of this patch changed significantly in this version. --- .../drm/bridge/analogix/analogix_dp_core.c | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index a48f8f3726da..dcec2ac7508a 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -31,7 +31,6 @@ #include <drm/drm_edid.h> #include <drm/drm_of.h> #include <drm/drm_print.h> -#include <drm/drm_probe_helper.h> #include <video/of_display_timing.h> @@ -748,9 +747,13 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) hpd_detected = (irq_type & DP_IRQ_TYPE_HP_CABLE_IN) || (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT); if (hpd_detected) { + enum drm_connector_status status; + dev_dbg(dp->dev, "Detected cable status changed!\n"); - if (dp->drm_dev) - drm_helper_hpd_irq_event(dp->drm_dev); + + status = analogix_dp_get_plug_in_status(dp) == 0 ? connector_status_connected : + connector_status_disconnected; + drm_bridge_hpd_notify(&dp->bridge, status); } if (!dp->hpd_gpiod) @@ -1284,6 +1287,14 @@ static void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge, DRM_ERROR("Failed to enable psr (%d)\n", ret); } +static void analogix_dp_bridge_hpd_enable(struct drm_bridge *bridge) +{ +} + +static void analogix_dp_bridge_hpd_disable(struct drm_bridge *bridge) +{ +} + static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, @@ -1296,6 +1307,8 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { .attach = analogix_dp_bridge_attach, .edid_read = analogix_dp_bridge_edid_read, .detect = analogix_dp_bridge_detect, + .hpd_enable = analogix_dp_bridge_hpd_enable, + .hpd_disable = analogix_dp_bridge_hpd_disable, }; static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp) @@ -1614,7 +1627,6 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) return ret; } - bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT; bridge->of_node = dp->dev->of_node; bridge->type = DRM_MODE_CONNECTOR_eDP; ret = devm_drm_bridge_add(dp->dev, &dp->bridge); @@ -1627,6 +1639,10 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) goto err_unregister_aux; } + bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT; + if (analogix_dp_supports_hpd(dp)) + bridge->ops |= DRM_BRIDGE_OP_HPD; + if (analogix_dp_require_pm_for_hpd_irq(dp)) { ret = pm_runtime_resume_and_get(dp->dev); if (ret) -- 2.34.1
