[PATCH 11/29] drm/omap: Factor out common init/cleanup code for output devices
Sebastian Reichel
sebastian.reichel at collabora.com
Sun Dec 9 22:01:43 UTC 2018
Hi,
On Wed, Dec 05, 2018 at 05:00:04PM +0200, Laurent Pinchart wrote:
> All the internal encoders share common init and cleanup code. Factor it
> out to separate functions.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.com>
-- Sebastian
> drivers/gpu/drm/omapdrm/dss/dpi.c | 17 +++--------------
> drivers/gpu/drm/omapdrm/dss/dsi.c | 17 +++--------------
> drivers/gpu/drm/omapdrm/dss/hdmi4.c | 17 +++--------------
> drivers/gpu/drm/omapdrm/dss/hdmi5.c | 17 +++--------------
> drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ++-
> drivers/gpu/drm/omapdrm/dss/output.c | 18 ++++++++++++++++--
> drivers/gpu/drm/omapdrm/dss/sdi.c | 17 +++--------------
> drivers/gpu/drm/omapdrm/dss/venc.c | 17 +++--------------
> 8 files changed, 36 insertions(+), 87 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 74e841a2b4eb..0db01cadf09f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
> out->ops = &dpi_ops;
> out->owner = THIS_MODULE;
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node *port)
> struct dpi_data *dpi = port->data;
> struct omap_dss_device *out = &dpi->output;
>
> - if (out->next)
> - omapdss_device_put(out->next);
> omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
> }
>
> static const struct soc_device_attribute dpi_soc_devices[] = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 99b34e409159..0ba4670fd6cf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5122,19 +5122,9 @@ static int dsi_init_output(struct dsi_data *dsi)
> | DRM_BUS_FLAG_DE_HIGH
> | DRM_BUS_FLAG_SYNC_NEGEDGE;
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -5145,9 +5135,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
> {
> struct omap_dss_device *out = &dsi->output;
>
> - if (out->next)
> - omapdss_device_put(out->next);
> omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
> }
>
> static int dsi_probe_of(struct dsi_data *dsi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 6f88fb4d6344..60792981a33f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
> out->of_ports = BIT(0);
> out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
> {
> struct omap_dss_device *out = &hdmi->output;
>
> - if (out->next)
> - omapdss_device_put(out->next);
> omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
> }
>
> static int hdmi4_probe_of(struct omap_hdmi *hdmi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 28cf1c32b158..d7d33b4d2bed 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -671,19 +671,9 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
> out->of_ports = BIT(0);
> out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -694,9 +684,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
> {
> struct omap_dss_device *out = &hdmi->output;
>
> - if (out->next)
> - omapdss_device_put(out->next);
> omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
> }
>
> static int hdmi5_probe_of(struct omap_hdmi *hdmi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 28e24d65f211..723a9b5060f5 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -501,7 +501,8 @@ 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_validate(struct omap_dss_device *out);
> +int omapdss_device_init_output(struct omap_dss_device *out);
> +void omapdss_device_cleanup_output(struct omap_dss_device *out);
>
> typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
> int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 18505bc70f7e..0ac400a521f3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -24,8 +24,15 @@
> #include "dss.h"
> #include "omapdss.h"
>
> -int omapdss_output_validate(struct omap_dss_device *out)
> +int omapdss_device_init_output(struct omap_dss_device *out)
> {
> + out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> + if (IS_ERR(out->next)) {
> + if (PTR_ERR(out->next) != -EPROBE_DEFER)
> + dev_err(out->dev, "failed to find video sink\n");
> + return PTR_ERR(out->next);
> + }
> +
> if (out->next && out->output_type != out->next->type) {
> dev_err(out->dev, "output type and display type don't match\n");
> return -EINVAL;
> @@ -33,7 +40,14 @@ int omapdss_output_validate(struct omap_dss_device *out)
>
> return 0;
> }
> -EXPORT_SYMBOL(omapdss_output_validate);
> +EXPORT_SYMBOL(omapdss_device_init_output);
> +
> +void omapdss_device_cleanup_output(struct omap_dss_device *out)
> +{
> + if (out->next)
> + omapdss_device_put(out->next);
> +}
> +EXPORT_SYMBOL(omapdss_device_cleanup_output);
>
> int dss_install_mgr_ops(struct dss_device *dss,
> const struct dss_mgr_ops *mgr_ops,
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 20e88c6e3d98..58c17566a4cb 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -281,19 +281,9 @@ static int sdi_init_output(struct sdi_device *sdi)
> out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE /* 15.5.9.1.2 */
> | DRM_BUS_FLAG_SYNC_POSEDGE;
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 1);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -302,9 +292,8 @@ static int sdi_init_output(struct sdi_device *sdi)
>
> static void sdi_uninit_output(struct sdi_device *sdi)
> {
> - if (sdi->output.next)
> - omapdss_device_put(sdi->output.next);
> omapdss_device_unregister(&sdi->output);
> + omapdss_device_cleanup_output(&sdi->output);
> }
>
> int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index dc4133718875..3fc776c45c4f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -752,19 +752,9 @@ static int venc_init_output(struct venc_device *venc)
> out->owner = THIS_MODULE;
> out->of_ports = BIT(0);
>
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
> return r;
> - }
>
> omapdss_device_register(out);
>
> @@ -773,9 +763,8 @@ static int venc_init_output(struct venc_device *venc)
>
> static void venc_uninit_output(struct venc_device *venc)
> {
> - if (venc->output.next)
> - omapdss_device_put(venc->output.next);
> omapdss_device_unregister(&venc->output);
> + omapdss_device_cleanup_output(&venc->output);
> }
>
> static int venc_probe_of(struct venc_device *venc)
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20181209/a3c9fcbf/attachment-0001.sig>
More information about the dri-devel
mailing list