public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Cc: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Hans Verkuil" <hverkuil@kernel.org>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: renesas: vin: Fix RAW8 (again)
Date: Wed, 18 Mar 2026 22:04:29 +0200	[thread overview]
Message-ID: <20260318200429.GA716464@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260127-rcar-fix-raw8-again-v1-1-642283bc0fa4@ideasonboard.com>

Hi Tomi,

Thank you for the patch.

On Tue, Jan 27, 2026 at 10:56:12AM +0200, Tomi Valkeinen wrote:
> Commit e7376745ad5c ("media: rcar-vin: Fix stride setting for RAW8
> formats") removed dividing the stride by two for RAW8 formats. It is
> unclear how this was tested, but in any of the recent tests this does
> not seem to work and produces quite distorted images.
> 
> However, reverting the patch fixes the issues only partially. VNIS_REG
> requires alignment to 16 bytes, and when dividing the stride by 2, in
> some cases we end up with a non-aligned stride, producing a tilted
> image. This issue has to be fixed in rvin_format_bytesperline() where we
> do the alignment for bytesperline.
> 
> Adding back the stride division and increasing the alignment for RAW8
> formats to 0x20 fixes the problems related to RAW8.
> 
> Fixes: e7376745ad5c ("media: rcar-vin: Fix stride setting for RAW8 formats")
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 22 ++++++++++++++++++++++
>  .../media/platform/renesas/rcar-vin/rcar-v4l2.c    | 12 ++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index b619d1436a41..f9af9177e02f 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -676,8 +676,30 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
>  	if (vin->scaler)
>  		vin->scaler(vin);
>  
> +	/*
> +	 * VNIS_REG has four lowest bits always 0, i.e. the stride has to be
> +	 * aligned to 16 bytes. This is done in rvin_format_bytesperline().

Isn't it "16 pixels" ? The code seems correct.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +	 */
> +
>  	fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
>  	stride = vin->format.bytesperline / fmt->bpp;
> +
> +	/*
> +	 * RAW8 format bpp is 1, but the hardware process RAW8 format in 2 pixel
> +	 * units, so we need to divide the stride by 2.
> +	 */
> +	switch (vin->format.pixelformat) {
> +	case V4L2_PIX_FMT_SBGGR8:
> +	case V4L2_PIX_FMT_SGBRG8:
> +	case V4L2_PIX_FMT_SGRBG8:
> +	case V4L2_PIX_FMT_SRGGB8:
> +	case V4L2_PIX_FMT_GREY:
> +		stride /= 2;
> +		break;
> +	default:
> +		break;
> +	}
> +
>  	rvin_write(vin, stride, VNIS_REG);
>  }
>  
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> index 079dbaf016c2..9d45e11898c1 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> @@ -155,6 +155,18 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin,
>  	case V4L2_PIX_FMT_NV16:
>  		align = 0x20;
>  		break;
> +	case V4L2_PIX_FMT_SBGGR8:
> +	case V4L2_PIX_FMT_SGBRG8:
> +	case V4L2_PIX_FMT_SGRBG8:
> +	case V4L2_PIX_FMT_SRGGB8:
> +	case V4L2_PIX_FMT_GREY:
> +		/*
> +		 * RAW8 format bpp is 1, but the hardware process RAW8 format in
> +		 * 2 pixel units, and we need to align to 32 bytes. See
> +		 * rvin_crop_scale_comp().
> +		 */
> +		align = 0x20;
> +		break;
>  	default:
>  		align = 0x10;
>  		break;
> 
> ---
> base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
> change-id: 20260127-rcar-fix-raw8-again-9dacab87ad33

-- 
Regards,

Laurent Pinchart

      parent reply	other threads:[~2026-03-18 20:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27  8:56 [PATCH] media: renesas: vin: Fix RAW8 (again) Tomi Valkeinen
2026-02-01 14:02 ` Niklas Söderlund
2026-03-18 20:04 ` Laurent Pinchart [this message]

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=20260318200429.GA716464@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=geert+renesas@glider.be \
    --cc=hverkuil@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=tomi.valkeinen+renesas@ideasonboard.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