]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: v4l2-common: add v4l2_fill_pixfmt_mp_aligned helper
authorSven Püschel <s.pueschel@pengutronix.de>
Wed, 20 May 2026 22:44:10 +0000 (00:44 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 10:32:19 +0000 (12:32 +0200)
commit2c225846271fc6b4f7e2a34271ebe828ed461772
treef46e2e124577597b01fd68210aead659fbe16984
parent84fbe791a6203e35a602f7fef94d967466cd8d29
media: v4l2-common: add v4l2_fill_pixfmt_mp_aligned helper

Add a v4l2_fill_pixfmt_mp_aligned helper which allows the user to
specify a custom stride alignment in bytes. This is necessary for
hardware like the Rockchip RGA3, which requires the stride value to be
aligned to a 16 bytes boundary.

The code makes some assumptions about the v4l2 format to simplify the
calculation. They currently hold for all known v4l2 formats.

v4l2_format_plane_stride uses an unsigned int as argument type to avoid
the later multiplication from overflowing the u8 value. All other places
use u8, as no practical use cases for a larger alignment are known at
the moment.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/v4l2-core/v4l2-common.c
include/media/v4l2-common.h