drm/omap: hdmi5: Simplify EDID read
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 26 Feb 2020 11:25:04 +0000 (13:25 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 26 Feb 2020 11:32:05 +0000 (13:32 +0200)
Now that the omap_dss_device EDID read operation has been removed,
simplify the bridge-based EDID access by merging multiple functions
together.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200226112514.12455-45-laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/hdmi5.c

index 6cb709c..4d4c1fa 100644 (file)
@@ -307,50 +307,6 @@ static void hdmi_core_disable(struct omap_hdmi *hdmi)
        mutex_unlock(&hdmi->lock);
 }
 
-static struct edid *
-hdmi_do_read_edid(struct omap_hdmi *hdmi,
-                 struct edid *(*read)(struct omap_hdmi *hdmi,
-                                      struct drm_connector *connector),
-                 struct drm_connector *connector)
-{
-       struct edid *edid;
-       bool need_enable;
-       int idlemode;
-       int r;
-
-       need_enable = hdmi->core_enabled == false;
-
-       if (need_enable) {
-               r = hdmi_core_enable(hdmi);
-               if (r)
-                       return NULL;
-       }
-
-       mutex_lock(&hdmi->lock);
-       r = hdmi_runtime_get(hdmi);
-       BUG_ON(r);
-
-       idlemode = REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
-       /* No-idle mode */
-       REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
-
-       hdmi5_core_ddc_init(&hdmi->core);
-
-       edid = read(hdmi, connector);
-
-       hdmi5_core_ddc_uninit(&hdmi->core);
-
-       REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
-
-       hdmi_runtime_put(hdmi);
-       mutex_unlock(&hdmi->lock);
-
-       if (need_enable)
-               hdmi_core_disable(hdmi);
-
-       return (struct edid *)edid;
-}
-
 /* -----------------------------------------------------------------------------
  * DRM Bridge Operations
  */
@@ -469,18 +425,46 @@ static void hdmi5_bridge_disable(struct drm_bridge *bridge,
        mutex_unlock(&hdmi->lock);
 }
 
-static struct edid *hdmi5_bridge_read_edid(struct omap_hdmi *hdmi,
-                                          struct drm_connector *connector)
-{
-       return drm_do_get_edid(connector, hdmi5_core_ddc_read, &hdmi->core);
-}
-
 static struct edid *hdmi5_bridge_get_edid(struct drm_bridge *bridge,
                                          struct drm_connector *connector)
 {
        struct omap_hdmi *hdmi = drm_bridge_to_hdmi(bridge);
+       struct edid *edid;
+       bool need_enable;
+       int idlemode;
+       int r;
+
+       need_enable = hdmi->core_enabled == false;
+
+       if (need_enable) {
+               r = hdmi_core_enable(hdmi);
+               if (r)
+                       return NULL;
+       }
+
+       mutex_lock(&hdmi->lock);
+       r = hdmi_runtime_get(hdmi);
+       BUG_ON(r);
 
-       return hdmi_do_read_edid(hdmi, hdmi5_bridge_read_edid, connector);
+       idlemode = REG_GET(hdmi->wp.base, HDMI_WP_SYSCONFIG, 3, 2);
+       /* No-idle mode */
+       REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, 1, 3, 2);
+
+       hdmi5_core_ddc_init(&hdmi->core);
+
+       edid = drm_do_get_edid(connector, hdmi5_core_ddc_read, &hdmi->core);
+
+       hdmi5_core_ddc_uninit(&hdmi->core);
+
+       REG_FLD_MOD(hdmi->wp.base, HDMI_WP_SYSCONFIG, idlemode, 3, 2);
+
+       hdmi_runtime_put(hdmi);
+       mutex_unlock(&hdmi->lock);
+
+       if (need_enable)
+               hdmi_core_disable(hdmi);
+
+       return (struct edid *)edid;
 }
 
 static const struct drm_bridge_funcs hdmi5_bridge_funcs = {