From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7E483D6CB7; Fri, 10 Jul 2026 09:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783676303; cv=none; b=Ku+rYDRg/1T97PG5ppertaJjNpeuiPQbMvC/FuqGXMqpU7uhyCQ1aWSbFivXXiJbgJtfmTmUfeG39pzo26f76mQb9owfawPpNbbdOhPL0aNhT9eClLhP4fdJCS3m/ncvuIG1oa95m6GeqEjnYaR5mTrfPOqPnFNBQYw83H/JN1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783676303; c=relaxed/simple; bh=bChyDOxuBfSs24Klt5WlN2EeJo189nvFjaDAK0cHc50=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NHOZjfK3CoCeU0MYzxWR2G87zC/7XIV/uG8MBzeTVTzoyL6H0JY06+czvWeQ6hP0l0IxXfuhFFb/8PcA4wkQrqj0K3QxSW6H+Aof/Ngd6eEFJLCTadp+31CNodk8fc/9jBznHMDPmzfSf7x6z5P9s/3mnNyNwcObKUHXVZuxYqk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=c06Zp7H4; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="c06Zp7H4" Received: from ideasonboard.com (mob-109-113-15-151.net.vodafone.it [109.113.15.151]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8930F12F; Fri, 10 Jul 2026 11:37:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783676245; bh=bChyDOxuBfSs24Klt5WlN2EeJo189nvFjaDAK0cHc50=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c06Zp7H4LyXaOzgsMZ7op+fQIB3PToyYzYJGMGGpQ7vOhAWNO265b6WvcWW+IiS2j +uUuMwWH533ifgDA+586lztYZM5uUG195In9SD2UECAR6cE/+BgVXq+Dkc+/ayEjsf kaIaWy0wnvt6Kshn9IfCnVOCqwLB2ZPoiI68yepY= Date: Fri, 10 Jul 2026 11:38:13 +0200 From: Jacopo Mondi To: Sven =?utf-8?Q?P=C3=BCschel?= Cc: Jacopo Mondi , Tommaso Merciai , tomm.merciai@gmail.com, linux-renesas-soc@vger.kernel.org, biju.das.jz@bp.renesas.com, Lad Prabhakar , Mauro Carvalho Chehab , Hans Verkuil , Nicolas Dufresne , Sakari Ailus , Laurent Pinchart , Mehdi Djait , Marek Szyprowski , Isaac Scott , Paul Cercueil , Daniel Scally , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/4] media: v4l2-common: Add v4l2_fill_pixfmt_aligned() helper Message-ID: References: <20260708161406.396183-1-tommaso.merciai.xr@bp.renesas.com> <20260708161406.396183-3-tommaso.merciai.xr@bp.renesas.com> <210aa2ee-8931-4dd2-a51f-eeb0c205d647@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <210aa2ee-8931-4dd2-a51f-eeb0c205d647@pengutronix.de> Hi Sven On Fri, Jul 10, 2026 at 10:36:53AM +0200, Sven Püschel wrote: > Hi Jacopo, > > On 7/9/26 11:35 AM, Jacopo Mondi wrote: > > Hi Tommaso > > > > On Wed, Jul 08, 2026 at 06:14:03PM +0200, Tommaso Merciai wrote: > > > > > + * > > > + * @pixfmt: pointer to the &struct v4l2_pix_format 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. Only formats stored in a single memory plane are > > > + * supported; returns -EINVAL for multi-memory-plane formats. > > > + * > > > + * @pixfmt->bytesperline is set to the stride of the primary (plane 0) plane, > > > + * rounded up to a multiple of @stride_alignment. For formats that store > > > + * multiple component planes in a single memory buffer (e.g. NV12), the > > > + * alignment applied to each component plane's stride is scaled relative to > > > + * @stride_alignment so that the chroma stride remains consistently derivable > > Does this rather mean that > > > > "For formats that store multiple component planes in a single memory > > buffer (e.g. NV12), the alignment applied to each component plane is > > the first plane @stride_alignment scaled by the plane's sub-sampling > > ratio" or have I mis-read this ? > > No, for the example of NV12, no stride will get scaled (although the > sub-sampling of 4:2:0, resulting in a vdiv and hdiv of 2). Ah, I had looked at v4l2_format_plane_stride() for the NV12 case where byte_alignment gets adjusted for the second plane as: byte_alignment *= DIV_ROUND_UP(info->bpp[1], info->hdiv * info->bpp[0]); which for NV12 resolves at *= 1 and I got confused Indeed this is not just "the first plane @stride_alignment scaled by the plane's sub-sampling ratio" I proposed > > This is due to the fact, that while we have a hdiv of 2 we also interleave > the cb and cr parts in a single plane, which results in the stride being the > same number of bytes as for the y plane (and vdiv isn't relevant for the > stride). > > Therefore the stride scaling also respects the bits per plane (bpp) value to > determine the scaling. > > @Tommaso : While the sentence looks ok, the NV12 example is misguided. The I guess the usage of NV12 was as example of a "formats that store multiple component planes in a single memory" NV24/42 works the same, but being 444 it needs the chroma plane stride to be a multiple of the fist plane stride and might prove as a better example ? > intention is that for non-mp (not ending with M) formats we might do the > scaling (e.g. YUV420 will have it's Y component stride alignment scaled to > not break the u and v stride alignments, but YUV420M not) > > Sincerely >     Sven > >