Thread (15 messages) 15 messages, 4 authors, 2018-08-24
STALE2957d

Revision v8 of 5 in this series.

Revisions (5)
  1. v5 [diff vs current]
  2. v6 [diff vs current]
  3. v7 [diff vs current]
  4. v8 current
  5. v9 [diff vs current]

[PATCH v8 3/4] drm/atmel-hlcdc: iterate over all output endpoints

From: Peter Rosin <hidden>
Date: 2018-08-10 13:04:30
Also in: dri-devel, linux-arm-kernel, lkml
Subsystem: drm drivers, drm drivers and misc gpu patches, drm drivers for atmel hlcdc, the rest · Maintainers: David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Manikandan Muralidharan, Dharma Balasubiramani, Linus Torvalds

This enables more flexible devicetrees. You can e.g. have two output
nodes where one is not enabled, without the ordering affecting things.

Prior to this patch the active node had to have endpoint id zero.

Signed-off-by: Peter Rosin <redacted>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 32 ++++++++++++++++++------
 1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 8db51fb131db..16c1b2f54b42 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -31,14 +31,16 @@ static const struct drm_encoder_funcs atmel_hlcdc_panel_encoder_funcs = {
 	.destroy = drm_encoder_cleanup,
 };
 
-static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
+static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
+				       struct of_endpoint *endpoint)
 {
 	struct drm_encoder *encoder;
 	struct drm_panel *panel;
 	struct drm_bridge *bridge;
 	int ret;
 
-	ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
+	ret = drm_of_find_panel_or_bridge(dev->dev->of_node,
+					  endpoint->port, endpoint->id,
 					  &panel, &bridge);
 	if (ret)
 		return ret;
@@ -77,13 +79,29 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
 
 int atmel_hlcdc_create_outputs(struct drm_device *dev)
 {
-	int endpoint, ret = 0;
-
-	for (endpoint = 0; !ret; endpoint++)
-		ret = atmel_hlcdc_attach_endpoint(dev, endpoint);
+	struct of_endpoint endpoint;
+	struct device_node *node = NULL;
+	int count = 0;
+	int ret = 0;
+
+	for_each_endpoint_of_node(dev->dev->of_node, node) {
+		of_graph_parse_endpoint(node, &endpoint);
+
+		if (endpoint.port)
+			continue;
+
+		ret = atmel_hlcdc_attach_endpoint(dev, &endpoint);
+		if (ret == -ENODEV)
+			continue;
+		if (ret) {
+			of_node_put(node);
+			break;
+		}
+		count++;
+	}
 
 	/* At least one device was successfully attached.*/
-	if (ret == -ENODEV && endpoint)
+	if (ret == -ENODEV && count)
 		return 0;
 
 	return ret;
-- 
2.11.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help