mbox series

[v8,0/4] usb: gadget: uvc: use configfs entries for negotiation and v4l2 VIDIOCS

Message ID 20220907140254.2378109-1-m.grzeschik@pengutronix.de (mailing list archive)
Headers show
Series usb: gadget: uvc: use configfs entries for negotiation and v4l2 VIDIOCS | expand

Message

Michael Grzeschik Sept. 7, 2022, 2:02 p.m. UTC
This series improves the uvc video gadget by parsing the configfs
entries. With the configfs data, the driver now is able to negotiate the
format with the usb host in the kernel and also exports the supported
frames/formats/intervals via the v4l2 VIDIOC interface.

The uvc userspace stack is also under development. One example is an generic
v4l2uvcsink gstreamer elemnt, which is currently under discussion. [1]

[1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1304

With the libusbgx library [1] used by the gadget-tool [2] it is now also
possible to fully describe the configfs layout of the uvc gadget with scheme
files.

[2] https://github.com/linux-usb-gadgets/libusbgx/pull/61/commits/53231c76f9d512f59fdc23b65cd5c46b7fb09eb4

[3] https://github.com/linux-usb-gadgets/gt/tree/master/examples/systemd

The bigger picture of these patches is to provide a more versatile interface to
the uvc gadget. The goal is to simply start a uvc-gadget with the following
commands:

$ gt load uvc.scheme
$ gst-launch v4l2src ! v4l2uvcsink

--

v1: https://lore.kernel.org/linux-usb/20210530222239.8793-1-m.grzeschik@pengutronix.de/
v2: https://lore.kernel.org/linux-usb/20211117004432.3763306-1-m.grzeschik@pengutronix.de/
v3: https://lore.kernel.org/linux-usb/20211117122435.2409362-1-m.grzeschik@pengutronix.de/
v4: https://lore.kernel.org/linux-usb/20211205225803.268492-1-m.grzeschik@pengutronix.de/
v5: https://lore.kernel.org/linux-usb/20211209084322.2662616-1-m.grzeschik@pengutronix.de/
v6: https://lore.kernel.org/linux-usb/20220105115527.3592860-1-m.grzeschik@pengutronix.de/
v7: https://lore.kernel.org/linux-usb/20220608105748.139922-1-m.grzeschik@pengutronix.de/

Regards,
Michael

Michael Grzeschik (4):
  media: v4l: move helper functions for fractions from uvc to v4l2-common
  media: uvcvideo: move uvc_format_desc to common header
  usb: gadget: uvc: add VIDIOC function
  usb: gadget: uvc: add format/frame handling code

 drivers/media/usb/uvc/uvc_ctrl.c        |   1 +
 drivers/media/usb/uvc/uvc_driver.c      | 290 +----------------
 drivers/media/usb/uvc/uvc_v4l2.c        |  14 +-
 drivers/media/usb/uvc/uvcvideo.h        | 147 ---------
 drivers/media/v4l2-core/v4l2-common.c   |  86 +++++
 drivers/usb/gadget/function/f_uvc.c     | 270 +++++++++++++++-
 drivers/usb/gadget/function/uvc.h       |  39 ++-
 drivers/usb/gadget/function/uvc_queue.c |   3 +-
 drivers/usb/gadget/function/uvc_v4l2.c  | 413 +++++++++++++++++++++---
 drivers/usb/gadget/function/uvc_video.c |  71 +++-
 include/media/v4l2-common.h             |   4 +
 include/media/v4l2-uvc.h                | 359 ++++++++++++++++++++
 12 files changed, 1196 insertions(+), 501 deletions(-)
 create mode 100644 include/media/v4l2-uvc.h

Comments

Greg Kroah-Hartman Sept. 7, 2022, 2:28 p.m. UTC | #1
On Wed, Sep 07, 2022 at 04:02:50PM +0200, Michael Grzeschik wrote:
> This series improves the uvc video gadget by parsing the configfs
> entries. With the configfs data, the driver now is able to negotiate the
> format with the usb host in the kernel and also exports the supported
> frames/formats/intervals via the v4l2 VIDIOC interface.
> 
> The uvc userspace stack is also under development. One example is an generic
> v4l2uvcsink gstreamer elemnt, which is currently under discussion. [1]
> 
> [1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1304
> 
> With the libusbgx library [1] used by the gadget-tool [2] it is now also
> possible to fully describe the configfs layout of the uvc gadget with scheme
> files.
> 
> [2] https://github.com/linux-usb-gadgets/libusbgx/pull/61/commits/53231c76f9d512f59fdc23b65cd5c46b7fb09eb4
> 
> [3] https://github.com/linux-usb-gadgets/gt/tree/master/examples/systemd
> 
> The bigger picture of these patches is to provide a more versatile interface to
> the uvc gadget. The goal is to simply start a uvc-gadget with the following
> commands:
> 
> $ gt load uvc.scheme
> $ gst-launch v4l2src ! v4l2uvcsink
> 
> --
> 
> v1: https://lore.kernel.org/linux-usb/20210530222239.8793-1-m.grzeschik@pengutronix.de/
> v2: https://lore.kernel.org/linux-usb/20211117004432.3763306-1-m.grzeschik@pengutronix.de/
> v3: https://lore.kernel.org/linux-usb/20211117122435.2409362-1-m.grzeschik@pengutronix.de/
> v4: https://lore.kernel.org/linux-usb/20211205225803.268492-1-m.grzeschik@pengutronix.de/
> v5: https://lore.kernel.org/linux-usb/20211209084322.2662616-1-m.grzeschik@pengutronix.de/
> v6: https://lore.kernel.org/linux-usb/20220105115527.3592860-1-m.grzeschik@pengutronix.de/
> v7: https://lore.kernel.org/linux-usb/20220608105748.139922-1-m.grzeschik@pengutronix.de/

Please say what changed somewhere :(

Anyway, this patch series does not even build properly:

drivers/usb/gadget/function/uvc_v4l2.c: In function ‘uvc_v4l2_get_format’:
drivers/usb/gadget/function/uvc_v4l2.c:258:42: error: ‘struct uvc_video’ has no member named ‘bpp’
  258 |         fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
      |                                          ^~
drivers/usb/gadget/function/uvc_v4l2.c:258:55: error: ‘struct uvc_video’ has no member named ‘width’
  258 |         fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
      |                                                       ^~
drivers/usb/gadget/function/uvc_v4l2.c:259:39: error: ‘struct uvc_video’ has no member named ‘imagesize’
  259 |         fmt->fmt.pix.sizeimage = video->imagesize;
      |                                       ^~
drivers/usb/gadget/function/uvc_v4l2.c: In function ‘uvc_v4l2_try_format’:
drivers/usb/gadget/function/uvc_v4l2.c:316:37: error: ‘bpl’ undeclared (first use in this function)
  316 |         fmt->fmt.pix.bytesperline = bpl;
      |                                     ^~~
drivers/usb/gadget/function/uvc_v4l2.c:316:37: note: each undeclared identifier is reported only once for each function it appears in
drivers/usb/gadget/function/uvc_v4l2.c:317:34: error: ‘imagesize’ undeclared (first use in this function); did you mean ‘page_size’?
  317 |         fmt->fmt.pix.sizeimage = imagesize;
      |                                  ^~~~~~~~~
      |                                  page_size


What did you test this with?

thanks,

greg k-h
Michael Grzeschik Sept. 7, 2022, 2:52 p.m. UTC | #2
On Wed, Sep 07, 2022 at 04:28:34PM +0200, Greg KH wrote:
>On Wed, Sep 07, 2022 at 04:02:50PM +0200, Michael Grzeschik wrote:
>> This series improves the uvc video gadget by parsing the configfs
>> entries. With the configfs data, the driver now is able to negotiate the
>> format with the usb host in the kernel and also exports the supported
>> frames/formats/intervals via the v4l2 VIDIOC interface.
>>
>> The uvc userspace stack is also under development. One example is an generic
>> v4l2uvcsink gstreamer elemnt, which is currently under discussion. [1]
>>
>> [1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1304
>>
>> With the libusbgx library [1] used by the gadget-tool [2] it is now also
>> possible to fully describe the configfs layout of the uvc gadget with scheme
>> files.
>>
>> [2] https://github.com/linux-usb-gadgets/libusbgx/pull/61/commits/53231c76f9d512f59fdc23b65cd5c46b7fb09eb4
>>
>> [3] https://github.com/linux-usb-gadgets/gt/tree/master/examples/systemd
>>
>> The bigger picture of these patches is to provide a more versatile interface to
>> the uvc gadget. The goal is to simply start a uvc-gadget with the following
>> commands:
>>
>> $ gt load uvc.scheme
>> $ gst-launch v4l2src ! v4l2uvcsink
>>
>> --
>>
>> v1: https://lore.kernel.org/linux-usb/20210530222239.8793-1-m.grzeschik@pengutronix.de/
>> v2: https://lore.kernel.org/linux-usb/20211117004432.3763306-1-m.grzeschik@pengutronix.de/
>> v3: https://lore.kernel.org/linux-usb/20211117122435.2409362-1-m.grzeschik@pengutronix.de/
>> v4: https://lore.kernel.org/linux-usb/20211205225803.268492-1-m.grzeschik@pengutronix.de/
>> v5: https://lore.kernel.org/linux-usb/20211209084322.2662616-1-m.grzeschik@pengutronix.de/
>> v6: https://lore.kernel.org/linux-usb/20220105115527.3592860-1-m.grzeschik@pengutronix.de/
>> v7: https://lore.kernel.org/linux-usb/20220608105748.139922-1-m.grzeschik@pengutronix.de/
>
>Please say what changed somewhere :(

I addressed each patch individually.

>Anyway, this patch series does not even build properly:
>
>drivers/usb/gadget/function/uvc_v4l2.c: In function ‘uvc_v4l2_get_format’:
>drivers/usb/gadget/function/uvc_v4l2.c:258:42: error: ‘struct uvc_video’ has no member named ‘bpp’
>  258 |         fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
>      |                                          ^~
>drivers/usb/gadget/function/uvc_v4l2.c:258:55: error: ‘struct uvc_video’ has no member named ‘width’
>  258 |         fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
>      |                                                       ^~
>drivers/usb/gadget/function/uvc_v4l2.c:259:39: error: ‘struct uvc_video’ has no member named ‘imagesize’
>  259 |         fmt->fmt.pix.sizeimage = video->imagesize;
>      |                                       ^~
>drivers/usb/gadget/function/uvc_v4l2.c: In function ‘uvc_v4l2_try_format’:
>drivers/usb/gadget/function/uvc_v4l2.c:316:37: error: ‘bpl’ undeclared (first use in this function)
>  316 |         fmt->fmt.pix.bytesperline = bpl;
>      |                                     ^~~
>drivers/usb/gadget/function/uvc_v4l2.c:316:37: note: each undeclared identifier is reported only once for each function it appears in
>drivers/usb/gadget/function/uvc_v4l2.c:317:34: error: ‘imagesize’ undeclared (first use in this function); did you mean ‘page_size’?
>  317 |         fmt->fmt.pix.sizeimage = imagesize;
>      |                                  ^~~~~~~~~
>      |                                  page_size
>
>
>What did you test this with?

I rebased and tested another series than I send.
Sorry for that. I will RESEND the v8 with the proper content.

Thanks,
Michael
Greg Kroah-Hartman Sept. 7, 2022, 3:01 p.m. UTC | #3
On Wed, Sep 07, 2022 at 04:52:04PM +0200, Michael Grzeschik wrote:
> On Wed, Sep 07, 2022 at 04:28:34PM +0200, Greg KH wrote:
> > On Wed, Sep 07, 2022 at 04:02:50PM +0200, Michael Grzeschik wrote:
> > > This series improves the uvc video gadget by parsing the configfs
> > > entries. With the configfs data, the driver now is able to negotiate the
> > > format with the usb host in the kernel and also exports the supported
> > > frames/formats/intervals via the v4l2 VIDIOC interface.
> > > 
> > > The uvc userspace stack is also under development. One example is an generic
> > > v4l2uvcsink gstreamer elemnt, which is currently under discussion. [1]
> > > 
> > > [1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1304
> > > 
> > > With the libusbgx library [1] used by the gadget-tool [2] it is now also
> > > possible to fully describe the configfs layout of the uvc gadget with scheme
> > > files.
> > > 
> > > [2] https://github.com/linux-usb-gadgets/libusbgx/pull/61/commits/53231c76f9d512f59fdc23b65cd5c46b7fb09eb4
> > > 
> > > [3] https://github.com/linux-usb-gadgets/gt/tree/master/examples/systemd
> > > 
> > > The bigger picture of these patches is to provide a more versatile interface to
> > > the uvc gadget. The goal is to simply start a uvc-gadget with the following
> > > commands:
> > > 
> > > $ gt load uvc.scheme
> > > $ gst-launch v4l2src ! v4l2uvcsink
> > > 
> > > --
> > > 
> > > v1: https://lore.kernel.org/linux-usb/20210530222239.8793-1-m.grzeschik@pengutronix.de/
> > > v2: https://lore.kernel.org/linux-usb/20211117004432.3763306-1-m.grzeschik@pengutronix.de/
> > > v3: https://lore.kernel.org/linux-usb/20211117122435.2409362-1-m.grzeschik@pengutronix.de/
> > > v4: https://lore.kernel.org/linux-usb/20211205225803.268492-1-m.grzeschik@pengutronix.de/
> > > v5: https://lore.kernel.org/linux-usb/20211209084322.2662616-1-m.grzeschik@pengutronix.de/
> > > v6: https://lore.kernel.org/linux-usb/20220105115527.3592860-1-m.grzeschik@pengutronix.de/
> > > v7: https://lore.kernel.org/linux-usb/20220608105748.139922-1-m.grzeschik@pengutronix.de/
> > 
> > Please say what changed somewhere :(
> 
> I addressed each patch individually.

Ah, yes, my mistake, I see that in the individual patches, sorry for the
noise.

greg k-h