linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Neil Armstrong <narmstrong@baylibre.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/11] drm/meson: Add G12A Support for VIU setup
Date: Tue, 09 Apr 2019 10:42:49 +0200	[thread overview]
Message-ID: <8d1c3c13e2ad05aac1f28327ddaa0169ab204b50.camel@baylibre.com> (raw)
In-Reply-To: <20190325141824.21259-5-narmstrong@baylibre.com>

On Mon, 2019-03-25 at 15:18 +0100, Neil Armstrong wrote:
> Amlogic G12A SoC needs a different VIU setup code,
> handle it.
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/meson/meson_viu.c | 72 ++++++++++++++++++++++++++++---
>  1 file changed, 67 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c
> index ac0f3687e09a..0169c98b01c9 100644
> --- a/drivers/gpu/drm/meson/meson_viu.c
> +++ b/drivers/gpu/drm/meson/meson_viu.c
> @@ -90,6 +90,34 @@ static int eotf_bypass_coeff[EOTF_COEFF_SIZE] = {
>  	EOTF_COEFF_RIGHTSHIFT /* right shift */
>  };
>  
> +void meson_viu_set_g12a_osd1_matrix(struct meson_drm *priv, int *m,
> +				   bool csc_on)
> +{
> +	/* VPP WRAP OSD1 matrix */
> +	writel(((m[0] & 0xfff) << 16) | (m[1] & 0xfff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_PRE_OFFSET0_1));
> +	writel(m[2] & 0xfff,
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_PRE_OFFSET2));
> +	writel(((m[3] & 0x1fff) << 16) | (m[4] & 0x1fff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF00_01));
> +	writel(((m[5] & 0x1fff) << 16) | (m[6] & 0x1fff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF02_10));
> +	writel(((m[7] & 0x1fff) << 16) | (m[8] & 0x1fff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF11_12));
> +	writel(((m[9] & 0x1fff) << 16) | (m[10] & 0x1fff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF20_21));
> +	writel((m[11] & 0x1fff) << 16,
> +		priv->io_base +	_REG(VPP_WRAP_OSD1_MATRIX_COEF22));
> +
> +	writel(((m[18] & 0xfff) << 16) | (m[19] & 0xfff),
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_OFFSET0_1));

Can you define some of the masks and shifts above ? possibly the same define
for all the registers I suppose ... maybe using FIELD_PREP ?

> +	writel(m[20] & 0xfff,
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_OFFSET2));
> +
> +	writel_bits_relaxed(BIT(0), csc_on ? BIT(0) : 0,
> +		priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_EN_CTRL));
> +}
> +
>  void meson_viu_set_osd_matrix(struct meson_drm *priv,
>  			      enum viu_matrix_sel_e m_select,
>  			      int *m, bool csc_on)
> @@ -336,14 +364,24 @@ void meson_viu_init(struct meson_drm *priv)
>  	if (meson_vpu_is_compatible(priv, "amlogic,meson-gxm-vpu") ||
>  	    meson_vpu_is_compatible(priv, "amlogic,meson-gxl-vpu"))
>  		meson_viu_load_matrix(priv);
> +	else if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu"))
> +		meson_viu_set_g12a_osd1_matrix(priv, RGB709_to_YUV709l_coeff,
> +					       true);
>  
>  	/* Initialize OSD1 fifo control register */
>  	reg = BIT(0) |	/* Urgent DDR request priority */
> -	      (4 << 5) | /* hold_fifo_lines */
> -	      (3 << 10) | /* burst length 64 */
> -	      (32 << 12) | /* fifo_depth_val: 32*8=256 */
> -	      (2 << 22) | /* 4 words in 1 burst */
> -	      (2 << 24);
> +	      (4 << 5); /* hold_fifo_lines */
> +	if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu"))
> +		reg |= (1 << 10) | /* burst length 32 */
> +		       (32 << 12) | /* fifo_depth_val: 32*8=256 */
> +		       (2 << 22) | /* 4 words in 1 burst */
> +		       (2 << 24) |
> +		       (1 << 31);
> +	else
> +		reg |= (3 << 10) | /* burst length 64 */
> +		       (32 << 12) | /* fifo_depth_val: 32*8=256 */
> +		       (2 << 22) | /* 4 words in 1 burst */
> +		       (2 << 24);

Could you use the BIT() macro and add some defines ?

>  	writel_relaxed(reg, priv->io_base + _REG(VIU_OSD1_FIFO_CTRL_STAT));
>  	writel_relaxed(reg, priv->io_base + _REG(VIU_OSD2_FIFO_CTRL_STAT));
>  
> @@ -369,6 +407,30 @@ void meson_viu_init(struct meson_drm *priv)
>  	writel_relaxed(0x00FF00C0,
>  			priv->io_base + _REG(VD2_IF0_LUMA_FIFO_SIZE));
>  
> +	if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
> +		writel_relaxed(4 << 29 |
> +				1 << 27 |
> +				1 << 26 | /* blend_din0 input to blend0 */
> +				1 << 25 | /* blend1_dout to blend2 */
> +				1 << 24 | /* blend1_din3 input to blend1 */
> +				1 << 20 |
> +				0 << 16 |
> +				1,
> +				priv->io_base + _REG(VIU_OSD_BLEND_CTRL));
> +		writel_relaxed(3 << 8 |
> +				1 << 20,
> +				priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
> +		writel_relaxed(1 << 20,
> +				priv->io_base + _REG(OSD2_BLEND_SRC_CTRL));
> +		writel_relaxed(0, priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
> +		writel_relaxed(0, priv->io_base + _REG(VD2_BLEND_SRC_CTRL));
> +		writel_relaxed(0,
> +				priv->io_base + _REG(VIU_OSD_BLEND_DUMMY_DATA0));
> +		writel_relaxed(0,
> +				priv->io_base + _REG(VIU_OSD_BLEND_DUMMY_ALPHA));
> +		writel_bits_relaxed(0x3 << 2, 0x3 << 2,
> +				priv->io_base + _REG(DOLBY_PATH_CTRL));

Same for this hunk

> +	}
>  
>  	priv->viu.osd1_enabled = false;
>  	priv->viu.osd1_commit = false;



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2019-04-09  8:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25 14:18 [PATCH 00/11] drm/meson: Add G12A Support Neil Armstrong
2019-03-25 14:18 ` [PATCH 01/11] drm/meson: Switch PLL to 5.94GHz base for 297Mhz pixel clock Neil Armstrong
2019-03-25 14:18 ` [PATCH 02/11] drm/meson: Add registers for G12A SoC Neil Armstrong
2019-03-25 14:18 ` [PATCH 03/11] drm/meson: Add G12A Support for VPP setup Neil Armstrong
2019-03-25 14:18 ` [PATCH 04/11] drm/meson: Add G12A Support for VIU setup Neil Armstrong
2019-04-09  8:42   ` Jerome Brunet [this message]
2019-04-09  9:19     ` Neil Armstrong
2019-03-25 14:18 ` [PATCH 05/11] drm/meson: Add G12A support for OSD1 Plane Neil Armstrong
2019-03-25 14:18 ` [PATCH 06/11] drm/meson: Add G12A Support for the Overlay video plane Neil Armstrong
2019-04-09  8:42   ` Jerome Brunet
2019-04-09  9:19     ` Neil Armstrong
2019-03-25 14:18 ` [PATCH 07/11] drm/meson: Add G12A support for plane handling in CRTC driver Neil Armstrong
2019-04-09  8:43   ` Jerome Brunet
2019-04-09  9:17     ` Neil Armstrong
2019-03-25 14:18 ` [PATCH 08/11] drm/meson: Add G12A support for CVBS Encoer Neil Armstrong
2019-04-09  8:43   ` Jerome Brunet
2019-04-09  8:44     ` Jerome Brunet
2019-04-09  9:18       ` Neil Armstrong
2019-04-09  9:18     ` Neil Armstrong
2019-03-25 14:18 ` [PATCH 09/11] drm/meson: Add G12A Video Clock setup Neil Armstrong
2019-04-09  8:46   ` Jerome Brunet
2019-04-09  9:19     ` Neil Armstrong
2019-03-25 14:18 ` [PATCH 10/11] drm/meson: Add G12A compatible Neil Armstrong
2019-03-25 14:18 ` [PATCH 11/11] drm/meson: Add G12A support for the DW-HDMI Glue Neil Armstrong
2019-04-09  8:42 ` [PATCH 00/11] drm/meson: Add G12A Support Jerome Brunet
2019-04-09  8:51   ` Neil Armstrong

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=8d1c3c13e2ad05aac1f28327ddaa0169ab204b50.camel@baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    /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;
as well as URLs for NNTP newsgroup(s).