Re: [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement

From: Laurent Pinchart

Date: Wed Jun 24 2026 - 15:53:53 EST


On Wed, Jun 24, 2026 at 12:41:31PM +0200, Tommaso Merciai wrote:
> The RZ/G3E CRU programs the line stride via the AMnIS register, whose
> IS field encodes the value in units of 128 bytes. If bytesperline is
> not a multiple of 128, the division truncates and the hardware uses a
> wrong stride, causing horizontal banding.
>
> commit ace92ccef0c9 ("media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()")

s/commit/Commit/

> replaced the open-coded aligned calculation with v4l2_fill_pixfmt(),
> which sets no alignment, reintroducing the issue.

I wonder how I missed that. Sorry.

> Switch to v4l2_fill_pixfmt_aligned() with RZG2L_CRU_STRIDE_ALIGN when
> info->has_stride is set. RZ/G2L has no AMnIS register and keeps using
> v4l2_fill_pixfmt() unchanged.
>
> Fixes: ace92ccef0c9 ("media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()")
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> ---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 69346a585f9f..478264f26466 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -860,7 +860,8 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> v4l_bound_align_image(&pix->width, 320, info->max_width, 1,
> &pix->height, 240, info->max_height, 0, 0);
>
> - v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
> + v4l2_fill_pixfmt_aligned(pix, pix->pixelformat, pix->width, pix->height,
> + info->has_stride ? RZG2L_CRU_STRIDE_ALIGN : 1);

The documentation states that, for RGB888, the stride has to be a
multiple of 384 (3*128). Shouldn't you take that into account here ?

Also, for semi-planar YUV 4:2:0, the hardware seems to use a stride
equal to AMnIS*2, which leaves blank lines after every U/V line. That's
something userspace doesn't expect.

>
> dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
> pix->width, pix->height, pix->bytesperline, pix->sizeimage);

--
Regards,

Laurent Pinchart