[PATCH v2 36/60] drm/omap: dss: Extend omapdss_of_find_source_for_first_ep() to sinks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The omapdss_of_find_source_for_first_ep() function locates the source
corresponding to the first endpoint of the first port of a device node.
We can easily extend it to locate sinks as well by passing the port
number as a parameter. This will be useful to find sinks in encoders
drivers.

Extend the function and rename it to omapdss_of_find_connected_device()
to reflect its new extended purpose.

Additionally, it is useful to differentiate between failures to return
the connected device because no link exists in the device tree for the
requested port, or because the connected device as described in the
device tree is invalid or not probed yet. Return NULL in the first case
and an error code in the second case, and update the callers
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c     |  6 +++---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c           |  6 +++---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c          |  6 +++---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c          |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c          |  2 +-
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c       |  2 +-
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c               |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c            |  6 +++---
 .../gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c    |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c    |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c    |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c    |  6 +++---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c    |  6 +++---
 drivers/gpu/drm/omapdrm/dss/dss-of.c                       | 14 +++++++-------
 drivers/gpu/drm/omapdrm/dss/omapdss.h                      |  2 +-
 16 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index b960c4d0e84d..4f32c8ddcfbd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -47,10 +47,10 @@ static int tvc_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(ddata->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 8ff674bf75e6..6eae18b42b82 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -61,10 +61,10 @@ static int dvic_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 2afaa2ca602b..b3f88ab0cd6e 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -57,10 +57,10 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(ddata->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(ddata->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index eb0ebb850114..904ebec5f5e1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -37,7 +37,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
 	if (IS_ERR(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		return PTR_ERR(src);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index fb767d674297..cd442f66fa1d 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -33,7 +33,7 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
 	if (IS_ERR(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		return PTR_ERR(src);
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index cd6da0e8f76a..d21d0829774e 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -42,7 +42,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
 	if (IS_ERR(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		return PTR_ERR(src);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 97ebfb51192e..049959309063 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -39,10 +39,10 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 92f521930c2c..db2e841f1b07 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -763,10 +763,10 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index 46ca37dd9205..76f9064106d4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -121,10 +121,10 @@ static int lb035q02_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index fec2de915200..0c64a734f28f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
@@ -116,10 +116,10 @@ static int nec_8048_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
index 0ff8f00a95cb..87baa8982f55 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
@@ -62,10 +62,10 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index 8d2bf114f47e..ac05cd252b1c 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -511,10 +511,10 @@ static int acx565akm_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
index 38d87a276261..acfa69b74ffa 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
@@ -170,10 +170,10 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
index c30b0809012a..383ffd0d21f2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
@@ -341,10 +341,10 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *src;
 	int r;
 
-	src = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
-	if (IS_ERR(src)) {
+	src = omapdss_of_find_connected_device(dssdev->dev->of_node, 0);
+	if (IS_ERR_OR_NULL(src)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
-		return PTR_ERR(src);
+		return src ? PTR_ERR(src) : -EINVAL;
 	}
 
 	r = omapdss_device_connect(dssdev->dss, src, dssdev);
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index 771b20db2d98..0422597ac6b0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -47,7 +47,7 @@ dss_of_port_get_parent_device(struct device_node *port)
 }
 
 struct omap_dss_device *
-omapdss_of_find_source_for_first_ep(struct device_node *node)
+omapdss_of_find_connected_device(struct device_node *node, unsigned int port)
 {
 	struct device_node *src_node;
 	struct device_node *src_port;
@@ -56,27 +56,27 @@ omapdss_of_find_source_for_first_ep(struct device_node *node)
 	u32 port_number = 0;
 
 	/* Get the endpoint... */
-	ep = of_graph_get_endpoint_by_regs(node, 0, 0);
+	ep = of_graph_get_endpoint_by_regs(node, port, 0);
 	if (!ep)
-		return ERR_PTR(-EINVAL);
+		return NULL;
 
 	/* ... and its remote port... */
 	src_port = of_graph_get_remote_port(ep);
 	of_node_put(ep);
 	if (!src_port)
-		return ERR_PTR(-EINVAL);
+		return NULL;
 
 	/* ... and the remote port's number and parent... */
 	of_property_read_u32(src_port, "reg", &port_number);
 	src_node = dss_of_port_get_parent_device(src_port);
 	of_node_put(src_port);
 	if (!src_node)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
-	/* ... and finally the source. */
+	/* ... and finally the connected device. */
 	src = omapdss_find_device_by_port(src_node, port_number);
 	of_node_put(src_node);
 
 	return src ? src : ERR_PTR(-EPROBE_DEFER);
 }
-EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);
+EXPORT_SYMBOL_GPL(omapdss_of_find_connected_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c2d9ebdec3d1..dc2f8167f61b 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -532,7 +532,7 @@ static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
 }
 
 struct omap_dss_device *
-omapdss_of_find_source_for_first_ep(struct device_node *node);
+omapdss_of_find_connected_device(struct device_node *node, unsigned int port);
 
 enum dss_writeback_channel {
 	DSS_WB_LCD1_MGR =	0,
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux