drm: of: Lookup if child node has DSI panel or bridge
Subsystems (3)
PATCH v14 1/3 drm: of: Lookup if child node has DSI panel or bridge
Devices can also be child nodes when we also control that device through the upstream device (ie, MIPI-DCS for a MIPI-DSI device).
Unlike the drm_of_find_panel_or_bridge helper it requires a special case to lookup a child node of the given parent that isn't either port or ports.
Lookup for a child DSI node of the given parent that isn't either port or ports. If it is found then it will directly find the panel or bridge otherwise lookup for the child node with a given port and endpoint number as drm_of_find_panel_or_bridge does.
Supporting this feature via existing drm_of_find_panel_or_bridge found several issues while handling usecases.
Here is the previously failed attempt of similar and the same has been reverted later.
commit <80253168dbfd> ("drm: of: Lookup if child node has panel or bridge")
So, add a separate helper to handle this DSI use case.
Example OF graph representation of DSI host, which has port but not has ports and has child panel node.
dsi {
compatible = "allwinner,sun6i-a31-mipi-dsi";
#address-cells = <1>;
#size-cells = <0>;
port {
dsi_in_tcon0: endpoint {
remote-endpoint = <tcon0_out_dsi>;
};
panel@0 {
reg = <0>;
};
};Example OF graph representation of DSI host, which has ports but not has port and has child panel node.
dsi {
compatible = "samsung,exynos5433-mipi-dsi";
#address-cells = <1>;
#size-cells = <0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
dsi_to_mic: endpoint {
remote-endpoint = <&mic_to_dsi>;
};
};
};
panel@0 {
reg = <0>;
};
};Example OF graph representation of DSI host, which has neither a port nor a ports but has child panel node.
dsi0 {
compatible = "ste,mcde-dsi";
#address-cells = <1>;
#size-cells = <0>;
panel@0 {
reg = <0>;
};
};---
Changes for v14, v13, v12:
- none
Changes for v11:
- drop extra line
Changes for v10:
- new patch
drivers/gpu/drm/drm_of.c | 112 ++++++++++++++++++++++++++++++++------- include/drm/drm_of.h | 12 +++++ 2 files changed, 104 insertions(+), 20 deletions(-)
drivers/gpu/drm/drm_of.c +92 -20
@@ -216,6 +216,35 @@ int drm_of_encoder_active_endpoint(struct device_node *node, }EXPORT_SYMBOL_GPL (drm_of_encoder_active_endpoint); +static int of_drm_find_panel_or_bridge (struct device_node *remote, +struct drm_panel **panel, +struct drm_bridge **bridge) +{ +int ret = -EPROBE_DEFER ; + +if (panel) { + *panel =of_drm_find_panel (remote); +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 ; + } + } + +of_node_put (remote); +return ret; +} +/** * drm_of_find_panel_or_bridge - return connected panel or bridge device * @np: device tree node containing encoder output ports
@@ -238,7 +267,6 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,struct drm_panel **panel, struct drm_bridge **bridge) { - int ret = -EPROBE_DEFER; struct device_node *remote;if (!panel && !bridge)
@@ -259,30 +287,74 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,if (!remote)return -ENODEV ; -if (panel) { - *panel =of_drm_find_panel (remote); -if (!IS_ERR (*panel)) - ret =0 ; -else - *panel =NULL ; - } +return of_drm_find_panel_or_bridge (remote, panel, bridge); +} +EXPORT_SYMBOL_GPL (drm_of_find_panel_or_bridge); -/* 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 ; - } +/** +* drm_of_dsi_find_panel_or_bridge - return connected DSI 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 +* @panel: pointer to hold returned drm_panel +* @bridge: pointer to hold returned drm_bridge +* +* Lookup for a child DSI node of the given parent that isn't either port +* or ports. If it is found then it will directly find the panel or bridge +* otherwise lookup for the child node with a given port and endpoint number +* as drm_of_find_panel_or_bridge does. +* +* Lookup a given child DSI node or a DT node's port and endpoint number, +* find the connected node and return either the associated struct drm_panel +* or drm_bridge device. Either @panel or @bridge must not be NULL. +* +* Returns zero if successful, or one of the standard error codes if it fails. +*/ +int drm_of_dsi_find_panel_or_bridge (const struct device_node *np, +int port,int endpoint, +struct drm_panel **panel, +struct drm_bridge **bridge) +{ +struct device_node *remote; + +if (!panel && !bridge) +return -EINVAL ; +if (panel) + *panel =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). +* +* Lookup for a child node of the given parent that isn't either port +* or ports. +*/ +for_each_available_child_of_node (np, remote) { +if (of_node_name_eq (remote,"port" ) || +of_node_name_eq (remote,"ports" )) +continue ; + + goto of_find_panel_or_bridge; } -of_node_put (remote); -return ret; +/* +* of_graph_get_remote_node() produces a noisy error message if port +* node isn't found and the absence of the port is a legit case here, +* so at first we silently check whether graph presents in the +* device-tree node. +*/ +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 ; + +return of_drm_find_panel_or_bridge (remote, panel, bridge); } -EXPORT_SYMBOL_GPL (drm_of_find_panel_or_bridge); +EXPORT_SYMBOL_GPL (drm_of_dsi_find_panel_or_bridge);enum drm_of_lvds_pixels {DRM_OF_LVDS_EVEN =BIT (0 ),
include/drm/drm_of.h +12 -0
@@ -47,6 +47,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); +int drm_of_dsi_find_panel_or_bridge (const struct device_node *np, +int port,int endpoint, +struct drm_panel **panel, +struct drm_bridge **bridge);int drm_of_lvds_get_dual_link_pixel_order (const struct device_node *port1,const struct device_node *port2);int drm_of_lvds_get_data_mapping (const struct device_node *port);
@@ -99,6 +103,14 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np,return -EINVAL ; } +static inline int drm_of_dsi_find_panel_or_bridge (const struct device_node *np, +int port,int endpoint, +struct drm_panel **panel, +struct drm_bridge **bridge) +{ +return -EINVAL ; +} +static inline int drm_of_lvds_get_dual_link_pixel_order (const struct device_node *port1,const struct device_node *port2)
Signature · 1 line
2.25.1
PATCH v14 2/3 drm: bridge: panel: Add drmm_panel_bridge_add_nodrm
drmm_panel_bridge_add_nodrm is an another type of DRM-managed action helper with nodrm pointer.
DRM pointer is required to perform DRM-managed action,
- The conventional component-based drm bridges, the DRM pointer can access in component ops bind API.
- The non-component-based bridges (like host DSI bridges), the DRM pointer can access only when a specific bridge has been found via bridge->dev.
This drmm_panel_bridge_add_nodrm helper exclusively for the non-component-based bridges.
---
Changes for v14:
- new patch
drivers/gpu/drm/bridge/panel.c | 48 ++++++++++++++++++++++++++++------ include/drm/drm_bridge.h | 1 + 2 files changed, 41 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/panel.c +40 -8
@@ -378,6 +378,22 @@ static void drmm_drm_panel_bridge_release(struct drm_device *drm, void *ptr)drm_panel_bridge_remove (bridge); } +static struct drm_bridge * +drmm_panel_bridge_add_action (struct drm_device *drm,struct drm_panel *panel, +struct drm_bridge *bridge) +{ +int ret; + + ret =drmm_add_action_or_reset (drm, drmm_drm_panel_bridge_release, + bridge); +if (ret) +return ERR_PTR (ret); + + bridge->pre_enable_prev_first = panel->prepare_prev_first; + +return bridge; +} +/** * drmm_panel_bridge_add - Creates a DRM-managed &drm_bridge and * &drm_connector that just calls the
@@ -394,22 +410,38 @@ struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm, struct drm_panel *panel) {struct drm_bridge *bridge; -int ret; bridge =drm_panel_bridge_add_typed (panel, panel->connector_type);if (IS_ERR (bridge))return bridge; - ret =drmm_add_action_or_reset (drm, drmm_drm_panel_bridge_release, - bridge); -if (ret) -return ERR_PTR (ret); +return drmm_panel_bridge_add_action (drm, panel, bridge); +} +EXPORT_SYMBOL (drmm_panel_bridge_add); - bridge->pre_enable_prev_first = panel->prepare_prev_first; +/** +* drmm_panel_bridge_add_nodrm - Creates a DRM-managed &drm_bridge and +* &drm_connector that just calls the +* appropriate functions from &drm_panel +* with no @dev. +* +* @panel: The drm_panel being wrapped. Must be non-NULL. +* +* This is the DRM-managed version of drm_panel_bridge_add() which +* automatically calls drm_panel_bridge_remove() when @dev is cleaned +* up. +*/ +struct drm_bridge *drmm_panel_bridge_add_nodrm (struct drm_panel *panel) +{ +struct drm_bridge *bridge; -return bridge; + bridge =drm_panel_bridge_add_typed (panel, panel->connector_type); +if (IS_ERR (bridge)) +return bridge; + +return drmm_panel_bridge_add_action (bridge->dev, panel, bridge); } -EXPORT_SYMBOL (drmm_panel_bridge_add); +EXPORT_SYMBOL (drmm_panel_bridge_add_nodrm);/** * drm_panel_bridge_connector - return the connector for the panel bridge
include/drm/drm_bridge.h +1 -0
@@ -912,6 +912,7 @@ struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, u32 connector_type);struct drm_bridge *drmm_panel_bridge_add (struct drm_device *drm,struct drm_panel *panel); +struct drm_bridge *drmm_panel_bridge_add_nodrm (struct drm_panel *panel);struct drm_connector *drm_panel_bridge_connector (struct drm_bridge *bridge);#else static inline bool drm_bridge_is_panel (const struct drm_bridge *bridge)
Signature · 1 line
2.25.1
Re: [PATCH v14 2/3] drm: bridge: panel: Add drmm_panel_bridge_add_nodrm
Quoted 10 lines · Jagan Teki
drmm_panel_bridge_add_nodrmis an another type of DRM-managed action helper with nodrm pointer.DRM pointer is required to perform DRM-managed action,
- The conventional component-based drm bridges, the DRM pointer can access in component ops bind API.
- The non-component-based bridges (like host DSI bridges), the DRM pointer can access only when a specific bridge has been found viabridge->dev.
Quoted 8 lines
This
drmm_panel_bridge_add_nodrmhelper exclusively for the non-component-based bridges.Cc Maxime Ripard <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Linus Walleij <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Jagan Teki <[email protected]>
It's the third or fourth time I'm telling you this, and second time today.
You keep respinning that patch, but the issue lies in the samsung driver. Fix it and you won't need that helper.
Until then, you'll only get an automatic NAK from me, I'm done reviewing those patches over and over again, making the same comments that you'll just ignore.
Maxime
Re: [PATCH v14 2/3] drm: bridge: panel: Add drmm_panel_bridge_add_nodrm
Quoted 15 lines · Maxime Ripard
Quoted 13 lines · Jagan Teki
drmm_panel_bridge_add_nodrmis an another type of DRM-managed action helper with nodrm pointer.DRM pointer is required to perform DRM-managed action,
- The conventional component-based drm bridges, the DRM pointer can access in component ops bind API.
- The non-component-based bridges (like host DSI bridges), the DRM pointer can access only when a specific bridge has been found viabridge->dev.This
drmm_panel_bridge_add_nodrmhelper exclusively for the non-component-based bridges.
Quoted 8 lines
Quoted 5 lines
Cc Maxime Ripard <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Linus Walleij <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Jagan Teki <[email protected]>It's the third or fourth time I'm telling you this, and second time today.
Apologies for this.
Quoted 3 lines
You keep respinning that patch, but the issue lies in the samsung driver. Fix it and you won't need that helper.
This is where all get' stuck. You mentioned in a previous e-mail was,
"I'm not quite sure what you mean. You shouldn't retrieve the bridge from the attach hook but from the probe / bind ones. If that's not working for you, this is a bug in the documentation we should address."
If I understand correctly this would be the third case from the bridge documentation
https://dri.freedesktop.org/docs/drm/gpu/drm-kms-helpers.html#special-care-with-mipi-dsi-bridges
"The upstream driver uses the component framework and is a MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be controlled. This is the same situation as above, and can run mipi_dsi_host_register() in either its probe or bind hooks."
But the problem here, The samsung-dsim bridge common bridge across Exynos and i.MX8MM.
So, the
- Upstream Exynos is component-based and
- Upstream i.MX8MM is non-component-based
With this dual scenario, retrieving the bridge pointer in a bind will work for the Exynos case, and retrieving the bridge pointer in bridge. attach will work for i.MX8MM. This is what I mentioned deadlock scenario in a previous e-mail.
Hope you clear the real issue now.
Thanks,
Jagan.
PATCH v14 3/3 drm: bridge: panel: Add drmm_of_dsi_get_bridge helper
In reply to Jagan TekiAdd devm OF helper to return the next DSI bridge in the chain.
Unlike general bridge return helper drmm_of_get_bridge, this helper uses the dsi specific panel_or_bridge helper to find the next DSI device in the pipeline.
Helper lookup a given child DSI node or a DT node's port and endpoint number, find the connected node and return either the associated struct drm_panel or drm_bridge device.
---
Changes for v14:
- add drmm_of_dsi_get_bridge
Changes for v13, v12, v11:
- none
Changes for v10:
- new patch
drivers/gpu/drm/bridge/panel.c | 32 ++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 8 ++++++++ 2 files changed, 40 insertions(+)
drivers/gpu/drm/bridge/panel.c +32 -0
@@ -531,4 +531,36 @@ struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, }EXPORT_SYMBOL (drmm_of_get_bridge); +/** +* drmm_of_dsi_get_bridge - Return next DSI bridge in the chain +* @np: device tree node containing DSI output ports +* @port: port in the device tree node +* @endpoint: endpoint in the device tree node +* +* Given a DT node's port and endpoint number, finds the connected node +* and returns the associated DSI bridge if any, or creates and returns +* a DSI panel bridge instance if a panel is connected. +* +* Returns a drmm managed pointer to the DSI bridge if successful, or +* an error pointer otherwise. +*/ +struct drm_bridge *drmm_of_dsi_get_bridge (struct device_node *np, +u32 port,u32 endpoint) +{ +struct drm_bridge *bridge; +struct drm_panel *panel; +int ret; + + ret =drm_of_dsi_find_panel_or_bridge (np, port, endpoint, + &panel, &bridge); +if (ret) +return ERR_PTR (ret); + +if (panel) + bridge =drmm_panel_bridge_add_nodrm (panel); + +return bridge; +} +EXPORT_SYMBOL (drmm_of_dsi_get_bridge); +#endif
include/drm/drm_bridge.h +8 -0
@@ -932,6 +932,8 @@ struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node u32 port, u32 endpoint);struct drm_bridge *drmm_of_get_bridge (struct drm_device *drm,struct device_node *node,u32 port,u32 endpoint); +struct drm_bridge *drmm_of_dsi_get_bridge (struct device_node *node, +u32 port,u32 endpoint);#else static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node,
@@ -948,6 +950,12 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, {return ERR_PTR (-ENODEV ); } + +static inline struct drm_bridge * +drmm_of_dsi_get_bridge (struct device_node *node,u32 port,u32 endpoint) +{ +return ERR_PTR (-ENODEV ); +}#endif #endif
Signature · 1 line
2.25.1