quirks.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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 <linux/usb/hcd.h>
  16. #include "usb.h"
  17. /* Lists of quirky USB devices, split in device quirks and interface quirks.
  18. * Device quirks are applied at the very beginning of the enumeration process,
  19. * right after reading the device descriptor. They can thus only match on device
  20. * information.
  21. *
  22. * Interface quirks are applied after reading all the configuration descriptors.
  23. * They can match on both device and interface information.
  24. *
  25. * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
  26. * interface quirks, as they only influence the enumeration process which is run
  27. * before processing the interface quirks.
  28. *
  29. * Please keep the lists ordered by:
  30. * 1) Vendor ID
  31. * 2) Product ID
  32. * 3) Class ID
  33. */
  34. static const struct usb_device_id usb_quirk_list[] = {
  35. /* CBM - Flash disk */
  36. { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
  37. /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
  38. { USB_DEVICE(0x0218, 0x0201), .driver_info =
  39. USB_QUIRK_CONFIG_INTF_STRINGS },
  40. /* WORLDE easy key (easykey.25) MIDI controller */
  41. { USB_DEVICE(0x0218, 0x0401), .driver_info =
  42. USB_QUIRK_CONFIG_INTF_STRINGS },
  43. /* HP 5300/5370C scanner */
  44. { USB_DEVICE(0x03f0, 0x0701), .driver_info =
  45. USB_QUIRK_STRING_FETCH_255 },
  46. /* HP v222w 16GB Mini USB Drive */
  47. { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
  48. /* Creative SB Audigy 2 NX */
  49. { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
  50. /* USB3503 */
  51. { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
  52. /* Microsoft Wireless Laser Mouse 6000 Receiver */
  53. { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
  54. /* Microsoft LifeCam-VX700 v2.0 */
  55. { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
  56. /* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */
  57. { USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME },
  58. /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */
  59. { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
  60. { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
  61. { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
  62. { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
  63. /* Logitech ConferenceCam CC3000e */
  64. { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
  65. { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
  66. /* Logitech PTZ Pro Camera */
  67. { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
  68. /* Logitech Quickcam Fusion */
  69. { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
  70. /* Logitech Quickcam Orbit MP */
  71. { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
  72. /* Logitech Quickcam Pro for Notebook */
  73. { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
  74. /* Logitech Quickcam Pro 5000 */
  75. { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
  76. /* Logitech Quickcam OEM Dell Notebook */
  77. { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
  78. /* Logitech Quickcam OEM Cisco VT Camera II */
  79. { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
  80. /* Logitech Harmony 700-series */
  81. { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
  82. /* Philips PSC805 audio device */
  83. { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
  84. /* Plantronic Audio 655 DSP */
  85. { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
  86. /* Plantronic Audio 648 USB */
  87. { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
  88. /* Artisman Watchdog Dongle */
  89. { USB_DEVICE(0x04b4, 0x0526), .driver_info =
  90. USB_QUIRK_CONFIG_INTF_STRINGS },
  91. /* Microchip Joss Optical infrared touchboard device */
  92. { USB_DEVICE(0x04d8, 0x000c), .driver_info =
  93. USB_QUIRK_CONFIG_INTF_STRINGS },
  94. /* CarrolTouch 4000U */
  95. { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
  96. /* CarrolTouch 4500U */
  97. { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
  98. /* Samsung Android phone modem - ID conflict with SPH-I500 */
  99. { USB_DEVICE(0x04e8, 0x6601), .driver_info =
  100. USB_QUIRK_CONFIG_INTF_STRINGS },
  101. /* Elan Touchscreen */
  102. { USB_DEVICE(0x04f3, 0x0089), .driver_info =
  103. USB_QUIRK_DEVICE_QUALIFIER },
  104. { USB_DEVICE(0x04f3, 0x009b), .driver_info =
  105. USB_QUIRK_DEVICE_QUALIFIER },
  106. { USB_DEVICE(0x04f3, 0x010c), .driver_info =
  107. USB_QUIRK_DEVICE_QUALIFIER },
  108. { USB_DEVICE(0x04f3, 0x0125), .driver_info =
  109. USB_QUIRK_DEVICE_QUALIFIER },
  110. { USB_DEVICE(0x04f3, 0x016f), .driver_info =
  111. USB_QUIRK_DEVICE_QUALIFIER },
  112. { USB_DEVICE(0x04f3, 0x0381), .driver_info =
  113. USB_QUIRK_NO_LPM },
  114. { USB_DEVICE(0x04f3, 0x21b8), .driver_info =
  115. USB_QUIRK_DEVICE_QUALIFIER },
  116. /* Roland SC-8820 */
  117. { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
  118. /* Edirol SD-20 */
  119. { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
  120. /* Alcor Micro Corp. Hub */
  121. { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
  122. /* appletouch */
  123. { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
  124. /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
  125. { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
  126. /* ELSA MicroLink 56K */
  127. { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
  128. /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
  129. { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
  130. /* Avision AV600U */
  131. { USB_DEVICE(0x0638, 0x0a13), .driver_info =
  132. USB_QUIRK_STRING_FETCH_255 },
  133. /* Saitek Cyborg Gold Joystick */
  134. { USB_DEVICE(0x06a3, 0x0006), .driver_info =
  135. USB_QUIRK_CONFIG_INTF_STRINGS },
  136. /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
  137. { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
  138. /* Guillemot Webcam Hercules Dualpix Exchange*/
  139. { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
  140. /* Midiman M-Audio Keystation 88es */
  141. { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
  142. /* SanDisk Ultra Fit and Ultra Flair */
  143. { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM },
  144. { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM },
  145. /* M-Systems Flash Disk Pioneers */
  146. { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
  147. /* Baum Vario Ultra */
  148. { USB_DEVICE(0x0904, 0x6101), .driver_info =
  149. USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
  150. { USB_DEVICE(0x0904, 0x6102), .driver_info =
  151. USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
  152. { USB_DEVICE(0x0904, 0x6103), .driver_info =
  153. USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
  154. /* Keytouch QWERTY Panel keyboard */
  155. { USB_DEVICE(0x0926, 0x3333), .driver_info =
  156. USB_QUIRK_CONFIG_INTF_STRINGS },
  157. /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
  158. { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
  159. /* Broadcom BCM92035DGROM BT dongle */
  160. { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
  161. /* MAYA44USB sound device */
  162. { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
  163. /* ASUS Base Station(T100) */
  164. { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
  165. USB_QUIRK_IGNORE_REMOTE_WAKEUP },
  166. /* Action Semiconductor flash disk */
  167. { USB_DEVICE(0x10d6, 0x2200), .driver_info =
  168. USB_QUIRK_STRING_FETCH_255 },
  169. /* SKYMEDI USB_DRIVE */
  170. { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
  171. /* Razer - Razer Blade Keyboard */
  172. { USB_DEVICE(0x1532, 0x0116), .driver_info =
  173. USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
  174. /* BUILDWIN Photo Frame */
  175. { USB_DEVICE(0x1908, 0x1315), .driver_info =
  176. USB_QUIRK_HONOR_BNUMINTERFACES },
  177. /* Protocol and OTG Electrical Test Device */
  178. { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
  179. USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
  180. /* Corsair K70 RGB */
  181. { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT |
  182. USB_QUIRK_DELAY_CTRL_MSG },
  183. /* Corsair Strafe */
  184. { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
  185. USB_QUIRK_DELAY_CTRL_MSG },
  186. /* Corsair Strafe RGB */
  187. { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
  188. USB_QUIRK_DELAY_CTRL_MSG },
  189. /* Corsair K70 LUX RGB */
  190. { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT },
  191. /* Corsair K70 LUX */
  192. { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
  193. /* MIDI keyboard WORLDE MINI */
  194. { USB_DEVICE(0x1c75, 0x0204), .driver_info =
  195. USB_QUIRK_CONFIG_INTF_STRINGS },
  196. /* Acer C120 LED Projector */
  197. { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
  198. /* Blackmagic Design Intensity Shuttle */
  199. { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
  200. /* Blackmagic Design UltraStudio SDI */
  201. { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
  202. /* Hauppauge HVR-950q */
  203. { USB_DEVICE(0x2040, 0x7200), .driver_info =
  204. USB_QUIRK_CONFIG_INTF_STRINGS },
  205. /* Raydium Touchscreen */
  206. { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
  207. { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
  208. /* DJI CineSSD */
  209. { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
  210. /* INTEL VALUE SSD */
  211. { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
  212. { } /* terminating entry must be last */
  213. };
  214. static const struct usb_device_id usb_interface_quirk_list[] = {
  215. /* Logitech UVC Cameras */
  216. { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
  217. .driver_info = USB_QUIRK_RESET_RESUME },
  218. { } /* terminating entry must be last */
  219. };
  220. static const struct usb_device_id usb_amd_resume_quirk_list[] = {
  221. /* Lenovo Mouse with Pixart controller */
  222. { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
  223. /* Pixart Mouse */
  224. { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
  225. { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
  226. { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
  227. { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
  228. /* Logitech Optical Mouse M90/M100 */
  229. { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
  230. { } /* terminating entry must be last */
  231. };
  232. static bool usb_match_any_interface(struct usb_device *udev,
  233. const struct usb_device_id *id)
  234. {
  235. unsigned int i;
  236. for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
  237. struct usb_host_config *cfg = &udev->config[i];
  238. unsigned int j;
  239. for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
  240. struct usb_interface_cache *cache;
  241. struct usb_host_interface *intf;
  242. cache = cfg->intf_cache[j];
  243. if (cache->num_altsetting == 0)
  244. continue;
  245. intf = &cache->altsetting[0];
  246. if (usb_match_one_id_intf(udev, intf, id))
  247. return true;
  248. }
  249. }
  250. return false;
  251. }
  252. static int usb_amd_resume_quirk(struct usb_device *udev)
  253. {
  254. struct usb_hcd *hcd;
  255. hcd = bus_to_hcd(udev->bus);
  256. /* The device should be attached directly to root hub */
  257. if (udev->level == 1 && hcd->amd_resume_bug == 1)
  258. return 1;
  259. return 0;
  260. }
  261. static u32 __usb_detect_quirks(struct usb_device *udev,
  262. const struct usb_device_id *id)
  263. {
  264. u32 quirks = 0;
  265. for (; id->match_flags; id++) {
  266. if (!usb_match_device(udev, id))
  267. continue;
  268. if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
  269. !usb_match_any_interface(udev, id))
  270. continue;
  271. quirks |= (u32)(id->driver_info);
  272. }
  273. return quirks;
  274. }
  275. /*
  276. * Detect any quirks the device has, and do any housekeeping for it if needed.
  277. */
  278. void usb_detect_quirks(struct usb_device *udev)
  279. {
  280. udev->quirks = __usb_detect_quirks(udev, usb_quirk_list);
  281. /*
  282. * Pixart-based mice would trigger remote wakeup issue on AMD
  283. * Yangtze chipset, so set them as RESET_RESUME flag.
  284. */
  285. if (usb_amd_resume_quirk(udev))
  286. udev->quirks |= __usb_detect_quirks(udev,
  287. usb_amd_resume_quirk_list);
  288. if (udev->quirks)
  289. dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
  290. udev->quirks);
  291. #ifdef CONFIG_USB_DEFAULT_PERSIST
  292. if (!(udev->quirks & USB_QUIRK_RESET))
  293. udev->persist_enabled = 1;
  294. #else
  295. /* Hubs are automatically enabled for USB-PERSIST */
  296. if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
  297. udev->persist_enabled = 1;
  298. #endif /* CONFIG_USB_DEFAULT_PERSIST */
  299. }
  300. void usb_detect_interface_quirks(struct usb_device *udev)
  301. {
  302. u32 quirks;
  303. quirks = __usb_detect_quirks(udev, usb_interface_quirk_list);
  304. if (quirks == 0)
  305. return;
  306. dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
  307. quirks);
  308. udev->quirks |= quirks;
  309. }