Add drm_bridge_get_panel() function to extract drm_panel pointer from panel_bridge. This can be used by bridges in the middle to look up and access drm_panel at the end, and e.g. extract display_timings from it. Signed-off-by: Marek Vasut <marex@xxxxxxx> --- Cc: Andrzej Hajda <andrzej.hajda@xxxxxxxxx> Cc: David Airlie <airlied@xxxxxxxxx> Cc: Jernej Skrabec <jernej.skrabec@xxxxxxxxx> Cc: Jonas Karlman <jonas@xxxxxxxxx> Cc: Laurent Pinchart <Laurent.pinchart@xxxxxxxxxxxxxxxx> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> Cc: Maxime Ripard <mripard@xxxxxxxxxx> Cc: Neil Armstrong <neil.armstrong@xxxxxxxxxx> Cc: Robert Foss <rfoss@xxxxxxxxxx> Cc: Simona Vetter <simona@xxxxxxxx> Cc: Thomas Zimmermann <tzimmermann@xxxxxxx> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx --- V2: - New patch --- drivers/gpu/drm/bridge/panel.c | 18 ++++++++++++++++++ include/drm/drm_bridge.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 6e88339dec0f5..0e5937dc7ab21 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -235,6 +235,24 @@ bool drm_bridge_is_panel(const struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_bridge_is_panel); +/** + * drm_bridge_get_panel - Return panel if a drm_bridge is a panel_bridge. + * + * @bridge: The drm_bridge. + * + * Returns drm_panel pointer if the bridge is a panel bridge, or NULL otherwise. + */ +struct drm_panel *drm_bridge_get_panel(struct drm_bridge *bridge) +{ + struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); + + if (!drm_bridge_is_panel(bridge)) + return NULL; + + return panel_bridge->panel; +} +EXPORT_SYMBOL(drm_bridge_get_panel); + /** * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that * just calls the appropriate functions from &drm_panel. diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index e8d735b7f6a48..4b64ab47c9d7f 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -984,6 +984,7 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge, #ifdef CONFIG_DRM_PANEL_BRIDGE bool drm_bridge_is_panel(const struct drm_bridge *bridge); +struct drm_panel *drm_bridge_get_panel(struct drm_bridge *bridge); struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, u32 connector_type); @@ -1004,6 +1005,11 @@ static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge) return false; } +static struct drm_panel *drm_bridge_get_panel(struct drm_bridge *bridge) +{ + return NULL; +} + static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector, struct drm_bridge *bridge) { -- 2.45.2