Re: [PATCH v2 20/46] drm/mediatek: mtk_crtc: Dynamically find vblank/cfg component indices
From: CK Hu (胡俊光)
Date: Thu Nov 05 2026 - 04:36:27 EST
On Tue, 2026-07-14 at 13:43 +0200, AngeloGioacchino Del Regno wrote:
> As of now mtk_crtc assumes that, on all MediaTek SoCs, both the
> vblank and configuration components are the same one, and also
> that this would always be the first one in a display pipeline.
>
> This is not true!
>
> Or at least, it's true for the display pipelines supported by the
> legacy SoCs like MT8173, and also for the ones that are currently
> used in the upstream boards on more recent SoCs like MT8188/95,
> but for the latter ones it just happens to be like this because
> of how the boards are configured.
>
> This is done both in preparation for adding support for complex
> Display Controller pipelines like needed in MT8196 and MT8894, but
> also for supporting display pipelines in MT8188/89/95 (and others
> from the same generation) that are not starting with a component
> that handles both vblank and layer configuration at the same time.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
> ---
[snip]
> @@ -1201,12 +1209,50 @@ int mtk_crtc_create(struct drm_device *drm_dev,
>
> if (comp->funcs->ctm_set)
> has_ctm = true;
> +
> + /*
> + * Assumes that there can only be one vblank enabler per CRTC,
> + * and that should there be more than one, the one that should
> + * handle vblanks has to be the bottom-most HW component.
> + */
> + if (mtk_crtc->vblank_comp_idx < 0 && comp->funcs->enable_vblank)
> + mtk_crtc->vblank_comp_idx = j;
> +
> + /*
> + * Assumes that there can only be one main configuration
> + * component per CRTC, and that if more than one has to
> + * be configured for at each frame, the main one would
> + * take care of the config chain.
> + *
> + * As a note, such component has specific characteristics:
> + * - It is configurable, and supports per-layer properties;
> + * - It is a main layer component and not a layer stage;
> + * - It is always the first one (the bottom-most) in the
> + * pipeline that has the characteristics explaned above.
> + *
> + * Such hardware is usually an OVL, RDMA or exDMA.
> + *
> + * This may change in the future with more complex pipelines.
> + */
> + if (mtk_crtc->config_comp_idx < 0 && comp->funcs->config &&
> + comp->funcs->layer_config && comp->funcs->layer_nr)
> + mtk_crtc->config_comp_idx = j;
> }
>
> mtk_ddp_comp_register_vblank_cb(comp, mtk_crtc_ddp_irq,
> &mtk_crtc->base);
> }
>
> + if (mtk_crtc->config_comp_idx < 0) {
> + dev_err(dev, "No HW component for layer configuration. Bailing out.\n");
> + return -EINVAL;
> + }
> +
> + if (mtk_crtc->vblank_comp_idx < 0) {
> + dev_info(dev, "No vblank enabler component found! Expect timeouts.\n");
> + mtk_crtc->vblank_comp_idx = 0;
Why not return error here?
If there is some reason, add comment to explain.
Regards,
CK
> + }
> +
> for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i];
>