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 v16 7/8] media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl
Date: Tue, 16 Jan 2024 11:42:56 +0100 [thread overview]
Message-ID: <60c942d8-e0bd-4609-8fc4-1e80102ac051@collabora.com> (raw)
In-Reply-To: <6b0e4c6b-493c-4916-ab3c-deeeb725fdec@xs4all.nl>
Le 15/01/2024 à 17:50, Hans Verkuil a écrit :
> On 15/12/2023 10:08, Benjamin Gaignard wrote:
>> Create v4l2-mem2mem helpers for VIDIOC_DELETE_BUFS ioctl.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
>> ---
>> .../media/platform/verisilicon/hantro_drv.c | 1 +
>> .../media/platform/verisilicon/hantro_v4l2.c | 1 +
>> drivers/media/test-drivers/vim2m.c | 2 ++
> The driver changes should be done in a separate patch.
>
>> drivers/media/v4l2-core/v4l2-mem2mem.c | 20 +++++++++++++++++++
>> include/media/v4l2-mem2mem.h | 12 +++++++++++
>> 5 files changed, 36 insertions(+)
>>
>> diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
>> index db3df6cc4513..f6b0a676a740 100644
>> --- a/drivers/media/platform/verisilicon/hantro_drv.c
>> +++ b/drivers/media/platform/verisilicon/hantro_drv.c
>> @@ -248,6 +248,7 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
>> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>> dst_vq->lock = &ctx->dev->vpu_mutex;
>> dst_vq->dev = ctx->dev->v4l2_dev.dev;
>> + src_vq->supports_delete_bufs = true;
> Isn't this something that can be supported for both queues?
For me it isn't useful to support it on the both queues because
only capture queue will store unused buffers after a dynamic
resolution change. Output queue buffers are smaller and always
recycled even after a dynamic resolution change.
>
>>
>> return vb2_queue_init(dst_vq);
>> }
>> diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
>> index 941fa23c211a..34eab90e8a42 100644
>> --- a/drivers/media/platform/verisilicon/hantro_v4l2.c
>> +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
>> @@ -756,6 +756,7 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops = {
>> .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
>> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
>> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
>> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
>> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
>>
>> .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
>> diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
>> index 3e3b424b4860..17213ce42059 100644
>> --- a/drivers/media/test-drivers/vim2m.c
>> +++ b/drivers/media/test-drivers/vim2m.c
>> @@ -960,6 +960,7 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = {
>> .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
>> .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
>> .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
>> + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs,
>> .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
>>
>> .vidioc_streamon = v4l2_m2m_ioctl_streamon,
>> @@ -1133,6 +1134,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 = &ctx->vb_mutex;
>> + dst_vq->supports_delete_bufs = true;
> Same question.
I want to test something similar to what the real use case does.
>
>>
>> return vb2_queue_init(dst_vq);
>> }
>> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
>> index 9e983176542b..dbc4711fc556 100644
>> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
>> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
>> @@ -834,6 +834,17 @@ int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> }
>> EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf);
>>
>> +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> + struct v4l2_delete_buffers *d)
>> +{
>> + struct vb2_queue *vq;
>> +
>> + vq = v4l2_m2m_get_vq(m2m_ctx, d->type);
> These 3 lines can be combined into one.
>
>> +
>> + return vb2_delete_bufs(vq, d);
>> +}
>> +EXPORT_SYMBOL_GPL(v4l2_m2m_delete_bufs);
> I'm not sure we need to export this. Drivers should really just use the
> v4l2_m2m_ioctl_ variant below.
ok
regards,
Benjamin
>
>> +
>> int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> struct v4l2_create_buffers *create)
>> {
>> @@ -1380,6 +1391,15 @@ int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv,
>> }
>> EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs);
>>
>> +int v4l2_m2m_ioctl_delete_bufs(struct file *file, void *priv,
>> + struct v4l2_delete_buffers *d)
>> +{
>> + struct v4l2_fh *fh = file->private_data;
>> +
>> + return v4l2_m2m_delete_bufs(file, fh->m2m_ctx, d);
>> +}
>> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_delete_bufs);
>> +
>> int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv,
>> struct v4l2_buffer *buf)
>> {
>> diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
>> index 7f1af1f7f912..5314952ad3d5 100644
>> --- a/include/media/v4l2-mem2mem.h
>> +++ b/include/media/v4l2-mem2mem.h
>> @@ -388,6 +388,16 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> struct v4l2_buffer *buf);
>>
>> +/**
>> + * v4l2_m2m_delete_bufs() - delete buffers from the queue
>> + *
>> + * @file: pointer to struct &file
>> + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx
>> + * @d: pointer to struct &v4l2_delete_buffers
>> + */
>> +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>> + struct v4l2_delete_buffers *d);
>> +
>> /**
>> * v4l2_m2m_create_bufs() - create a source or destination buffer, depending
>> * on the type
>> @@ -867,6 +877,8 @@ int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
>> struct v4l2_requestbuffers *rb);
>> int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh,
>> struct v4l2_create_buffers *create);
>> +int v4l2_m2m_ioctl_delete_bufs(struct file *file, void *priv,
>> + struct v4l2_delete_buffers *d);
>> int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh,
>> struct v4l2_buffer *buf);
>> int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh,
> Regards,
>
> Hans
>
next prev parent reply other threads:[~2024-01-16 10:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 9:08 [PATCH v16 0/8] Add DELETE_BUF ioctl Benjamin Gaignard
2023-12-15 9:08 ` [PATCH v16 1/8] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
2024-01-15 9:16 ` Hans Verkuil
2024-01-15 10:27 ` Hans Verkuil
2023-12-15 9:08 ` [PATCH v16 2/8] media: test-drivers: Set REQBUFS minimum number of buffers Benjamin Gaignard
2024-01-15 10:35 ` Hans Verkuil
2023-12-15 9:08 ` [PATCH v16 3/8] media: core: Rework how create_buf index returned value is computed Benjamin Gaignard
2024-01-15 11:00 ` Hans Verkuil
2024-01-15 11:40 ` Hans Verkuil
2024-01-15 12:11 ` Hans Verkuil
2024-01-15 14:52 ` Benjamin Gaignard
2024-01-15 15:17 ` Hans Verkuil
2024-01-15 16:04 ` Hans Verkuil
2023-12-15 9:08 ` [PATCH v16 4/8] media: core: Add bitmap manage bufs array entries Benjamin Gaignard
2024-01-15 12:21 ` Hans Verkuil
2024-01-15 14:51 ` Benjamin Gaignard
2024-01-15 15:14 ` Hans Verkuil
2023-12-15 9:08 ` [PATCH v16 5/8] media: core: Free range of buffers Benjamin Gaignard
2024-01-15 16:08 ` Hans Verkuil
2023-12-15 9:08 ` [PATCH v16 6/8] media: v4l2: Add DELETE_BUFS ioctl Benjamin Gaignard
2024-01-15 16:43 ` Hans Verkuil
2024-01-16 9:37 ` Benjamin Gaignard
2023-12-15 9:08 ` [PATCH v16 7/8] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2024-01-15 16:50 ` Hans Verkuil
2024-01-16 10:42 ` Benjamin Gaignard [this message]
2023-12-15 9:08 ` [PATCH v16 8/8] media: test-drivers: Use helper " Benjamin Gaignard
2024-01-15 16:53 ` Hans Verkuil
2024-01-09 9:37 ` [PATCH v16 0/8] Add DELETE_BUF ioctl 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=60c942d8-e0bd-4609-8fc4-1e80102ac051@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®