drm/omap: dss: Add functions to connect and disconnect devices
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 28 Feb 2018 15:30:30 +0000 (17:30 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:26 +0000 (16:13 +0300)
The omap_dss_device objects model display components and are connected
at runtime to create display pipelines. The connect and disconnect
operations implemented by each component contain lots of duplicate code.
As a first step towards fixing this, create new functions to wrap the
direct calls to those operations and use them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
17 files changed:
drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
drivers/gpu/drm/omapdrm/displays/connector-dvi.c
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
drivers/gpu/drm/omapdrm/displays/panel-dpi.c
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/omap_drv.c

index a94868d9398bc531fba70c4c06ca1c0ec8a4abc2..41ba3c5dbe7db9aabc0c9cab4d8c7aad7e69040e 100644 (file)
@@ -59,7 +59,7 @@ static int tvc_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -79,7 +79,7 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 021e3b651c893a868266beda726277237ed0fe5b..f193bbda550c4e6099bf7d1aaeeac9e7de8a0fd5 100644 (file)
@@ -72,7 +72,7 @@ static int dvic_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -90,7 +90,7 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index b528bd51ada3282ec52a4548f56bacb8b3bedefb..014554afbb0d15569010701b4b29f37438bc3253 100644 (file)
@@ -69,7 +69,7 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -89,7 +89,7 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 37982ffe0ad408a3f832d04783471ff10f4ce94a..752b565987c1ec83fc92f311623b7e5586b944e2 100644 (file)
@@ -50,7 +50,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -82,7 +82,7 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
        dst->src = NULL;
        dssdev->dst = NULL;
 
-       in->ops->disconnect(in, &ddata->dssdev);
+       omapdss_device_disconnect(in, &ddata->dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 1fbc5559e54f2f8afec99f33858744da8d3e3ea2..a8660e5e5ffc679f775fbe34147b2b6562b36838 100644 (file)
@@ -44,7 +44,7 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -74,7 +74,7 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
        dst->src = NULL;
        dssdev->dst = NULL;
 
-       in->ops->disconnect(in, &ddata->dssdev);
+       omapdss_device_disconnect(in, &ddata->dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 21a4a2fd42bf6ae53878c7e39300eb65aabad8b0..640f15b8846725daaf2505a1b2eeba036f32d6bd 100644 (file)
@@ -49,7 +49,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -85,7 +85,7 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
        dst->src = NULL;
        dssdev->dst = NULL;
 
-       in->ops->disconnect(in, &ddata->dssdev);
+       omapdss_device_disconnect(in, &ddata->dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 15042351ace373e6917ba691afef77667415616a..9875195013367ad4d09f641c2be8906690e2856c 100644 (file)
@@ -50,7 +50,7 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -68,7 +68,7 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 4296f4ca39fe0be4760eedc2754e6e0ae3018e76..b7cd2ef17fbb7449c650f46fbdce1e9033e1e9d7 100644 (file)
@@ -772,7 +772,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                dev_err(dev, "Failed to connect to video source\n");
                goto err_connect;
@@ -796,7 +796,7 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
 err_vc_id:
        in->ops->dsi.release_vc(in, ddata->channel);
 err_req_vc:
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 err_connect:
        omap_dss_put_device(in);
        return r;
@@ -811,7 +811,7 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
                return;
 
        in->ops->dsi.release_vc(in, ddata->channel);
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 8e293708261c196e651de9f51a331ae0c68f6b85..e4a3b5828bf904e80a87caf1bfe5d143f39c5a50 100644 (file)
@@ -131,7 +131,7 @@ static int lb035q02_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -151,7 +151,7 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 7296c794326c7b94ce03ea65f6369e78c41371ee..e89dd32a2a602d12e096a3a38b05bd8f7fd60ec9 100644 (file)
@@ -127,7 +127,7 @@ static int nec_8048_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -145,7 +145,7 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 00291b9ecfde75dedaa85e3cc15f9b42242a30b4..d0451cfab7f88ad0098e9659e58291cf325199a1 100644 (file)
@@ -73,7 +73,7 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -91,7 +91,7 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 694ac42b72475e6447a564598e0dc9ba4f5bc956..9033e9d25b7f96324c0fe64e419669e0f52da59a 100644 (file)
@@ -522,7 +522,7 @@ static int acx565akm_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -540,7 +540,7 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index 3cd1e4ccd43a4e9cdc577535a53a4dcebe3a88aa..8865459b6c90169922b9ec7610854583d214588b 100644 (file)
@@ -181,7 +181,7 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -199,7 +199,7 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index de1140314a7ad53cef0d191eb0ab59a4cc7e41a7..1daba7a60a9c0652564498a7cbfec3148f31d962 100644 (file)
@@ -352,7 +352,7 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev)
                return PTR_ERR(in);
        }
 
-       r = in->ops->connect(in, dssdev);
+       r = omapdss_device_connect(in, dssdev);
        if (r) {
                omap_dss_put_device(in);
                return r;
@@ -370,7 +370,7 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_connected(dssdev))
                return;
 
-       in->ops->disconnect(in, dssdev);
+       omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
        ddata->in = NULL;
index df6cb1ac43c8cc99cf58d2dc990e2babf134bf57..576fd3d1325949d5450e2ea05c83ac237dc1c2ab 100644 (file)
@@ -102,6 +102,26 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
        return NULL;
 }
 
+int omapdss_device_connect(struct omap_dss_device *src,
+                          struct omap_dss_device *dst)
+{
+       if (src->driver)
+               return src->driver->connect(src);
+       else
+               return src->ops->connect(src, dst);
+}
+EXPORT_SYMBOL_GPL(omapdss_device_connect);
+
+void omapdss_device_disconnect(struct omap_dss_device *src,
+                              struct omap_dss_device *dst)
+{
+       if (src->driver)
+               src->driver->disconnect(src);
+       else
+               src->ops->disconnect(src, dst);
+}
+EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
+
 /* -----------------------------------------------------------------------------
  * Components Handling
  */
index fb6c9d522013768f4d8010395f12d3f0ca481b8f..58bd6948bcde9d6bb430f83c0fa044ad7421fa05 100644 (file)
@@ -498,6 +498,10 @@ void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
 struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
                                                    unsigned int port);
+int omapdss_device_connect(struct omap_dss_device *src,
+                          struct omap_dss_device *dst);
+void omapdss_device_disconnect(struct omap_dss_device *src,
+                              struct omap_dss_device *dst);
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
index e411d46bd803b152ddc7977f27a0b06c486f7647..6bc4b01c8e9c5b5a6b4cc41aeefdb022aeffed91 100644 (file)
@@ -159,7 +159,7 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev)
        for (i = 0; i < priv->num_dssdevs; i++) {
                struct omap_dss_device *dssdev = priv->dssdevs[i];
 
-               dssdev->driver->disconnect(dssdev);
+               omapdss_device_disconnect(dssdev, NULL);
                priv->dssdevs[i] = NULL;
                omap_dss_put_device(dssdev);
        }
@@ -189,7 +189,7 @@ static int omap_connect_dssdevs(struct drm_device *ddev)
                return -EPROBE_DEFER;
 
        for_each_dss_dev(dssdev) {
-               r = dssdev->driver->connect(dssdev);
+               r = omapdss_device_connect(dssdev, NULL);
                if (r == -EPROBE_DEFER) {
                        omap_dss_put_device(dssdev);
                        goto cleanup;