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 <william.wu@rock-chips.com>
This commit is contained in:
William Wu
2020-07-02 13:02:56 +08:00
committed by Tao Huang
parent bb21ab49d6
commit cdd4d2410c

View File

@@ -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 ||