public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>
To: "angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Bibby Hsieh (謝濟遠)" <Bibby.Hsieh@mediatek.com>,
	"jason-ch.chen@mediatek.corp-partner.google.com"
	<jason-ch.chen@mediatek.corp-partner.google.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"CK Hu (胡俊光)" <ck.hu@mediatek.com>,
	"seanpaul@chromium.org" <seanpaul@chromium.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"fshao@chromium.org" <fshao@chromium.org>
Subject: Re: [PATCH v5 08/13] drm/mediatek: Support alpha blending in OVL
Date: Fri, 16 Feb 2024 02:17:48 +0000	[thread overview]
Message-ID: <111ddf7030051aa71d1283bd2eb4f23718eb8a9c.camel@mediatek.com> (raw)
In-Reply-To: <7664fece-c29a-4374-a59c-4ce8fe831494@collabora.com>

Hi Angelo,

On Thu, 2024-02-15 at 12:02 +0100, AngeloGioacchino Del Regno wrote:
> Il 15/02/24 11:11, Hsiao Chien Sung ha scritto:
> > Support "Pre-multiplied" and "None" blend mode on MediaTek's chips.
> > Before this patch, only the "Coverage" mode is supported.
> > 
> > Please refer to the description of the commit
> > "drm/mediatek: Support alpha blending in display driver"
> > for more information.
> > 
> > Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
> > ---
> >   drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 83
> > +++++++++++++++++++++----
> >   1 file changed, 72 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > index c42fce38a35eb..98c989fddcc08 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > @@ -39,6 +39,7 @@
> >   #define DISP_REG_OVL_PITCH_MSB(n)		(0x0040 + 0x20 * (n))
> >   #define OVL_PITCH_MSB_2ND_SUBBUF			BIT(16)
> >   #define DISP_REG_OVL_PITCH(n)			(0x0044 + 0x20
> > * (n))
> > +#define OVL_CONST_BLEND					BIT(28)
> >   #define DISP_REG_OVL_RDMA_CTRL(n)		(0x00c0 + 0x20 * (n))
> >   #define DISP_REG_OVL_RDMA_GMC(n)		(0x00c8 + 0x20 * (n))
> >   #define DISP_REG_OVL_ADDR_MT2701		0x0040
> > @@ -52,13 +53,16 @@
> >   #define GMC_THRESHOLD_HIGH	((1 << GMC_THRESHOLD_BITS) / 4)
> >   #define GMC_THRESHOLD_LOW	((1 << GMC_THRESHOLD_BITS) / 8)
> >   
> > +#define OVL_CON_CLRFMT_MAN	BIT(23)
> >   #define OVL_CON_BYTE_SWAP	BIT(24)
> > -#define OVL_CON_MTX_YUV_TO_RGB	(6 << 16)
> > +#define OVL_CON_RGB_SWAP	BIT(25)
> >   #define OVL_CON_CLRFMT_RGB	(1 << 12)
> >   #define OVL_CON_CLRFMT_RGBA8888	(2 << 12)
> >   #define OVL_CON_CLRFMT_ARGB8888	(3 << 12)
> >   #define OVL_CON_CLRFMT_UYVY	(4 << 12)
> >   #define OVL_CON_CLRFMT_YUYV	(5 << 12)
> > +#define OVL_CON_MTX_YUV_TO_RGB	(6 << 16)
> > +#define OVL_CON_CLRFMT_PARGB8888	(OVL_CON_CLRFMT_ARGB8888 |
> > OVL_CON_CLRFMT_MAN)
> >   #define OVL_CON_CLRFMT_RGB565(ovl)	((ovl)->data-
> > >fmt_rgb565_is_0 ? \
> >   					0 : OVL_CON_CLRFMT_RGB)
> >   #define OVL_CON_CLRFMT_RGB888(ovl)	((ovl)->data-
> > >fmt_rgb565_is_0 ? \
> > @@ -72,6 +76,22 @@
> >   #define	OVL_CON_VIRT_FLIP	BIT(9)
> >   #define	OVL_CON_HORZ_FLIP	BIT(10)
> >   
> > +static inline bool is_10bit_rgb(u32 fmt)
> > +{
> > +	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;
> > +}
> > +
> >   static const u32 mt8173_formats[] = {
> >   	DRM_FORMAT_XRGB8888,
> >   	DRM_FORMAT_ARGB8888,
> > @@ -89,12 +109,20 @@ static const u32 mt8173_formats[] = {
> >   static const u32 mt8195_formats[] = {
> >   	DRM_FORMAT_XRGB8888,
> >   	DRM_FORMAT_ARGB8888,
> > +	DRM_FORMAT_XRGB2101010,
> >   	DRM_FORMAT_ARGB2101010,
> >   	DRM_FORMAT_BGRX8888,
> >   	DRM_FORMAT_BGRA8888,
> > +	DRM_FORMAT_BGRX1010102,
> >   	DRM_FORMAT_BGRA1010102,
> >   	DRM_FORMAT_ABGR8888,
> >   	DRM_FORMAT_XBGR8888,
> > +	DRM_FORMAT_XBGR2101010,
> > +	DRM_FORMAT_ABGR2101010,
> > +	DRM_FORMAT_RGBX8888,
> > +	DRM_FORMAT_RGBA8888,
> > +	DRM_FORMAT_RGBX1010102,
> > +	DRM_FORMAT_RGBA1010102,
> >   	DRM_FORMAT_RGB888,
> >   	DRM_FORMAT_BGR888,
> >   	DRM_FORMAT_RGB565,
> > @@ -254,9 +282,7 @@ static void mtk_ovl_set_bit_depth(struct device
> > *dev, int idx, u32 format,
> >   	reg = readl(ovl->regs + DISP_REG_OVL_CLRFMT_EXT);
> >   	reg &= ~OVL_CON_CLRFMT_BIT_DEPTH_MASK(idx);
> >   
> > -	if (format == DRM_FORMAT_RGBA1010102 ||
> > -	    format == DRM_FORMAT_BGRA1010102 ||
> > -	    format == DRM_FORMAT_ARGB2101010)
> > +	if (is_10bit_rgb(format))
> >   		bit_depth = OVL_CON_CLRFMT_10_BIT;
> >   
> >   	reg |= OVL_CON_CLRFMT_BIT_DEPTH(bit_depth, idx);
> > @@ -274,7 +300,13 @@ void mtk_ovl_config(struct device *dev,
> > unsigned int w,
> >   	if (w != 0 && h != 0)
> >   		mtk_ddp_write_relaxed(cmdq_pkt, h << 16 | w, &ovl-
> > >cmdq_reg, ovl->regs,
> >   				      DISP_REG_OVL_ROI_SIZE);
> > -	mtk_ddp_write_relaxed(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs, 
> > DISP_REG_OVL_ROI_BGCLR);
> > +
> > +	/*
> > +	 * The background color should be opaque black (ARGB),
> > +	 * otherwise there will be no effect with alpha blend
> > +	 */
> > +	mtk_ddp_write_relaxed(cmdq_pkt, 0xff000000, &ovl->cmdq_reg,
> > +			      ovl->regs, DISP_REG_OVL_ROI_BGCLR);
> 
> Multiple (all of?) OVL color registers, like{L0-3,EL0-
> 2}_YUV1BIT_COLOR(x),
> ROI_BGCLR, L{0-3}_CLR and others do follow this exact layout:
> 
> #define OVL_COLOR_ALPHA				GENMASK(31, 24)
> #define OVL_COLOR_GREEN				GENMASK(23, 16)
> #define OVL_COLOR_RED				GENMASK(15, 8)
> #define OVL_COLOR_BLUE				GENMASK(7, 0)
> 
> ...so we can define those as they're valid for multiple registers,
> and then
> we can use the definition instead of an apparently random value.

Got it. Will modify it in the next version.

> 
> /*
>   * The background color should be opaque black (ARGB),
>   * otherwise there will be no effect with alpha blend
>   */
> mtk_ddp_write_relaxed(cmdq_pkt, OVL_COLOR_ALPHA, &ovl->cmdq_reg,
> 		      ovl->regs, DISP_REG_OVL_ROI_BGCLR);
> 
> Everything else looks ok.
> 
> Regards,
> Angelo
> 

Thanks,
Shawn
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-02-16  2:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 10:11 [PATCH v5 00/13] Support IGT in display driver Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 01/13] soc: mediatek: Disable 9-bit alpha in ETHDR Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 02/13] drm/mediatek: Add OVL compatible name for MT8195 Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 03/13] drm/mediatek: Add missing plane settings when async update Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 04/13] drm/mediatek: Fix errors when reporting rotation capability Hsiao Chien Sung
2024-03-01  6:56   ` CK Hu (胡俊光)
2024-02-15 10:11 ` [PATCH v5 05/13] drm/mediatek: Set DRM mode configs accordingly Hsiao Chien Sung
2024-03-01  7:21   ` CK Hu (胡俊光)
2024-03-19  7:16     ` Shawn Sung (宋孝謙)
2024-02-15 10:11 ` [PATCH v5 06/13] drm/mediatek: Turn off the layers with zero width or height Hsiao Chien Sung
2024-02-15 10:45   ` AngeloGioacchino Del Regno
2024-02-16  2:03     ` Shawn Sung (宋孝謙)
2024-03-01  7:51   ` CK Hu (胡俊光)
2024-03-19  7:34     ` Shawn Sung (宋孝謙)
2024-02-15 10:11 ` [PATCH v5 07/13] drm/mediatek: Support alpha blending in display driver Hsiao Chien Sung
2024-02-15 10:46   ` AngeloGioacchino Del Regno
2024-02-15 10:11 ` [PATCH v5 08/13] drm/mediatek: Support alpha blending in OVL Hsiao Chien Sung
2024-02-15 11:02   ` AngeloGioacchino Del Regno
2024-02-16  2:17     ` Shawn Sung (宋孝謙) [this message]
2024-03-01  9:01   ` CK Hu (胡俊光)
2024-02-15 10:11 ` [PATCH v5 09/13] drm/mediatek: Support alpha blending in Mixer Hsiao Chien Sung
2024-03-01  9:07   ` CK Hu (胡俊光)
2024-02-15 10:11 ` [PATCH v5 10/13] drm/mediatek: Support CRC in display driver Hsiao Chien Sung
2024-02-15 11:06   ` AngeloGioacchino Del Regno
2024-02-16  2:16     ` Shawn Sung (宋孝謙)
2024-02-16 17:04   ` Daniel Vetter
2024-02-16 17:17     ` Daniel Vetter
2024-02-19  2:28       ` Shawn Sung (宋孝謙)
2024-02-19  2:06     ` Shawn Sung (宋孝謙)
2024-02-15 10:11 ` [PATCH v5 11/13] drm/mediatek: Support CRC in OVL Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 12/13] drm/mediatek: Support CRC in OVL adaptor Hsiao Chien Sung
2024-02-15 10:11 ` [PATCH v5 13/13] drm/mediatek: Add comments for the structures Hsiao Chien Sung

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=111ddf7030051aa71d1283bd2eb4f23718eb8a9c.camel@mediatek.com \
    --to=shawn.sung@mediatek.com \
    --cc=Bibby.Hsieh@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=ck.hu@mediatek.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fshao@chromium.org \
    --cc=jason-ch.chen@mediatek.corp-partner.google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=seanpaul@chromium.org \
    /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