From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: "Sven Püschel" <s.pueschel@pengutronix.de>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>,
tomm.merciai@gmail.com, linux-renesas-soc@vger.kernel.org,
biju.das.jz@bp.renesas.com,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mehdi Djait <mehdi.djait@linux.intel.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Isaac Scott <isaac.scott@ideasonboard.com>,
Paul Cercueil <paul@crapouillou.net>,
Daniel Scally <dan.scally+renesas@ideasonboard.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] media: v4l2-common: Add kernel-doc for v4l2_fill_pixfmt_mp_aligned()
Date: Fri, 10 Jul 2026 11:56:29 +0200 [thread overview]
Message-ID: <alC9xRYyzo6nRg58@zed> (raw)
In-Reply-To: <d4ee7cc1-fd04-480b-8543-46ca5c746107@pengutronix.de>
Hi Sven
On Fri, Jul 10, 2026 at 10:57:41AM +0200, Sven Püschel wrote:
> Hi Jacopo,
>
> On 7/9/26 11:51 AM, Jacopo Mondi wrote:
> > Hi Tommaso
> >
> > On Wed, Jul 08, 2026 at 06:14:04PM +0200, Tommaso Merciai wrote:
> > > Replace the bare placeholder comment with a full kernel-doc block
> > > documenting all parameters, the function behaviour for both single
> > > memory plane (mem_planes == 1) and multiple memory plane (mem_planes > 1)
> > > formats, and the return value.
> > >
> > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > > ---
> > > v2->v3:
> > > - Moved to PATCH 3/4
> > > - Fixed documentation as suggested by Sven Püschel
> > >
> > > v1->v2:
> > > - New patch
> > >
> > > include/media/v4l2-common.h | 28 +++++++++++++++++++++++++++-
> > > 1 file changed, 27 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > > index be4dd9762196..f2b0c336ac81 100644
> > > --- a/include/media/v4l2-common.h
> > > +++ b/include/media/v4l2-common.h
> > > @@ -591,7 +591,33 @@ static inline int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt,
> > > return v4l2_fill_pixfmt_aligned(pixfmt, pixelformat, width, height, 1);
> > > }
> > >
> > > -/* @stride_alignment is a power of 2 value in bytes */
> > > +/**
> > > + * v4l2_fill_pixfmt_mp_aligned - Fill in a &struct v4l2_pix_format_mplane with
> > > + * stride alignment requirements.
> > > + *
> > > + * @pixfmt: pointer to the &struct v4l2_pix_format_mplane to be filled
> > > + * @pixelformat: the V4L2 pixel format (V4L2_PIX_FMT_*)
> > > + * @width: image width in pixels
> > > + * @height: image height in pixels
> > > + * @stride_alignment: stride alignment in bytes; must be a power of 2
> > > + *
> > > + * Fills all fields of @pixfmt for the given pixel format, dimensions, and
> > > + * stride alignment.
> > > + *
> > > + * For formats stored in a single memory plane (mem_planes == 1), the
> > > + * behaviour matches v4l2_fill_pixfmt_aligned(): plane_fmt[0].bytesperline
> > > + * is set to the primary plane stride. The strides of all components are
> > > + * aligned to the @stride_alignment. To keep the chroma strides consistently
> > > + * derivable from the luma stride, strides may be aligned to a multiple of
> > > + * the @stride_alignment instead. plane_fmt[0].sizeimage covers all
> >
> > I guess this
> >
> > "To keep the chroma strides consistently derivable from the luma
> > stride, strides may be aligned to a multiple of the @stride_alignment
> > instead."
> >
> > comes from teh v4l2_format_plane_stride() implementation.
> >
> > I admit is not 100% clear to me why the chroma strides is multiplied
> > and to which format this applies. But this is not on this patch...
>
> When not using multi-planar formats, we only have the stride value for the Y
> component and the other stride values are derived from it. This is the cause
> of this whole scaling.
>
> E.g. for YUV420 4x2px picture, we have 4 bytes stride in the y plane and 2
> byte in the cb and cr plane. If we align the stride to 4 bytes (in all
> planes), we want both values to be a multiple of 4. As the cb/cr stride is
> derived from the y stride, we have to set the y stride to 8 bytes to get the
> desired 4 bytes stride in the cb/cr planes.
>
> The rare case for scaling the component stride is NV24/42 (at least this is
> the only one I currently know of), where we actually have 4:4:4 sub-sampling
> and have the cb/cr parts interleaved. So for a 1x2px picture we have 1 bytes
> in the y plane and 2 bytes in the c plane. To align to 4 bytes we need to
> set the c plane stride to 8 to be able to set the y plane stride to 4.
I see, I was probably confusing strides and strides -alignments-.
Thanks for the explanation.
>
>
> For multi-planar formats we have a separate stride for each component, so we
> just align all component strides to the given alignment.
>
>
> Sincerely
> Sven
>
>
next prev parent reply other threads:[~2026-07-10 9:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 16:14 [PATCH v3 0/4] media: rzg2l-cru: Fix DMA stride alignment Tommaso Merciai
2026-07-08 16:14 ` [PATCH v3 1/4] media: v4l2-common: Convert v4l2_fill_pixfmt_mp() to static inline wrapper Tommaso Merciai
2026-07-09 9:24 ` Jacopo Mondi
2026-07-08 16:14 ` [PATCH v3 2/4] media: v4l2-common: Add v4l2_fill_pixfmt_aligned() helper Tommaso Merciai
2026-07-09 9:35 ` Jacopo Mondi
2026-07-09 15:09 ` Tommaso Merciai
2026-07-10 8:36 ` Sven Püschel
2026-07-10 9:38 ` Jacopo Mondi
2026-07-10 11:54 ` Sven Püschel
2026-07-10 12:15 ` Jacopo Mondi
2026-07-10 12:26 ` Sven Püschel
2026-07-10 13:45 ` Tommaso Merciai
2026-07-10 13:50 ` Sven Püschel
2026-07-08 16:14 ` [PATCH v3 3/4] media: v4l2-common: Add kernel-doc for v4l2_fill_pixfmt_mp_aligned() Tommaso Merciai
2026-07-09 9:51 ` Jacopo Mondi
2026-07-10 8:57 ` Sven Püschel
2026-07-10 9:56 ` Jacopo Mondi [this message]
2026-07-08 16:14 ` [PATCH v3 4/4] media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement Tommaso Merciai
2026-07-09 9:19 ` Jacopo Mondi
2026-07-09 10:16 ` Tommaso Merciai
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=alC9xRYyzo6nRg58@zed \
--to=jacopo.mondi@ideasonboard.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=dan.scally+renesas@ideasonboard.com \
--cc=hverkuil+cisco@kernel.org \
--cc=isaac.scott@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=nicolas.dufresne@collabora.com \
--cc=paul@crapouillou.net \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=s.pueschel@pengutronix.de \
--cc=sakari.ailus@linux.intel.com \
--cc=tomm.merciai@gmail.com \
--cc=tommaso.merciai.xr@bp.renesas.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 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.