From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
To: Hans Verkuil <hverkuil@xs4all.nl>, mchehab@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
kernel@collabora.com
Subject: Re: [PATCH v19 0/9] Add DELETE_BUF ioctl
Date: Wed, 7 Feb 2024 12:22:46 +0100 [thread overview]
Message-ID: <c2c63cfd-4f43-4ecc-8258-1ba91ac39412@collabora.com> (raw)
In-Reply-To: <c2bbab59-1b07-4a3c-985c-be01836af756@xs4all.nl>
Le 07/02/2024 à 12:20, Hans Verkuil a écrit :
> On 07/02/2024 12:15, Benjamin Gaignard wrote:
>> Le 07/02/2024 à 10:12, Hans Verkuil a écrit :
>>> Hi Benjamin,
>>>
>>> On 06/02/2024 09:58, Hans Verkuil wrote:
>>>> On 06/02/2024 09:02, Benjamin Gaignard wrote:
>>>>> Unlike when resolution change on keyframes, dynamic resolution change
>>>>> on inter frames doesn't allow to do a stream off/on sequence because
>>>>> it is need to keep all previous references alive to decode inter frames.
>>>>> This constraint have two main problems:
>>>>> - more memory consumption.
>>>>> - more buffers in use.
>>>>> To solve these issue this series introduce DELETE_BUFS ioctl and remove
>>>>> the 32 buffers limit per queue.
>>>> This v19 looks good. There are three outstanding issues that I need to take a
>>>> look at:
>>>>
>>>> 1) Can we still signal support for DELETE_BUFS in the V4L2_BUF_CAP_ caps?
>>>> It would be nice to have, but I'm not sure if and how that can be done.
>>> So, I came up with the following patch to add back the V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS
>>> capability. If the DELETE_BUFS ioctl is valid, then it sets this capability
>>> before calling vidioc_reqbufs or vidioc_create_bufs. So right now it will set
>>> this for any queue. If we ever want to disable this for a specific queue, then
>>> either the driver has to override these two ops and clear the flag, or a new
>>> vb2_queue flag (e.g. disable_delete_bufs) is added and vb2_set_flags_and_caps()
>>> will clear that capability based on that flag.
>>>
>>> In any case, for now just set it for both queues by default.
>>>
>>> If you agree that this is a good way to proceed, then can you incorporate this
>>> into a v20? You can add the documentation for this cap from the v17 version.
>> Do you want it to be a separate patch or included in the patch introducing DELETE_BUFS ioctl ?
> Up to you, whatever makes the most sense.
I will include it in DELETE_BUFS patch because it is strongly related to it.
Regards,
Benjamin
>
> Regards,
>
> Hans
>
>>> Regards,
>>>
>>> Hans
>>>
>>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>>> ---
>>> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
>>> index 8e437104f9c1..64f2d662d068 100644
>>> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
>>> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
>>> @@ -685,7 +685,7 @@ static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
>>> *flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
>>> }
>>>
>>> - *caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS;
>>> + *caps |= V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS;
>>> if (q->io_modes & VB2_MMAP)
>>> *caps |= V4L2_BUF_CAP_SUPPORTS_MMAP;
>>> if (q->io_modes & VB2_USERPTR)
>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
>>> index a172d33edd19..45bc705e171e 100644
>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>> @@ -2100,6 +2100,7 @@ static int v4l_overlay(const struct v4l2_ioctl_ops *ops,
>>> static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops,
>>> struct file *file, void *fh, void *arg)
>>> {
>>> + struct video_device *vfd = video_devdata(file);
>>> struct v4l2_requestbuffers *p = arg;
>>> int ret = check_fmt(file, p->type);
>>>
>>> @@ -2108,6 +2109,9 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops,
>>>
>>> memset_after(p, 0, flags);
>>>
>>> + if (is_valid_ioctl(vfd, VIDIOC_DELETE_BUFS))
>>> + p->capabilities = V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS;
>>> +
>>> return ops->vidioc_reqbufs(file, fh, p);
>>> }
>>>
>>> @@ -2141,6 +2145,7 @@ static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops,
>>> static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
>>> struct file *file, void *fh, void *arg)
>>> {
>>> + struct video_device *vfd = video_devdata(file);
>>> struct v4l2_create_buffers *create = arg;
>>> int ret = check_fmt(file, create->format.type);
>>>
>>> @@ -2151,6 +2156,9 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
>>>
>>> v4l_sanitize_format(&create->format);
>>>
>>> + if (is_valid_ioctl(vfd, VIDIOC_DELETE_BUFS))
>>> + create->capabilities = V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS;
>>> +
>>> ret = ops->vidioc_create_bufs(file, fh, create);
>>>
>>> if (create->format.type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
>>> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
>>> index 03443833aaaa..da307f46f903 100644
>>> --- a/include/uapi/linux/videodev2.h
>>> +++ b/include/uapi/linux/videodev2.h
>>> @@ -1036,6 +1036,7 @@ struct v4l2_requestbuffers {
>>> #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
>>> #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6)
>>> #define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7)
>>> +#define V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS (1 << 8)
>>>
>>> /**
>>> * struct v4l2_plane - plane info for multi-planar buffers
>>>
>>>
>>>
next prev parent reply other threads:[~2024-02-07 11:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 8:02 Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 1/9] media: videobuf2: Update vb2_is_busy() logic Benjamin Gaignard
2024-02-06 8:43 ` Hans Verkuil
2024-02-06 8:02 ` [PATCH v19 2/9] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 3/9] media: test-drivers: Set REQBUFS minimum number of buffers Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 4/9] media: core: Rework how create_buf index returned value is computed Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 5/9] media: core: Add bitmap manage bufs array entries Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 6/9] media: core: Free range of buffers Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 7/9] media: v4l2: Add DELETE_BUFS ioctl Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 8/9] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2024-02-06 8:02 ` [PATCH v19 9/9] media: verisilicon: Support deleting buffers on capture queue Benjamin Gaignard
2024-02-06 8:58 ` [PATCH v19 0/9] Add DELETE_BUF ioctl Hans Verkuil
2024-02-07 9:12 ` Hans Verkuil
2024-02-07 11:15 ` Benjamin Gaignard
2024-02-07 11:20 ` Hans Verkuil
2024-02-07 11:22 ` Benjamin Gaignard [this message]
2024-02-07 10:28 ` Hans Verkuil
2024-02-07 11:25 ` Benjamin Gaignard
2024-02-07 11:32 ` Hans Verkuil
2024-02-07 16:35 ` Benjamin Gaignard
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=c2c63cfd-4f43-4ecc-8258-1ba91ac39412@collabora.com \
--to=benjamin.gaignard@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®