From: "Màxim Pedraza Padilla" <maximpedraza@gmail.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: "Neil Armstrong" <neil.armstrong@linaro.org>,
"Jessica Zhang" <jesszhan0024@gmail.com>,
"Jyri Sarha" <jyri.sarha@iki.fi>,
"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Andrzej Hajda" <andrzej.hajda@intel.com>,
"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>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/4] drm/panel: Implement state readout in the panel bridge
Date: Mon, 16 Nov 2026 15:27:05 +0100 [thread overview]
Message-ID: <20261116142707.1299360-3-maximpedraza@gmail.com> (raw)
In-Reply-To: <20261116142707.1299360-1-maximpedraza@gmail.com>
The state readout core gives up if a private object doesn't implement
readout, so a driver using a panel bridge can't adopt the firmware state,
even if it implements readout itself.
A panel has no state to read back: it's part of the pipeline if the CRTC
feeding its encoder is active. Implement the connector and bridge readout
on that assumption, relying on the encoder's
atomic_sro_get_current_crtc hook, and fill the bus configuration with what
the commit negotiation would give.
When the state is installed, prepare and enable the panel, since nothing
else would until the first modeset.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Màxim Pedraza Padilla <maximpedraza@gmail.com>
---
drivers/gpu/drm/drm_panel.c | 92 ++++++++++++++++++++++++++++++++++++-
1 file changed, 91 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index c00529bfb706..7cee228f798b 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -9,10 +9,14 @@
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/export.h>
+#include <linux/media-bus-format.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_atomic_state_readout.h>
+#include <drm/drm_atomic_state_readout_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
@@ -216,6 +220,88 @@ static void panel_bridge_debugfs_init(struct drm_bridge *bridge,
panel->funcs->debugfs_init(panel, root);
}
+/*
+ * A panel has no state to read back: it's part of the pipeline if the CRTC
+ * feeding its encoder is active.
+ */
+static int panel_bridge_connector_readout(struct drm_bridge *bridge,
+ struct drm_atomic_sro_state *state,
+ struct drm_connector_state *conn_state)
+{
+ struct drm_connector *connector = conn_state->connector;
+ struct drm_encoder *encoder = bridge->encoder;
+ struct drm_crtc_state *crtc_state;
+ struct drm_crtc *crtc;
+
+ if (!encoder->funcs || !encoder->funcs->atomic_sro_get_current_crtc)
+ return -ENODEV;
+
+ crtc = encoder->funcs->atomic_sro_get_current_crtc(encoder);
+ if (!crtc)
+ return -ENODEV;
+
+ crtc_state = drm_atomic_sro_get_crtc_state(state, crtc);
+ if (!crtc_state)
+ return -ENODEV;
+
+ if (!crtc_state->active)
+ return 0;
+
+ crtc_state->encoder_mask |= drm_encoder_mask(encoder);
+ crtc_state->connector_mask |= drm_connector_mask(connector);
+
+ /* Released by __drm_atomic_helper_connector_destroy_state(). */
+ drm_connector_get(connector);
+ conn_state->crtc = crtc;
+ conn_state->best_encoder = encoder;
+
+ return 0;
+}
+
+/*
+ * Same result as the bus format negotiation of a commit, which doesn't run
+ * during readout: the panel asks for its first format and flags, and passes
+ * them on through drm_atomic_helper_bridge_propagate_bus_fmt().
+ */
+static int panel_bridge_readout_state(struct drm_bridge *bridge,
+ struct drm_atomic_sro_state *state,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state)
+{
+ const struct drm_display_info *di = &conn_state->connector->display_info;
+ u32 format = di->num_bus_formats ? di->bus_formats[0] : MEDIA_BUS_FMT_FIXED;
+
+ bridge_state->input_bus_cfg.format = format;
+ bridge_state->input_bus_cfg.flags = di->bus_flags;
+ bridge_state->output_bus_cfg.format = format;
+ bridge_state->output_bus_cfg.flags = di->bus_flags;
+
+ return 0;
+}
+
+/*
+ * The firmware left the pipeline running, so the panel is taken as part of it.
+ * Without this it would stay off until the first modeset.
+ */
+static void panel_bridge_install_state(struct drm_bridge *bridge,
+ struct drm_bridge_state *state)
+{
+ struct drm_panel *panel = drm_bridge_to_panel(bridge);
+ struct drm_encoder *encoder = bridge->encoder;
+ struct drm_crtc *crtc;
+
+ if (!encoder->funcs || !encoder->funcs->atomic_sro_get_current_crtc)
+ return;
+
+ crtc = encoder->funcs->atomic_sro_get_current_crtc(encoder);
+ if (!crtc || !crtc->state->active)
+ return;
+
+ drm_panel_prepare(panel);
+ drm_panel_enable(panel);
+}
+
static const struct drm_bridge_funcs panel_bridge_bridge_funcs = {
.attach = panel_bridge_attach,
.detach = panel_bridge_detach,
@@ -228,6 +314,10 @@ static const struct drm_bridge_funcs panel_bridge_bridge_funcs = {
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
.atomic_get_input_bus_fmts = drm_atomic_helper_bridge_propagate_bus_fmt,
+ .atomic_sro_readout_state = panel_bridge_readout_state,
+ .atomic_sro_compare_state = drm_atomic_helper_bridge_compare_state,
+ .atomic_sro_connector_readout = panel_bridge_connector_readout,
+ .atomic_sro_install_state = panel_bridge_install_state,
.debugfs_init = panel_bridge_debugfs_init,
};
@@ -600,7 +690,7 @@ void drm_panel_add(struct drm_panel *panel)
mutex_unlock(&panel_lock);
panel->bridge.of_node = panel->dev->of_node;
- panel->bridge.ops = DRM_BRIDGE_OP_MODES;
+ panel->bridge.ops = DRM_BRIDGE_OP_MODES | DRM_BRIDGE_OP_CONNECTOR_HW_READOUT;
panel->bridge.type = panel->connector_type;
panel->bridge.pre_enable_prev_first = panel->prepare_prev_first;
--
2.39.5
next prev parent reply other threads:[~2026-11-16 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 14:27 [RFC PATCH 0/4] drm/tilcdc: Implement state readout Màxim Pedraza Padilla
2026-11-16 14:27 ` [RFC PATCH 1/4] drm/bridge: Add atomic_sro_install_state hook Màxim Pedraza Padilla
2026-11-16 14:27 ` Màxim Pedraza Padilla [this message]
2026-11-16 14:27 ` [RFC PATCH 3/4] drm/tilcdc: Implement state readout support Màxim Pedraza Padilla
2026-11-16 14:27 ` [RFC PATCH 4/4] drm/panel: simple: Keep the enable GPIO as left by the bootloader Màxim Pedraza Padilla
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=20261116142707.1299360-3-maximpedraza@gmail.com \
--to=maximpedraza@gmail.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jesszhan0024@gmail.com \
--cc=jonas@kwiboo.se \
--cc=jyri.sarha@iki.fi \
--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=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tzimmermann@suse.de \
--cc=ukleinek@kernel.org \
/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®