Commit 67bae5f2 authored by Paul Kocialkowski's avatar Paul Kocialkowski Committed by Maxime Ripard

drm: of: Properly try all possible cases for bridge/panel detection

While bridge/panel detection was initially relying on the usual
port/ports-based of graph detection, it was recently changed to
perform the lookup on any child node that is not port/ports
instead when such a node is available, with no fallback on the
usual way.

This results in breaking detection when a child node is present
but does not contain any panel or bridge node, even when the
usual port/ports-based of graph is there.

In order to support both situations properly, this commit reworks
the logic to try both options and not just one of the two: it will
only return -EPROBE_DEFER when both have failed.
Signed-off-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Fixes: 80253168 ("drm: of: Lookup if child node has panel or bridge")
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20220329132732.628474-1-paul.kocialkowski@bootlin.com
parent c42ee39c
...@@ -219,6 +219,29 @@ int drm_of_encoder_active_endpoint(struct device_node *node, ...@@ -219,6 +219,29 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
} }
EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
static int find_panel_or_bridge(struct device_node *node,
struct drm_panel **panel,
struct drm_bridge **bridge)
{
if (panel) {
*panel = of_drm_find_panel(node);
if (!IS_ERR(*panel))
return 0;
/* Clear the panel pointer in case of error. */
*panel = NULL;
}
/* No panel found yet, check for a bridge next. */
if (bridge) {
*bridge = of_drm_find_bridge(node);
if (*bridge)
return 0;
}
return -EPROBE_DEFER;
}
/** /**
* drm_of_find_panel_or_bridge - return connected panel or bridge device * drm_of_find_panel_or_bridge - return connected panel or bridge device
* @np: device tree node containing encoder output ports * @np: device tree node containing encoder output ports
...@@ -241,66 +264,44 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, ...@@ -241,66 +264,44 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
struct drm_panel **panel, struct drm_panel **panel,
struct drm_bridge **bridge) struct drm_bridge **bridge)
{ {
int ret = -EPROBE_DEFER; struct device_node *node;
struct device_node *remote; int ret;
if (!panel && !bridge) if (!panel && !bridge)
return -EINVAL; return -EINVAL;
if (panel) if (panel)
*panel = NULL; *panel = NULL;
if (bridge)
/** *bridge = NULL;
* Devices can also be child nodes when we also control that device
* through the upstream device (ie, MIPI-DCS for a MIPI-DSI device). /* Check for a graph on the device node first. */
* if (of_graph_is_present(np)) {
* Lookup for a child node of the given parent that isn't either port node = of_graph_get_remote_node(np, port, endpoint);
* or ports. if (node) {
*/ ret = find_panel_or_bridge(node, panel, bridge);
for_each_available_child_of_node(np, remote) { of_node_put(node);
if (of_node_name_eq(remote, "port") ||
of_node_name_eq(remote, "ports")) if (!ret)
continue; return 0;
}
goto of_find_panel_or_bridge;
} }
/* /* Otherwise check for any child node other than port/ports. */
* of_graph_get_remote_node() produces a noisy error message if port for_each_available_child_of_node(np, node) {
* node isn't found and the absence of the port is a legit case here, if (of_node_name_eq(node, "port") ||
* so at first we silently check whether graph presents in the of_node_name_eq(node, "ports"))
* device-tree node. continue;
*/
if (!of_graph_is_present(np))
return -ENODEV;
remote = of_graph_get_remote_node(np, port, endpoint);
of_find_panel_or_bridge:
if (!remote)
return -ENODEV;
if (panel) { ret = find_panel_or_bridge(node, panel, bridge);
*panel = of_drm_find_panel(remote); of_node_put(node);
if (!IS_ERR(*panel))
ret = 0;
else
*panel = NULL;
}
/* No panel found yet, check for a bridge next. */
if (bridge) {
if (ret) {
*bridge = of_drm_find_bridge(remote);
if (*bridge)
ret = 0;
} else {
*bridge = NULL;
}
/* Stop at the first found occurrence. */
if (!ret)
return 0;
} }
of_node_put(remote); return -EPROBE_DEFER;
return ret;
} }
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge); EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment