From: Baihan Li <libai...@huawei.com>

The issue is that drm_connector_helper_detect_from_ddc() returns wrong
status when plugging or unplugging the monitor. To perform a DP detect(),
add read_dpcd_cap() and read_sink_count() to detect DP monitor, and 200ms
delay doesn't need anymore.

Fixes: 3c7623fb5bb6 ("drm/hisilicon/hibmc: Enable this hot plug detect of irq 
feature")
Signed-off-by: Baihan Li <libai...@huawei.com>
Signed-off-by: Yongbang Shi <shiyongb...@huawei.com>
---
ChangeLog:
v4 -> v5:
  - fix the commit message and DP detect_ctx(), suggested by Dmitry Baryshkov.
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
index d06832e62e96..123372ae2d40 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
@@ -12,6 +12,7 @@
 
 #include "hibmc_drm_drv.h"
 #include "dp/dp_hw.h"
+#include "dp/dp_comm.h"
 
 #define DP_MASKED_SINK_HPD_PLUG_INT    BIT(2)
 
@@ -34,7 +35,16 @@ static int hibmc_dp_connector_get_modes(struct drm_connector 
*connector)
 static int hibmc_dp_detect(struct drm_connector *connector,
                           struct drm_modeset_acquire_ctx *ctx, bool force)
 {
-       mdelay(200);
+       struct hibmc_dp *dp = to_hibmc_dp(connector);
+       int ret;
+
+       ret = drm_dp_read_dpcd_caps(&dp->aux, dp->dp_dev->dpcd);
+       if (ret)
+               return connector_status_disconnected;
+
+       ret = drm_dp_read_sink_count(&dp->aux);
+       if (ret <= 0)
+               return connector_status_disconnected;
 
        return drm_connector_helper_detect_from_ddc(connector, ctx, force);
 }
-- 
2.33.0

Reply via email to