[v14,56/56] media: test-drivers: Use helper for DELETE_BUFS ioctl
Commit Message
Allow test drivers to use DELETE_BUFS by adding vb2_ioctl_delete_bufs() helper.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/media/test-drivers/vicodec/vicodec-core.c | 2 ++
drivers/media/test-drivers/vimc/vimc-capture.c | 2 ++
drivers/media/test-drivers/visl/visl-video.c | 2 ++
drivers/media/test-drivers/vivid/vivid-core.c | 13 ++++++++++---
4 files changed, 16 insertions(+), 3 deletions(-)
Comments
On Tue, Oct 31, 2023 at 05:31:04PM +0100, Benjamin Gaignard wrote:
> Allow test drivers to use DELETE_BUFS by adding vb2_ioctl_delete_bufs() helper.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
> drivers/media/test-drivers/vicodec/vicodec-core.c | 2 ++
> drivers/media/test-drivers/vimc/vimc-capture.c | 2 ++
> drivers/media/test-drivers/visl/visl-video.c | 2 ++
> drivers/media/test-drivers/vivid/vivid-core.c | 13 ++++++++++---
> 4 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
> index 69cbe2c094e1..f14a8fd506d0 100644
> --- a/drivers/media/test-drivers/vicodec/vicodec-core.c
> +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
> @@ -1339,6 +1339,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = {
> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
>
> .vidioc_streamon = v4l2_m2m_ioctl_streamon,
> .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
> @@ -1725,6 +1726,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->mem_ops = &vb2_vmalloc_memops;
> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = src_vq->lock;
> + dst_vq->supports_delete_bufs = true;
Since we have to explicitly provide the vidioc_delete_bufs callback anyway,
is there any value in having a separate supports_delete_bufs flag? Or we
envision that some drivers would support deleting buffers only for some
queues?
Best regards,
Tomasz
Le 09/11/2023 à 10:43, Tomasz Figa a écrit :
> On Tue, Oct 31, 2023 at 05:31:04PM +0100, Benjamin Gaignard wrote:
>> Allow test drivers to use DELETE_BUFS by adding vb2_ioctl_delete_bufs() helper.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
>> ---
>> drivers/media/test-drivers/vicodec/vicodec-core.c | 2 ++
>> drivers/media/test-drivers/vimc/vimc-capture.c | 2 ++
>> drivers/media/test-drivers/visl/visl-video.c | 2 ++
>> drivers/media/test-drivers/vivid/vivid-core.c | 13 ++++++++++---
>> 4 files changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
>> index 69cbe2c094e1..f14a8fd506d0 100644
>> --- a/drivers/media/test-drivers/vicodec/vicodec-core.c
>> +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
>> @@ -1339,6 +1339,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = {
>> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
>> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
>> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
>> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
>>
>> .vidioc_streamon = v4l2_m2m_ioctl_streamon,
>> .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
>> @@ -1725,6 +1726,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
>> dst_vq->mem_ops = &vb2_vmalloc_memops;
>> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>> dst_vq->lock = src_vq->lock;
>> + dst_vq->supports_delete_bufs = true;
> Since we have to explicitly provide the vidioc_delete_bufs callback anyway,
> is there any value in having a separate supports_delete_bufs flag? Or we
> envision that some drivers would support deleting buffers only for some
> queues?
That exactly the case for Hantro driver, it can support deleting buffers on
capture queue but not on output queue.
>
> Best regards,
> Tomasz
>
On Thu, Nov 9, 2023 at 6:46 PM Benjamin Gaignard
<benjamin.gaignard@collabora.com> wrote:
>
>
> Le 09/11/2023 à 10:43, Tomasz Figa a écrit :
> > On Tue, Oct 31, 2023 at 05:31:04PM +0100, Benjamin Gaignard wrote:
> >> Allow test drivers to use DELETE_BUFS by adding vb2_ioctl_delete_bufs() helper.
> >>
> >> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> >> ---
> >> drivers/media/test-drivers/vicodec/vicodec-core.c | 2 ++
> >> drivers/media/test-drivers/vimc/vimc-capture.c | 2 ++
> >> drivers/media/test-drivers/visl/visl-video.c | 2 ++
> >> drivers/media/test-drivers/vivid/vivid-core.c | 13 ++++++++++---
> >> 4 files changed, 16 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
> >> index 69cbe2c094e1..f14a8fd506d0 100644
> >> --- a/drivers/media/test-drivers/vicodec/vicodec-core.c
> >> +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
> >> @@ -1339,6 +1339,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = {
> >> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
> >> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
> >> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
> >> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
> >>
> >> .vidioc_streamon = v4l2_m2m_ioctl_streamon,
> >> .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
> >> @@ -1725,6 +1726,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
> >> dst_vq->mem_ops = &vb2_vmalloc_memops;
> >> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> >> dst_vq->lock = src_vq->lock;
> >> + dst_vq->supports_delete_bufs = true;
> > Since we have to explicitly provide the vidioc_delete_bufs callback anyway,
> > is there any value in having a separate supports_delete_bufs flag? Or we
> > envision that some drivers would support deleting buffers only for some
> > queues?
>
> That exactly the case for Hantro driver, it can support deleting buffers on
> capture queue but not on output queue.
Fair enough.
Best regards,
Tomasz
@@ -1339,6 +1339,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = {
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
+ .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
.vidioc_streamon = v4l2_m2m_ioctl_streamon,
.vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
@@ -1725,6 +1726,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->mem_ops = &vb2_vmalloc_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = src_vq->lock;
+ dst_vq->supports_delete_bufs = true;
return vb2_queue_init(dst_vq);
}
@@ -221,6 +221,7 @@ static const struct v4l2_ioctl_ops vimc_capture_ioctl_ops = {
.vidioc_expbuf = vb2_ioctl_expbuf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
+ .vidioc_delete_bufs = vb2_ioctl_delete_bufs,
};
static void vimc_capture_return_all_buffers(struct vimc_capture_device *vcapture,
@@ -435,6 +436,7 @@ static struct vimc_ent_device *vimc_capture_add(struct vimc_device *vimc,
q->min_buffers_needed = 2;
q->lock = &vcapture->lock;
q->dev = v4l2_dev->dev;
+ q->supports_delete_bufs = true;
ret = vb2_queue_init(q);
if (ret) {
@@ -521,6 +521,7 @@ const struct v4l2_ioctl_ops visl_ioctl_ops = {
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
+ .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
.vidioc_streamon = v4l2_m2m_ioctl_streamon,
.vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
@@ -728,6 +729,7 @@ int visl_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->mem_ops = &vb2_vmalloc_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->vb_mutex;
+ dst_vq->supports_delete_bufs = true;
return vb2_queue_init(dst_vq);
}
@@ -769,6 +769,7 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = {
.vidioc_expbuf = vb2_ioctl_expbuf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
+ .vidioc_delete_bufs = vb2_ioctl_delete_bufs,
.vidioc_enum_input = vivid_enum_input,
.vidioc_g_input = vivid_g_input,
@@ -883,12 +884,18 @@ static int vivid_create_queue(struct vivid_dev *dev,
* PAGE_SHIFT > 12, but then max_num_buffers will be clamped by
* videobuf2-core.c to MAX_BUFFER_INDEX.
*/
- if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
q->max_num_buffers = 64;
- if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE)
+ q->supports_delete_bufs = true;
+ }
+ if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE) {
q->max_num_buffers = 1024;
- if (buf_type == V4L2_BUF_TYPE_VBI_CAPTURE)
+ q->supports_delete_bufs = true;
+ }
+ if (buf_type == V4L2_BUF_TYPE_VBI_CAPTURE) {
q->max_num_buffers = 32768;
+ q->supports_delete_bufs = true;
+ }
if (allocators[dev->inst] != 1)
q->io_modes |= VB2_USERPTR;