All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2]  media: rzg2l-cru: Fix DMA stride alignment
@ 2026-06-24 10:41 Tommaso Merciai
  2026-06-24 10:41 ` [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper Tommaso Merciai
  2026-06-24 10:41 ` [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement Tommaso Merciai
  0 siblings, 2 replies; 6+ messages in thread
From: Tommaso Merciai @ 2026-06-24 10:41 UTC (permalink / raw)
  To: tomm.merciai
  Cc: linux-renesas-soc, biju.das.jz, jacopo.mondi, Tommaso Merciai,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Laurent Pinchart, Sakari Ailus,
	Sven Püschel, Mehdi Djait, Paul Cercueil, Isaac Scott,
	Daniel Scally, linux-media, linux-kernel

Dear All,

While testing ov5645 + RZ/G3E we found out that the UYVY8_2X8/2592x1944
is broken. The issue is that the CRU DMA engine requires the line stride
to be a multiple of 128 bytes (RZG2L_CRU_STRIDE_ALIGN). v4l2_fill_pixfmt()
sets bytesperline as width * bytes_per_pixel with no alignment, so for
widths whose natural stride is not 128-byte aligned the hardware silently
rounds up, causing a mismatch that produces visible horizontal banding in
the captured image.

Tested using:

media-ctl -d /dev/media0 --set-v4l2 '"ov5645 0-003c":0[fmt:UYVY8_2X8/2592x1944 field:none]'
media-ctl -d /dev/media0 --set-v4l2 '"csi-16000400.csi2":0[fmt:UYVY8_2X8/2592x1944]'
media-ctl -d /dev/media0 --set-v4l2 '"cru-ip-16000000.video":0[fmt:UYVY8_2X8/2592x1944]'

v4l2-ctl -d /dev/video0 --verbose --set-fmt-video=width=2592,height=1944,pixelformat=UYVY --stream-mmap --stream-count=100 --stream-to=./frame.raw
gst-launch-1.0 v4l2src device=/dev/video0 blocksize=76800 io-mode=dmabuf num-buffers=200 ! video/x-raw,format=UYVY,width=2592,height=1944 !  videoconvert ! queue ! waylandsink sync=false

This patch fix the issue.

Kind Regards,
Tommaso

Tommaso Merciai (2):
  media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper
  media: rzg2l-cru: Align bytesperline to hardware DMA stride
    requirement

 .../platform/renesas/rzg2l-cru/rzg2l-video.c    |  3 ++-
 drivers/media/v4l2-core/v4l2-common.c           | 17 +++++++++++++----
 include/media/v4l2-common.h                     |  3 +++
 3 files changed, 18 insertions(+), 5 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper
  2026-06-24 10:41 [PATCH 0/2] media: rzg2l-cru: Fix DMA stride alignment Tommaso Merciai
@ 2026-06-24 10:41 ` Tommaso Merciai
  2026-06-24 19:28   ` Laurent Pinchart
  2026-06-24 10:41 ` [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement Tommaso Merciai
  1 sibling, 1 reply; 6+ messages in thread
From: Tommaso Merciai @ 2026-06-24 10:41 UTC (permalink / raw)
  To: tomm.merciai
  Cc: linux-renesas-soc, biju.das.jz, jacopo.mondi, Tommaso Merciai,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Laurent Pinchart, Sakari Ailus,
	Sven Püschel, Mehdi Djait, Paul Cercueil, Isaac Scott,
	Daniel Scally, linux-media, linux-kernel

Add v4l2_fill_pixfmt_aligned(), a variant of v4l2_fill_pixfmt()
that accepts a stride_alignment parameter, mirroring the existing
v4l2_fill_pixfmt_mp() / v4l2_fill_pixfmt_mp_aligned() pair.

v4l2_fill_pixfmt() is refactored to call v4l2_fill_pixfmt_aligned()
with stride_alignment=1, preserving its existing behaviour.

The new helper is needed by drivers whose DMA engine requires the
line stride to be a multiple of a specific value, such as the
Renesas RZ/G3E CRU which requires 128-byte alignment.

Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
 drivers/media/v4l2-core/v4l2-common.c | 17 +++++++++++++----
 include/media/v4l2-common.h           |  3 +++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 65db7340ad38..1de246acc7ab 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -545,8 +545,8 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_mp);
 
-int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
-		     u32 width, u32 height)
+int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
+			     u32 width, u32 height, u8 stride_alignment)
 {
 	const struct v4l2_format_info *info;
 	int i;
@@ -562,14 +562,23 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 	pixfmt->width = width;
 	pixfmt->height = height;
 	pixfmt->pixelformat = pixelformat;
-	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width, 1);
+	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width,
+							stride_alignment);
 	pixfmt->sizeimage = 0;
 
 	for (i = 0; i < info->comp_planes; i++)
 		pixfmt->sizeimage +=
-			v4l2_format_plane_size(info, i, width, height, 1);
+			v4l2_format_plane_size(info, i, width, height,
+					       stride_alignment);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_aligned);
+
+int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
+		     u32 width, u32 height)
+{
+	return v4l2_fill_pixfmt_aligned(pixfmt, pixelformat, width, height, 1);
+}
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
 #ifdef CONFIG_MEDIA_CONTROLLER
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index edd416178c33..718a0f47f36b 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -556,6 +556,9 @@ void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
 				    const struct v4l2_frmsize_stepwise *frmsize);
 int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 		     u32 width, u32 height);
+/* @stride_alignment is a power of 2 value in bytes */
+int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
+			     u32 width, u32 height, u8 stride_alignment);
 int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
 			u32 width, u32 height);
 /* @stride_alignment is a power of 2 value in bytes */
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement
  2026-06-24 10:41 [PATCH 0/2] media: rzg2l-cru: Fix DMA stride alignment Tommaso Merciai
  2026-06-24 10:41 ` [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper Tommaso Merciai
@ 2026-06-24 10:41 ` Tommaso Merciai
  2026-06-24 19:53   ` Laurent Pinchart
  1 sibling, 1 reply; 6+ messages in thread
From: Tommaso Merciai @ 2026-06-24 10:41 UTC (permalink / raw)
  To: tomm.merciai
  Cc: linux-renesas-soc, biju.das.jz, jacopo.mondi, Tommaso Merciai,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Laurent Pinchart, Sakari Ailus,
	Sven Püschel, Mehdi Djait, Paul Cercueil, Isaac Scott,
	Daniel Scally, linux-media, linux-kernel

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()")
replaced the open-coded aligned calculation with v4l2_fill_pixfmt(),
which sets no alignment, reintroducing the issue.

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@bp.renesas.com>
---
 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);
 
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper
  2026-06-24 10:41 ` [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper Tommaso Merciai
@ 2026-06-24 19:28   ` Laurent Pinchart
  2026-06-25  8:12     ` Tommaso Merciai
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2026-06-24 19:28 UTC (permalink / raw)
  To: Tommaso Merciai
  Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, jacopo.mondi,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Sakari Ailus, Sven Püschel, Mehdi Djait,
	Paul Cercueil, Isaac Scott, Daniel Scally, linux-media,
	linux-kernel

Hi Tommaso,

Thank you for the patch.

On Wed, Jun 24, 2026 at 12:41:30PM +0200, Tommaso Merciai wrote:
> Add v4l2_fill_pixfmt_aligned(), a variant of v4l2_fill_pixfmt()
> that accepts a stride_alignment parameter, mirroring the existing
> v4l2_fill_pixfmt_mp() / v4l2_fill_pixfmt_mp_aligned() pair.
> 
> v4l2_fill_pixfmt() is refactored to call v4l2_fill_pixfmt_aligned()
> with stride_alignment=1, preserving its existing behaviour.
> 
> The new helper is needed by drivers whose DMA engine requires the
> line stride to be a multiple of a specific value, such as the
> Renesas RZ/G3E CRU which requires 128-byte alignment.
> 
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
>  drivers/media/v4l2-core/v4l2-common.c | 17 +++++++++++++----
>  include/media/v4l2-common.h           |  3 +++
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 65db7340ad38..1de246acc7ab 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -545,8 +545,8 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt,
>  }
>  EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_mp);
>  
> -int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> -		     u32 width, u32 height)
> +int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> +			     u32 width, u32 height, u8 stride_alignment)
>  {
>  	const struct v4l2_format_info *info;
>  	int i;
> @@ -562,14 +562,23 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
>  	pixfmt->width = width;
>  	pixfmt->height = height;
>  	pixfmt->pixelformat = pixelformat;
> -	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width, 1);
> +	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width,
> +							stride_alignment);
>  	pixfmt->sizeimage = 0;
>  
>  	for (i = 0; i < info->comp_planes; i++)
>  		pixfmt->sizeimage +=
> -			v4l2_format_plane_size(info, i, width, height, 1);
> +			v4l2_format_plane_size(info, i, width, height,
> +					       stride_alignment);
>  	return 0;
>  }
> +EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_aligned);
> +
> +int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> +		     u32 width, u32 height)
> +{
> +	return v4l2_fill_pixfmt_aligned(pixfmt, pixelformat, width, height, 1);
> +}

This could be an inline wrapper in include/media/v4l2-common.h, it would
be more efficient.

>  EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index edd416178c33..718a0f47f36b 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -556,6 +556,9 @@ void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
>  				    const struct v4l2_frmsize_stepwise *frmsize);
>  int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
>  		     u32 width, u32 height);
> +/* @stride_alignment is a power of 2 value in bytes */
> +int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> +			     u32 width, u32 height, u8 stride_alignment);

I know the existing functions lack documentation, but it's not a reason
to continue with that bad habit :-)

One point that needs to be clearly documented is how the stride
alignment is handled for different planes.

>  int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
>  			u32 width, u32 height);
>  /* @stride_alignment is a power of 2 value in bytes */

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement
  2026-06-24 10:41 ` [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement Tommaso Merciai
@ 2026-06-24 19:53   ` Laurent Pinchart
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2026-06-24 19:53 UTC (permalink / raw)
  To: Tommaso Merciai
  Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, jacopo.mondi,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Sakari Ailus, Sven Püschel, Mehdi Djait,
	Paul Cercueil, Isaac Scott, Daniel Scally, linux-media,
	linux-kernel

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@bp.renesas.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper
  2026-06-24 19:28   ` Laurent Pinchart
@ 2026-06-25  8:12     ` Tommaso Merciai
  0 siblings, 0 replies; 6+ messages in thread
From: Tommaso Merciai @ 2026-06-25  8:12 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, jacopo.mondi,
	Lad Prabhakar, Mauro Carvalho Chehab, Hans Verkuil,
	Nicolas Dufresne, Sakari Ailus, Sven Püschel, Mehdi Djait,
	Paul Cercueil, Isaac Scott, Daniel Scally, linux-media,
	linux-kernel

Hi Laurent,
Thanks for your review.

On Wed, Jun 24, 2026 at 10:28:55PM +0300, Laurent Pinchart wrote:
> Hi Tommaso,
> 
> Thank you for the patch.
> 
> On Wed, Jun 24, 2026 at 12:41:30PM +0200, Tommaso Merciai wrote:
> > Add v4l2_fill_pixfmt_aligned(), a variant of v4l2_fill_pixfmt()
> > that accepts a stride_alignment parameter, mirroring the existing
> > v4l2_fill_pixfmt_mp() / v4l2_fill_pixfmt_mp_aligned() pair.
> > 
> > v4l2_fill_pixfmt() is refactored to call v4l2_fill_pixfmt_aligned()
> > with stride_alignment=1, preserving its existing behaviour.
> > 
> > The new helper is needed by drivers whose DMA engine requires the
> > line stride to be a multiple of a specific value, such as the
> > Renesas RZ/G3E CRU which requires 128-byte alignment.
> > 
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > ---
> >  drivers/media/v4l2-core/v4l2-common.c | 17 +++++++++++++----
> >  include/media/v4l2-common.h           |  3 +++
> >  2 files changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> > index 65db7340ad38..1de246acc7ab 100644
> > --- a/drivers/media/v4l2-core/v4l2-common.c
> > +++ b/drivers/media/v4l2-core/v4l2-common.c
> > @@ -545,8 +545,8 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt,
> >  }
> >  EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_mp);
> >  
> > -int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> > -		     u32 width, u32 height)
> > +int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> > +			     u32 width, u32 height, u8 stride_alignment)
> >  {
> >  	const struct v4l2_format_info *info;
> >  	int i;
> > @@ -562,14 +562,23 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> >  	pixfmt->width = width;
> >  	pixfmt->height = height;
> >  	pixfmt->pixelformat = pixelformat;
> > -	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width, 1);
> > +	pixfmt->bytesperline = v4l2_format_plane_stride(info, 0, width,
> > +							stride_alignment);
> >  	pixfmt->sizeimage = 0;
> >  
> >  	for (i = 0; i < info->comp_planes; i++)
> >  		pixfmt->sizeimage +=
> > -			v4l2_format_plane_size(info, i, width, height, 1);
> > +			v4l2_format_plane_size(info, i, width, height,
> > +					       stride_alignment);
> >  	return 0;
> >  }
> > +EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt_aligned);
> > +
> > +int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> > +		     u32 width, u32 height)
> > +{
> > +	return v4l2_fill_pixfmt_aligned(pixfmt, pixelformat, width, height, 1);
> > +}
> 
> This could be an inline wrapper in include/media/v4l2-common.h, it would
> be more efficient.

Ok, thanks.
I guess we want the same for v4l2_fill_pixfmt_mp() ?

> 
> >  EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
> >  
> >  #ifdef CONFIG_MEDIA_CONTROLLER
> > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > index edd416178c33..718a0f47f36b 100644
> > --- a/include/media/v4l2-common.h
> > +++ b/include/media/v4l2-common.h
> > @@ -556,6 +556,9 @@ void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
> >  				    const struct v4l2_frmsize_stepwise *frmsize);
> >  int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> >  		     u32 width, u32 height);
> > +/* @stride_alignment is a power of 2 value in bytes */
> > +int v4l2_fill_pixfmt_aligned(struct v4l2_pix_format *pixfmt, u32 pixelformat,
> > +			     u32 width, u32 height, u8 stride_alignment);
> 
> I know the existing functions lack documentation, but it's not a reason
> to continue with that bad habit :-)

Ouch :)

> 
> One point that needs to be clearly documented is how the stride
> alignment is handled for different planes.

Thanks, I will add documentation in v2.


Kind Regards,
Tommaso

> 
> >  int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
> >  			u32 width, u32 height);
> >  /* @stride_alignment is a power of 2 value in bytes */
> 
> -- 
> Regards,
> 
> Laurent Pinchart

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-25  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 10:41 [PATCH 0/2] media: rzg2l-cru: Fix DMA stride alignment Tommaso Merciai
2026-06-24 10:41 ` [PATCH 1/2] media: v4l2-common: add v4l2_fill_pixfmt_aligned() helper Tommaso Merciai
2026-06-24 19:28   ` Laurent Pinchart
2026-06-25  8:12     ` Tommaso Merciai
2026-06-24 10:41 ` [PATCH 2/2] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement Tommaso Merciai
2026-06-24 19:53   ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.