usb: gadget: uvc: fix interval_duration calculation
commit010dc57cb5upstream. According to USB specification: For full-/high-speed isochronous endpoints, the bInterval value is used as the exponent for a 2^(bInterval-1) value. To correctly convert bInterval as interval_duration: interval_duration = 2^(bInterval-1) * frame_interval Because the unit of video->interval is 100ns, add a comment info to make it clear. Fixes:48dbe73117("usb: gadget: uvc: set req_size and n_requests based on the frame interval") Cc: stable@vger.kernel.org Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Link: https://patch.msgid.link/20260113-uvc-gadget-fix-patch-v2-2-62950ef5bcb5@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
34f6634dba
commit
aee4732461
@@ -107,7 +107,7 @@ struct uvc_video {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int imagesize;
|
||||
unsigned int interval;
|
||||
unsigned int interval; /* in 100ns units */
|
||||
struct mutex mutex; /* protects frame parameters */
|
||||
|
||||
unsigned int uvc_num_requests;
|
||||
|
||||
@@ -499,7 +499,7 @@ uvc_video_prep_requests(struct uvc_video *video)
|
||||
{
|
||||
struct uvc_device *uvc = container_of(video, struct uvc_device, video);
|
||||
struct usb_composite_dev *cdev = uvc->func.config->cdev;
|
||||
unsigned int interval_duration = video->ep->desc->bInterval * 1250;
|
||||
unsigned int interval_duration;
|
||||
unsigned int max_req_size, req_size, header_size;
|
||||
unsigned int nreq;
|
||||
|
||||
@@ -515,8 +515,11 @@ uvc_video_prep_requests(struct uvc_video *video)
|
||||
return;
|
||||
}
|
||||
|
||||
interval_duration = 2 << (video->ep->desc->bInterval - 1);
|
||||
if (cdev->gadget->speed < USB_SPEED_HIGH)
|
||||
interval_duration = video->ep->desc->bInterval * 10000;
|
||||
interval_duration *= 10000;
|
||||
else
|
||||
interval_duration *= 1250;
|
||||
|
||||
nreq = DIV_ROUND_UP(video->interval, interval_duration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user