[PATCH v4 12/19] drm/mediatek: Export OVL formats definitions and format conversion API

CK Hu (胡俊光) ck.hu at mediatek.com
Wed Sep 10 00:19:00 PDT 2025


On Thu, 2025-08-28 at 16:07 +0800, Paul Chen wrote:
> From: Nancy Lin <nancy.lin at mediatek.com>
> 
> In upcoming SoCs, the OVL component will be divided into multiple
> smaller hardware units to enhance flexibility. To facilitate this
> transition, the OVL format definitions and format conversion API
> should be exported for reuse across these units.
> 
> Signed-off-by: Nancy Lin <nancy.lin at mediatek.com>
> Signed-off-by: Paul-pl Chen <paul-pl.chen at mediatek.com>
> ---

[snip]

>  
> +bool mtk_ovl_is_10bit_rgb(unsigned int fmt)

You add mtk_ovl_is_10bit_rgb() here, so you should remove is_10bit_rgb().

> +{
> +	switch (fmt) {
> +	case DRM_FORMAT_XRGB2101010:
> +	case DRM_FORMAT_ARGB2101010:
> +	case DRM_FORMAT_RGBX1010102:
> +	case DRM_FORMAT_RGBA1010102:
> +	case DRM_FORMAT_XBGR2101010:
> +	case DRM_FORMAT_ABGR2101010:
> +	case DRM_FORMAT_BGRX1010102:
> +	case DRM_FORMAT_BGRA1010102:
> +		return true;
> +	}
> +	return false;
> +}
> +

[snip]

>  static void mtk_ovl_afbc_layer_config(struct mtk_disp_ovl *ovl,
> @@ -511,7 +550,15 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  		return;
>  	}
>  
> -	con = mtk_ovl_fmt_convert(ovl, state);
> +	if (ovl->data->blend_modes & BIT(DRM_MODE_BLEND_PREMULTI))
> +		con = mtk_ovl_fmt_convert(fmt, blend_mode,
> +					  ovl->data->fmt_rgb565_is_0, true, 12,

Why color_convert is true for all fmt?
In original code, only YUV format would do color convert.

> +					  OVL_CON_CLRFMT_MAN, OVL_CON_BYTE_SWAP, OVL_CON_RGB_SWAP);
> +	else
> +		con = mtk_ovl_fmt_convert(fmt, DRM_MODE_BLEND_COVERAGE,
> +					  ovl->data->fmt_rgb565_is_0, true, 12,

Symbolize 12. Maybe

#define OVL_CON_CLRFMT_SHIFT 12

> +					  OVL_CON_CLRFMT_MAN, OVL_CON_BYTE_SWAP, OVL_CON_RGB_SWAP);
> +
>  	if (state->base.fb) {
>  		con |= state->base.alpha & OVL_CON_ALPHA;
>  
> @@ -668,7 +715,7 @@ static const struct mtk_disp_ovl_data mt2701_ovl_driver_data = {
>  	.layer_nr = 4,
>  	.fmt_rgb565_is_0 = false,
>  	.formats = mt8173_ovl_formats,
> -	.num_formats = ARRAY_SIZE(mt8173_ovl_formats),
> +	.num_formats = mt8173_ovl_formats_len,
>  };
>  

[snip]

> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.h b/drivers/gpu/drm/mediatek/mtk_disp_ovl.h
> new file mode 100644
> index 000000000000..4f446d2e0712
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2025 MediaTek Inc.
> + */
> +
> +#ifndef __MTK_DISP_OVL_H__
> +#define __MTK_DISP_OVL_H__
> +
> +#include <drm/drm_fourcc.h>
> +
> +extern const u32 mt8173_ovl_formats[];

No other file need mt8173_ovl_formats[], so do not export it.

> +extern const size_t mt8173_ovl_formats_len;
> +extern const u32 mt8195_ovl_formats[];
> +extern const size_t mt8195_ovl_formats_len;
> +
> +bool mtk_ovl_is_10bit_rgb(unsigned int fmt);
> +unsigned int mtk_ovl_fmt_convert(unsigned int fmt, unsigned int blend_mode,
> +				 bool fmt_rgb565_is_0, bool color_convert,
> +				 u8 clrfmt_shift, u32 clrfmt_man, u32 byte_swap, u32 rgb_swap);
> +
> +#endif



More information about the linux-arm-kernel mailing list