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>
Subject: [PATCH v2 3/4] USB: Add a function to obtain USB version independent maximum bpi value
Date: Fri, 11 Jul 2025 11:34:12 +0300 [thread overview]
Message-ID: <20250711083413.1552423-4-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20250711083413.1552423-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>
---
include/linux/usb.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 68166718ab30..bd70bd5ca82d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -2038,6 +2038,28 @@ static inline int usb_translate_errors(int error_code)
}
}
+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 (!usb_endpoint_maxp(&ep->desc) && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
+ 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-07-11 8:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 8:34 [PATCH v2 0/4] eUSB2 support Sakari Ailus
2025-07-11 8:34 ` [PATCH v2 1/4] xhci: Add host support for eUSB2 double isochronous bandwidth devices Sakari Ailus
2025-07-11 8:34 ` [PATCH v2 2/4] USB: core: support eUSB2 double bandwidth large isoc URB frames Sakari Ailus
2025-07-11 8:34 ` Sakari Ailus [this message]
2025-07-11 13:44 ` [PATCH v2 3/4] USB: Add a function to obtain USB version independent maximum bpi value Hans de Goede
2025-07-15 8:13 ` Sakari Ailus
2025-07-16 16:35 ` Hans de Goede
2025-07-28 22:21 ` Sakari Ailus
2025-07-11 14:18 ` Alan Stern
2025-07-11 8:34 ` [PATCH v2 4/4] media: uvcvideo: eUSB2 double isochronous bandwidth support Sakari Ailus
2025-07-15 9:10 ` Laurent Pinchart
2025-08-21 9:08 ` Sakari Ailus
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=20250711083413.1552423-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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.