Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "robh@kernel.org" <robh@kernel.org>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"kernel@collabora.com" <kernel@collabora.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"Paul-pl Chen (陳柏霖)" <Paul-pl.Chen@mediatek.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"Justin Yeh (葉英茂)" <Justin.Yeh@mediatek.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>
Subject: Re: [PATCH 03/42] drm/mediatek: Export OVL Blend function
Date: Fri, 3 Jul 2026 05:38:01 +0000	[thread overview]
Message-ID: <a1f7548137633981f5b0fe8be2bfa09f7bef99d7.camel@mediatek.com> (raw)
In-Reply-To: <20260701122057.19648-4-angelogioacchino.delregno@collabora.com>

On Wed, 2026-07-01 at 14:20 +0200, AngeloGioacchino Del Regno wrote:
> From: Paul-pl Chen <paul-pl.chen@mediatek.com>
> 
> For the new BLENDER component, the OVL ignore pixel alpha logic
> should be exported as a function and reused it.
> 
> Signed-off-by: Nancy Lin <nancy.lin@mediatek.com>
> Signed-off-by: Paul-pl Chen <paul-pl.chen@mediatek.com>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 68 +++++++++++++++++--------
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.h |  8 +++
>  2 files changed, 56 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 9ded20202191..fa4607304acb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -215,6 +215,23 @@ void mtk_ovl_disable_vblank(struct device *dev)
>  	writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_INTEN);
>  }
>  
> +bool mtk_ovl_is_ignore_pixel_alpha(struct mtk_plane_state *state, unsigned int blend_mode)
> +{
> +	if (!state->base.fb)
> +		return false;
> +
> +	/*
> +	 * 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)
> +		return true;
> +
> +	return false;
> +}
> +
>  u32 mtk_ovl_get_blend_modes(struct device *dev)
>  {
>  	struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> @@ -401,6 +418,29 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int idx,
>  		      DISP_REG_OVL_RDMA_CTRL(idx));
>  }
>  
> +unsigned int mtk_ovl_get_blend_mode(struct mtk_plane_state *state, unsigned int blend_modes)
> +{
> +	unsigned int blend_mode = DRM_MODE_BLEND_COVERAGE;
> +
> +	/*
> +	 * For the platforms where OVL_CON_CLRFMT_MAN is defined in the hardware data sheet
> +	 * and supports premultiplied color formats, such as OVL_CON_CLRFMT_PARGB888
> +	 * and supports premultiplied color formats, such as OVL_CON_CLRFMT_PARGB8888.
> +	 *
> +	 * Check blend_modes in the driver data to see if premultiplied mode is supported.
> +	 * If not, use coverage mode instead to set it to the supported color formats.
> +	 *
> +	 * Current DRM assumption is that alpha is default premultiplied, so the bitmask of
> +	 * blend_modes must include BIT(DRM_MODE_BLEND_PREMULTI). Otherwise, mtk_plane_init()
> +	 * will get an error return from drm_plane_create_blend_mode_property() and
> +	 * state->base.pixel_blend_mode should not be used.
> +	 */
> +	if (blend_modes & BIT(DRM_MODE_BLEND_PREMULTI))
> +		blend_mode = state->base.pixel_blend_mode;
> +
> +	return blend_mode;
> +}
> +
>  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)
> @@ -529,7 +569,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  	unsigned int rotation = pending->rotation;
>  	unsigned int offset = (pending->y << 16) | pending->x;
>  	unsigned int src_size = (pending->height << 16) | pending->width;
> -	unsigned int blend_mode = state->base.pixel_blend_mode;
> +	unsigned int blend_mode = mtk_ovl_get_blend_mode(state, ovl->data->blend_modes);

In [02/42], you add these statement.

+       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, OVL_CON_CLRFMT_SHIFT,
+                                               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, OVL_CON_CLRFMT_SHIFT,
+                                               OVL_CON_CLRFMT_MAN, OVL_CON_BYTE_SWAP, OVL_CON_RGB_SWAP);

And here you change definition of blend_mode, so these statement could be simplified as

+       con = mtk_ovl_fmt_convert(fmt, blend_mode,
+                                 ovl->data->fmt_rgb565_is_0, true, OVL_CON_CLRFMT_SHIFT,
+                                 OVL_CON_CLRFMT_MAN, OVL_CON_BYTE_SWAP, OVL_CON_RGB_SWAP);


>  	unsigned int ignore_pixel_alpha = 0;
>  	unsigned int con;
>  
> @@ -554,17 +594,8 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  		 * For blend_modes supported SoCs, always enable alpha blending.
>  		 * For blend_modes unsupported SoCs, enable alpha blending when has_alpha is set.
>  		 */
> -		if (blend_mode || state->base.fb->format->has_alpha)
> +		if (state->base.pixel_blend_mode || state->base.fb->format->has_alpha)
>  			con |= OVL_CON_AEN;
> -
> -		/*
> -		 * 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;
>  	}
>  
>  	/*
> @@ -590,6 +621,9 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  
>  	mtk_ddp_write_relaxed(cmdq_pkt, con, &ovl->cmdq_reg, ovl->regs,
>  			      DISP_REG_OVL_CON(idx));
> +
> +	if (mtk_ovl_is_ignore_pixel_alpha(state, blend_mode))

if (mtk_ovl_is_ignore_pixel_alpha(state, state->base.pixel_blend_mode))

Regards,
CK

> +		ignore_pixel_alpha = OVL_CONST_BLEND;
>  	mtk_ddp_write_relaxed(cmdq_pkt, pitch_lsb | ignore_pixel_alpha,
>  			      &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_PITCH(idx));
>  	mtk_ddp_write_relaxed(cmdq_pkt, src_size, &ovl->cmdq_reg, ovl->regs,
> 


  reply	other threads:[~2026-07-03  5:38 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 12:20 [PATCH 00/42] drm/mediatek: The Huge Restructuring and MT8196 support AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 01/42] drm/mediatek: Rename OVL format naming AngeloGioacchino Del Regno
2026-07-02  7:30   ` CK Hu (胡俊光)
2026-07-01 12:20 ` [PATCH 02/42] drm/mediatek: Export OVL formats definitions and format conversion API AngeloGioacchino Del Regno
2026-07-02  9:36   ` CK Hu (胡俊光)
2026-07-01 12:20 ` [PATCH 03/42] drm/mediatek: Export OVL Blend function AngeloGioacchino Del Regno
2026-07-03  5:38   ` CK Hu (胡俊光) [this message]
2026-07-01 12:20 ` [PATCH 04/42] drm/mediatek: Move mtk_ddp_comp_type enumeration to mtk-mmsys.h AngeloGioacchino Del Regno
2026-07-03  6:03   ` CK Hu (胡俊光)
2026-07-01 12:20 ` [PATCH 05/42] drm/mediatek: Rename all display component type to have DISP_ prefix AngeloGioacchino Del Regno
2026-07-03  6:25   ` CK Hu (胡俊光)
2026-07-01 12:20 ` [PATCH 06/42] drm/mediatek: Use hashtable for components discovery and registration AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 07/42] drm/mediatek: ddp_comp: Move internal component register in function AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 08/42] drm/mediatek: De-duplicate internal component checks AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 09/42] drm/mediatek: Introduce and use path/comp definition structures AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 10/42] drm/mediatek: Create new mtk_drm_legacy and move deprecated code AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 11/42] drm/mediatek: Add support for MuteX trigger-sources parsing AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 12/42] drm/mediatek: ovl_adaptor: Add special MERGE component check AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 13/42] drm/mediatek: mtk_hdmi_v2: Don't warn on RPM active during detach AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 14/42] drm/mediatek: Add support for hardware multi-stage layers AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 15/42] drm/mediatek: mtk_crtc: Complete documentation for struct mtk_crtc AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 16/42] drm/mediatek: mtk_crtc: Minimize spinlocked time in cmdq callback AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 17/42] drm/mediatek: mtk_crtc: Dynamically find vblank/cfg component indices AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 18/42] soc: mediatek: mtk-mmsys: Migrate to new Multimedia DDP HW indexing AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 19/42] drm/mediatek: Fully migrate to new Display Controller " AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 20/42] drm/mediatek: mtk_dpi: Pass parameters with new mtk_dpi_sync structure AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 21/42] drm/mediatek: mtk_dpi: Fully separate HW setup from common code AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 22/42] drm/mediatek: Create new mtk_dpi_common lib and move mtk_dpi code AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 23/42] dt-bindings: display: mediatek: Introduce Digital Video Output HW AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 16:53     ` AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 24/42] drm/mediatek: Add support for MediaTek Digital Video Output (DVO) AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 25/42] drm/mediatek: Pass mtk_ddp_comp in clk and config callbacks AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 26/42] dt-bindings: display: mediatek: Introduce MT8196 Layer Blender AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 12:20 ` [PATCH 27/42] drm/mediatek: Add support for Display Layer Blender component AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 28/42] dt-bindings: display: mediatek: Introduce MT8196 extended DMA Engine AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 12:20 ` [PATCH 29/42] drm/mediatek: Add support for Display Controller exDMA component AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 30/42] dt-bindings: display: mediatek: Introduce MT8196 Output Processor AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 12:20 ` [PATCH 31/42] drm/mediatek: Add support for Display Output Processor component AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 32/42] drm/mediatek: mtk_crtc: Dynamically find suitable CRTC DMA device AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 33/42] drm/mediatek: Prepare path builder for multi-controller architecture AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 34/42] drm/mediatek: Enable bring-up of multi-controller CRTC paths AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 35/42] drm/mediatek: Introduce MediaTek Asynchronous DirectLink Controller AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 36/42] drm/mediatek: Support registering disp controller device subnodes AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 37/42] soc: mediatek: mtk-mmsys: Populate multimedia subsystem subdevices AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 38/42] dt-bindings: display: mediatek: Introduce MT8196 2D Sharpness Processor AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 12:20 ` [PATCH 39/42] drm/mediatek: Add Two-Dimension Sharpness Processor (TDSHP) driver AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 40/42] dt-bindings: display: mediatek: Introduce MT8196 Image Resizer AngeloGioacchino Del Regno
2026-07-01 14:23   ` Rob Herring (Arm)
2026-07-01 12:20 ` [PATCH 41/42] drm/mediatek: Add support for Display Image Resizer (Scaler) AngeloGioacchino Del Regno
2026-07-01 12:20 ` [PATCH 42/42] drm/mediatek: mtk_drm_drv: Fail init only if all paths are invalid AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1f7548137633981f5b0fe8be2bfa09f7bef99d7.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Justin.Yeh@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Paul-pl.Chen@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox