]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: uvcvideo: Undup use uvc_endpoint_max_bpi() code
authorRicardo Ribalda <ribalda@chromium.org>
Fri, 1 Apr 2022 17:24:37 +0000 (19:24 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 8 May 2022 05:10:32 +0000 (07:10 +0200)
Replace manual decoding of psize in uvc_parse_streaming(), with the code
from uvc_endpoint_max_bpi(). It also handles usb3 devices.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_video.c
drivers/media/usb/uvc/uvcvideo.h

index e0a33a0a00c629579c466c3d2034b29f63928006..c780394059e726f69c0c6545601acde3ec70a519 100644 (file)
@@ -1009,9 +1009,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
                                streaming->header.bEndpointAddress);
                if (ep == NULL)
                        continue;
-
-               psize = le16_to_cpu(ep->desc.wMaxPacketSize);
-               psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
+               psize = uvc_endpoint_max_bpi(dev->udev, ep);
                if (psize > streaming->maxpsize)
                        streaming->maxpsize = psize;
        }
index 6712982abafb2be2d6328de059ed94b44a1eab1f..6d3dfa4e0bb26059fbb05ecba66d3788aac78287 100644 (file)
@@ -1754,8 +1754,7 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream,
 /*
  * Compute the maximum number of bytes per interval for an endpoint.
  */
-static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev,
-                                        struct usb_host_endpoint *ep)
+u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
 {
        u16 psize;
 
index 143230b3275b3720ae11c57b004c368b05d098c8..28eb337a6cfbfbd809a54aa96f04badca97b61d9 100644 (file)
@@ -911,6 +911,7 @@ void uvc_simplify_fraction(u32 *numerator, u32 *denominator,
 u32 uvc_fraction_to_interval(u32 numerator, u32 denominator);
 struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
                                            u8 epaddr);
+u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep);
 
 /* Quirks support */
 void uvc_video_decode_isight(struct uvc_urb *uvc_urb,