]> www.infradead.org Git - users/hch/misc.git/commitdiff
media: uvcvideo: eUSB2 double isochronous bandwidth support
authorTao Q Tao <tao.q.tao@intel.com>
Wed, 20 Aug 2025 14:38:24 +0000 (17:38 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Sep 2025 13:25:06 +0000 (15:25 +0200)
Use usb_endpoint_max_esit_payload() from the USB framework to find the
maximum bytes per interval for the endpoint. Consequently this adds eUSB2
isochronous mode and SuperSpeedPlus Isochronous Endpoint Companion support
where larger payloads within a service interval are possible.

Co-developed-by: Amardeep Rai <amardeep.rai@intel.com>
Signed-off-by: Amardeep Rai <amardeep.rai@intel.com>
Signed-off-by: Tao Q Tao <tao.q.tao@intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250820143824.551777-10-sakari.ailus@linux.intel.com
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_video.c
drivers/media/usb/uvc/uvcvideo.h

index 775bede0d93d9b3e5391914aa395326d3de6a3b1..d06ca79ae2d96109dd38e3c7410b9cca559d751f 100644 (file)
@@ -539,7 +539,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
        unsigned int nformats = 0, nframes = 0, nintervals = 0;
        unsigned int size, i, n, p;
        u32 *interval;
-       u16 psize;
+       u32 psize;
        int ret = -EINVAL;
 
        if (intf->cur_altsetting->desc.bInterfaceSubClass
@@ -775,7 +775,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
                                streaming->header.bEndpointAddress);
                if (ep == NULL)
                        continue;
-               psize = uvc_endpoint_max_bpi(dev->udev, ep);
+               psize = usb_endpoint_max_periodic_payload(dev->udev, ep);
                if (psize > streaming->maxpsize)
                        streaming->maxpsize = psize;
        }
index a5013a7fbca40168b97268986a5972c349ccbaa8..1a0cc937de9bc17fb2745866325ac65405734d87 100644 (file)
@@ -1869,24 +1869,6 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream,
                uvc_free_urb_buffers(stream);
 }
 
-/*
- * Compute the maximum number of bytes per interval for an endpoint.
- */
-u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
-{
-       u16 psize;
-
-       switch (dev->speed) {
-       case USB_SPEED_SUPER:
-       case USB_SPEED_SUPER_PLUS:
-               return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
-       default:
-               psize = usb_endpoint_maxp(&ep->desc);
-               psize *= usb_endpoint_maxp_mult(&ep->desc);
-               return psize;
-       }
-}
-
 /*
  * Initialize isochronous URBs and allocate transfer buffers. The packet size
  * is given by the endpoint.
@@ -1897,10 +1879,10 @@ static int uvc_init_video_isoc(struct uvc_streaming *stream,
        struct urb *urb;
        struct uvc_urb *uvc_urb;
        unsigned int npackets, i;
-       u16 psize;
+       u32 psize;
        u32 size;
 
-       psize = uvc_endpoint_max_bpi(stream->dev->udev, ep);
+       psize = usb_endpoint_max_periodic_payload(stream->dev->udev, ep);
        size = stream->ctrl.dwMaxVideoFrameSize;
 
        npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags);
@@ -2043,7 +2025,7 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,
                                continue;
 
                        /* Check if the bandwidth is high enough. */
-                       psize = uvc_endpoint_max_bpi(stream->dev->udev, ep);
+                       psize = usb_endpoint_max_periodic_payload(stream->dev->udev, ep);
                        if (psize >= bandwidth && psize < best_psize) {
                                altsetting = alts->desc.bAlternateSetting;
                                best_psize = psize;
index 757254fc4fe930ae61c9d0425f04d4cd074a617e..ac19ca721f297cfab2bec29a0552053e1e366a46 100644 (file)
@@ -456,7 +456,7 @@ struct uvc_streaming {
 
        struct usb_interface *intf;
        int intfnum;
-       u16 maxpsize;
+       u32 maxpsize;
 
        struct uvc_streaming_header header;
        enum v4l2_buf_type type;
@@ -798,8 +798,6 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle);
 /* Utility functions */
 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,
                             struct uvc_buffer *buf,