From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>,
"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>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"wenst@chromium.org" <wenst@chromium.org>,
"Bibby Hsieh (謝濟遠)" <Bibby.Hsieh@mediatek.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"airlied@gmail.com" <airlied@gmail.com>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"sean@poorly.run" <sean@poorly.run>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"fshao@chromium.org" <fshao@chromium.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 06/17] drm/mediatek: Support alpha blending in OVL
Date: Tue, 2 Jan 2024 05:43:30 +0000 [thread overview]
Message-ID: <8eb9f45eea4dfd5feb67d52630cd058293d33abf.camel@mediatek.com> (raw)
In-Reply-To: <20231212121957.19231-7-shawn.sung@mediatek.com>
Hi, Hsiao-chien:
On Tue, 2023-12-12 at 20:19 +0800, Hsiao Chien Sung wrote:
> Support premultiply and coverage alpha blending in
> Overlay.
Describe what kind of alpha blending already support for cursor plane.
And separate premultiply alpha and coverage alpha to two patches.
>
> Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 73 +++++++++++++++++----
> ----
> 1 file changed, 51 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 5aaf4342cdbd..66074c2d917c 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_BYTE_SWAP BIT(24)
> -#define OVL_CON_MTX_YUV_TO_RGB (6 << 16)
> -#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_CLRFMT_MAN BIT(23)
> +#define OVL_CON_BYTE_SWAP BIT(24)
> +#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_PARGB8888 (OVL_CON_CLRFMT_ARGB8888 |
> OVL_CON_CLRFMT_MAN)
> +#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_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 ?
> \
> @@ -208,14 +212,12 @@ void mtk_ovl_clk_disable(struct device *dev)
> void mtk_ovl_start(struct device *dev)
> {
> struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> + unsigned int reg = readl(ovl->regs +
> DISP_REG_OVL_DATAPATH_CON);
>
> - if (ovl->data->smi_id_en) {
> - unsigned int reg;
> + if (ovl->data->smi_id_en)
> + reg |= OVL_LAYER_SMI_ID_EN;
>
> - reg = readl(ovl->regs + DISP_REG_OVL_DATAPATH_CON);
> - reg = reg | OVL_LAYER_SMI_ID_EN;
> - writel_relaxed(reg, ovl->regs +
> DISP_REG_OVL_DATAPATH_CON);
> - }
> + writel_relaxed(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON);
Nothing change in this function, so drop this modification.
> writel_relaxed(0x1, ovl->regs + DISP_REG_OVL_EN);
> }
>
> @@ -274,7 +276,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);
If cursor plane also has this problem, separate this to a bug-fix
patch. If only new alpha blending mode has this problem, describe more
detail why new blending mode has this problem.
Regards,
CK
>
> mtk_ddp_write(cmdq_pkt, 0x1, &ovl->cmdq_reg, ovl->regs,
> DISP_REG_OVL_RST);
> mtk_ddp_write(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs,
> DISP_REG_OVL_RST);
> @@ -357,7 +365,8 @@ void mtk_ovl_layer_off(struct device *dev,
> unsigned int idx,
> DISP_REG_OVL_RDMA_CTRL(idx));
> }
>
> -static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl,
> unsigned int fmt)
> +static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl,
> unsigned int fmt,
> + unsigned int blend_mode)
> {
> /* The return value in switch "MEM_MODE_INPUT_FORMAT_XXX"
> * is defined in mediatek HW data sheet.
> @@ -376,18 +385,30 @@ static unsigned int ovl_fmt_convert(struct
> mtk_disp_ovl *ovl, unsigned int fmt)
> return OVL_CON_CLRFMT_RGB888(ovl) | OVL_CON_BYTE_SWAP;
> case DRM_FORMAT_RGBX8888:
> case DRM_FORMAT_RGBA8888:
> - return OVL_CON_CLRFMT_ARGB8888;
> + return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> + OVL_CON_CLRFMT_ARGB8888 :
> + OVL_CON_CLRFMT_PARGB8888;
> case DRM_FORMAT_BGRX8888:
> case DRM_FORMAT_BGRA8888:
> + return OVL_CON_BYTE_SWAP |
> + (blend_mode == DRM_MODE_BLEND_COVERAGE ?
> + OVL_CON_CLRFMT_ARGB8888 :
> + OVL_CON_CLRFMT_PARGB8888);
> case DRM_FORMAT_BGRA1010102:
> return OVL_CON_CLRFMT_ARGB8888 | OVL_CON_BYTE_SWAP;
> case DRM_FORMAT_XRGB8888:
> case DRM_FORMAT_ARGB8888:
> + return blend_mode == DRM_MODE_BLEND_COVERAGE ?
> + OVL_CON_CLRFMT_RGBA8888 :
> + OVL_CON_CLRFMT_PARGB8888;
> case DRM_FORMAT_ARGB2101010:
> return OVL_CON_CLRFMT_RGBA8888;
> case DRM_FORMAT_XBGR8888:
> case DRM_FORMAT_ABGR8888:
> - return OVL_CON_CLRFMT_RGBA8888 | OVL_CON_BYTE_SWAP;
> + return OVL_CON_RGB_SWAP |
> + (blend_mode == DRM_MODE_BLEND_COVERAGE ?
> + OVL_CON_CLRFMT_RGBA8888 :
> + OVL_CON_CLRFMT_PARGB8888);
> case DRM_FORMAT_UYVY:
> return OVL_CON_CLRFMT_UYVY | OVL_CON_MTX_YUV_TO_RGB;
> case DRM_FORMAT_YUYV:
> @@ -408,6 +429,8 @@ void mtk_ovl_layer_config(struct device *dev,
> unsigned int idx,
> unsigned int fmt = pending->format;
> 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 ignore_pixel_alpha = 0;
> unsigned int con;
> bool is_afbc = pending->modifier != DRM_FORMAT_MOD_LINEAR;
> union overlay_pitch {
> @@ -425,9 +448,15 @@ void mtk_ovl_layer_config(struct device *dev,
> unsigned int idx,
> return;
> }
>
> - con = ovl_fmt_convert(ovl, fmt);
> - if (state->base.fb && state->base.fb->format->has_alpha)
> - con |= OVL_CON_AEN | OVL_CON_ALPHA;
> + con = ovl_fmt_convert(ovl, fmt, blend_mode);
> + if (state->base.fb) {
> + con |= OVL_CON_AEN;
> + con |= state->base.alpha & OVL_CON_ALPHA;
> + }
> +
> + if (blend_mode == DRM_MODE_BLEND_PIXEL_NONE ||
> + (state->base.fb && !state->base.fb->format->has_alpha))
> + ignore_pixel_alpha = OVL_CONST_BLEND;
>
> if (pending->rotation & DRM_MODE_REFLECT_Y) {
> con |= OVL_CON_VIRT_FLIP;
> @@ -444,8 +473,8 @@ 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));
> - mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_pitch.lsb,
> &ovl->cmdq_reg, ovl->regs,
> - DISP_REG_OVL_PITCH(idx));
> + mtk_ddp_write_relaxed(cmdq_pkt, overlay_pitch.split_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,
> DISP_REG_OVL_SRC_SIZE(idx));
> mtk_ddp_write_relaxed(cmdq_pkt, offset, &ovl->cmdq_reg, ovl-
> >regs,
next prev parent reply other threads:[~2024-01-02 5:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 12:19 [PATCH v4 00/17] Support IGT in display driver Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 01/17] soc: mediatek: Add register definitions for GCE Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 02/17] soc: mediatek: Disable 9-bit alpha in ETHDR Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 03/17] dt-bindings: display: mediatek: ovl: Modify rules for MT8195/MT8188 Hsiao Chien Sung
2023-12-12 13:27 ` AngeloGioacchino Del Regno
2023-12-12 12:19 ` [PATCH v4 04/17] drm/mediatek: Add OVL compatible name for MT8195 Hsiao Chien Sung
2023-12-12 13:27 ` AngeloGioacchino Del Regno
2023-12-12 12:19 ` [PATCH v4 05/17] drm/mediatek: Set DRM mode configs accordingly Hsiao Chien Sung
2023-12-12 13:27 ` AngeloGioacchino Del Regno
2024-01-02 3:36 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 06/17] drm/mediatek: Support alpha blending in OVL Hsiao Chien Sung
2024-01-02 5:43 ` CK Hu (胡俊光) [this message]
2023-12-12 12:19 ` [PATCH v4 07/17] drm/mediatek: Support alpha blending in Mixer Hsiao Chien Sung
2024-01-02 5:54 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 08/17] drm/mediatek: Support alpha blending in display driver Hsiao Chien Sung
2024-01-02 6:13 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 09/17] drm/mediatek: Support CSC in OVL Hsiao Chien Sung
2024-01-02 7:14 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 10/17] drm/mediatek: Support more color formats " Hsiao Chien Sung
2024-01-02 7:25 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 11/17] drm/mediatek: Turn off the layers with zero width or height Hsiao Chien Sung
2023-12-12 13:27 ` AngeloGioacchino Del Regno
2023-12-12 12:19 ` [PATCH v4 12/17] drm/mediatek: Support CRC in display driver Hsiao Chien Sung
2024-01-02 8:04 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 13/17] drm/mediatek: Support CRC in OVL Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 14/17] drm/mediatek: Support CRC in OVL adaptor Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 15/17] drm/mediatek: Add missing plane settings when async update Hsiao Chien Sung
2023-12-12 12:19 ` [PATCH v4 16/17] drm/mediatek: Fix errors when reporting rotation capability Hsiao Chien Sung
2024-01-02 8:26 ` CK Hu (胡俊光)
2023-12-12 12:19 ` [PATCH v4 17/17] drm/mediatek: Add comments for the structures Hsiao Chien Sung
2023-12-12 13:27 ` AngeloGioacchino Del Regno
2024-02-01 10:16 ` [PATCH v4 00/17] Support IGT in display driver AngeloGioacchino Del Regno
2024-02-02 9:03 ` Shawn 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=8eb9f45eea4dfd5feb67d52630cd058293d33abf.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=Bibby.Hsieh@mediatek.com \
--cc=Shawn.Sung@mediatek.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fshao@chromium.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--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=robh+dt@kernel.org \
--cc=sean@poorly.run \
--cc=wenst@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
all inboxes | Powered by JetHome®