1 // SPDX-License-Identifier: GPL-2.0
3 * USB device quirk handling logic and table
5 * Copyright (c) 2007 Oliver Neukum
6 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
10 #include <linux/usb/quirks.h>
11 #include <linux/usb/hcd.h>
20 static DEFINE_MUTEX(quirk_mutex);
22 static struct quirk_entry *quirk_list;
23 static unsigned int quirk_count;
25 static char quirks_param[128];
27 static int quirks_param_set(const char *val, const struct kernel_param *kp)
34 mutex_lock(&quirk_mutex);
43 for (quirk_count = 1, i = 0; val[i]; i++)
52 quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
55 mutex_unlock(&quirk_mutex);
59 for (i = 0, p = (char *)val; p && *p;) {
60 /* Each entry consists of VID:PID:flags */
61 field = strsep(&p, ":");
65 if (kstrtou16(field, 16, &vid))
68 field = strsep(&p, ":");
72 if (kstrtou16(field, 16, &pid))
75 field = strsep(&p, ",");
76 if (!field || !*field)
79 /* Collect the flags */
80 for (flags = 0; *field; field++) {
83 flags |= USB_QUIRK_STRING_FETCH_255;
86 flags |= USB_QUIRK_RESET_RESUME;
89 flags |= USB_QUIRK_NO_SET_INTF;
92 flags |= USB_QUIRK_CONFIG_INTF_STRINGS;
95 flags |= USB_QUIRK_RESET;
98 flags |= USB_QUIRK_HONOR_BNUMINTERFACES;
101 flags |= USB_QUIRK_DELAY_INIT;
104 flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL;
107 flags |= USB_QUIRK_DEVICE_QUALIFIER;
110 flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP;
113 flags |= USB_QUIRK_NO_LPM;
116 flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL;
119 flags |= USB_QUIRK_DISCONNECT_SUSPEND;
121 /* Ignore unrecognized flag characters */
125 quirk_list[i++] = (struct quirk_entry)
126 { .vid = vid, .pid = pid, .flags = flags };
133 mutex_unlock(&quirk_mutex);
135 return param_set_copystring(val, kp);
138 static const struct kernel_param_ops quirks_param_ops = {
139 .set = quirks_param_set,
140 .get = param_get_string,
143 static struct kparam_string quirks_param_string = {
144 .maxlen = sizeof(quirks_param),
145 .string = quirks_param,
148 module_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
149 MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
151 /* Lists of quirky USB devices, split in device quirks and interface quirks.
152 * Device quirks are applied at the very beginning of the enumeration process,
153 * right after reading the device descriptor. They can thus only match on device
156 * Interface quirks are applied after reading all the configuration descriptors.
157 * They can match on both device and interface information.
159 * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
160 * interface quirks, as they only influence the enumeration process which is run
161 * before processing the interface quirks.
163 * Please keep the lists ordered by:
168 static const struct usb_device_id usb_quirk_list[] = {
169 /* CBM - Flash disk */
170 { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
172 /* WORLDE easy key (easykey.25) MIDI controller */
173 { USB_DEVICE(0x0218, 0x0401), .driver_info =
174 USB_QUIRK_CONFIG_INTF_STRINGS },
176 /* HP 5300/5370C scanner */
177 { USB_DEVICE(0x03f0, 0x0701), .driver_info =
178 USB_QUIRK_STRING_FETCH_255 },
180 /* Creative SB Audigy 2 NX */
181 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
184 { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
186 /* Microsoft Wireless Laser Mouse 6000 Receiver */
187 { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
189 /* Microsoft LifeCam-VX700 v2.0 */
190 { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
192 /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */
193 { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
194 { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
195 { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
196 { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
198 /* Logitech ConferenceCam CC3000e */
199 { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
200 { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
202 /* Logitech PTZ Pro Camera */
203 { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
205 /* Logitech Quickcam Fusion */
206 { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
208 /* Logitech Quickcam Orbit MP */
209 { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
211 /* Logitech Quickcam Pro for Notebook */
212 { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
214 /* Logitech Quickcam Pro 5000 */
215 { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
217 /* Logitech Quickcam OEM Dell Notebook */
218 { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
220 /* Logitech Quickcam OEM Cisco VT Camera II */
221 { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
223 /* Logitech Harmony 700-series */
224 { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
226 /* Philips PSC805 audio device */
227 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
229 /* Plantronic Audio 655 DSP */
230 { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
232 /* Plantronic Audio 648 USB */
233 { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
235 /* Artisman Watchdog Dongle */
236 { USB_DEVICE(0x04b4, 0x0526), .driver_info =
237 USB_QUIRK_CONFIG_INTF_STRINGS },
239 /* Microchip Joss Optical infrared touchboard device */
240 { USB_DEVICE(0x04d8, 0x000c), .driver_info =
241 USB_QUIRK_CONFIG_INTF_STRINGS },
243 /* CarrolTouch 4000U */
244 { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
246 /* CarrolTouch 4500U */
247 { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
249 /* Samsung Android phone modem - ID conflict with SPH-I500 */
250 { USB_DEVICE(0x04e8, 0x6601), .driver_info =
251 USB_QUIRK_CONFIG_INTF_STRINGS },
253 /* Elan Touchscreen */
254 { USB_DEVICE(0x04f3, 0x0089), .driver_info =
255 USB_QUIRK_DEVICE_QUALIFIER },
257 { USB_DEVICE(0x04f3, 0x009b), .driver_info =
258 USB_QUIRK_DEVICE_QUALIFIER },
260 { USB_DEVICE(0x04f3, 0x010c), .driver_info =
261 USB_QUIRK_DEVICE_QUALIFIER },
263 { USB_DEVICE(0x04f3, 0x0125), .driver_info =
264 USB_QUIRK_DEVICE_QUALIFIER },
266 { USB_DEVICE(0x04f3, 0x016f), .driver_info =
267 USB_QUIRK_DEVICE_QUALIFIER },
269 { USB_DEVICE(0x04f3, 0x0381), .driver_info =
272 { USB_DEVICE(0x04f3, 0x21b8), .driver_info =
273 USB_QUIRK_DEVICE_QUALIFIER },
276 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
279 { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
281 /* Alcor Micro Corp. Hub */
282 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
285 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
287 /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
288 { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
290 /* ELSA MicroLink 56K */
291 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
293 /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
294 { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
297 { USB_DEVICE(0x0638, 0x0a13), .driver_info =
298 USB_QUIRK_STRING_FETCH_255 },
300 /* Saitek Cyborg Gold Joystick */
301 { USB_DEVICE(0x06a3, 0x0006), .driver_info =
302 USB_QUIRK_CONFIG_INTF_STRINGS },
304 /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
305 { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
307 /* Guillemot Webcam Hercules Dualpix Exchange*/
308 { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
310 /* Midiman M-Audio Keystation 88es */
311 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
313 /* M-Systems Flash Disk Pioneers */
314 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
316 /* Baum Vario Ultra */
317 { USB_DEVICE(0x0904, 0x6101), .driver_info =
318 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
319 { USB_DEVICE(0x0904, 0x6102), .driver_info =
320 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
321 { USB_DEVICE(0x0904, 0x6103), .driver_info =
322 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
324 /* Keytouch QWERTY Panel keyboard */
325 { USB_DEVICE(0x0926, 0x3333), .driver_info =
326 USB_QUIRK_CONFIG_INTF_STRINGS },
328 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
329 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
331 /* Broadcom BCM92035DGROM BT dongle */
332 { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
334 /* MAYA44USB sound device */
335 { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
337 /* ASUS Base Station(T100) */
338 { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
339 USB_QUIRK_IGNORE_REMOTE_WAKEUP },
341 /* Action Semiconductor flash disk */
342 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
343 USB_QUIRK_STRING_FETCH_255 },
345 /* Huawei 4G LTE module */
346 { USB_DEVICE(0x12d1, 0x15bb), .driver_info =
347 USB_QUIRK_DISCONNECT_SUSPEND },
348 { USB_DEVICE(0x12d1, 0x15c3), .driver_info =
349 USB_QUIRK_DISCONNECT_SUSPEND },
351 /* SKYMEDI USB_DRIVE */
352 { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
354 /* Razer - Razer Blade Keyboard */
355 { USB_DEVICE(0x1532, 0x0116), .driver_info =
356 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
358 /* BUILDWIN Photo Frame */
359 { USB_DEVICE(0x1908, 0x1315), .driver_info =
360 USB_QUIRK_HONOR_BNUMINTERFACES },
362 /* Protocol and OTG Electrical Test Device */
363 { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
364 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
366 /* Corsair K70 RGB */
367 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
369 /* Corsair Strafe RGB */
370 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
372 /* Corsair K70 LUX */
373 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
375 /* MIDI keyboard WORLDE MINI */
376 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
377 USB_QUIRK_CONFIG_INTF_STRINGS },
379 /* Acer C120 LED Projector */
380 { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
382 /* Blackmagic Design Intensity Shuttle */
383 { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
385 /* Blackmagic Design UltraStudio SDI */
386 { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
388 /* Hauppauge HVR-950q */
389 { USB_DEVICE(0x2040, 0x7200), .driver_info =
390 USB_QUIRK_CONFIG_INTF_STRINGS },
392 /* INTEL VALUE SSD */
393 { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
395 { } /* terminating entry must be last */
398 static const struct usb_device_id usb_interface_quirk_list[] = {
399 /* Logitech UVC Cameras */
400 { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
401 .driver_info = USB_QUIRK_RESET_RESUME },
403 { } /* terminating entry must be last */
406 static const struct usb_device_id usb_amd_resume_quirk_list[] = {
407 /* Lenovo Mouse with Pixart controller */
408 { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
411 { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
412 { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
413 { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
414 { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
416 /* Logitech Optical Mouse M90/M100 */
417 { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
419 { } /* terminating entry must be last */
422 static bool usb_match_any_interface(struct usb_device *udev,
423 const struct usb_device_id *id)
427 for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
428 struct usb_host_config *cfg = &udev->config[i];
431 for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
432 struct usb_interface_cache *cache;
433 struct usb_host_interface *intf;
435 cache = cfg->intf_cache[j];
436 if (cache->num_altsetting == 0)
439 intf = &cache->altsetting[0];
440 if (usb_match_one_id_intf(udev, intf, id))
448 static int usb_amd_resume_quirk(struct usb_device *udev)
452 hcd = bus_to_hcd(udev->bus);
453 /* The device should be attached directly to root hub */
454 if (udev->level == 1 && hcd->amd_resume_bug == 1)
460 static u32 usb_detect_static_quirks(struct usb_device *udev,
461 const struct usb_device_id *id)
465 for (; id->match_flags; id++) {
466 if (!usb_match_device(udev, id))
469 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
470 !usb_match_any_interface(udev, id))
473 quirks |= (u32)(id->driver_info);
479 static u32 usb_detect_dynamic_quirks(struct usb_device *udev)
481 u16 vid = le16_to_cpu(udev->descriptor.idVendor);
482 u16 pid = le16_to_cpu(udev->descriptor.idProduct);
485 mutex_lock(&quirk_mutex);
487 for (i = 0; i < quirk_count; i++) {
488 if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) {
489 flags = quirk_list[i].flags;
494 mutex_unlock(&quirk_mutex);
500 * Detect any quirks the device has, and do any housekeeping for it if needed.
502 void usb_detect_quirks(struct usb_device *udev)
504 udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list);
507 * Pixart-based mice would trigger remote wakeup issue on AMD
508 * Yangtze chipset, so set them as RESET_RESUME flag.
510 if (usb_amd_resume_quirk(udev))
511 udev->quirks |= usb_detect_static_quirks(udev,
512 usb_amd_resume_quirk_list);
514 udev->quirks ^= usb_detect_dynamic_quirks(udev);
517 dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
520 #ifdef CONFIG_USB_DEFAULT_PERSIST
521 if (!(udev->quirks & USB_QUIRK_RESET))
522 udev->persist_enabled = 1;
524 /* Hubs are automatically enabled for USB-PERSIST */
525 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
526 udev->persist_enabled = 1;
527 #endif /* CONFIG_USB_DEFAULT_PERSIST */
530 void usb_detect_interface_quirks(struct usb_device *udev)
534 quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list);
538 dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
540 udev->quirks |= quirks;
543 void usb_release_quirk_list(void)
545 mutex_lock(&quirk_mutex);
548 mutex_unlock(&quirk_mutex);