MLK-21553 drm/bridge: it6263: Do hotplug detect quickly in unforced case
authorLiu Ying <victor.liu@nxp.com>
Thu, 25 Apr 2019 07:18:03 +0000 (15:18 +0800)
committerLiu Ying <victor.liu@nxp.com>
Fri, 26 Apr 2019 02:21:56 +0000 (10:21 +0800)
We should avoid expensive, destructive operations during automated hotplug
probing, otherwise, it could cause flickering on other running displays.
So, let's check the parameter 'force' of ->detect() and do the appropriate
detection accordingly.

Reported-by: Luo Danwei <danwei.luo@nxp.com>
Tested-by: Luo Danwei <danwei.luo@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
drivers/gpu/drm/bridge/it6263.c

index 3c314c4..4548c27 100644 (file)
@@ -457,24 +457,36 @@ static void it6263_hdmi_config(struct it6263 *it6263)
                                                HDMI_COLOR_DEPTH_24);
 }
 
+static bool it6263_hpd_is_connected(struct it6263 *it6263)
+{
+       unsigned int status;
+
+       regmap_read(it6263->hdmi_regmap, HDMI_REG_SYS_STATUS, &status);
+
+       return !!(status & HPDETECT);
+}
+
 static enum drm_connector_status
 it6263_connector_detect(struct drm_connector *connector, bool force)
 {
        struct it6263 *it6263 = connector_to_it6263(connector);
-       unsigned int status;
        int i;
 
-       /*
-        * FIXME: We read status tens of times to workaround
-        * cable detection failure issue at boot time on some
-        * platforms.
-        * Spin on this for up to one second.
-        */
-       for (i = 0; i < 100; i++) {
-               regmap_read(it6263->hdmi_regmap, HDMI_REG_SYS_STATUS, &status);
-               if (status & HPDETECT)
+       if (force) {
+               /*
+                * FIXME: We read status tens of times to workaround
+                * cable detection failure issue at boot time on some
+                * platforms.
+                * Spin on this for up to one second.
+                */
+               for (i = 0; i < 100; i++) {
+                       if (it6263_hpd_is_connected(it6263))
+                               return connector_status_connected;
+                       usleep_range(5000, 10000);
+               }
+       } else {
+               if (it6263_hpd_is_connected(it6263))
                        return connector_status_connected;
-               usleep_range(5000, 10000);
        }
 
        return connector_status_disconnected;