Skip to content

Commit 169466d

Browse files
anderssonmripard
authored andcommitted
Revert "drm: of: Properly try all possible cases for bridge/panel detection"
Commit '80253168dbfd ("drm: of: Lookup if child node has panel or bridge")' introduced the ability to describe a panel under a display controller without having to use a graph to connect the controller to its single child panel (or bridge). The implementation of this would find the first non-graph node and attempt to acquire the related panel or bridge. This prevents cases where any other child node, such as a aux bus for a DisplayPort controller, or an opp-table to find the referenced panel. Commit '67bae5f28c89 ("drm: of: Properly try all possible cases for bridge/panel detection")' attempted to solve this problem by not bypassing the graph reference lookup before attempting to find the panel or bridge. While this does solve the case where a proper graph reference is present, it does not allow the caller to distinguish between a yet-to-be-probed panel or bridge and the absence of a reference to a panel. One such case is a DisplayPort controller that on some boards have an explicitly described reference to a panel, but on others have a discoverable DisplayPort display attached (which doesn't need to be expressed in DeviceTree). This reverts commit '67bae5f28c89 ("drm: of: Properly try all possible cases for bridge/panel detection")', as a step towards reverting commit '80253168dbfd ("drm: of: Lookup if child node has panel or bridge")'. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20220420231230.58499-1-bjorn.andersson@linaro.org
1 parent 3d0b93d commit 169466d

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

drivers/gpu/drm/drm_of.c

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -214,29 +214,6 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
214214
}
215215
EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
216216

217-
static int find_panel_or_bridge(struct device_node *node,
218-
struct drm_panel **panel,
219-
struct drm_bridge **bridge)
220-
{
221-
if (panel) {
222-
*panel = of_drm_find_panel(node);
223-
if (!IS_ERR(*panel))
224-
return 0;
225-
226-
/* Clear the panel pointer in case of error. */
227-
*panel = NULL;
228-
}
229-
230-
/* No panel found yet, check for a bridge next. */
231-
if (bridge) {
232-
*bridge = of_drm_find_bridge(node);
233-
if (*bridge)
234-
return 0;
235-
}
236-
237-
return -EPROBE_DEFER;
238-
}
239-
240217
/**
241218
* drm_of_find_panel_or_bridge - return connected panel or bridge device
242219
* @np: device tree node containing encoder output ports
@@ -259,44 +236,66 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
259236
struct drm_panel **panel,
260237
struct drm_bridge **bridge)
261238
{
262-
struct device_node *node;
263-
int ret;
239+
int ret = -EPROBE_DEFER;
240+
struct device_node *remote;
264241

265242
if (!panel && !bridge)
266243
return -EINVAL;
267-
268244
if (panel)
269245
*panel = NULL;
270-
if (bridge)
271-
*bridge = NULL;
272-
273-
/* Check for a graph on the device node first. */
274-
if (of_graph_is_present(np)) {
275-
node = of_graph_get_remote_node(np, port, endpoint);
276-
if (node) {
277-
ret = find_panel_or_bridge(node, panel, bridge);
278-
of_node_put(node);
279-
280-
if (!ret)
281-
return 0;
282-
}
283-
}
284246

285-
/* Otherwise check for any child node other than port/ports. */
286-
for_each_available_child_of_node(np, node) {
287-
if (of_node_name_eq(node, "port") ||
288-
of_node_name_eq(node, "ports"))
247+
/**
248+
* Devices can also be child nodes when we also control that device
249+
* through the upstream device (ie, MIPI-DCS for a MIPI-DSI device).
250+
*
251+
* Lookup for a child node of the given parent that isn't either port
252+
* or ports.
253+
*/
254+
for_each_available_child_of_node(np, remote) {
255+
if (of_node_name_eq(remote, "port") ||
256+
of_node_name_eq(remote, "ports"))
289257
continue;
290258

291-
ret = find_panel_or_bridge(node, panel, bridge);
292-
of_node_put(node);
259+
goto of_find_panel_or_bridge;
260+
}
261+
262+
/*
263+
* of_graph_get_remote_node() produces a noisy error message if port
264+
* node isn't found and the absence of the port is a legit case here,
265+
* so at first we silently check whether graph presents in the
266+
* device-tree node.
267+
*/
268+
if (!of_graph_is_present(np))
269+
return -ENODEV;
270+
271+
remote = of_graph_get_remote_node(np, port, endpoint);
272+
273+
of_find_panel_or_bridge:
274+
if (!remote)
275+
return -ENODEV;
276+
277+
if (panel) {
278+
*panel = of_drm_find_panel(remote);
279+
if (!IS_ERR(*panel))
280+
ret = 0;
281+
else
282+
*panel = NULL;
283+
}
284+
285+
/* No panel found yet, check for a bridge next. */
286+
if (bridge) {
287+
if (ret) {
288+
*bridge = of_drm_find_bridge(remote);
289+
if (*bridge)
290+
ret = 0;
291+
} else {
292+
*bridge = NULL;
293+
}
293294

294-
/* Stop at the first found occurrence. */
295-
if (!ret)
296-
return 0;
297295
}
298296

299-
return -EPROBE_DEFER;
297+
of_node_put(remote);
298+
return ret;
300299
}
301300
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
302301

0 commit comments

Comments
 (0)