From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: 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>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Jessica Zhang <jesszhan0024@gmail.com>,
Konrad Dybcio <konradybcio@kernel.org>,
Val Packett <val@packett.cool>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: [PATCH RFC 5/9] drm/panel: add atomic_check callback
Date: Thu, 08 Oct 2026 16:14:27 +0300 [thread overview]
Message-ID: <20261008-panel-atomic-state-v1-5-b157fddb8de1@oss.qualcomm.com> (raw)
In-Reply-To: <20261008-panel-atomic-state-v1-0-b157fddb8de1@oss.qualcomm.com>
A panel driver cannot reject a configuration it does not support, nor
compute its state for the configuration that is being requested: none of
its callbacks is called in the check phase of an atomic update.
Add an optional atomic_check callback, called from the atomic_check of
the bridge embedded in the panel. Following the other atomic_check
callbacks it receives the whole commit rather than individual object
states.
Add helpers returning the new CRTC and connector states for a panel, so
that panel drivers don't have to open-code the walk through the encoder.
The callback is only meant for the panels using atomic state, warn about
the panels implementing it without the state callbacks.
Assisted-by: LLM
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/gpu/drm/drm_panel.c | 84 +++++++++++++++++++++++++++++++++++++++++++++
include/drm/drm_panel.h | 30 ++++++++++++++++
2 files changed, 114 insertions(+)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index 481caa294243..3a154be128a0 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -243,6 +243,19 @@ static void panel_bridge_debugfs_init(struct drm_bridge *bridge,
panel->funcs->debugfs_init(panel, root);
}
+static int panel_bridge_atomic_check(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state)
+{
+ struct drm_panel *panel = drm_bridge_to_panel(bridge);
+
+ if (!panel->funcs->atomic_check)
+ return 0;
+
+ return panel->funcs->atomic_check(panel, crtc_state->state);
+}
+
static struct drm_bridge_state *
panel_bridge_atomic_create_state(struct drm_bridge *bridge)
{
@@ -297,6 +310,7 @@ static const struct drm_bridge_funcs panel_bridge_bridge_funcs = {
.atomic_disable = panel_bridge_atomic_disable,
.atomic_post_disable = panel_bridge_atomic_post_disable,
.get_modes = panel_bridge_get_modes,
+ .atomic_check = panel_bridge_atomic_check,
.atomic_create_state = panel_bridge_atomic_create_state,
.atomic_duplicate_state = panel_bridge_atomic_duplicate_state,
.atomic_destroy_state = panel_bridge_atomic_destroy_state,
@@ -654,6 +668,9 @@ static void drm_panel_init(struct drm_panel *panel, struct device *dev,
!funcs->atomic_create_state != !funcs->atomic_destroy_state,
"Panel state callbacks have to be implemented together\n");
+ dev_WARN_ONCE(dev, !funcs->atomic_create_state && funcs->atomic_check,
+ "Atomic callbacks require the panel state callbacks\n");
+
INIT_LIST_HEAD(&panel->list);
INIT_LIST_HEAD(&panel->followers);
mutex_init(&panel->follower_lock);
@@ -1185,6 +1202,73 @@ struct drm_panel_state *drm_panel_get_current_state(struct drm_panel *panel)
}
EXPORT_SYMBOL(drm_panel_get_current_state);
+/**
+ * drm_atomic_get_new_crtc_state_for_panel() - get new CRTC state for a panel
+ * @commit: global atomic state object
+ * @panel: panel to get the CRTC state for
+ *
+ * This function returns the new state of the CRTC that drives @panel as of
+ * @commit. It is meant to be used from &drm_panel_funcs.atomic_check and the
+ * enable path. In the disable path the panel might not be driven by any CRTC
+ * anymore.
+ *
+ * Return:
+ *
+ * The new CRTC state, or NULL if the panel is not driven by a CRTC that is
+ * part of the global atomic state.
+ */
+struct drm_crtc_state *
+drm_atomic_get_new_crtc_state_for_panel(struct drm_atomic_commit *commit,
+ struct drm_panel *panel)
+{
+ struct drm_encoder *encoder = panel->bridge.encoder;
+ struct drm_crtc *crtc;
+
+ if (!encoder)
+ return NULL;
+
+ crtc = drm_atomic_get_new_crtc_for_encoder(commit, encoder);
+ if (!crtc)
+ return NULL;
+
+ return drm_atomic_get_new_crtc_state(commit, crtc);
+}
+EXPORT_SYMBOL(drm_atomic_get_new_crtc_state_for_panel);
+
+/**
+ * drm_atomic_get_new_connector_state_for_panel() - get new connector state for
+ * a panel
+ * @commit: global atomic state object
+ * @panel: panel to get the connector state for
+ *
+ * This function returns the new state of the connector that @panel is routed
+ * to as of @commit. It is meant to be used from &drm_panel_funcs.atomic_check
+ * and the enable path. In the disable path the panel might not be routed to
+ * any connector anymore.
+ *
+ * Return:
+ *
+ * The new connector state, or NULL if the panel is not routed to a connector
+ * that is part of the global atomic state.
+ */
+struct drm_connector_state *
+drm_atomic_get_new_connector_state_for_panel(const struct drm_atomic_commit *commit,
+ struct drm_panel *panel)
+{
+ struct drm_encoder *encoder = panel->bridge.encoder;
+ struct drm_connector *connector;
+
+ if (!encoder)
+ return NULL;
+
+ connector = drm_atomic_get_new_connector_for_encoder(commit, encoder);
+ if (!connector)
+ return NULL;
+
+ return drm_atomic_get_new_connector_state(commit, connector);
+}
+EXPORT_SYMBOL(drm_atomic_get_new_connector_state_for_panel);
+
/**
* drm_panel_get - Acquire a panel reference
* @panel: DRM panel
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index ff63bed934fa..a5879b7b986b 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -38,6 +38,8 @@ struct device_node;
struct drm_atomic_commit;
struct drm_bridge;
struct drm_connector;
+struct drm_connector_state;
+struct drm_crtc_state;
struct drm_device;
struct drm_panel_follower;
struct drm_panel;
@@ -168,6 +170,28 @@ struct drm_panel_funcs {
*/
void (*debugfs_init)(struct drm_panel *panel, struct dentry *root);
+ /**
+ * @atomic_check:
+ *
+ * Check that the configuration requested in @commit can be handled by
+ * the panel and compute the new panel state. The new panel state can
+ * be retrieved with drm_atomic_get_new_panel_state(), the CRTC and
+ * connector states with drm_atomic_get_new_crtc_state_for_panel() and
+ * drm_atomic_get_new_connector_state_for_panel().
+ *
+ * This function is called in the check phase of an atomic update, it
+ * must not touch the hardware or any persistent driver data.
+ *
+ * This function is optional. It can only be implemented together with
+ * @atomic_create_state.
+ *
+ * Return:
+ *
+ * Zero if the check passed, a negative error code otherwise.
+ */
+ int (*atomic_check)(struct drm_panel *panel,
+ struct drm_atomic_commit *commit);
+
/**
* @atomic_create_state:
*
@@ -438,6 +462,12 @@ drm_atomic_get_old_panel_state(const struct drm_atomic_commit *commit,
struct drm_panel_state *
drm_atomic_get_new_panel_state(const struct drm_atomic_commit *commit,
struct drm_panel *panel);
+struct drm_crtc_state *
+drm_atomic_get_new_crtc_state_for_panel(struct drm_atomic_commit *commit,
+ struct drm_panel *panel);
+struct drm_connector_state *
+drm_atomic_get_new_connector_state_for_panel(const struct drm_atomic_commit *commit,
+ struct drm_panel *panel);
#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL)
struct drm_panel *of_drm_find_panel(const struct device_node *np);
--
2.47.3
next prev parent reply other threads:[~2026-10-08 13:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 13:14 [PATCH RFC 0/9] drm/panel: add atomic state Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 1/9] drm/bridge: terminate the lines of the bridge state dump Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 2/9] drm/bridge: add atomic_print_state callback Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 3/9] drm/bridge: drop the bridge pointer from drm_bridge_state Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 4/9] drm/panel: add atomic state Dmitry Baryshkov
2026-10-08 13:14 ` Dmitry Baryshkov [this message]
2026-10-08 13:14 ` [PATCH RFC 6/9] drm/panel: factor out the panel follower notifications Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 7/9] drm/panel: add atomic variants of the enable and disable callbacks Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 8/9] drm/panel: add atomic_print_state callback Dmitry Baryshkov
2026-10-08 13:14 ` [PATCH RFC 9/9] drm/panel: novatek-nt35950: use the atomic state to select the mode Dmitry Baryshkov
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=20261008-panel-atomic-state-v1-5-b157fddb8de1@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jesszhan0024@gmail.com \
--cc=jonas@kwiboo.se \
--cc=konradybcio@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rdunlap@infradead.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=tzimmermann@suse.de \
--cc=val@packett.cool \
/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
all inboxes | Powered by JetHome®