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 02/42] drm/mediatek: Export OVL formats definitions and format conversion API
Date: Thu, 2 Jul 2026 09:36:11 +0000	[thread overview]
Message-ID: <fb138206f2b2043d5207f341a1d97f53b024a2e7.camel@mediatek.com> (raw)
In-Reply-To: <20260701122057.19648-3-angelogioacchino.delregno@collabora.com>

On Wed, 2026-07-01 at 14:20 +0200, AngeloGioacchino Del Regno wrote:
> From: Nancy Lin <nancy.lin@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@mediatek.com>
> Signed-off-by: Paul-pl Chen <paul-pl.chen@mediatek.com>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---

[snip]

>  
> -static unsigned int mtk_ovl_fmt_convert(struct mtk_disp_ovl *ovl,
> -					struct mtk_plane_state *state)
> +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)
>  {
> -	unsigned int fmt = state->pending.format;
> -	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_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 (ovl->data->blend_modes & BIT(DRM_MODE_BLEND_PREMULTI))
> -		blend_mode = state->base.pixel_blend_mode;
> +	unsigned int con = 0;
> +	bool need_byte_swap = false, need_rgb_swap = false;
>  
>  	switch (fmt) {
>  	default:
>  	case DRM_FORMAT_RGB565:
> -		return OVL_CON_CLRFMT_RGB565(ovl);
> +		con = fmt_rgb565_is_0 ?
> +			OVL_CON_CLRFMT_RGB565(clrfmt_shift) : OVL_CON_CLRFMT_RGB888(clrfmt_shift);
> +	break;

One more indent.

>  	case DRM_FORMAT_BGR565:
> -		return OVL_CON_CLRFMT_RGB565(ovl) | OVL_CON_BYTE_SWAP;
> +		con = fmt_rgb565_is_0 ?
> +			OVL_CON_CLRFMT_RGB565(clrfmt_shift) : OVL_CON_CLRFMT_RGB888(clrfmt_shift);
> +		need_byte_swap = true;	/* RGB565 -> BGR565 */
> +	break;
>  	case DRM_FORMAT_RGB888:
> -		return OVL_CON_CLRFMT_RGB888(ovl);
> +		con = fmt_rgb565_is_0 ?
> +			OVL_CON_CLRFMT_RGB888(clrfmt_shift) : OVL_CON_CLRFMT_RGB565(clrfmt_shift);
> +	break;
>  	case DRM_FORMAT_BGR888:
> -		return OVL_CON_CLRFMT_RGB888(ovl) | OVL_CON_BYTE_SWAP;
> +		con = fmt_rgb565_is_0 ?
> +			OVL_CON_CLRFMT_RGB888(clrfmt_shift) : OVL_CON_CLRFMT_RGB565(clrfmt_shift);
> +		need_byte_swap = true;	/* RGB888 -> BGR888 */
> +	break;
>  	case DRM_FORMAT_RGBX8888:
>  	case DRM_FORMAT_RGBA8888:
>  	case DRM_FORMAT_RGBX1010102:
>  	case DRM_FORMAT_RGBA1010102:
> -		return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> -		       OVL_CON_CLRFMT_RGBA8888 :
> -		       OVL_CON_CLRFMT_PRGBA8888;
> +		if (blend_mode == DRM_MODE_BLEND_COVERAGE) {
> +			con = OVL_CON_CLRFMT_RGBA8888(clrfmt_shift);
> +		} else {
> +			con = OVL_CON_CLRFMT_PARGB8888(clrfmt_shift, clrfmt_man);
> +			need_byte_swap = true;	/* PARGB8888 -> PBGRA8888 */
> +			need_rgb_swap = true;	/* PBGRA8888 -> PRGBA8888 */
> +		}
> +	break;
>  	case DRM_FORMAT_BGRX8888:
>  	case DRM_FORMAT_BGRA8888:
>  	case DRM_FORMAT_BGRX1010102:
>  	case DRM_FORMAT_BGRA1010102:
> -		return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> -		       OVL_CON_CLRFMT_BGRA8888 :
> -		       OVL_CON_CLRFMT_PBGRA8888;
> +		if (blend_mode == DRM_MODE_BLEND_COVERAGE) {
> +			con = OVL_CON_CLRFMT_RGBA8888(clrfmt_shift);
> +			need_byte_swap = true;	/* RGB8888 -> BGR8888 */

/* RGBA8888 -> BGRA8888 */

Regards,
CK

> +		} else {
> +			con = OVL_CON_CLRFMT_PARGB8888(clrfmt_shift, clrfmt_man);
> +			need_byte_swap = true;	/* PARGB8888 -> PBGRA8888 */
> +		}
> +	break;
>  	case DRM_FORMAT_XRGB8888:
>  	case DRM_FORMAT_ARGB8888:
>  	case DRM_FORMAT_XRGB2101010:
>  	case DRM_FORMAT_ARGB2101010:
> -		return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> -		       OVL_CON_CLRFMT_ARGB8888 :
> -		       OVL_CON_CLRFMT_PARGB8888;
> +		if (blend_mode == DRM_MODE_BLEND_COVERAGE)
> +			con = OVL_CON_CLRFMT_ARGB8888(clrfmt_shift);
> +		else
> +			con = OVL_CON_CLRFMT_PARGB8888(clrfmt_shift, clrfmt_man);
> +	break;
>  	case DRM_FORMAT_XBGR8888:
>  	case DRM_FORMAT_ABGR8888:
>  	case DRM_FORMAT_XBGR2101010:
>  	case DRM_FORMAT_ABGR2101010:
> -		return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> -		       OVL_CON_CLRFMT_ABGR8888 :
> -		       OVL_CON_CLRFMT_PABGR8888;
> +		if (blend_mode == DRM_MODE_BLEND_COVERAGE) {
> +			con = OVL_CON_CLRFMT_ARGB8888(clrfmt_shift);
> +			need_rgb_swap = true;	/* ARGB8888 -> ABGR8888 */
> +		} else {
> +			con = OVL_CON_CLRFMT_PARGB8888(clrfmt_shift, clrfmt_man);
> +			need_rgb_swap = true;	/* PARGB8888 -> PABGR8888 */
> +		}
> +	break;
>  	case DRM_FORMAT_UYVY:
> -		return OVL_CON_CLRFMT_UYVY | OVL_CON_MTX_YUV_TO_RGB;
> +		con = OVL_CON_CLRFMT_UYVY(clrfmt_shift);
> +		if (color_convert)
> +			con |= OVL_CON_MTX_YUV_TO_RGB;
> +	break;
>  	case DRM_FORMAT_YUYV:
> -		return OVL_CON_CLRFMT_YUYV | OVL_CON_MTX_YUV_TO_RGB;
> +		con = OVL_CON_CLRFMT_YUYV(clrfmt_shift);
> +		if (color_convert)
> +			con |= OVL_CON_MTX_YUV_TO_RGB;
> +	break;
>  	}
> +
> +	if (need_byte_swap)
> +		con |= byte_swap;
> +
> +	if (need_rgb_swap)
> +		con |= rgb_swap;
> +
> +	return con;
>  }
>  


  reply	other threads:[~2026-07-02  9:36 UTC|newest]

Thread overview: 52+ 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 (胡俊光) [this message]
2026-07-01 12:20 ` [PATCH 03/42] drm/mediatek: Export OVL Blend function AngeloGioacchino Del Regno
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-01 12:20 ` [PATCH 05/42] drm/mediatek: Rename all display component type to have DISP_ prefix AngeloGioacchino Del Regno
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=fb138206f2b2043d5207f341a1d97f53b024a2e7.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