2024-02-14 00:14:44

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 0/2] usb: gadget: uvc: improve tagging transmit errors

This series contains patches to improve signaling of transmit errors on
gadget and host side. The gadget now will tag an frame with
UVC_STREAM_ERROR in the header for the host to know that the transferred
frame has errors. The gadget will also skip tagging the frame erroneous
if the request that got not transmitted to the host did not contain any
data.

Signed-off-by: Michael Grzeschik <[email protected]>
---
Michael Grzeschik (2):
usb: gadget: uvc: dont drop frames if zero length packages are late
usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR

drivers/usb/gadget/function/uvc_video.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
base-commit: 88bae831f3810e02c9c951233c7ee662aa13dc2c
change-id: 20240214-uvc-error-tag-7b7d25c8eeff

Best regards,
--
Michael Grzeschik <[email protected]>



2024-02-14 00:15:14

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 2/2] usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR

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 <[email protected]>
---
drivers/usb/gadget/function/uvc_video.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index c288aceee92ac..af99958e6abf8 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -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;

--
2.39.2