From: Maxime Ripard <mripard@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Douglas Anderson <dianders@chromium.org>
Cc: Herve Codina <herve.codina@bootlin.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Maxime Ripard <mripard@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Subject: [PATCH v4 02/15] drm/bridge: Provide a helper to retrieve current bridge state
Date: Tue, 25 Feb 2025 17:43:50 +0100 [thread overview]
Message-ID: <20250225-bridge-connector-v4-2-7ecb07b09cad@kernel.org> (raw)
In-Reply-To: <20250225-bridge-connector-v4-0-7ecb07b09cad@kernel.org>
The current bridge state is accessible from the drm_bridge structure,
but since it's fairly indirect it's not easy to figure out.
Provide a helper to retrieve it.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
include/drm/drm_bridge.h | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 2b65466540306feb0694abdc7cd801369cb9c9f0..6fb1da7c195e99143a67a999d16fe361c1e3f4ab 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -955,10 +955,42 @@ static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
{
return NULL;
}
#endif
+/**
+ * drm_bridge_get_current_state() - Get the current bridge state
+ * @bridge: bridge object
+ *
+ * This function must be called with the modeset lock held.
+ *
+ * RETURNS:
+ *
+ * The current bridge state, or NULL if there is none.
+ */
+static inline struct drm_bridge_state *
+drm_bridge_get_current_state(struct drm_bridge *bridge)
+{
+ if (!bridge)
+ return NULL;
+
+ /*
+ * Only atomic bridges will have bridge->base initialized by
+ * drm_atomic_private_obj_init(), so we need to make sure we're
+ * working with one before we try to use the lock.
+ */
+ if (!bridge->funcs || !bridge->funcs->atomic_reset)
+ return NULL;
+
+ drm_modeset_lock_assert_held(&bridge->base.lock);
+
+ if (!bridge->base.state)
+ return NULL;
+
+ return drm_priv_to_bridge_state(bridge->base.state);
+}
+
/**
* drm_bridge_get_next_bridge() - Get the next bridge in the chain
* @bridge: bridge object
*
* RETURNS:
--
2.48.1
next prev parent reply other threads:[~2025-02-25 16:44 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 16:43 [PATCH v4 00/15] drm/bridge: Various quality of life improvements Maxime Ripard
2025-02-25 16:43 ` [PATCH v4 01/15] drm/bridge: Add encoder parameter to drm_bridge_funcs.attach Maxime Ripard
2025-02-25 16:43 ` Maxime Ripard [this message]
2025-02-25 16:43 ` [PATCH v4 03/15] drm/tests: Add kunit tests for bridges Maxime Ripard
2025-02-26 6:40 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 04/15] drm/atomic: Introduce helper to lookup connector by encoder Maxime Ripard
2025-02-26 6:17 ` Dmitry Baryshkov
2025-02-26 6:38 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 05/15] drm/tests: helpers: Create new helper to enable output Maxime Ripard
2025-02-26 6:38 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 06/15] drm/tests: Create tests for drm_atomic Maxime Ripard
2025-02-26 6:40 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 07/15] drm/bridge: Add helper to reset bridge pipeline Maxime Ripard
2025-02-26 6:41 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 08/15] drm/tests: bridge: Provide tests for drm_bridge_reset_crtc Maxime Ripard
2025-02-26 6:43 ` Dmitry Baryshkov
2025-02-26 6:46 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 09/15] drm/bridge: ti-sn65dsi83: Switch to drm_bridge_reset_crtc Maxime Ripard
2025-02-26 6:46 ` Dmitry Baryshkov
2025-02-25 16:43 ` [PATCH v4 10/15] drm/bridge: Introduce drm_bridge_is_atomic() helper Maxime Ripard
2025-02-25 16:43 ` [PATCH v4 11/15] drm/bridge: cdns-csi: Switch to atomic helpers Maxime Ripard
2025-02-26 6:12 ` Dmitry Baryshkov
2025-02-25 16:44 ` [PATCH v4 12/15] drm/bridge: tc358775: Switch to atomic commit Maxime Ripard
2025-02-25 16:44 ` [PATCH v4 13/15] drm/bridge: tc358768: Stop disabling when failing to enable Maxime Ripard
2025-02-25 16:44 ` [PATCH v4 14/15] drm/bridge: tc358768: Convert to atomic helpers Maxime Ripard
2025-02-25 16:44 ` [PATCH v4 15/15] drm/bridge: ti-sn65dsi86: Use bridge_state crtc pointer Maxime Ripard
2025-02-28 22:29 ` Doug Anderson
2025-02-27 11:00 ` [PATCH v4 00/15] drm/bridge: Various quality of life improvements Herve Codina
2025-03-03 13:11 ` Maxime Ripard
2025-03-03 13:34 ` Herve Codina
2025-03-03 13:34 ` Herve Codina
2025-03-03 15:00 ` Maxime Ripard
2025-03-03 16:50 ` Herve Codina
2025-03-04 11:11 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250225-bridge-connector-v4-2-7ecb07b09cad@kernel.org \
--to=mripard@kernel.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dianders@chromium.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=herve.codina@bootlin.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox