[PATCH v2 15/21] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper
Boris Brezillon
boris.brezillon at collabora.com
Mon Aug 26 15:26:43 UTC 2019
Will be useful for bridge drivers that want to do bus format
negotiation with their neighbours.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
Changes in v2:
* Fix the kerneldoc
* Drop the !bridge || !bridge->encoder check
---
drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++++++
include/drm/drm_bridge.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 7f7e0ea5b06c..9c74b285da9d 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -238,6 +238,23 @@ drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge)
}
EXPORT_SYMBOL(drm_bridge_chain_get_next_bridge);
+/**
+ * drm_bridge_chain_get_prev_bridge() - Get the previous bridge in the chain
+ * @bridge: bridge object
+ *
+ * RETURNS:
+ * the previous bridge in the chain, or NULL if @bridge is the last.
+ */
+struct drm_bridge *
+drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge)
+{
+ if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
+ return NULL;
+
+ return list_prev_entry(bridge, chain_node);
+}
+EXPORT_SYMBOL(drm_bridge_chain_get_prev_bridge);
+
/**
* DOC: bridge callbacks
*
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 7fdce6dc5f26..95dc58c3a4e8 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -521,6 +521,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
struct drm_bridge *
drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge);
+struct drm_bridge *
+drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge);
bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode);
--
2.21.0
More information about the dri-devel
mailing list