Hi, On Sat, May 26, 2018 at 08:25:11PM +0300, Laurent Pinchart wrote: > 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> > --- Reviewed-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxxxx> -- Sebastian > 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 dc50a220382c..831de09770a3 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dpi.c > +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c > @@ -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; > 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 9f883669e71b..22f8b74f5bf5 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, > @@ -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; > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c > index beb70b1fab94..d8592d02a58d 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, > @@ -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; > diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h > index d88e302fbc8d..7add73a5479a 100644 > --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h > +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h > @@ -517,8 +517,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
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel