From cdd4d2410c2cc8b8c1a96edfb86087ca6ea236ec Mon Sep 17 00:00:00 2001 From: William Wu Date: Thu, 2 Jul 2020 13:02:56 +0800 Subject: [PATCH] usb: gadget: uvc: fix zero length packet xfer bug for uvc bulk Refer to USB 2.0 spec, if a transfer with size divisible to EPs max packet size and with req->zero field is set, which means that after data is transfered it is also should be transfered a zero length packet at the end. For uvc bulk in transfer, it only sets the req->zero flag to enable sent the zero length packet to USB Host if the video->payload_size equal to video->max_payload_size. However, this condition is not enough, because if the image size is more than the max_payload_size, the image will be split to several transaction, and if the payload_size at the last transaction is less than then max_payload_size, it will not enable the zero length packet xfer. This patch sets the req->zero flag if the whole image has been transferred. Change-Id: I9a62a8b1df0e44b4291b6add664357d148c19d1f Signed-off-by: William Wu --- drivers/usb/gadget/function/uvc_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index 0a5a278be10b..c5092d1a8fa8 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -88,6 +88,7 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video, video->fid ^= UVC_STREAM_FID; video->payload_size = 0; + req->zero = 1; } if (video->payload_size == video->max_payload_size ||