mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rex-BC Chen <rex-bc.chen@mediatek.com>
To: CK Hu <ck.hu@mediatek.com>, <chunkuang.hu@kernel.org>,
	<p.zabel@pengutronix.de>, <daniel@ffwll.ch>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <matthias.bgg@gmail.com>,
	<airlied@linux.ie>
Cc: <msp@baylibre.com>, <granquet@baylibre.com>,
	<jitao.shi@mediatek.com>, <wenst@chromium.org>,
	<angelogioacchino.delregno@collabora.com>,
	<dri-devel@lists.freedesktop.org>,
	<linux-mediatek@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<Project_Global_Chrome_Upstream_Group@mediatek.com>
Subject: Re: [PATCH v14 12/15] drm/mediatek: dpi: Add YUV422 output support
Date: Tue, 28 Jun 2022 10:28:56 +0800	[thread overview]
Message-ID: <5b0613b9cc983e24a997c122b2892b35cf8346d3.camel@mediatek.com> (raw)
In-Reply-To: <a59a61a81e45fd361774a28a66ffd3d673cb3148.camel@mediatek.com>

On Tue, 2022-06-28 at 10:15 +0800, CK Hu wrote:
> Hi, Bo-Chen:
> 
> On Fri, 2022-06-24 at 11:09 +0800, Bo-Chen Chen wrote:
> > Dp_intf supports YUV422 as output format. In MT8195 Chrome project,
> > YUV422 output format is used for 4K resolution.
> > 
> > To support this, it is also needed to support color format
> > transfer.
> > Color format transfer is a new feature for both dpi and dpintf of
> > MT8195.
> > 
> > The input format could be RGB888 and output format for dp_intf
> > should
> > be
> > YUV422. Therefore, we add a mtk_dpi_matrix_sel() helper to update
> > the
> > DPI_MATRIX_SET register depending on the color format.
> > 
> > Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
> > Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com>
> > Reviewed-by: AngeloGioacchino Del Regno <
> > angelogioacchino.delregno@collabora.com>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_dpi.c      | 34
> > ++++++++++++++++++++++++-
> >  drivers/gpu/drm/mediatek/mtk_dpi_regs.h |  3 +++
> >  2 files changed, 36 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c
> > b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > index 9e4250356342..438bf3bc5e4a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > @@ -128,6 +128,7 @@ struct mtk_dpi_yc_limit {
> >   * @num_output_fmts: Quantity of supported output formats.
> >   * @is_ck_de_pol: Support CK/DE polarity.
> >   * @swap_input_support: Support input swap function.
> > + * @color_fmt_trans_support: Enable color format transfer.
> >   * @dimension_mask: Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and
> > VSYNC_PORCH
> >   *		    (no shift).
> >   * @hvsize_mask: Mask of HSIZE and VSIZE mask (no shift).
> > @@ -144,6 +145,7 @@ struct mtk_dpi_conf {
> >  	u32 num_output_fmts;
> >  	bool is_ck_de_pol;
> >  	bool swap_input_support;
> > +	bool color_fmt_trans_support;
> >  	u32 dimension_mask;
> >  	u32 hvsize_mask;
> >  	u32 channel_swap_shift;
> > @@ -412,6 +414,31 @@ static void mtk_dpi_config_disable_edge(struct
> > mtk_dpi *dpi)
> >  		mtk_dpi_mask(dpi, dpi->conf->reg_h_fre_con, 0,
> > EDGE_SEL_EN);
> >  }
> >  
> > +static void mtk_dpi_matrix_sel(struct mtk_dpi *dpi,
> > +			       enum mtk_dpi_out_color_format format)
> > +{
> > +	u32 matrix_sel = 0;
> > +
> > +	if (!dpi->conf->color_fmt_trans_support) {
> > +		dev_info(dpi->dev, "matrix_sel is not supported.\n");
> > +		return;
> > +	}
> > +
> > +	switch (format) {
> > +	case MTK_DPI_COLOR_FORMAT_YCBCR_422:
> > +	case MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL:
> > +	case MTK_DPI_COLOR_FORMAT_YCBCR_444:
> > +	case MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL:
> 
> I think the transform formula are different for full range and non-
> full 
> range. Please make sure '0x2' is for full range or non-full range. If
> you are not sure, you could provide the transform matrix of '0x2' so
> we
> could find out it's full or non-full.
> 
> > +	case MTK_DPI_COLOR_FORMAT_XV_YCC:
> > +		if (dpi->mode.hdisplay <= 720)
> > +			matrix_sel = 0x2;
> 
> Symbolize '0x2'.
> 
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +	mtk_dpi_mask(dpi, DPI_MATRIX_SET, matrix_sel,
> > INT_MATRIX_SEL_MASK);
> > +}
> > +
> >  static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
> >  					enum mtk_dpi_out_color_format
> > format)
> >  {
> > @@ -419,6 +446,7 @@ static void mtk_dpi_config_color_format(struct
> > mtk_dpi *dpi,
> >  	    (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
> >  		mtk_dpi_config_yuv422_enable(dpi, false);
> >  		mtk_dpi_config_csc_enable(dpi, true);
> > +		mtk_dpi_matrix_sel(dpi, format);
> 
> Why mt8173 support MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL but it does
> not
> call mtk_dpi_matrix_sel()? It seems that mt8173 also need to call
> mtk_dpi_matrix_sel() but lost and this patch looks like a bug fix for
> all SoC DPI driver.
> 
> Regards,
> CK
> 

Hello CK,

MT8173 does not support MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL as output
format, the output format is:

static const u32 mt8173_output_fmts[] = {
	MEDIA_BUS_FMT_RGB888_1X24,
};

or do I misunderstand?

BRs,
Bo-Chen

> >  		if (dpi->conf->swap_input_support)
> >  			mtk_dpi_config_swap_input(dpi, false);
> >  		mtk_dpi_config_channel_swap(dpi,
> > MTK_DPI_OUT_CHANNEL_SWAP_BGR);
> > @@ -426,6 +454,7 @@ static void mtk_dpi_config_color_format(struct
> > mtk_dpi *dpi,
> >  		   (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
> >  		mtk_dpi_config_yuv422_enable(dpi, true);
> >  		mtk_dpi_config_csc_enable(dpi, true);
> > +		mtk_dpi_matrix_sel(dpi, format);
> >  		if (dpi->conf->swap_input_support)
> >  			mtk_dpi_config_swap_input(dpi, true);
> >  		else
> > @@ -673,7 +702,10 @@ static int mtk_dpi_bridge_atomic_check(struct
> > drm_bridge *bridge,
> >  	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
> >  	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
> >  	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
> > -	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
> > +	if (out_bus_format == MEDIA_BUS_FMT_YUYV8_1X16)
> > +		dpi->color_format =
> > MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL;
> > +	else
> > +		dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
> >  
> >  	return 0;
> >  }
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> > b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> > index 3a02fabe1662..cca0dccb84a2 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> > +++ b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> > @@ -217,4 +217,7 @@
> >  
> >  #define EDGE_SEL_EN			BIT(5)
> >  #define H_FRE_2N			BIT(25)
> > +
> > +#define DPI_MATRIX_SET		0xB4
> > +#define INT_MATRIX_SEL_MASK		GENMASK(4, 0)
> >  #endif /* __MTK_DPI_REGS_H */
> 
> 


  reply	other threads:[~2022-06-28  2:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  3:09 [PATCH v14 00/15] drm/mediatek: Add MT8195 dp_intf driver Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 01/15] dt-bindings: mediatek,dpi: Add DP_INTF compatible Bo-Chen Chen
2022-06-27  7:50   ` CK Hu
2022-06-27  9:07     ` Rex-BC Chen
2022-06-28  2:42       ` CK Hu
2022-06-30 22:15   ` Rob Herring
2022-06-24  3:09 ` [PATCH v14 02/15] dt-bindings: mediatek,dpi: Revise mediatek strings to correct format Bo-Chen Chen
2022-06-27  7:55   ` CK Hu
2022-06-30 22:16   ` Rob Herring
2022-06-24  3:09 ` [PATCH v14 03/15] drm/mediatek: dpi: Add kernel document for struct mtk_dpi_conf Bo-Chen Chen
2022-06-27  8:54   ` CK Hu
2022-06-24  3:09 ` [PATCH v14 04/15] drm/mediatek: dpi: Add support for quantization range Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 05/15] drm/mediatek: dpi: implement a CK/DE pol toggle in SoC config Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 06/15] drm/mediatek: dpi: implement a swap_input " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 07/15] drm/mediatek: dpi: move dimension mask to " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 08/15] drm/mediatek: dpi: move hvsize_mask " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 09/15] drm/mediatek: dpi: move swap_shift " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 10/15] drm/mediatek: dpi: move the yuv422_en_bit " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 11/15] drm/mediatek: dpi: move the csc_enable bit " Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 12/15] drm/mediatek: dpi: Add YUV422 output support Bo-Chen Chen
2022-06-28  2:15   ` CK Hu
2022-06-28  2:28     ` Rex-BC Chen [this message]
2022-06-28  2:38       ` CK Hu
2022-06-28  3:01         ` Rex-BC Chen
2022-06-28  3:23           ` CK Hu
2022-06-28  3:27             ` Rex-BC Chen
2022-06-24  3:09 ` [PATCH v14 13/15] drm/mediatek: dpi: add config to support direct connection to dpi panels Bo-Chen Chen
2022-06-24  3:09 ` [PATCH v14 14/15] drm/mediatek: dpi: Add dp_intf support Bo-Chen Chen
2022-06-27 10:52   ` AngeloGioacchino Del Regno
2022-06-24  3:09 ` [PATCH v14 15/15] drm/mediatek: dpi: Only enable dpi after the bridge is enabled Bo-Chen Chen
2022-06-27 10:52   ` 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=5b0613b9cc983e24a997c122b2892b35cf8346d3.camel@mediatek.com \
    --to=rex-bc.chen@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=airlied@linux.ie \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=ck.hu@mediatek.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=granquet@baylibre.com \
    --cc=jitao.shi@mediatek.com \
    --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=msp@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --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®