[PATCH v14 3/3] drm: bridge: panel: Add drmm_of_dsi_get_bridge helper
Jagan Teki
jagan at amarulasolutions.com
Mon Feb 27 17:32:31 UTC 2023
Add 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.
Cc: Maxime Ripard <mripard at kernel.org>
Cc: Laurent Pinchart <Laurent.pinchart at ideasonboard.com>
Cc: Linus Walleij <linus.walleij at linaro.org>
Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
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(+)
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index d235a3843fcb..92fc7143a249 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -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
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index acc118bab758..a88391cf64b8 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -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
--
2.25.1
More information about the dri-devel
mailing list