mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.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>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"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>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v8 15/16] drm/mediatek: Support CRC in OVL
Date: Wed, 12 Jun 2024 01:35:15 +0000	[thread overview]
Message-ID: <a470806f72747044c29097f33978faa545b9936d.camel@mediatek.com> (raw)
In-Reply-To: <20240606092635.27981-16-shawn.sung@mediatek.com>

Hi, Shawn:

On Thu, 2024-06-06 at 17:26 +0800, Shawn Sung wrote:
> From: Hsiao Chien Sung <shawn.sung@mediatek.com>
> 
> We choose OVL as the CRC generator from other hardware
> components that are also capable of calculating CRCs,
> since its frame done event triggers vblanks, it can be
> used as a signal to know when is safe to retrieve CRC of
> the frame.
> 
> Please note that position of the hardware component
> that is chosen as CRC generator in the display path is
> significant. For example, while OVL is the first module
> in VDOSYS0, its CRC won't be affected by the modules
> after it, which means effects applied by PQ, Gamma,
> Dither or any other components after OVL won't be
> calculated in CRC generation.
> 
> Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
> ---

[snip]

>  
>  void mtk_ovl_stop(struct device *dev)
> @@ -489,6 +579,83 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  	    (state->base.fb && !state->base.fb->format->has_alpha))
>  		ignore_pixel_alpha = OVL_CONST_BLEND;
>  
> +	/*
> +	 * OVL only supports 8 bits data in CRC calculation, transform 10-bit
> +	 * RGB to 8-bit RGB by leveraging the ability of the Y2R (YUV-to-RGB)
> +	 * hardware to multiply coefficients, although there is nothing to do
> +	 * with the YUV format.
> +	 */
> +	if (ovl->data->supports_clrfmt_ext) {
> +		u32 y2r_coef = 0, y2r_offset = 0, r2r_coef = 0, csc_en = 0;
> +
> +		if (is_10bit_rgb(fmt)) {
> +			con |= OVL_CON_MTX_AUTO_DIS | OVL_CON_MTX_EN | OVL_CON_MTX_PROGRAMMABLE;
> +
> +			/*
> +			 * Y2R coefficient setting
> +			 * bit 13 is 2^1, bit 12 is 2^0, bit 11 is 2^-1,
> +			 * bit 10 is 2^-2 = 0.25
> +			 */
> +			y2r_coef = BIT(10);
> +
> +			/* -1 in 10bit */
> +			y2r_offset = GENMASK(10, 0) - 1;

I don't know why do this? If an input value is 0x100, then

0x100 right shit 2 bit become 0x40.
0x40 - 1 = 0x3f.
0x3f left shift 2 bit become 0xfc.

So input 0x100 and output 0xfc. Why?

> +
> +			/*
> +			 * R2R coefficient setting
> +			 * bit 19 is 2^1, bit 18 is 2^0, bit 17 is 2^-1,
> +			 * bit 20 is 2^2 = 4
> +			 */
> +			r2r_coef = BIT(20);
> +
> +			/* CSC_EN is for R2R */
> +			csc_en = OVL_CLRFMT_EXT1_CSC_EN(idx);
> +
> +			/*
> +			 * 1. YUV input data - 1 and shift right for 2 bits to remove it
> +			 * [R']   [0.25    0    0]   [Y in - 1]
> +			 * [G'] = [   0 0.25    0] * [U in - 1]
> +			 * [B']   [   0    0 0.25]   [V in - 1]
> +			 *
> +			 * 2. shift left for 2 bit letting the last 2 bits become 0

You truncate the last two bit, so some quality lost. I think the
quality is main function and CRC is just for debug. So it's better that
in normal case we keep quality and only for debug to lost the quality.
 
I have another question. You just truncate the last two bit but it is
still 10 bit value, so CRC could calculate this 10 bit value? I don't
know why you say CRC just for 8 bit?
 
Regards,
CK

> +			 * [R out]   [ 4  0  0]   [R']
> +			 * [G out] = [ 0  4  0] * [G']
> +			 * [B out]   [ 0  0  4]   [B']
> +			 */
> +		}
> +
> +		mtk_ddp_write_mask(cmdq_pkt, y2r_coef,
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_R0(idx),
> +				   OVL_Y2R_PARA_C_CF_RMY);
> +		mtk_ddp_write_mask(cmdq_pkt, (y2r_coef << 16),
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_G0(idx),
> +				   OVL_Y2R_PARA_C_CF_GMU);
> +		mtk_ddp_write_mask(cmdq_pkt, y2r_coef,
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_B1(idx),
> +				   OVL_Y2R_PARA_C_CF_BMV);
> +
> +		mtk_ddp_write_mask(cmdq_pkt, y2r_offset,
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_0(idx),
> +				   OVL_Y2R_PARA_C_CF_YA);
> +		mtk_ddp_write_mask(cmdq_pkt, (y2r_offset << 16),
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_0(idx),
> +				   OVL_Y2R_PARA_C_CF_UA);
> +		mtk_ddp_write_mask(cmdq_pkt, y2r_offset,
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_Y2R_PARA_YUV_A_1(idx),
> +				   OVL_Y2R_PARA_C_CF_VA);
> +
> +		mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef,
> +				      &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_R0(idx));
> +		mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef,
> +				      &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_G1(idx));
> +		mtk_ddp_write_relaxed(cmdq_pkt, r2r_coef,
> +				      &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_R2R_B2(idx));
> +
> +		mtk_ddp_write_mask(cmdq_pkt, csc_en,
> +				   &ovl->cmdq_reg, ovl->regs, DISP_REG_OVL_CLRFMT_EXT1,
> +				   OVL_CLRFMT_EXT1_CSC_EN(idx));
> +	}
> +
>  	if (pending->rotation & DRM_MODE_REFLECT_Y) {
>  		con |= OVL_CON_VIRT_FLIP;
>  		addr += (pending->height - 1) * pending->pitch;
> 

  reply	other threads:[~2024-06-12  1:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  9:26 [PATCH v8 00/16] Support IGT in display driver Shawn Sung
2024-06-06  9:26 ` [PATCH v8 01/16] soc: mediatek: Disable 9-bit alpha in ETHDR Shawn Sung
2024-06-06  9:26 ` [PATCH v8 02/16] drm/mediatek: Add OVL compatible name for MT8195 Shawn Sung
2024-06-06  9:26 ` [PATCH v8 03/16] drm/mediatek: Add missing plane settings when async update Shawn Sung
2024-06-06  9:26 ` [PATCH v8 04/16] drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property Shawn Sung
2024-06-06  9:26 ` [PATCH v8 05/16] drm/mediatek: Set DRM mode configs accordingly Shawn Sung
2024-06-10  8:14   ` AngeloGioacchino Del Regno
2024-06-06  9:26 ` [PATCH v8 06/16] drm/mediatek: Turn off the layers with zero width or height Shawn Sung
2024-06-06  9:26 ` [PATCH v8 07/16] drm/mediatek: Support more 10bit formats in OVL Shawn Sung
2024-06-10  8:14   ` AngeloGioacchino Del Regno
2024-06-06  9:26 ` [PATCH v8 08/16] drm/mediatek: Support RGBA8888 and RGBX8888 in OVL on MT8195 Shawn Sung
2024-06-10  8:14   ` AngeloGioacchino Del Regno
2024-06-11  8:10   ` CK Hu (胡俊光)
2024-06-06  9:26 ` [PATCH v8 09/16] drm/mediatek: Support "None" blending in OVL Shawn Sung
2024-06-11  8:06   ` CK Hu (胡俊光)
2024-06-06  9:26 ` [PATCH v8 10/16] drm/mediatek: Support "None" blending in Mixer Shawn Sung
2024-06-11  9:01   ` CK Hu (胡俊光)
2024-06-06  9:26 ` [PATCH v8 11/16] drm/mediatek: Support "Pre-multiplied" blending in OVL Shawn Sung
2024-06-11  9:39   ` CK Hu (胡俊光)
2024-06-06  9:26 ` [PATCH v8 12/16] drm/mediatek: Support "Pre-multiplied" blending in Mixer Shawn Sung
2024-06-11 10:05   ` CK Hu (胡俊光)
2024-06-06  9:26 ` [PATCH v8 13/16] drm/mediatek: Support alpha blending in display driver Shawn Sung
2024-06-06  9:26 ` [PATCH v8 14/16] drm/mediatek: Support CRC " Shawn Sung
2024-06-12  1:22   ` CK Hu (胡俊光)
2024-06-21  7:27     ` Jason-JH Lin (林睿祥)
2024-06-15 21:21   ` kernel test robot
2024-06-06  9:26 ` [PATCH v8 15/16] drm/mediatek: Support CRC in OVL Shawn Sung
2024-06-12  1:35   ` CK Hu (胡俊光) [this message]
2024-06-21  9:57     ` Jason-JH Lin (林睿祥)
2024-06-06  9:26 ` [PATCH v8 16/16] drm/mediatek: Support CRC in OVL adaptor 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=a470806f72747044c29097f33978faa545b9936d.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Bibby.Hsieh@mediatek.com \
    --cc=Nancy.Lin@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=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=sean@poorly.run \
    /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®