Skip to content

Commit cd83ce9

Browse files
kamujingregkh
authored andcommitted
usb-core bInterval quirk
This patch adds a usb quirk to support devices with interupt endpoints and bInterval values expressed as microframes. The quirk causes the parse endpoint function to modify the reported bInterval to a standards conforming value. There is currently code in the endpoint parser that checks for bIntervals that are outside of the valid range (1-16 for USB 2+ high speed and super speed interupt endpoints). In this case, the code assumes the bInterval is being reported in 1ms frames. As well, the correction is only applied if the original bInterval value is out of the 1-16 range. With this quirk applied to the device, the bInterval will be accurately adjusted from microframes to an exponent. Signed-off-by: James P Michels III <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4bdcde3 commit cd83ce9

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/usb/core/config.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
199199
if (n == 0)
200200
n = 9; /* 32 ms = 2^(9-1) uframes */
201201
j = 16;
202+
203+
/*
204+
* Adjust bInterval for quirked devices.
205+
* This quirk fixes bIntervals reported in
206+
* linear microframes.
207+
*/
208+
if (to_usb_device(ddev)->quirks &
209+
USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) {
210+
n = clamp(fls(d->bInterval), i, j);
211+
i = j = n;
212+
}
202213
break;
203214
default: /* USB_SPEED_FULL or _LOW */
204215
/* For low-speed, 10 ms is the official minimum.

drivers/usb/core/quirks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ static const struct usb_device_id usb_quirk_list[] = {
145145
/* SKYMEDI USB_DRIVE */
146146
{ USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
147147

148+
/* Razer - Razer Blade Keyboard */
149+
{ USB_DEVICE(0x1532, 0x0116), .driver_info =
150+
USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
151+
148152
/* BUILDWIN Photo Frame */
149153
{ USB_DEVICE(0x1908, 0x1315), .driver_info =
150154
USB_QUIRK_HONOR_BNUMINTERFACES },

include/linux/usb/quirks.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@
3030
descriptor */
3131
#define USB_QUIRK_DELAY_INIT 0x00000040
3232

33+
/*
34+
* For high speed and super speed interupt endpoints, the USB 2.0 and
35+
* USB 3.0 spec require the interval in microframes
36+
* (1 microframe = 125 microseconds) to be calculated as
37+
* interval = 2 ^ (bInterval-1).
38+
*
39+
* Devices with this quirk report their bInterval as the result of this
40+
* calculation instead of the exponent variable used in the calculation.
41+
*/
42+
#define USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL 0x00000080
43+
3344
#endif /* __LINUX_USB_QUIRKS_H */

0 commit comments

Comments
 (0)