mbox series

[0/2] vb2: add (un)prepare_streaming vb2_queue ops

Message ID 20220622093145.927377-1-hverkuil-cisco@xs4all.nl (mailing list archive)
Headers show
Series vb2: add (un)prepare_streaming vb2_queue ops | expand

Message

Hans Verkuil June 22, 2022, 9:31 a.m. UTC
Add support for two new (un)prepare_streaming queue ops that are called
when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).

This gives drivers a callback to validate the video pipeline and claim
or release streaming resources at the time that userspace indicates
that it wants to start streaming (VIDIOC_STREAMON) rather than when
the actual DMA engine kicks in (the start_streaming callback). This
is relevant for drivers that needs a minimum of X buffers before the
DMA can start. The actual pipeline validation needs to happen sooner
to avoid unnecessary errors at VIDIOC_QBUF time.

As a bonus this allows us to move the horrible call to
v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
driver (currently the only driver that uses this feature).

That call never belonged in vb2, but it had the same purpose as the
new prepare_streaming op: validate the pipeline.

This is a follow-up from my previous RFCv2:

https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/

I would like to get consensus for this series.

Regards,

	Hans

Hans Verkuil (2):
  vb2: add (un)prepare_streaming queue ops
  vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver

 .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
 drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
 drivers/media/usb/au0828/au0828-video.c       |  1 +
 include/media/videobuf2-core.h                | 14 ++++++++++
 4 files changed, 37 insertions(+), 6 deletions(-)

Comments

Laurent Pinchart June 22, 2022, 9:44 a.m. UTC | #1
Hi Hans,

On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
> Add support for two new (un)prepare_streaming queue ops that are called
> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
> 
> This gives drivers a callback to validate the video pipeline and claim
> or release streaming resources at the time that userspace indicates
> that it wants to start streaming (VIDIOC_STREAMON) rather than when
> the actual DMA engine kicks in (the start_streaming callback). This
> is relevant for drivers that needs a minimum of X buffers before the
> DMA can start. The actual pipeline validation needs to happen sooner
> to avoid unnecessary errors at VIDIOC_QBUF time.
> 
> As a bonus this allows us to move the horrible call to
> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
> driver (currently the only driver that uses this feature).

Can we drop the horrible .enable_source() from media_device too ? :-)

> That call never belonged in vb2, but it had the same purpose as the
> new prepare_streaming op: validate the pipeline.
> 
> This is a follow-up from my previous RFCv2:
> 
> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
> 
> I would like to get consensus for this series.

I don't like it much. vb2 is already doing too much in my opinion,
growing it isn't the right way to fix it.

I'm still working on a new version of the V4L2 streams series that may
conflict with this, I'd propose discussing the two together.

> Hans Verkuil (2):
>   vb2: add (un)prepare_streaming queue ops
>   vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
> 
>  .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
>  drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
>  drivers/media/usb/au0828/au0828-video.c       |  1 +
>  include/media/videobuf2-core.h                | 14 ++++++++++
>  4 files changed, 37 insertions(+), 6 deletions(-)
Hans Verkuil June 22, 2022, 10 a.m. UTC | #2
Hi Laurent,

On 22/06/2022 11:44, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
>> Add support for two new (un)prepare_streaming queue ops that are called
>> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
>>
>> This gives drivers a callback to validate the video pipeline and claim
>> or release streaming resources at the time that userspace indicates
>> that it wants to start streaming (VIDIOC_STREAMON) rather than when
>> the actual DMA engine kicks in (the start_streaming callback). This
>> is relevant for drivers that needs a minimum of X buffers before the
>> DMA can start. The actual pipeline validation needs to happen sooner
>> to avoid unnecessary errors at VIDIOC_QBUF time.
>>
>> As a bonus this allows us to move the horrible call to
>> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
>> driver (currently the only driver that uses this feature).
> 
> Can we drop the horrible .enable_source() from media_device too ? :-)

The second patch helps a bit with that, at least it's out of vb2.

> 
>> That call never belonged in vb2, but it had the same purpose as the
>> new prepare_streaming op: validate the pipeline.
>>
>> This is a follow-up from my previous RFCv2:
>>
>> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
>>
>> I would like to get consensus for this series.
> 
> I don't like it much. vb2 is already doing too much in my opinion,
> growing it isn't the right way to fix it.

We disagree on that :-)

> 
> I'm still working on a new version of the V4L2 streams series that may
> conflict with this, I'd propose discussing the two together.

What is the ETA for that? I don't mind waiting a few months, but if it
takes a lot longer, then I'd rather merge this first so Eugen can use it
in his atmel MC support. It's a kernel API, so it can always be changed
or removed later.

Regards,

	Hans

> 
>> Hans Verkuil (2):
>>   vb2: add (un)prepare_streaming queue ops
>>   vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
>>
>>  .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
>>  drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
>>  drivers/media/usb/au0828/au0828-video.c       |  1 +
>>  include/media/videobuf2-core.h                | 14 ++++++++++
>>  4 files changed, 37 insertions(+), 6 deletions(-)
>
Laurent Pinchart June 22, 2022, 10:08 a.m. UTC | #3
Hi Hans,

On Wed, Jun 22, 2022 at 12:00:58PM +0200, Hans Verkuil wrote:
> On 22/06/2022 11:44, Laurent Pinchart wrote:
> > On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
> >> Add support for two new (un)prepare_streaming queue ops that are called
> >> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
> >>
> >> This gives drivers a callback to validate the video pipeline and claim
> >> or release streaming resources at the time that userspace indicates
> >> that it wants to start streaming (VIDIOC_STREAMON) rather than when
> >> the actual DMA engine kicks in (the start_streaming callback). This
> >> is relevant for drivers that needs a minimum of X buffers before the
> >> DMA can start. The actual pipeline validation needs to happen sooner
> >> to avoid unnecessary errors at VIDIOC_QBUF time.
> >>
> >> As a bonus this allows us to move the horrible call to
> >> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
> >> driver (currently the only driver that uses this feature).
> > 
> > Can we drop the horrible .enable_source() from media_device too ? :-)
> 
> The second patch helps a bit with that, at least it's out of vb2.
> 
> > 
> >> That call never belonged in vb2, but it had the same purpose as the
> >> new prepare_streaming op: validate the pipeline.
> >>
> >> This is a follow-up from my previous RFCv2:
> >>
> >> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
> >>
> >> I would like to get consensus for this series.
> > 
> > I don't like it much. vb2 is already doing too much in my opinion,
> > growing it isn't the right way to fix it.
> 
> We disagree on that :-)

I like polite and constructive disagreements, they help moving forward
:-)

> > I'm still working on a new version of the V4L2 streams series that may
> > conflict with this, I'd propose discussing the two together.
> 
> What is the ETA for that? I don't mind waiting a few months, but if it
> takes a lot longer, then I'd rather merge this first so Eugen can use it
> in his atmel MC support. It's a kernel API, so it can always be changed
> or removed later.

I have a few other things to complete first, an dI plan to resume the
work in the first half of July, to post a v12 before the end of the
month.

> >> Hans Verkuil (2):
> >>   vb2: add (un)prepare_streaming queue ops
> >>   vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
> >>
> >>  .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
> >>  drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
> >>  drivers/media/usb/au0828/au0828-video.c       |  1 +
> >>  include/media/videobuf2-core.h                | 14 ++++++++++
> >>  4 files changed, 37 insertions(+), 6 deletions(-)
Eugen Hristev June 22, 2022, 10:23 a.m. UTC | #4
On 6/22/22 1:00 PM, Hans Verkuil wrote:

> Hi Laurent,
> 
> On 22/06/2022 11:44, Laurent Pinchart wrote:
>> Hi Hans,
>>
>> On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
>>> Add support for two new (un)prepare_streaming queue ops that are called
>>> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
>>>
>>> This gives drivers a callback to validate the video pipeline and claim
>>> or release streaming resources at the time that userspace indicates
>>> that it wants to start streaming (VIDIOC_STREAMON) rather than when
>>> the actual DMA engine kicks in (the start_streaming callback). This
>>> is relevant for drivers that needs a minimum of X buffers before the
>>> DMA can start. The actual pipeline validation needs to happen sooner
>>> to avoid unnecessary errors at VIDIOC_QBUF time.
>>>
>>> As a bonus this allows us to move the horrible call to
>>> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
>>> driver (currently the only driver that uses this feature).
>>
>> Can we drop the horrible .enable_source() from media_device too ? :-)
> 
> The second patch helps a bit with that, at least it's out of vb2.
> 
>>
>>> That call never belonged in vb2, but it had the same purpose as the
>>> new prepare_streaming op: validate the pipeline.
>>>
>>> This is a follow-up from my previous RFCv2:
>>>
>>> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
>>>
>>> I would like to get consensus for this series.
>>
>> I don't like it much. vb2 is already doing too much in my opinion,
>> growing it isn't the right way to fix it.
> 
> We disagree on that :-)
> 
>>
>> I'm still working on a new version of the V4L2 streams series that may
>> conflict with this, I'd propose discussing the two together.
> 
> What is the ETA for that? I don't mind waiting a few months, but if it
> takes a lot longer, then I'd rather merge this first so Eugen can use it
> in his atmel MC support. It's a kernel API, so it can always be changed
> or removed later.

Hi,

The atmel MC support is done on top of v4l2 without this patch, and I 
have a subsequent patch that changes the atmel MC to use the new RFC API.

One option is to have the atmel MC like I initially sent it, and add my 
patch that switches to the prepare_streaming to this series .

> 
> Regards,
> 
>          Hans
> 
>>
>>> Hans Verkuil (2):
>>>    vb2: add (un)prepare_streaming queue ops
>>>    vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
>>>
>>>   .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
>>>   drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
>>>   drivers/media/usb/au0828/au0828-video.c       |  1 +
>>>   include/media/videobuf2-core.h                | 14 ++++++++++
>>>   4 files changed, 37 insertions(+), 6 deletions(-)
>>
>
Hans Verkuil Nov. 4, 2022, 9:46 a.m. UTC | #5
Hi Laurent,

On 22/06/2022 12:08, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Wed, Jun 22, 2022 at 12:00:58PM +0200, Hans Verkuil wrote:
>> On 22/06/2022 11:44, Laurent Pinchart wrote:
>>> On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
>>>> Add support for two new (un)prepare_streaming queue ops that are called
>>>> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
>>>>
>>>> This gives drivers a callback to validate the video pipeline and claim
>>>> or release streaming resources at the time that userspace indicates
>>>> that it wants to start streaming (VIDIOC_STREAMON) rather than when
>>>> the actual DMA engine kicks in (the start_streaming callback). This
>>>> is relevant for drivers that needs a minimum of X buffers before the
>>>> DMA can start. The actual pipeline validation needs to happen sooner
>>>> to avoid unnecessary errors at VIDIOC_QBUF time.
>>>>
>>>> As a bonus this allows us to move the horrible call to
>>>> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
>>>> driver (currently the only driver that uses this feature).
>>>
>>> Can we drop the horrible .enable_source() from media_device too ? :-)
>>
>> The second patch helps a bit with that, at least it's out of vb2.
>>
>>>
>>>> That call never belonged in vb2, but it had the same purpose as the
>>>> new prepare_streaming op: validate the pipeline.
>>>>
>>>> This is a follow-up from my previous RFCv2:
>>>>
>>>> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
>>>>
>>>> I would like to get consensus for this series.
>>>
>>> I don't like it much. vb2 is already doing too much in my opinion,
>>> growing it isn't the right way to fix it.
>>
>> We disagree on that :-)
> 
> I like polite and constructive disagreements, they help moving forward
> :-)
> 
>>> I'm still working on a new version of the V4L2 streams series that may
>>> conflict with this, I'd propose discussing the two together.
>>
>> What is the ETA for that? I don't mind waiting a few months, but if it
>> takes a lot longer, then I'd rather merge this first so Eugen can use it
>> in his atmel MC support. It's a kernel API, so it can always be changed
>> or removed later.
> 
> I have a few other things to complete first, an dI plan to resume the
> work in the first half of July, to post a v12 before the end of the
> month.

Looking at the latest v15 series there are no conflicts with this patch.

Eugen posted a v11 of his "atmel-isc: driver redesign" series, and wants
to use this functionality.

I think with this change it is also possible to remove the enable_source
callback from the mc. I can try to post a v2 that does this, if that's
what it takes to convince you :-)

Regards,

	Hans

> 
>>>> Hans Verkuil (2):
>>>>   vb2: add (un)prepare_streaming queue ops
>>>>   vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
>>>>
>>>>  .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
>>>>  drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
>>>>  drivers/media/usb/au0828/au0828-video.c       |  1 +
>>>>  include/media/videobuf2-core.h                | 14 ++++++++++
>>>>  4 files changed, 37 insertions(+), 6 deletions(-)
>
Eugen Hristev Nov. 4, 2022, 10:57 a.m. UTC | #6
On 11/4/22 11:46, Hans Verkuil wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Hi Laurent,
> 
> On 22/06/2022 12:08, Laurent Pinchart wrote:
>> Hi Hans,
>>
>> On Wed, Jun 22, 2022 at 12:00:58PM +0200, Hans Verkuil wrote:
>>> On 22/06/2022 11:44, Laurent Pinchart wrote:
>>>> On Wed, Jun 22, 2022 at 11:31:43AM +0200, Hans Verkuil wrote:
>>>>> Add support for two new (un)prepare_streaming queue ops that are called
>>>>> when the user calls VIDIOC_STREAMON and STREAMOFF (or closes the fh).
>>>>>
>>>>> This gives drivers a callback to validate the video pipeline and claim
>>>>> or release streaming resources at the time that userspace indicates
>>>>> that it wants to start streaming (VIDIOC_STREAMON) rather than when
>>>>> the actual DMA engine kicks in (the start_streaming callback). This
>>>>> is relevant for drivers that needs a minimum of X buffers before the
>>>>> DMA can start. The actual pipeline validation needs to happen sooner
>>>>> to avoid unnecessary errors at VIDIOC_QBUF time.
>>>>>
>>>>> As a bonus this allows us to move the horrible call to
>>>>> v4l_vb2q_enable_media_source() in vb2_core_streamon() to the au0828
>>>>> driver (currently the only driver that uses this feature).
>>>>
>>>> Can we drop the horrible .enable_source() from media_device too ? :-)
>>>
>>> The second patch helps a bit with that, at least it's out of vb2.
>>>
>>>>
>>>>> That call never belonged in vb2, but it had the same purpose as the
>>>>> new prepare_streaming op: validate the pipeline.
>>>>>
>>>>> This is a follow-up from my previous RFCv2:
>>>>>
>>>>> https://patchwork.linuxtv.org/project/linux-media/patch/ba4bca14-488f-94ea-48d9-e7343103c5aa@xs4all.nl/
>>>>>
>>>>> I would like to get consensus for this series.
>>>>
>>>> I don't like it much. vb2 is already doing too much in my opinion,
>>>> growing it isn't the right way to fix it.
>>>
>>> We disagree on that :-)
>>
>> I like polite and constructive disagreements, they help moving forward
>> :-)
>>
>>>> I'm still working on a new version of the V4L2 streams series that may
>>>> conflict with this, I'd propose discussing the two together.
>>>
>>> What is the ETA for that? I don't mind waiting a few months, but if it
>>> takes a lot longer, then I'd rather merge this first so Eugen can use it
>>> in his atmel MC support. It's a kernel API, so it can always be changed
>>> or removed later.
>>
>> I have a few other things to complete first, an dI plan to resume the
>> work in the first half of July, to post a v12 before the end of the
>> month.
> 
> Looking at the latest v15 series there are no conflicts with this patch.
> 
> Eugen posted a v11 of his "atmel-isc: driver redesign" series, and wants
> to use this functionality.
> 
> I think with this change it is also possible to remove the enable_source
> callback from the mc. I can try to post a v2 that does this, if that's
> what it takes to convince you :-)

Hello,

The ISC driver looks more clean with these ops.
I don't know how much it matters though.
It's not a big improvement, rather small, but it looks cleaner.

Thanks,
Eugen

> 
> Regards,
> 
>          Hans
> 
>>
>>>>> Hans Verkuil (2):
>>>>>    vb2: add (un)prepare_streaming queue ops
>>>>>    vb2/au0828: move the v4l_vb2q_enable_media_source to the au0828 driver
>>>>>
>>>>>   .../media/common/videobuf2/videobuf2-core.c   | 26 ++++++++++++++-----
>>>>>   drivers/media/usb/au0828/au0828-vbi.c         |  2 ++
>>>>>   drivers/media/usb/au0828/au0828-video.c       |  1 +
>>>>>   include/media/videobuf2-core.h                | 14 ++++++++++
>>>>>   4 files changed, 37 insertions(+), 6 deletions(-)
>>
>