drm/omap: dss: Move display type validation to initialization time
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 5 Mar 2018 23:25:13 +0000 (01:25 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:28 +0000 (16:13 +0300)
The display type is validated when the display is connected to the DSS
output. We already have all the information we need for validation when
initializing the outputs. Move validation to output initialization to
simplify pipeline connection handling.

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>
drivers/gpu/drm/omapdrm/dss/dpi.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/omapdrm/dss/hdmi4.c
drivers/gpu/drm/omapdrm/dss/hdmi5.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/dss/output.c
drivers/gpu/drm/omapdrm/dss/sdi.c
drivers/gpu/drm/omapdrm/dss/venc.c

index 6bd0fd12883e8241d337702592fbdc10aaaf90da..eeeea936f889c0ebb46128719f979685c6857b27 100644 (file)
@@ -620,24 +620,13 @@ static int dpi_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst->next);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void dpi_disconnect(struct omap_dss_device *src,
@@ -664,6 +653,7 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
 {
        struct omap_dss_device *out = &dpi->output;
        u32 port_num = 0;
+       int r;
 
        of_property_read_u32(port, "reg", &port_num);
        dpi->id = port_num <= 2 ? port_num : 0;
@@ -696,6 +686,13 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;
index 0e88ae1178f75a07e5b7fc7cbb0be707ed8c7b63..9c617e35efd1f7fdfb43edf6308a415c754ef83a 100644 (file)
@@ -4890,24 +4890,13 @@ static int dsi_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst->next);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void dsi_disconnect(struct omap_dss_device *src,
@@ -5147,6 +5136,7 @@ static const struct component_ops dsi_component_ops = {
 static int dsi_init_output(struct dsi_data *dsi)
 {
        struct omap_dss_device *out = &dsi->output;
+       int r;
 
        out->dev = dsi->dev;
        out->id = dsi->module_id == 0 ?
@@ -5166,6 +5156,13 @@ static int dsi_init_output(struct dsi_data *dsi)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;
index 9f883669e71bc20aec2165e396e1bcc4883e1610..22f8b74f5bf5dd86f77985d9085810d339e4101c 100644 (file)
@@ -437,24 +437,13 @@ static int hdmi_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst->next);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void hdmi_disconnect(struct omap_dss_device *src,
@@ -717,6 +706,7 @@ static const struct component_ops hdmi4_component_ops = {
 static int hdmi4_init_output(struct omap_hdmi *hdmi)
 {
        struct omap_dss_device *out = &hdmi->output;
+       int r;
 
        out->dev = &hdmi->pdev->dev;
        out->id = OMAP_DSS_OUTPUT_HDMI;
@@ -734,6 +724,13 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;
index beb70b1fab947d83efba86167fd910d9e391b3e5..d8592d02a58d4f317115676e1c0330d7f6627642 100644 (file)
@@ -442,24 +442,13 @@ static int hdmi_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst->next);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void hdmi_disconnect(struct omap_dss_device *src,
@@ -709,6 +698,7 @@ static const struct component_ops hdmi5_component_ops = {
 static int hdmi5_init_output(struct omap_hdmi *hdmi)
 {
        struct omap_dss_device *out = &hdmi->output;
+       int r;
 
        out->dev = &hdmi->pdev->dev;
        out->id = OMAP_DSS_OUTPUT_HDMI;
@@ -726,6 +716,13 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;
index 80c4c2ae306ac999f044fbf75248815110490313..600ac7c2572442b1ffe931546f36f10ec0cde5e8 100644 (file)
@@ -521,8 +521,7 @@ int omap_dss_get_num_overlays(void);
 
 #define for_each_dss_output(d) \
        while ((d = omapdss_device_get_next(d, OMAP_DSS_DEVICE_TYPE_OUTPUT)) != NULL)
-int omapdss_output_set_device(struct omap_dss_device *out,
-               struct omap_dss_device *dssdev);
+int omapdss_output_validate(struct omap_dss_device *out);
 int omapdss_output_unset_device(struct omap_dss_device *out);
 
 typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
index 96d74218cf91d0565521f5537c3d3d796b1c8257..be544dd48bf4c9fc031a65ee4c8c5de65305afa6 100644 (file)
 
 static DEFINE_MUTEX(output_lock);
 
-int omapdss_output_set_device(struct omap_dss_device *out,
-               struct omap_dss_device *dssdev)
+int omapdss_output_validate(struct omap_dss_device *out)
 {
-       int r = 0;
-
-       mutex_lock(&output_lock);
-
-       if (out->output_type != dssdev->type) {
+       if (out->next && out->output_type != out->next->type) {
                dev_err(out->dev, "output type and display type don't match\n");
-               r = -EINVAL;
+               return -EINVAL;
        }
 
-       mutex_unlock(&output_lock);
-
-       return r;
+       return 0;
 }
-EXPORT_SYMBOL(omapdss_output_set_device);
+EXPORT_SYMBOL(omapdss_output_validate);
 
 int omapdss_output_unset_device(struct omap_dss_device *out)
 {
index c32e8ed2a96febcc5c5e44198f5cf26b986e9295..2101a697a08ad12c618ab46c02b6a8da79d80f20 100644 (file)
@@ -261,24 +261,13 @@ static int sdi_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void sdi_disconnect(struct omap_dss_device *src,
@@ -304,6 +293,7 @@ static const struct omap_dss_device_ops sdi_ops = {
 static int sdi_init_output(struct sdi_device *sdi)
 {
        struct omap_dss_device *out = &sdi->output;
+       int r;
 
        out->dev = &sdi->pdev->dev;
        out->id = OMAP_DSS_OUTPUT_SDI;
@@ -322,6 +312,13 @@ static int sdi_init_output(struct sdi_device *sdi)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;
index db0aa8f1ff7cc411dd6480bd425c6ced019a5193..e673f3e78c6910c85a86b53fb03db78a70db7099 100644 (file)
@@ -700,24 +700,13 @@ static int venc_connect(struct omap_dss_device *src,
        if (r)
                return r;
 
-       r = omapdss_output_set_device(dst, dst->next);
+       r = omapdss_device_connect(dst->dss, dst, dst->next);
        if (r) {
-               DSSERR("failed to connect output to new device: %s\n",
-                               dst->name);
-               goto err_mgr_disconnect;
+               dss_mgr_disconnect(dst);
+               return r;
        }
 
-       r = omapdss_device_connect(dst->dss, dst, dst->next);
-       if (r)
-               goto err_output_unset;
-
        return 0;
-
-err_output_unset:
-       omapdss_output_unset_device(dst);
-err_mgr_disconnect:
-       dss_mgr_disconnect(dst);
-       return r;
 }
 
 static void venc_disconnect(struct omap_dss_device *src,
@@ -787,6 +776,7 @@ static const struct component_ops venc_component_ops = {
 static int venc_init_output(struct venc_device *venc)
 {
        struct omap_dss_device *out = &venc->output;
+       int r;
 
        out->dev = &venc->pdev->dev;
        out->id = OMAP_DSS_OUTPUT_VENC;
@@ -804,6 +794,13 @@ static int venc_init_output(struct venc_device *venc)
                return PTR_ERR(out->next);
        }
 
+       r = omapdss_output_validate(out);
+       if (r) {
+               omapdss_device_put(out->next);
+               out->next = NULL;
+               return r;
+       }
+
        omapdss_device_register(out);
 
        return 0;