From d90a0d9f9409a35edc8be9c0298d80912a7e3d1b Mon Sep 17 00:00:00 2001 From: Wyon Bi Date: Tue, 25 Aug 2020 10:49:43 +0800 Subject: [PATCH] video/drm: analogix_dp: Implement detect callback Change-Id: I1e6746768092747920afcb3af07e36c1ecae9856 Signed-off-by: Wyon Bi --- drivers/video/drm/analogix_dp.c | 11 +++++++++++ drivers/video/drm/analogix_dp.h | 3 ++- drivers/video/drm/analogix_dp_reg.c | 21 +++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/video/drm/analogix_dp.c b/drivers/video/drm/analogix_dp.c index a6ff9f9fdd..5488b7d272 100644 --- a/drivers/video/drm/analogix_dp.c +++ b/drivers/video/drm/analogix_dp.c @@ -900,11 +900,20 @@ static int analogix_dp_connector_disable(struct display_state *state) return 0; } +static int analogix_dp_connector_detect(struct display_state *state) +{ + struct connector_state *conn_state = &state->conn_state; + struct analogix_dp_device *dp = dev_get_priv(conn_state->dev); + + return analogix_dp_detect(dp); +} + static const struct rockchip_connector_funcs analogix_dp_connector_funcs = { .init = analogix_dp_connector_init, .get_edid = analogix_dp_connector_get_edid, .enable = analogix_dp_connector_enable, .disable = analogix_dp_connector_disable, + .detect = analogix_dp_connector_detect, }; static int analogix_dp_probe(struct udevice *dev) @@ -933,6 +942,8 @@ static int analogix_dp_probe(struct udevice *dev) return ret; } + dp->force_hpd = dev_read_bool(dev, "force-hpd"); + dp->plat_data.dev_type = ROCKCHIP_DP; dp->plat_data.subdev_type = pdata->chip_type; /* diff --git a/drivers/video/drm/analogix_dp.h b/drivers/video/drm/analogix_dp.h index adde139fd7..9cfc994a46 100644 --- a/drivers/video/drm/analogix_dp.h +++ b/drivers/video/drm/analogix_dp.h @@ -1075,6 +1075,7 @@ struct analogix_dp_device { void *grf; struct reset_ctl reset; struct gpio_desc hpd_gpio; + bool force_hpd; struct video_info video_info; struct link_train link_train; struct drm_display_mode *mode; @@ -1105,7 +1106,7 @@ enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp); void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp); void analogix_dp_reset_aux(struct analogix_dp_device *dp); void analogix_dp_init_aux(struct analogix_dp_device *dp); -int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp); +int analogix_dp_detect(struct analogix_dp_device *dp); void analogix_dp_enable_sw_function(struct analogix_dp_device *dp); int analogix_dp_start_aux_transaction(struct analogix_dp_device *dp); int analogix_dp_write_byte_to_dpcd(struct analogix_dp_device *dp, diff --git a/drivers/video/drm/analogix_dp_reg.c b/drivers/video/drm/analogix_dp_reg.c index 6204d0f1f3..6f6b9098b4 100644 --- a/drivers/video/drm/analogix_dp_reg.c +++ b/drivers/video/drm/analogix_dp_reg.c @@ -495,20 +495,21 @@ void analogix_dp_init_aux(struct analogix_dp_device *dp) analogix_dp_write(dp, ANALOGIX_DP_FUNC_EN_2, reg); } -int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp) +int analogix_dp_detect(struct analogix_dp_device *dp) { u32 reg; - if (dm_gpio_is_valid(&dp->hpd_gpio)) { - if (dm_gpio_get_value(&dp->hpd_gpio)) - return 0; - } else { - reg = analogix_dp_read(dp, ANALOGIX_DP_SYS_CTL_3); - if (reg & HPD_STATUS) - return 0; - } + if (dm_gpio_is_valid(&dp->hpd_gpio)) + return dm_gpio_get_value(&dp->hpd_gpio); - return -EINVAL; + if (dp->force_hpd) + analogix_dp_force_hpd(dp); + + reg = analogix_dp_read(dp, ANALOGIX_DP_SYS_CTL_3); + if (reg & HPD_STATUS) + return 1; + + return 0; } void analogix_dp_enable_sw_function(struct analogix_dp_device *dp)