quirks.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * USB device quirk handling logic and table
  3. *
  4. * Copyright (c) 2007 Oliver Neukum
  5. * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation, version 2.
  10. *
  11. *
  12. */
  13. #include <linux/usb.h>
  14. #include <linux/usb/quirks.h>
  15. #include "usb.h"
  16. /* Lists of quirky USB devices, split in device quirks and interface quirks.
  17. * Device quirks are applied at the very beginning of the enumeration process,
  18. * right after reading the device descriptor. They can thus only match on device
  19. * information.
  20. *
  21. * Interface quirks are applied after reading all the configuration descriptors.
  22. * They can match on both device and interface information.
  23. *
  24. * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
  25. * interface quirks, as they only influence the enumeration process which is run
  26. * before processing the interface quirks.
  27. *
  28. * Please keep the lists ordered by:
  29. * 1) Vendor ID
  30. * 2) Product ID
  31. * 3) Class ID
  32. */
  33. static const struct usb_device_id usb_quirk_list[] = {
  34. /* CBM - Flash disk */
  35. { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
  36. /* HP 5300/5370C scanner */
  37. { USB_DEVICE(0x03f0, 0x0701), .driver_info =
  38. USB_QUIRK_STRING_FETCH_255 },
  39. /* Creative SB Audigy 2 NX */
  40. { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
  41. /* Microsoft LifeCam-VX700 v2.0 */
  42. { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
  43. /* Logitech Quickcam Fusion */
  44. { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
  45. /* Logitech Quickcam Orbit MP */
  46. { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
  47. /* Logitech Quickcam Pro for Notebook */
  48. { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
  49. /* Logitech Quickcam Pro 5000 */
  50. { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
  51. /* Logitech Quickcam OEM Dell Notebook */
  52. { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
  53. /* Logitech Quickcam OEM Cisco VT Camera II */
  54. { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
  55. /* Logitech Harmony 700-series */
  56. { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
  57. /* Philips PSC805 audio device */
  58. { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
  59. /* Artisman Watchdog Dongle */
  60. { USB_DEVICE(0x04b4, 0x0526), .driver_info =
  61. USB_QUIRK_CONFIG_INTF_STRINGS },
  62. /* Microchip Joss Optical infrared touchboard device */
  63. { USB_DEVICE(0x04d8, 0x000c), .driver_info =
  64. USB_QUIRK_CONFIG_INTF_STRINGS },
  65. /* Samsung Android phone modem - ID conflict with SPH-I500 */
  66. { USB_DEVICE(0x04e8, 0x6601), .driver_info =
  67. USB_QUIRK_CONFIG_INTF_STRINGS },
  68. /* Roland SC-8820 */
  69. { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
  70. /* Edirol SD-20 */
  71. { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
  72. /* appletouch */
  73. { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
  74. /* Avision AV600U */
  75. { USB_DEVICE(0x0638, 0x0a13), .driver_info =
  76. USB_QUIRK_STRING_FETCH_255 },
  77. /* Saitek Cyborg Gold Joystick */
  78. { USB_DEVICE(0x06a3, 0x0006), .driver_info =
  79. USB_QUIRK_CONFIG_INTF_STRINGS },
  80. /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
  81. { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
  82. /* Guillemot Webcam Hercules Dualpix Exchange*/
  83. { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
  84. /* Midiman M-Audio Keystation 88es */
  85. { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
  86. /* M-Systems Flash Disk Pioneers */
  87. { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
  88. /* Keytouch QWERTY Panel keyboard */
  89. { USB_DEVICE(0x0926, 0x3333), .driver_info =
  90. USB_QUIRK_CONFIG_INTF_STRINGS },
  91. /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
  92. { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
  93. /* Broadcom BCM92035DGROM BT dongle */
  94. { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
  95. /* Action Semiconductor flash disk */
  96. { USB_DEVICE(0x10d6, 0x2200), .driver_info =
  97. USB_QUIRK_STRING_FETCH_255 },
  98. /* SKYMEDI USB_DRIVE */
  99. { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
  100. /* BUILDWIN Photo Frame */
  101. { USB_DEVICE(0x1908, 0x1315), .driver_info =
  102. USB_QUIRK_HONOR_BNUMINTERFACES },
  103. /* INTEL VALUE SSD */
  104. { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
  105. { } /* terminating entry must be last */
  106. };
  107. static const struct usb_device_id usb_interface_quirk_list[] = {
  108. /* Logitech UVC Cameras */
  109. { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
  110. .driver_info = USB_QUIRK_RESET_RESUME },
  111. { } /* terminating entry must be last */
  112. };
  113. static bool usb_match_any_interface(struct usb_device *udev,
  114. const struct usb_device_id *id)
  115. {
  116. unsigned int i;
  117. for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
  118. struct usb_host_config *cfg = &udev->config[i];
  119. unsigned int j;
  120. for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
  121. struct usb_interface_cache *cache;
  122. struct usb_host_interface *intf;
  123. cache = cfg->intf_cache[j];
  124. if (cache->num_altsetting == 0)
  125. continue;
  126. intf = &cache->altsetting[0];
  127. if (usb_match_one_id_intf(udev, intf, id))
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. static u32 __usb_detect_quirks(struct usb_device *udev,
  134. const struct usb_device_id *id)
  135. {
  136. u32 quirks = 0;
  137. for (; id->match_flags; id++) {
  138. if (!usb_match_device(udev, id))
  139. continue;
  140. if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
  141. !usb_match_any_interface(udev, id))
  142. continue;
  143. quirks |= (u32)(id->driver_info);
  144. }
  145. return quirks;
  146. }
  147. /*
  148. * Detect any quirks the device has, and do any housekeeping for it if needed.
  149. */
  150. void usb_detect_quirks(struct usb_device *udev)
  151. {
  152. udev->quirks = __usb_detect_quirks(udev, usb_quirk_list);
  153. if (udev->quirks)
  154. dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
  155. udev->quirks);
  156. /* For the present, all devices default to USB-PERSIST enabled */
  157. #if 0 /* was: #ifdef CONFIG_PM */
  158. /* Hubs are automatically enabled for USB-PERSIST */
  159. if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
  160. udev->persist_enabled = 1;
  161. #else
  162. /* In the absence of PM, we can safely enable USB-PERSIST
  163. * for all devices. It will affect things like hub resets
  164. * and EMF-related port disables.
  165. */
  166. if (!(udev->quirks & USB_QUIRK_RESET))
  167. udev->persist_enabled = 1;
  168. #endif /* CONFIG_PM */
  169. }
  170. void usb_detect_interface_quirks(struct usb_device *udev)
  171. {
  172. u32 quirks;
  173. quirks = __usb_detect_quirks(udev, usb_interface_quirk_list);
  174. if (quirks == 0)
  175. return;
  176. dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
  177. quirks);
  178. udev->quirks |= quirks;
  179. }