Re: [PATCH v2 09/46] drm/mediatek: De-duplicate internal component checks

From: Fei Shao

Date: Mon Nov 09 2026 - 04:56:45 EST


On Tue, Jul 14, 2026 at 7:45 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@xxxxxxxxxxxxx> wrote:
>
> Both mtk_ddp_comp and mtk_drm_drv are performing similar checks
> to distinguish components that have an external driver from ones
> that don't - with the exception of mtk_ddp_comp also checking if
> the component is related to a backlight driver.
>
> Create helper functions in the main component management driver
> mtk_ddp_comp, one to check if the currently checked component is
> internal/simple, and one (static, internal to mtk_ddp_comp only)
> to check if it is a backlight related one.
>
> Since the amount of internal/simple components is lower than the
> amount of ones having a specific driver, and since it is expected
> that most of (if not all) of any new hardware support will need a
> specific driver as well, the helpers are doing an inverted check
> compared to what the code was doing before, as both mtk_ddp_comp
> and mtk_drm_drv were checking for external component explicitly,
> while now they're doing the same, but checking if NOT internal.
>
> Also, while at it, for the OVL_ADAPTOR components case, instead
> of checking for MTK_DISP_OVL_ADAPTOR, call the already provided
> mtk_ovl_adaptor_is_comp_present() function to check for this type
> of component.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
> ---
> drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 46 ++++++++++++++-----------
> drivers/gpu/drm/mediatek/mtk_ddp_comp.h | 1 +
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 ++-------
> 3 files changed, 29 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
> index 2ba2123238b3..a9c3e29fb340 100644
> --- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c

[snip]

> @@ -700,26 +720,12 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node,
> if (ret)
> return ret;
>
> - if (type == MTK_DISP_AAL ||
> - type == MTK_DISP_BLS ||
> - type == MTK_DISP_CCORR ||
> - type == MTK_DISP_COLOR ||
> - type == MTK_DISP_DSC ||
> - type == MTK_DISP_GAMMA ||
> - type == MTK_DISP_MERGE ||
> - type == MTK_DISP_OVL ||
> - type == MTK_DISP_OVL_2L ||
> - type == MTK_DISP_PWM ||
> - type == MTK_DISP_RDMA ||
> - type == MTK_DISP_WDMA ||
> - type == MTK_DISP_DPI ||
> - type == MTK_DISP_DP_INTF ||
> - type == MTK_DISP_DSI)
> - goto end;
> -
> - ret = mtk_ddp_comp_init_internal_comp(dev, comp->dev);
> - if (ret)
> - return ret;
> + /* If there's no external driver for this component, allocate and init now */
> + if (mtk_ddp_comp_is_internal_comp(type) || mtk_ddp_comp_is_backlight_comp(type)) {

If I understand this correctly, MTK_DISP_BLS and MTK_DISP_PWM are
bound by the standalone pwm-mtk-disp driver. Initializing them as
internal components requests the same exclusive MMIO region and fails
with -EBUSY on whichever driver probes second.

Drop `mtk_ddp_comp_is_backlight_comp()` here so backlight nodes skip
internal init as before.

> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index e956e1966b86..18683aee61ff 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -1166,20 +1166,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
> * blocks have separate component platform drivers and initialize their own
> * DDP component structure. The others are initialized here.
> */
> - if (comp_type == MTK_DISP_AAL ||
> - comp_type == MTK_DISP_CCORR ||
> - comp_type == MTK_DISP_COLOR ||
> - comp_type == MTK_DISP_DSC ||
> - comp_type == MTK_DISP_GAMMA ||
> - comp_type == MTK_DISP_MERGE ||
> - comp_type == MTK_DISP_OVL ||
> - comp_type == MTK_DISP_OVL_2L ||
> - comp_type == MTK_DISP_OVL_ADAPTOR ||
> - comp_type == MTK_DISP_RDMA ||
> - comp_type == MTK_DISP_WDMA ||
> - comp_type == MTK_DISP_DP_INTF ||
> - comp_type == MTK_DISP_DPI ||
> - comp_type == MTK_DISP_DSI) {
> + if (!mtk_ddp_comp_is_internal_comp(comp_type) &&
> + !mtk_ovl_adaptor_is_comp_present(node)) {

And here, pwm-mtk-disp isn't a component driver and never registers a
component. Adding a backlight component may prevent the DRM master
from ever binding on SoCs.

Add `!mtk_ddp_comp_is_backlight_comp()` here, and in
`mtk_drm_register_sibling()` in patch 40/46.

Regards,
Fei