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@xxxxxxxxxxxxxxxx> --- drivers/gpu/drm/omapdrm/dss/dpi.c | 25 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/dsi.c | 25 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 25 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 25 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 +-- drivers/gpu/drm/omapdrm/dss/output.c | 17 +++++------------ drivers/gpu/drm/omapdrm/dss/sdi.c | 25 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/venc.c | 25 +++++++++++-------------- 8 files changed, 72 insertions(+), 98 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index 97f6bba1a510..3c4863e351f0 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -619,24 +619,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, @@ -663,6 +652,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; @@ -695,6 +685,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; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index a5516d6e8017..53a32e20c3bd 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -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; diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index d73a924c745c..1d852928ed6f 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -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, @@ -707,6 +696,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; @@ -724,6 +714,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; diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index 28c68c96db56..d3752c9defe4 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -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, @@ -699,6 +688,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; @@ -716,6 +706,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; diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index d52c5cde70ac..be59b9b28d81 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -515,8 +515,7 @@ int omap_dss_get_num_overlays(void); #define for_each_dss_output(d) \ while ((d = omapdss_device_get_next(d, false, true)) != 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); diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c index 96d74218cf91..be544dd48bf4 100644 --- a/drivers/gpu/drm/omapdrm/dss/output.c +++ b/drivers/gpu/drm/omapdrm/dss/output.c @@ -26,23 +26,16 @@ 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) { diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c index f6e26a0a7efd..5c197688c0f9 100644 --- a/drivers/gpu/drm/omapdrm/dss/sdi.c +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c @@ -258,24 +258,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, @@ -301,6 +290,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; @@ -319,6 +309,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; diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index dfdd066a0ee5..216b31cc5ec1 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -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; -- Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel