[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240917-hotplug-drm-bridge-v4-2-bc4dfee61be6@bootlin.com>
Date: Tue, 17 Sep 2024 10:53:06 +0200
From: Luca Ceresoli <luca.ceresoli@...tlin.com>
To: Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Andrzej Hajda <andrzej.hajda@...el.com>,
Neil Armstrong <neil.armstrong@...aro.org>, Robert Foss <rfoss@...nel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jonas Karlman <jonas@...boo.se>, Jernej Skrabec <jernej.skrabec@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Derek Kiernan <derek.kiernan@....com>,
Dragan Cvetic <dragan.cvetic@....com>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Saravana Kannan <saravanak@...gle.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
"Rafael J. Wysocki" <rafael@...nel.org>, Lee Jones <lee@...nel.org>,
Daniel Thompson <daniel.thompson@...aro.org>,
Jingoo Han <jingoohan1@...il.com>, Helge Deller <deller@....de>
Cc: Paul Kocialkowski <contact@...lk.fr>,
Hervé Codina <herve.codina@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-i2c@...r.kernel.org, linux-fbdev@...r.kernel.org,
Paul Kocialkowski <paul.kocialkowski@...tlin.com>,
Luca Ceresoli <luca.ceresoli@...tlin.com>
Subject: [PATCH v4 2/8] drm/bridge: allow bridges to be informed about
added and removed bridges
In preparation for allowing bridges to be added to and removed from a DRM
card without destroying the whole card, add a new DRM bridge function
called on addition and removal of bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@...tlin.com>
---
drivers/gpu/drm/drm_bridge.c | 12 ++++++++++++
include/drm/drm_bridge.h | 23 +++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index d44f055dbe3e..c98117f1abec 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -205,8 +205,14 @@ static LIST_HEAD(bridge_list);
*/
void drm_bridge_add(struct drm_bridge *bridge)
{
+ struct drm_bridge *br, *tmp;
+
mutex_init(&bridge->hpd_mutex);
+ list_for_each_entry_safe(br, tmp, &bridge_list, list)
+ if (br->funcs->bridge_event_notify)
+ br->funcs->bridge_event_notify(br, DRM_EVENT_BRIDGE_ADD, bridge);
+
mutex_lock(&bridge_lock);
list_add_tail(&bridge->list, &bridge_list);
mutex_unlock(&bridge_lock);
@@ -243,10 +249,16 @@ EXPORT_SYMBOL(devm_drm_bridge_add);
*/
void drm_bridge_remove(struct drm_bridge *bridge)
{
+ struct drm_bridge *br, *tmp;
+
mutex_lock(&bridge_lock);
list_del_init(&bridge->list);
mutex_unlock(&bridge_lock);
+ list_for_each_entry_safe(br, tmp, &bridge_list, list)
+ if (br->funcs->bridge_event_notify)
+ br->funcs->bridge_event_notify(br, DRM_EVENT_BRIDGE_REMOVE, bridge);
+
mutex_destroy(&bridge->hpd_mutex);
}
EXPORT_SYMBOL(drm_bridge_remove);
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 75019d16be64..635cc24bdeba 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -54,6 +54,11 @@ enum drm_bridge_attach_flags {
DRM_BRIDGE_ATTACH_NO_CONNECTOR = BIT(0),
};
+enum drm_bridge_event_type {
+ DRM_EVENT_BRIDGE_ADD,
+ DRM_EVENT_BRIDGE_REMOVE,
+};
+
/**
* struct drm_bridge_funcs - drm_bridge control functions
*/
@@ -676,6 +681,24 @@ struct drm_bridge_funcs {
enum hdmi_infoframe_type type,
const u8 *buffer, size_t len);
+ /**
+ * @bridge_event_notify:
+ *
+ * Notify that another bridge is being added or removed.
+ *
+ * This callback is optional. Bridges implementing it must always
+ * check whether the event refers to a bridge they actually need to
+ * interact with.
+ *
+ * @bridge: bridge being notified
+ * @event: event happened (add/remove bridge)
+ * @new_bridge: the bridge mentioned by the event (i.e. the bridge
+ * being added or removed)
+ */
+ void (*bridge_event_notify)(struct drm_bridge *bridge,
+ enum drm_bridge_event_type event,
+ struct drm_bridge *event_bridge);
+
/**
* @debugfs_init:
*
--
2.34.1
Powered by blists - more mailing lists