mbox series

[0/3] Fix Sonix Technology MJPEG streams

Message ID 20241108142310.19794-1-isaac.scott@ideasonboard.com (mailing list archive)
Headers show
Series Fix Sonix Technology MJPEG streams | expand

Message

Isaac Scott Nov. 8, 2024, 2:23 p.m. UTC
Some cameras, such as the Sonix Technology Co. 292A, allow multiple
streams to be sent over the same USB device. It was found during testing
that occasionally, when one H.264 stream sends a new keyframe during an
MJPEG stream, a URB buffer would be lost, and a frame lost in the
resulting capture.

This was because some EOF markers in URB buffers are lost. This particular
use case is not covered by the uvc_video driver, which causes two
consecutive buffers to be erroneously considered to be as part of
the same buffer, and lead to the whole erroneous buffer to be dropped.
This can be seen when using the current driver, as frames occasionally
are double the expected size, containing two images. Furthermore, the
interval between the frames was double that of what it should be (~66ms
as opposed to the usual ~33ms). Upon further investigation, it was found
that the packets within the erroneous buffer were being dropped.

The changes in this series supply a new quirk for the UVC Driver, which
cause the buffers of MJPEG streams to be closed when a new JPEG SOI
marker is discovered, and be treated as a new buffer. This works around
the missing EOF marker and separates the buffers.

Tested on v6.12-rc3

Isaac Scott (3):
  media: uvcvideo: Introduce header length
  media: uvcvideo: Add new quirk definition for the Sonix Technology Co.
    292a camera
  media: uvcvideo: Implement dual stream quirk to fix loss of usb
    packets

 drivers/media/usb/uvc/uvc_driver.c |  9 +++++++++
 drivers/media/usb/uvc/uvc_video.c  | 27 ++++++++++++++++++++++++++-
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 3 files changed, 36 insertions(+), 1 deletion(-)