[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191207203553.286017-3-robdclark@gmail.com>
Date: Sat, 7 Dec 2019 12:35:51 -0800
From: Rob Clark <robdclark@...il.com>
To: dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
aarch64-laptops@...ts.linaro.org
Cc: Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Vasily Khoruzhick <anarsoul@...il.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Jeffrey Hugo <jhugo@...eaurora.org>,
Rob Clark <robdclark@...omium.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Sean Paul <sean@...rly.run>, David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 2/4] drm/of: add support to find any enabled endpoint
From: Rob Clark <robdclark@...omium.org>
To handle the case where there are multiple panel endpoints, only one of
which is enabled/installed, add support for a wildcard endpoint value to
request finding whichever endpoint is enabled.
Signed-off-by: Rob Clark <robdclark@...omium.org>
---
drivers/gpu/drm/drm_of.c | 41 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 0ca58803ba46..2baf44e401b8 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -219,11 +219,44 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
}
EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
+static int find_enabled_endpoint(const struct device_node *node, u32 port)
+{
+ struct device_node *endpoint_node, *remote;
+ u32 endpoint = 0;
+
+ for (endpoint = 0; ; endpoint++) {
+ endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint);
+ if (!endpoint_node) {
+ pr_debug("No more endpoints!\n");
+ return -ENODEV;
+ }
+
+ remote = of_graph_get_remote_port_parent(endpoint_node);
+ of_node_put(endpoint_node);
+ if (!remote) {
+ pr_debug("no valid remote node\n");
+ continue;
+ }
+
+ if (!of_device_is_available(remote)) {
+ pr_debug("not available for remote node\n");
+ of_node_put(remote);
+ continue;
+ }
+
+ pr_debug("found enabled endpoint %d for %s\n", endpoint, remote->name);
+ of_node_put(remote);
+ return endpoint;
+ }
+
+ return -ENODEV;
+}
+
/**
* drm_of_find_panel_or_bridge - return connected panel or bridge device
* @np: device tree node containing encoder output ports
* @port: port in the device tree node
- * @endpoint: endpoint in the device tree node
+ * @endpoint: endpoint in the device tree node, or -1 to find an enabled endpoint
* @panel: pointer to hold returned drm_panel
* @bridge: pointer to hold returned drm_bridge
*
@@ -246,6 +279,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
if (panel)
*panel = NULL;
+ if (endpoint == -1) {
+ endpoint = find_enabled_endpoint(np, port);
+ if (endpoint < 0)
+ return endpoint;
+ }
+
remote = of_graph_get_remote_node(np, port, endpoint);
if (!remote)
return -ENODEV;
--
2.23.0
Powered by blists - more mailing lists