[PATCH 09/14] drm/imx: dc-ed: Support getting source selection

Liu Ying
2025-07-04T10:44:51Z

Add a helper to get ExtDst source selection. This is needed by
disabling CRTC at boot in an upcoming commit which tries to get
the source selection.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
drivers/gpu/drm/imx/dc/dc-ed.c | 26 ++++++++++++++++++++++++++
drivers/gpu/drm/imx/dc/dc-pe.h | 1 +
2 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/imx/dc/dc-ed.c b/drivers/gpu/drm/imx/dc/dc-ed.c
index 86ecc22d0a554bf3eced218df0312b513e10e179..b514790bb765329295553f89d16ee1167ef411dd 100644
--- a/drivers/gpu/drm/imx/dc/dc-ed.c
+++ b/drivers/gpu/drm/imx/dc/dc-ed.c
@@ -150,6 +150,32 @@ void dc_ed_pec_src_sel(struct dc_ed *ed, enum dc_link_id src)
}
}

+int dc_ed_pec_src_sel_get(struct dc_ed *ed, enum dc_link_id *src)
+{
+ u32 val;
+
+ regmap_read(ed->reg_pec, PIXENGCFG_DYNAMIC, &val);
+
+ switch (val) {
+ case LINK_ID_NONE:
+ case LINK_ID_CONSTFRAME0:
+ case LINK_ID_CONSTFRAME4:
+ case LINK_ID_CONSTFRAME1:
+ case LINK_ID_CONSTFRAME5:
+ case LINK_ID_FETCHWARP2:
+ case LINK_ID_FETCHLAYER0:
+ case LINK_ID_LAYERBLEND0:
+ case LINK_ID_LAYERBLEND1:
+ case LINK_ID_LAYERBLEND2:
+ case LINK_ID_LAYERBLEND3:
+ *src = val;
+ dev_dbg(ed->dev, "get source selection: 0x%02x\n", val);
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
void dc_ed_pec_sync_trigger(struct dc_ed *ed)
{
regmap_write(ed->reg_pec, PIXENGCFG_TRIGGER, SYNC_TRIGGER);
diff --git a/drivers/gpu/drm/imx/dc/dc-pe.h b/drivers/gpu/drm/imx/dc/dc-pe.h
index f5e01a6eb9e918516adfc89949665fdd2ff1e40e..0b81dc6b251c452e7ca72f1cd12af065bafaa198 100644
--- a/drivers/gpu/drm/imx/dc/dc-pe.h
+++ b/drivers/gpu/drm/imx/dc/dc-pe.h
@@ -85,6 +85,7 @@ void dc_cf_init(struct dc_cf *cf);

/* External Destination Unit */
void dc_ed_pec_src_sel(struct dc_ed *ed, enum dc_link_id src);
+int dc_ed_pec_src_sel_get(struct dc_ed *ed, enum dc_link_id *src);
void dc_ed_pec_sync_trigger(struct dc_ed *ed);
void dc_ed_init(struct dc_ed *ed);

--
2.34.1