Re: [PATCH] drm/mediatek: Fix XRGB format breakage for blend_modes unsupported SoCs

From: CK Hu (胡俊光)
Date: Mon Oct 07 2024 - 01:57:30 EST


Hi, Jason:

On Sat, 2024-10-05 at 17:52 +0800, Jason-JH.Lin wrote:
> If the constant alpha always set, the SoCs that is not supported the
> ignore alpha bit will still use constant alpha. That will break the
> original constant alpha setting of XRGB foramt for blend_modes
> unsupported SoCs, such as MT8173.
>
> Make the constatnt alpha only set when setting has_alpha or supported
> blend_modes SoC to fix the downgrade issue.

I would like this patch to be cherry-picked to kernel 6.11 easily, so let this patch base on 6.12-rc1.

>
> Fixes: bc46eb5d5d77 ("drm/mediatek: Support DRM plane alpha in OVL")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@xxxxxxxxxxxx>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 28 +++++++++++++++----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 703cd3f6c6d3..de3addd89442 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -494,19 +494,25 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>
> con = mtk_ovl_fmt_convert(ovl, state);
> if (state->base.fb) {
> - con |= OVL_CON_AEN;
> - con |= state->base.alpha & OVL_CON_ALPHA;
> + /*
> + * For blend_modes supported SoCs, always set constant alpha.
> + * For blend_modes unsupported SoCs, set constant alpha when has_alpha is set.
> + */
> + if (ovl->data->blend_modes || state->base.fb->format->has_alpha) {
> + con |= OVL_CON_AEN;
> + con |= state->base.alpha & OVL_CON_ALPHA;

MT8173 does not support ignore pixel alpha, so OVL_CON_AEN would be disabled for XRGB.
And this is not related to plane alpha, so plane alpha setting should be moved out of here.

> + }
> +
> + /*
> + * Although the alpha channel can be ignored, CONST_BLD must be enabled
> + * for XRGB format, otherwise OVL will still read the value from memory.
> + * For RGB888 related formats, whether CONST_BLD is enabled or not won't
> + * affect the result. Therefore we use !has_alpha as the condition.
> + */
> + if (blend_mode == DRM_MODE_BLEND_PIXEL_NONE || !state->base.fb->format->has_alpha)
> + ignore_pixel_alpha = OVL_CONST_BLEND;

This modification is not related to the bug fix, so separate to another patch.

Regards,
CK

> }
>
> - /* CONST_BLD must be enabled for XRGB formats although the alpha channel
> - * can be ignored, or OVL will still read the value from memory.
> - * For RGB888 related formats, whether CONST_BLD is enabled or not won't
> - * affect the result. Therefore we use !has_alpha as the condition.
> - */
> - if ((state->base.fb && !state->base.fb->format->has_alpha) ||
> - blend_mode == DRM_MODE_BLEND_PIXEL_NONE)
> - ignore_pixel_alpha = OVL_CONST_BLEND;
> -
> if (pending->rotation & DRM_MODE_REFLECT_Y) {
> con |= OVL_CON_VIRT_FLIP;
> addr += (pending->height - 1) * pending->pitch;