From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: linux-media@vger.kernel.org, gregkh@linuxfoundation.org,
laurent.pinchart@ideasonboard.com, hdegoede@redhat.com,
Thinh.Nguyen@synopsys.com, Amardeep Rai <amardeep.rai@intel.com>,
Kannappan R <r.kannappan@intel.com>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Alan Stern <stern@rowland.harvard.edu>
Subject: [PATCH v3 3/4] USB: Add a function to obtain USB version independent maximum bpi value
Date: Thu, 7 Aug 2025 08:53:54 +0300 [thread overview]
Message-ID: <20250807055355.1257029-4-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20250807055355.1257029-1-sakari.ailus@linux.intel.com>
From: "Rai, Amardeep" <amardeep.rai@intel.com>
Add usb_endpoint_max_isoc_bpi() to obtain maximum bytes per interval for
isochronous endpoints in a USB version independent way.
Signed-off-by: Rai, Amardeep <amardeep.rai@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: Hans de Goede <hansg@kernel.org>
---
include/linux/usb.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 535ac37198a1..da0f51dfe15f 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -2049,6 +2049,37 @@ static inline int usb_translate_errors(int error_code)
}
}
+/**
+ * usb_endpoint_max_isoc_bpi - Get maximum isochronous transfer bytes per interval
+ * @dev: The USB device
+ * @ep: The endpoint
+ *
+ * Returns: the maximum number of bytes isochronous endpoint @endpoint can
+ * transfer in during a service interval, or 0 for non-isochronous endpoints.
+ */
+static inline u32 usb_endpoint_max_isoc_bpi(struct usb_device *dev,
+ const struct usb_host_endpoint *ep)
+{
+ if (usb_endpoint_type(&ep->desc) != USB_ENDPOINT_XFER_ISOC)
+ return 0;
+
+ switch (dev->speed) {
+ case USB_SPEED_SUPER_PLUS:
+ if (USB_SS_SSP_ISOC_COMP(ep->ss_ep_comp.bmAttributes))
+ return le32_to_cpu(ep->ssp_isoc_ep_comp.dwBytesPerInterval);
+ fallthrough;
+ case USB_SPEED_SUPER:
+ return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
+ case USB_SPEED_HIGH:
+ if (ep->eusb2_isoc_ep_comp.bDescriptorType &&
+ !usb_endpoint_maxp(&ep->desc) && usb_endpoint_dir_in(&ep->desc))
+ return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+ fallthrough;
+ default:
+ return usb_endpoint_maxp(&ep->desc) * usb_endpoint_maxp_mult(&ep->desc);
+ }
+}
+
/* Events from the usb core */
#define USB_DEVICE_ADD 0x0001
#define USB_DEVICE_REMOVE 0x0002
--
2.39.5
next prev parent reply other threads:[~2025-08-07 5:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 5:53 [PATCH v3 0/4] eUSB2 Double Isochronous IN Bandwidth support Sakari Ailus
2025-08-07 5:53 ` [PATCH v3 1/4] xhci: Add host support for eUSB2 double isochronous bandwidth devices Sakari Ailus
2025-08-07 15:25 ` Greg KH
2025-08-08 7:55 ` Sakari Ailus
2025-08-07 5:53 ` [PATCH v3 2/4] USB: core: support eUSB2 double bandwidth large isoc URB frames Sakari Ailus
2025-08-07 15:20 ` Alan Stern
2025-08-07 5:53 ` Sakari Ailus [this message]
2025-08-07 15:19 ` [PATCH v3 3/4] USB: Add a function to obtain USB version independent maximum bpi value Alan Stern
2025-08-08 8:18 ` Sakari Ailus
2025-08-08 15:16 ` Alan Stern
2025-08-12 6:15 ` Sakari Ailus
2025-08-07 5:53 ` [PATCH v3 4/4] media: uvcvideo: eUSB2 double isochronous bandwidth support Sakari Ailus
2025-08-07 6:38 ` Ricardo Ribalda
2025-08-07 13:15 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250807055355.1257029-4-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=amardeep.rai@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=r.kannappan@intel.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox