media: vb2: refactor setting flags and caps, fix missing cap
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 19 Jan 2024 09:03:23 +0000 (10:03 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 24 Jan 2024 16:27:51 +0000 (17:27 +0100)
commitb32431b753217d8d45b018443b1a7aac215921fb
treec8d8b787fbe5c209efa15dbe57c626bb9b01696a
parent78e23c3e914a5e678a20286fb09bc218017af89a
media: vb2: refactor setting flags and caps, fix missing cap

Several functions implementing VIDIOC_REQBUFS and _CREATE_BUFS all use
almost the same code to fill in the flags and capability fields. Refactor
this into a new vb2_set_flags_and_caps() function that replaces the old
fill_buf_caps() and validate_memory_flags() functions.

This also fixes a bug where vb2_ioctl_create_bufs() would not set the
V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS cap and also not fill in the
max_num_buffers field.

Fixes: d055a76c0065 ("media: core: Report the maximum possible number of buffers for the queue")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
drivers/media/common/videobuf2/videobuf2-v4l2.c