[PATCH v14 2/3] drm: bridge: panel: Add drmm_panel_bridge_add_nodrm
Jagan Teki
jagan at amarulasolutions.com
Mon Feb 27 17:32:30 UTC 2023
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.
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:
- new patch
drivers/gpu/drm/bridge/panel.c | 48 ++++++++++++++++++++++++++++------
include/drm/drm_bridge.h | 1 +
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index e8aae3cdc73d..d235a3843fcb 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -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
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 42f86327b40a..acc118bab758 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -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)
--
2.25.1
More information about the dri-devel
mailing list