[PATCH v2 27/28] drm/tidss: encoder: Implement atomic_sro_get_current_crtc

From: Maxime Ripard

Date: Thu Apr 23 2026 - 06:30:42 EST


The tidss driver doesn't really implement anything with encoders, it
just relies on simple encoders, bridges and drm_bridge_connector.

In order to figure out the CRTC -> connector association from the
hardware state, we do need encoder support though, through the
get_current_crtc callback.

Since the tidss encoders are always connected to a single CRTC, we don't
really need to read the hardware state though, we can simply return the
one we know we are always connected to.

Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx>
---
drivers/gpu/drm/tidss/tidss_encoder.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c b/drivers/gpu/drm/tidss/tidss_encoder.c
index a20d7826e3cc..7883f5ec6d41 100644
--- a/drivers/gpu/drm/tidss/tidss_encoder.c
+++ b/drivers/gpu/drm/tidss/tidss_encoder.c
@@ -92,10 +92,29 @@ static const struct drm_bridge_funcs tidss_bridge_funcs = {
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
.atomic_sro_readout_state = tidss_readout_state,
.atomic_sro_compare_state = drm_atomic_helper_bridge_compare_state,
};

+static struct drm_crtc *tidss_encoder_get_current_crtc(struct drm_encoder *encoder)
+{
+ struct drm_crtc *crtc;
+
+ WARN_ON(hweight32(encoder->possible_crtcs) > 1);
+
+ drm_for_each_crtc(crtc, encoder->dev) {
+ if (encoder->possible_crtcs == (1 << drm_crtc_index(crtc)))
+ return crtc;
+ }
+
+ return NULL;
+}
+
+static const struct drm_encoder_funcs tidss_encoder_funcs = {
+ .atomic_sro_get_current_crtc = tidss_encoder_get_current_crtc,
+ .destroy = drm_encoder_cleanup,
+};
+
int tidss_encoder_create(struct tidss_device *tidss,
struct drm_bridge *next_bridge,
u32 encoder_type, u32 possible_crtcs)
{
struct tidss_encoder *t_enc;
@@ -106,12 +125,13 @@ int tidss_encoder_create(struct tidss_device *tidss,
t_enc = devm_drm_bridge_alloc(tidss->dev, struct tidss_encoder,
bridge, &tidss_bridge_funcs);
if (IS_ERR(t_enc))
return PTR_ERR(t_enc);

- ret = drm_simple_encoder_init(&tidss->ddev, &t_enc->encoder,
- encoder_type);
+ ret = drm_encoder_init(&tidss->ddev, &t_enc->encoder,
+ &tidss_encoder_funcs,
+ encoder_type, NULL);
if (ret)
return ret;

t_enc->tidss = tidss;
t_enc->next_bridge = next_bridge;

--
2.53.0