usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR
authorMichael Grzeschik <m.grzeschik@pengutronix.de>
Tue, 13 Feb 2024 23:37:55 +0000 (00:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Feb 2024 16:08:45 +0000 (17:08 +0100)
If an frame was transmitted incomplete to the host, we set the
UVC_STREAM_ERR bit in the header for the last request that is going
to be queued. This way the host will know that it should drop the
frame instead of trying to display the corrupted content.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240214-uvc-error-tag-v1-2-37659a3877fe@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/uvc_video.c

index d677d7daa1878a86722edb31d86bee68be642a34..d41f5f31dadd583e44a7823a7a89e5b4dafcb78f 100644 (file)
@@ -35,6 +35,9 @@ uvc_video_encode_header(struct uvc_video *video, struct uvc_buffer *buf,
 
        data[1] = UVC_STREAM_EOH | video->fid;
 
+       if (video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE)
+               data[1] |= UVC_STREAM_ERR;
+
        if (video->queue.buf_used == 0 && ts.tv_sec) {
                /* dwClockFrequency is 48 MHz */
                u32 pts = ((u64)ts.tv_sec * USEC_PER_SEC + ts.tv_nsec / NSEC_PER_USEC) * 48;