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>
9 #include <linux/moduleparam.h>
10 #include <linux/usb.h>
11 #include <linux/usb/quirks.h>
12 #include <linux/usb/hcd.h>
21 static DEFINE_MUTEX(quirk_mutex);
23 static struct quirk_entry *quirk_list;
24 static unsigned int quirk_count;
26 static char quirks_param[128];
28 static int quirks_param_set(const char *val, const struct kernel_param *kp)
36 err = param_set_copystring(val, kp);
40 mutex_lock(&quirk_mutex);
49 for (quirk_count = 1, i = 0; val[i]; i++)
58 quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
61 mutex_unlock(&quirk_mutex);
65 for (i = 0, p = (char *)val; p && *p;) {
66 /* Each entry consists of VID:PID:flags */
67 field = strsep(&p, ":");
71 if (kstrtou16(field, 16, &vid))
74 field = strsep(&p, ":");
78 if (kstrtou16(field, 16, &pid))
81 field = strsep(&p, ",");
82 if (!field || !*field)
85 /* Collect the flags */
86 for (flags = 0; *field; field++) {
89 flags |= USB_QUIRK_STRING_FETCH_255;
92 flags |= USB_QUIRK_RESET_RESUME;
95 flags |= USB_QUIRK_NO_SET_INTF;
98 flags |= USB_QUIRK_CONFIG_INTF_STRINGS;
101 flags |= USB_QUIRK_RESET;
104 flags |= USB_QUIRK_HONOR_BNUMINTERFACES;
107 flags |= USB_QUIRK_DELAY_INIT;
110 flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL;
113 flags |= USB_QUIRK_DEVICE_QUALIFIER;
116 flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP;
119 flags |= USB_QUIRK_NO_LPM;
122 flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL;
125 flags |= USB_QUIRK_DISCONNECT_SUSPEND;
128 flags |= USB_QUIRK_DELAY_CTRL_MSG;
130 /* Ignore unrecognized flag characters */
134 quirk_list[i++] = (struct quirk_entry)
135 { .vid = vid, .pid = pid, .flags = flags };
142 mutex_unlock(&quirk_mutex);
147 static const struct kernel_param_ops quirks_param_ops = {
148 .set = quirks_param_set,
149 .get = param_get_string,
152 static struct kparam_string quirks_param_string = {
153 .maxlen = sizeof(quirks_param),
154 .string = quirks_param,
157 module_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
158 MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
160 /* Lists of quirky USB devices, split in device quirks and interface quirks.
161 * Device quirks are applied at the very beginning of the enumeration process,
162 * right after reading the device descriptor. They can thus only match on device
165 * Interface quirks are applied after reading all the configuration descriptors.
166 * They can match on both device and interface information.
168 * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
169 * interface quirks, as they only influence the enumeration process which is run
170 * before processing the interface quirks.
172 * Please keep the lists ordered by:
177 static const struct usb_device_id usb_quirk_list[] = {
178 /* CBM - Flash disk */
179 { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
181 /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
182 { USB_DEVICE(0x0218, 0x0201), .driver_info =
183 USB_QUIRK_CONFIG_INTF_STRINGS },
185 /* WORLDE easy key (easykey.25) MIDI controller */
186 { USB_DEVICE(0x0218, 0x0401), .driver_info =
187 USB_QUIRK_CONFIG_INTF_STRINGS },
189 /* HP 5300/5370C scanner */
190 { USB_DEVICE(0x03f0, 0x0701), .driver_info =
191 USB_QUIRK_STRING_FETCH_255 },
193 /* HP v222w 16GB Mini USB Drive */
194 { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
196 /* Creative SB Audigy 2 NX */
197 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
200 { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
202 /* Microsoft Wireless Laser Mouse 6000 Receiver */
203 { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
205 /* Microsoft LifeCam-VX700 v2.0 */
206 { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
208 /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */
209 { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
210 { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
211 { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
212 { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
214 /* Logitech ConferenceCam CC3000e */
215 { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
216 { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
218 /* Logitech PTZ Pro Camera */
219 { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
221 /* Logitech Quickcam Fusion */
222 { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
224 /* Logitech Quickcam Orbit MP */
225 { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
227 /* Logitech Quickcam Pro for Notebook */
228 { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
230 /* Logitech Quickcam Pro 5000 */
231 { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
233 /* Logitech Quickcam OEM Dell Notebook */
234 { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
236 /* Logitech Quickcam OEM Cisco VT Camera II */
237 { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
239 /* Logitech Harmony 700-series */
240 { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
242 /* Philips PSC805 audio device */
243 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
245 /* Plantronic Audio 655 DSP */
246 { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
248 /* Plantronic Audio 648 USB */
249 { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
251 /* Artisman Watchdog Dongle */
252 { USB_DEVICE(0x04b4, 0x0526), .driver_info =
253 USB_QUIRK_CONFIG_INTF_STRINGS },
255 /* Microchip Joss Optical infrared touchboard device */
256 { USB_DEVICE(0x04d8, 0x000c), .driver_info =
257 USB_QUIRK_CONFIG_INTF_STRINGS },
259 /* CarrolTouch 4000U */
260 { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
262 /* CarrolTouch 4500U */
263 { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
265 /* Samsung Android phone modem - ID conflict with SPH-I500 */
266 { USB_DEVICE(0x04e8, 0x6601), .driver_info =
267 USB_QUIRK_CONFIG_INTF_STRINGS },
269 /* Elan Touchscreen */
270 { USB_DEVICE(0x04f3, 0x0089), .driver_info =
271 USB_QUIRK_DEVICE_QUALIFIER },
273 { USB_DEVICE(0x04f3, 0x009b), .driver_info =
274 USB_QUIRK_DEVICE_QUALIFIER },
276 { USB_DEVICE(0x04f3, 0x010c), .driver_info =
277 USB_QUIRK_DEVICE_QUALIFIER },
279 { USB_DEVICE(0x04f3, 0x0125), .driver_info =
280 USB_QUIRK_DEVICE_QUALIFIER },
282 { USB_DEVICE(0x04f3, 0x016f), .driver_info =
283 USB_QUIRK_DEVICE_QUALIFIER },
285 { USB_DEVICE(0x04f3, 0x0381), .driver_info =
288 { USB_DEVICE(0x04f3, 0x21b8), .driver_info =
289 USB_QUIRK_DEVICE_QUALIFIER },
292 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
295 { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
297 /* Alcor Micro Corp. Hub */
298 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
301 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
303 /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
304 { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
306 /* ELSA MicroLink 56K */
307 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
309 /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
310 { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
313 { USB_DEVICE(0x0638, 0x0a13), .driver_info =
314 USB_QUIRK_STRING_FETCH_255 },
316 /* Saitek Cyborg Gold Joystick */
317 { USB_DEVICE(0x06a3, 0x0006), .driver_info =
318 USB_QUIRK_CONFIG_INTF_STRINGS },
320 /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
321 { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
323 /* Guillemot Webcam Hercules Dualpix Exchange*/
324 { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
326 /* Midiman M-Audio Keystation 88es */
327 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
329 /* M-Systems Flash Disk Pioneers */
330 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
332 /* Baum Vario Ultra */
333 { USB_DEVICE(0x0904, 0x6101), .driver_info =
334 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
335 { USB_DEVICE(0x0904, 0x6102), .driver_info =
336 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
337 { USB_DEVICE(0x0904, 0x6103), .driver_info =
338 USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
340 /* Keytouch QWERTY Panel keyboard */
341 { USB_DEVICE(0x0926, 0x3333), .driver_info =
342 USB_QUIRK_CONFIG_INTF_STRINGS },
344 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
345 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
347 /* Broadcom BCM92035DGROM BT dongle */
348 { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
350 /* MAYA44USB sound device */
351 { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
353 /* ASUS Base Station(T100) */
354 { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
355 USB_QUIRK_IGNORE_REMOTE_WAKEUP },
357 /* Action Semiconductor flash disk */
358 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
359 USB_QUIRK_STRING_FETCH_255 },
361 /* Huawei 4G LTE module */
362 { USB_DEVICE(0x12d1, 0x15bb), .driver_info =
363 USB_QUIRK_DISCONNECT_SUSPEND },
364 { USB_DEVICE(0x12d1, 0x15c3), .driver_info =
365 USB_QUIRK_DISCONNECT_SUSPEND },
367 /* SKYMEDI USB_DRIVE */
368 { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
370 /* Razer - Razer Blade Keyboard */
371 { USB_DEVICE(0x1532, 0x0116), .driver_info =
372 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
374 /* BUILDWIN Photo Frame */
375 { USB_DEVICE(0x1908, 0x1315), .driver_info =
376 USB_QUIRK_HONOR_BNUMINTERFACES },
378 /* Protocol and OTG Electrical Test Device */
379 { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
380 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
382 /* Corsair K70 RGB */
383 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
386 { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
387 USB_QUIRK_DELAY_CTRL_MSG },
389 /* Corsair Strafe RGB */
390 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
391 USB_QUIRK_DELAY_CTRL_MSG },
393 /* Corsair K70 LUX */
394 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
396 /* MIDI keyboard WORLDE MINI */
397 { USB_DEVICE(0x1c75, 0x0204), .driver_info =
398 USB_QUIRK_CONFIG_INTF_STRINGS },
400 /* Acer C120 LED Projector */
401 { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
403 /* Blackmagic Design Intensity Shuttle */
404 { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
406 /* Blackmagic Design UltraStudio SDI */
407 { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
409 /* Hauppauge HVR-950q */
410 { USB_DEVICE(0x2040, 0x7200), .driver_info =
411 USB_QUIRK_CONFIG_INTF_STRINGS },
414 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
416 /* INTEL VALUE SSD */
417 { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
419 { } /* terminating entry must be last */
422 static const struct usb_device_id usb_interface_quirk_list[] = {
423 /* Logitech UVC Cameras */
424 { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
425 .driver_info = USB_QUIRK_RESET_RESUME },
427 { } /* terminating entry must be last */
430 static const struct usb_device_id usb_amd_resume_quirk_list[] = {
431 /* Lenovo Mouse with Pixart controller */
432 { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
435 { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
436 { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
437 { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
438 { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
440 /* Logitech Optical Mouse M90/M100 */
441 { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
443 { } /* terminating entry must be last */
446 static bool usb_match_any_interface(struct usb_device *udev,
447 const struct usb_device_id *id)
451 for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
452 struct usb_host_config *cfg = &udev->config[i];
455 for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
456 struct usb_interface_cache *cache;
457 struct usb_host_interface *intf;
459 cache = cfg->intf_cache[j];
460 if (cache->num_altsetting == 0)
463 intf = &cache->altsetting[0];
464 if (usb_match_one_id_intf(udev, intf, id))
472 static int usb_amd_resume_quirk(struct usb_device *udev)
476 hcd = bus_to_hcd(udev->bus);
477 /* The device should be attached directly to root hub */
478 if (udev->level == 1 && hcd->amd_resume_bug == 1)
484 static u32 usb_detect_static_quirks(struct usb_device *udev,
485 const struct usb_device_id *id)
489 for (; id->match_flags; id++) {
490 if (!usb_match_device(udev, id))
493 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
494 !usb_match_any_interface(udev, id))
497 quirks |= (u32)(id->driver_info);
503 static u32 usb_detect_dynamic_quirks(struct usb_device *udev)
505 u16 vid = le16_to_cpu(udev->descriptor.idVendor);
506 u16 pid = le16_to_cpu(udev->descriptor.idProduct);
509 mutex_lock(&quirk_mutex);
511 for (i = 0; i < quirk_count; i++) {
512 if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) {
513 flags = quirk_list[i].flags;
518 mutex_unlock(&quirk_mutex);
524 * Detect any quirks the device has, and do any housekeeping for it if needed.
526 void usb_detect_quirks(struct usb_device *udev)
528 udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list);
531 * Pixart-based mice would trigger remote wakeup issue on AMD
532 * Yangtze chipset, so set them as RESET_RESUME flag.
534 if (usb_amd_resume_quirk(udev))
535 udev->quirks |= usb_detect_static_quirks(udev,
536 usb_amd_resume_quirk_list);
538 udev->quirks ^= usb_detect_dynamic_quirks(udev);
541 dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
544 #ifdef CONFIG_USB_DEFAULT_PERSIST
545 if (!(udev->quirks & USB_QUIRK_RESET))
546 udev->persist_enabled = 1;
548 /* Hubs are automatically enabled for USB-PERSIST */
549 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
550 udev->persist_enabled = 1;
551 #endif /* CONFIG_USB_DEFAULT_PERSIST */
554 void usb_detect_interface_quirks(struct usb_device *udev)
558 quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list);
562 dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
564 udev->quirks |= quirks;
567 void usb_release_quirk_list(void)
569 mutex_lock(&quirk_mutex);
572 mutex_unlock(&quirk_mutex);