[PATCH] Support of /dev/video read with USB camera devices

From: Hugues Fruchet
Date: Mon Mar 04 2019 - 07:35:59 EST

Currently, read() call from /dev/video entry of an USB camera is
returning invalid argument error.
This is quite common for userspace application to read compressed data such as
JPEG from /dev/video then redirect those data to a multimedia player or any
other compressed format consumer, see [1].

There was a tentative of implementation in the past [2] but it was prior to
switch on vb2 helpers usage inside uvc.
Now that vb2 is in place, we can implement read support using vb2_read()

Tested with Logitech HD Webcam C525 using v4l2-ctl to configure camera
then GStreamer player to play stream:
$> v4l2-ctl -d /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=MJPG
$> gst-play-1.0 /dev/video0


[2] https://www.mail-archive.com/linux-uvc-devel@xxxxxxxxxxxxxxxx/msg01258.html

Hugues Fruchet (1):
media: uvcvideo: Read support

drivers/media/usb/uvc/uvc_queue.c | 15 ++++++++++++++-
drivers/media/usb/uvc/uvc_v4l2.c | 11 ++++++++---
drivers/media/usb/uvc/uvcvideo.h | 2 ++
3 files changed, 24 insertions(+), 4 deletions(-)