Will be useful for bridge drivers that want to do bus format negotiation with their neighbours. Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> --- drivers/gpu/drm/drm_bridge.c | 19 +++++++++++++++++++ include/drm/drm_bridge.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index dcad661daa74..9efb27087e70 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -271,6 +271,25 @@ 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 there's @bridge is the + * last. + */ +struct drm_bridge * +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge) +{ + if (!bridge || !bridge->encoder || + list_is_first(&bridge->encoder->bridge_chain, &bridge->chain_node)) + 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 5d8fe3709bde..2f69adb7b0f3 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -485,6 +485,8 @@ struct drm_bridge * drm_bridge_chain_get_last_bridge(struct drm_encoder *encoder); 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_encoder *encoder, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); -- 2.21.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel