All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 15/49] drm/omap: Factor out common init/cleanup code for output devices
Date: Fri, 11 Jan 2019 05:50:46 +0200	[thread overview]
Message-ID: <20190111035120.20668-16-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20190111035120.20668-1-laurent.pinchart@ideasonboard.com>

All the internal encoders share common init and cleanup code. Factor it
out to separate functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 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 4dad2bf6b551..4ac325e664b5 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5131,19 +5131,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);
 
@@ -5154,9 +5144,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 fc82b8f545ae..fbdeeaa521d6 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -493,7 +493,8 @@ int omap_dss_get_num_overlays(void);
 #define for_each_dss_output(d) \
 	while ((d = omapdss_device_next_output(d)) != NULL)
 struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
-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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-01-11  3:51 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11  3:50 [PATCH v2 00/49] omapdrm: drm_bridge and drm_panel support Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 01/49] drm/atomic: Constify mode argument to mode_valid_path() Laurent Pinchart
2019-01-14 11:10   ` Tomi Valkeinen
2019-02-09  2:01   ` Sebastian Reichel
2019-01-11  3:50 ` [PATCH v2 02/49] drm/omap: dsi: Fix crash in DSI debug dumps Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 03/49] drm/omap: dsi: Fix OF platform depopulate Laurent Pinchart
2019-01-14 11:40   ` Tomi Valkeinen
2019-01-14 14:32     ` Laurent Pinchart
2019-02-09  2:03   ` Sebastian Reichel
2019-01-11  3:50 ` [PATCH v2 04/49] drm/omap: dsi: Hack-fix DSI bus flags Laurent Pinchart
2019-02-09  2:04   ` Sebastian Reichel
2019-01-11  3:50 ` [PATCH v2 05/49] drm/omap: Remove declaration of nonexisting function Laurent Pinchart
2019-01-14 11:48   ` Tomi Valkeinen
2019-01-11  3:50 ` [PATCH v2 06/49] drm/omap: Remove unused kobj field from struct omap_dss_device Laurent Pinchart
2019-01-14 11:49   ` Tomi Valkeinen
2019-01-11  3:50 ` [PATCH v2 07/49] drm/omap: venc: Remove wss_data field from venc_device structure Laurent Pinchart
2019-01-14 11:50   ` Tomi Valkeinen
2019-01-11  3:50 ` [PATCH v2 08/49] drm/omap: Use atomic suspend/resume helpers Laurent Pinchart
2019-01-14 12:13   ` Tomi Valkeinen
2019-01-11  3:50 ` [PATCH v2 09/49] drm/omap: Move common display enable/disable code to encoder Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 10/49] drm/omap: Remove connection checks from internal encoders .enable() Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 11/49] drm/omap: Remove connection checks from display .enable() and .remove() Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 12/49] drm/omap: Remove enable " Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 13/49] drm/omap: Reverse direction of the DSS device enable/disable operations Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 14/49] drm/omap: Remove omap_dss_device dst field Laurent Pinchart
2019-01-11  3:50 ` Laurent Pinchart [this message]
2019-01-11  3:50 ` [PATCH v2 16/49] drm/omap: Expose DRM modes instead of timings in display devices Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 17/49] drm/omap: Merge display .get_modes() and .get_size() operations Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 18/49] drm/omap: Add a dss device operation flag for .get_modes() Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 19/49] drm/omap: venc: List both PAL and NTSC modes Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 20/49] drm/omap: Don't pass display pointer to encoder init function Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 21/49] drm/omap: Move display alias ID to omap_drm_pipeline Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 22/49] drm/omap: Don't store display pointer in omap_connector structure Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 23/49] drm/omap: panel-dsi-cm: Store source pointer internally Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 24/49] drm/omap: Notify all devices in the pipeline of output disconnection Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 25/49] drm/omap: Remove src field from omap_dss_device structure Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 26/49] drm/omap: Move DISPC timing checks to CRTC .mode_valid() operation Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 27/49] drm/omap: venc: Simplify mode setting by caching configuration Laurent Pinchart
2019-01-11  3:50 ` [PATCH v2 28/49] drm/omap: Factor out common mode validation code Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 29/49] drm/omap: Pass drm_display_mode to .check_timings() and .set_timings() Laurent Pinchart
2019-02-09  2:33   ` Sebastian Reichel
2019-01-11  3:51 ` [PATCH v2 30/49] drm/omap: venc: Use drm_display_mode natively Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 31/49] drm/omap: Store pixel clock instead of full mode in DPI and SDI encoders Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 32/49] drm/omap: Simplify OF lookup of DSS devices Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 33/49] drm/omap: Refactor initialization sequence Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 34/49] drm/omap: Merge omap_dss_device type and output_type fields Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 35/49] drm: Clarify definition of the DRM_BUS_FLAG_(PIXDATA|SYNC)_* macros Laurent Pinchart
2019-01-11  8:47   ` Stefan Agner
2019-01-11  9:23   ` Daniel Vetter
2019-01-12  1:13     ` Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 36/49] drm: Use new DRM_BUS_FLAG_*_(DRIVE|SAMPLE)_(POS|NEG)EDGE flags Laurent Pinchart
2019-01-11  8:53   ` Stefan Agner
2019-01-11  3:51 ` [PATCH v2 37/49] drm/bridge: use bus flags in bridge timings Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 38/49] dt-bindings: display: tfp410: Add bus parameters properties Laurent Pinchart
2019-01-15 21:37   ` Rob Herring
2019-01-11  3:51 ` [PATCH v2 39/49] drm/bridge: ti-tfp410: Set connector type based on DT connector node Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 40/49] drm/bridge: ti-tfp410: Add support for the powerdown GPIO Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 41/49] drm/bridge: ti-tfp410: Report input bus config through bridge timings Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 42/49] dt-bindings: Add vendor prefix for OSD Displays Laurent Pinchart
2019-01-14 12:15   ` Tomi Valkeinen
2019-01-15 21:38   ` Rob Herring
2019-01-11  3:51 ` [PATCH v2 43/49] dt-bindings: display: Add OSD Displays OSD070T1718-19TS panel binding Laurent Pinchart
2019-01-14 12:15   ` Tomi Valkeinen
2019-01-15 21:39   ` Rob Herring
2019-02-08 11:19     ` [PATCH v2.1 " Laurent Pinchart
2019-02-25 23:27       ` Rob Herring
2019-01-11  3:51 ` [PATCH v2 44/49] drm/panel: simple: Add OSD070T1718-19TS panel support Laurent Pinchart
2019-01-14 12:15   ` Tomi Valkeinen
2019-01-11  3:51 ` [PATCH v2 45/49] drm/omap: Add support for drm_bridge Laurent Pinchart
2019-01-18 10:33   ` Tomi Valkeinen
2019-02-08 15:20     ` Laurent Pinchart
2019-02-11  9:32       ` Tomi Valkeinen
2019-02-09  2:00   ` Sebastian Reichel
2019-02-09  3:26   ` Sebastian Reichel
2019-02-11  7:50   ` [PATCH v2.1 " Laurent Pinchart
2019-01-11  3:51 ` [PATCH v2 46/49] drm/omap: Add support for drm_panel Laurent Pinchart
2019-02-09  3:26   ` Sebastian Reichel
2019-01-11  3:51 ` [PATCH v2 47/49] drm/omap: Whitelist DT nodes to fixup with omapdss, prefix Laurent Pinchart
2019-02-09  3:26   ` Sebastian Reichel
2019-01-11  3:51 ` [PATCH v2 48/49] drm/omap: Remove TFP410 and DVI connector drivers Laurent Pinchart
2019-02-09  3:26   ` Sebastian Reichel
2019-01-11  3:51 ` [PATCH v2 49/49] drm/omap: Remove panel-dpi driver Laurent Pinchart
2019-02-09  3:27   ` Sebastian Reichel
2019-02-06 11:41 ` [PATCH v2 00/49] omapdrm: drm_bridge and drm_panel support Tomi Valkeinen
2019-02-09  3:32 ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190111035120.20668-16-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.