Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 2 | /* |
| 3 | * USB device quirk handling logic and table |
| 4 | * |
| 5 | * Copyright (c) 2007 Oliver Neukum |
| 6 | * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 9 | #include <linux/moduleparam.h> |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 10 | #include <linux/usb.h> |
| 11 | #include <linux/usb/quirks.h> |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 12 | #include <linux/usb/hcd.h> |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 13 | #include "usb.h" |
| 14 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 15 | struct quirk_entry { |
| 16 | u16 vid; |
| 17 | u16 pid; |
| 18 | u32 flags; |
| 19 | }; |
| 20 | |
| 21 | static DEFINE_MUTEX(quirk_mutex); |
| 22 | |
| 23 | static struct quirk_entry *quirk_list; |
| 24 | static unsigned int quirk_count; |
| 25 | |
| 26 | static char quirks_param[128]; |
| 27 | |
| 28 | static int quirks_param_set(const char *val, const struct kernel_param *kp) |
| 29 | { |
| 30 | char *p, *field; |
| 31 | u16 vid, pid; |
| 32 | u32 flags; |
| 33 | size_t i; |
Kai-Heng Feng | a030501 | 2018-03-24 03:26:35 +0800 | [diff] [blame] | 34 | int err; |
| 35 | |
| 36 | err = param_set_copystring(val, kp); |
| 37 | if (err) |
| 38 | return err; |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 39 | |
| 40 | mutex_lock(&quirk_mutex); |
| 41 | |
Kai-Heng Feng | a030501 | 2018-03-24 03:26:35 +0800 | [diff] [blame] | 42 | if (!*val) { |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 43 | quirk_count = 0; |
| 44 | kfree(quirk_list); |
| 45 | quirk_list = NULL; |
| 46 | goto unlock; |
| 47 | } |
| 48 | |
| 49 | for (quirk_count = 1, i = 0; val[i]; i++) |
| 50 | if (val[i] == ',') |
| 51 | quirk_count++; |
| 52 | |
| 53 | if (quirk_list) { |
| 54 | kfree(quirk_list); |
| 55 | quirk_list = NULL; |
| 56 | } |
| 57 | |
| 58 | quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry), |
| 59 | GFP_KERNEL); |
| 60 | if (!quirk_list) { |
Harry Pan | 16c4cb1 | 2018-09-14 16:58:16 +0800 | [diff] [blame] | 61 | quirk_count = 0; |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 62 | mutex_unlock(&quirk_mutex); |
| 63 | return -ENOMEM; |
| 64 | } |
| 65 | |
| 66 | for (i = 0, p = (char *)val; p && *p;) { |
| 67 | /* Each entry consists of VID:PID:flags */ |
| 68 | field = strsep(&p, ":"); |
| 69 | if (!field) |
| 70 | break; |
| 71 | |
| 72 | if (kstrtou16(field, 16, &vid)) |
| 73 | break; |
| 74 | |
| 75 | field = strsep(&p, ":"); |
| 76 | if (!field) |
| 77 | break; |
| 78 | |
| 79 | if (kstrtou16(field, 16, &pid)) |
| 80 | break; |
| 81 | |
| 82 | field = strsep(&p, ","); |
| 83 | if (!field || !*field) |
| 84 | break; |
| 85 | |
| 86 | /* Collect the flags */ |
| 87 | for (flags = 0; *field; field++) { |
| 88 | switch (*field) { |
| 89 | case 'a': |
| 90 | flags |= USB_QUIRK_STRING_FETCH_255; |
| 91 | break; |
| 92 | case 'b': |
| 93 | flags |= USB_QUIRK_RESET_RESUME; |
| 94 | break; |
| 95 | case 'c': |
| 96 | flags |= USB_QUIRK_NO_SET_INTF; |
| 97 | break; |
| 98 | case 'd': |
| 99 | flags |= USB_QUIRK_CONFIG_INTF_STRINGS; |
| 100 | break; |
| 101 | case 'e': |
| 102 | flags |= USB_QUIRK_RESET; |
| 103 | break; |
| 104 | case 'f': |
| 105 | flags |= USB_QUIRK_HONOR_BNUMINTERFACES; |
| 106 | break; |
| 107 | case 'g': |
| 108 | flags |= USB_QUIRK_DELAY_INIT; |
| 109 | break; |
| 110 | case 'h': |
| 111 | flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL; |
| 112 | break; |
| 113 | case 'i': |
| 114 | flags |= USB_QUIRK_DEVICE_QUALIFIER; |
| 115 | break; |
| 116 | case 'j': |
| 117 | flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP; |
| 118 | break; |
| 119 | case 'k': |
| 120 | flags |= USB_QUIRK_NO_LPM; |
| 121 | break; |
| 122 | case 'l': |
| 123 | flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL; |
| 124 | break; |
| 125 | case 'm': |
| 126 | flags |= USB_QUIRK_DISCONNECT_SUSPEND; |
| 127 | break; |
Kai-Heng Feng | 4d8d5a3 | 2018-03-24 03:26:36 +0800 | [diff] [blame] | 128 | case 'n': |
| 129 | flags |= USB_QUIRK_DELAY_CTRL_MSG; |
| 130 | break; |
Kai-Heng Feng | 781f076 | 2018-10-19 16:14:50 +0800 | [diff] [blame] | 131 | case 'o': |
| 132 | flags |= USB_QUIRK_HUB_SLOW_RESET; |
| 133 | break; |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 134 | /* Ignore unrecognized flag characters */ |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | quirk_list[i++] = (struct quirk_entry) |
| 139 | { .vid = vid, .pid = pid, .flags = flags }; |
| 140 | } |
| 141 | |
| 142 | if (i < quirk_count) |
| 143 | quirk_count = i; |
| 144 | |
| 145 | unlock: |
| 146 | mutex_unlock(&quirk_mutex); |
| 147 | |
Kai-Heng Feng | a030501 | 2018-03-24 03:26:35 +0800 | [diff] [blame] | 148 | return 0; |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | static const struct kernel_param_ops quirks_param_ops = { |
| 152 | .set = quirks_param_set, |
| 153 | .get = param_get_string, |
| 154 | }; |
| 155 | |
| 156 | static struct kparam_string quirks_param_string = { |
| 157 | .maxlen = sizeof(quirks_param), |
| 158 | .string = quirks_param, |
| 159 | }; |
| 160 | |
Harry Pan | 16c4cb1 | 2018-09-14 16:58:16 +0800 | [diff] [blame] | 161 | device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644); |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 162 | MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks"); |
| 163 | |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 164 | /* Lists of quirky USB devices, split in device quirks and interface quirks. |
| 165 | * Device quirks are applied at the very beginning of the enumeration process, |
| 166 | * right after reading the device descriptor. They can thus only match on device |
| 167 | * information. |
| 168 | * |
| 169 | * Interface quirks are applied after reading all the configuration descriptors. |
| 170 | * They can match on both device and interface information. |
| 171 | * |
| 172 | * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as |
| 173 | * interface quirks, as they only influence the enumeration process which is run |
| 174 | * before processing the interface quirks. |
| 175 | * |
| 176 | * Please keep the lists ordered by: |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 177 | * 1) Vendor ID |
| 178 | * 2) Product ID |
| 179 | * 3) Class ID |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 180 | */ |
| 181 | static const struct usb_device_id usb_quirk_list[] = { |
Oliver Neukum | ce05916 | 2007-09-04 16:11:41 +0200 | [diff] [blame] | 182 | /* CBM - Flash disk */ |
| 183 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, |
Alan Stern | 14f3546 | 2008-02-27 15:43:47 -0500 | [diff] [blame] | 184 | |
Maxence Duprès | 9b83a1c | 2018-08-08 23:56:33 +0000 | [diff] [blame] | 185 | /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */ |
| 186 | { USB_DEVICE(0x0218, 0x0201), .driver_info = |
| 187 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 188 | |
Lukáš Lalinský | d9b2997 | 2017-01-20 19:46:34 +0100 | [diff] [blame] | 189 | /* WORLDE easy key (easykey.25) MIDI controller */ |
| 190 | { USB_DEVICE(0x0218, 0x0401), .driver_info = |
| 191 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 192 | |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 193 | /* HP 5300/5370C scanner */ |
Alan Stern | 14f3546 | 2008-02-27 15:43:47 -0500 | [diff] [blame] | 194 | { USB_DEVICE(0x03f0, 0x0701), .driver_info = |
| 195 | USB_QUIRK_STRING_FETCH_255 }, |
Oliver Neukum | e6a20ff | 2007-08-28 10:34:22 +0200 | [diff] [blame] | 196 | |
Kamil Lulko | 3180dab | 2018-04-19 16:54:02 -0700 | [diff] [blame] | 197 | /* HP v222w 16GB Mini USB Drive */ |
| 198 | { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 199 | |
Oliver Neukum | b68a42b | 2008-02-04 16:34:11 +0100 | [diff] [blame] | 200 | /* Creative SB Audigy 2 NX */ |
| 201 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 202 | |
Hans de Goede | 81099f9 | 2016-05-19 17:12:19 +0200 | [diff] [blame] | 203 | /* USB3503 */ |
| 204 | { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 205 | |
Hans de Goede | 263e80b | 2014-11-24 11:22:38 +0100 | [diff] [blame] | 206 | /* Microsoft Wireless Laser Mouse 6000 Receiver */ |
| 207 | { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 208 | |
Andreas Fleig | bc009ec | 2012-12-05 16:17:49 +0100 | [diff] [blame] | 209 | /* Microsoft LifeCam-VX700 v2.0 */ |
| 210 | { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 211 | |
Michael Niewöhner | effd14f6 | 2018-11-25 17:57:33 +0100 | [diff] [blame] | 212 | /* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */ |
| 213 | { USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 214 | |
Dmitry Fleytman Dmitry Fleytman | 7f038d2 | 2017-12-19 06:02:04 +0200 | [diff] [blame] | 215 | /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */ |
Julius Werner | e042936 | 2014-03-04 10:52:39 -0800 | [diff] [blame] | 216 | { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, |
Dmitry Fleytman | a1279ef | 2017-08-25 10:38:35 +0300 | [diff] [blame] | 217 | { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, |
Julius Werner | e042936 | 2014-03-04 10:52:39 -0800 | [diff] [blame] | 218 | { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, |
Dmitry Fleytman Dmitry Fleytman | 7f038d2 | 2017-12-19 06:02:04 +0200 | [diff] [blame] | 219 | { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, |
Julius Werner | e042936 | 2014-03-04 10:52:39 -0800 | [diff] [blame] | 220 | |
Vincent Palatin | 7219473 | 2015-10-01 14:10:22 -0700 | [diff] [blame] | 221 | /* Logitech ConferenceCam CC3000e */ |
| 222 | { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 223 | { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 224 | |
| 225 | /* Logitech PTZ Pro Camera */ |
| 226 | { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 227 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 228 | /* Logitech Quickcam Fusion */ |
| 229 | { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME }, |
Oliver Neukum | 2394d67e | 2011-09-13 08:42:21 +0200 | [diff] [blame] | 230 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 231 | /* Logitech Quickcam Orbit MP */ |
| 232 | { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME }, |
Oliver Neukum | 2394d67e | 2011-09-13 08:42:21 +0200 | [diff] [blame] | 233 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 234 | /* Logitech Quickcam Pro for Notebook */ |
| 235 | { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME }, |
Jon Levell | 5b253d8 | 2011-09-29 20:42:52 +0100 | [diff] [blame] | 236 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 237 | /* Logitech Quickcam Pro 5000 */ |
| 238 | { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME }, |
Oliver Neukum | 2394d67e | 2011-09-13 08:42:21 +0200 | [diff] [blame] | 239 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 240 | /* Logitech Quickcam OEM Dell Notebook */ |
| 241 | { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME }, |
Josh Boyer | 60c71ca | 2011-10-26 13:53:17 -0400 | [diff] [blame] | 242 | |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 243 | /* Logitech Quickcam OEM Cisco VT Camera II */ |
| 244 | { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME }, |
sordna | 0d145d7 | 2011-10-27 21:06:26 -0700 | [diff] [blame] | 245 | |
Phil Dibowitz | 93362a8 | 2010-07-22 00:05:01 +0200 | [diff] [blame] | 246 | /* Logitech Harmony 700-series */ |
| 247 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 248 | |
Alan Stern | 14f3546 | 2008-02-27 15:43:47 -0500 | [diff] [blame] | 249 | /* Philips PSC805 audio device */ |
| 250 | { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 251 | |
Yao-Wen Mao | 8484bf2 | 2015-08-31 14:24:09 +0800 | [diff] [blame] | 252 | /* Plantronic Audio 655 DSP */ |
| 253 | { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 254 | |
| 255 | /* Plantronic Audio 648 USB */ |
| 256 | { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 257 | |
Paul Mortier | 47f19c0 | 2010-07-09 13:18:50 +0100 | [diff] [blame] | 258 | /* Artisman Watchdog Dongle */ |
| 259 | { USB_DEVICE(0x04b4, 0x0526), .driver_info = |
| 260 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 261 | |
Alan Stern | 92fc7a8 | 2012-09-04 10:41:02 -0400 | [diff] [blame] | 262 | /* Microchip Joss Optical infrared touchboard device */ |
| 263 | { USB_DEVICE(0x04d8, 0x000c), .driver_info = |
| 264 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 265 | |
Oliver Neukum | 304ab4a | 2013-08-14 11:01:46 +0200 | [diff] [blame] | 266 | /* CarrolTouch 4000U */ |
| 267 | { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 268 | |
| 269 | /* CarrolTouch 4500U */ |
| 270 | { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 271 | |
Maciej Szmigiero | 72a012c | 2011-02-05 21:52:00 +0100 | [diff] [blame] | 272 | /* Samsung Android phone modem - ID conflict with SPH-I500 */ |
| 273 | { USB_DEVICE(0x04e8, 0x6601), .driver_info = |
| 274 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 275 | |
Johan Hovold | c68929f | 2014-08-25 17:51:27 +0200 | [diff] [blame] | 276 | /* Elan Touchscreen */ |
| 277 | { USB_DEVICE(0x04f3, 0x0089), .driver_info = |
| 278 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 279 | |
Adel Gadllah | 876af5d | 2014-10-09 09:29:29 +0200 | [diff] [blame] | 280 | { USB_DEVICE(0x04f3, 0x009b), .driver_info = |
| 281 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 282 | |
Oliver Neukum | a32c99e | 2014-11-17 17:11:42 +0100 | [diff] [blame] | 283 | { USB_DEVICE(0x04f3, 0x010c), .driver_info = |
| 284 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 285 | |
Logan Gunthorpe | dc703ec | 2015-05-09 11:09:11 -0600 | [diff] [blame] | 286 | { USB_DEVICE(0x04f3, 0x0125), .driver_info = |
| 287 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 288 | |
Adel Gadllah | d749947 | 2014-10-09 09:29:30 +0200 | [diff] [blame] | 289 | { USB_DEVICE(0x04f3, 0x016f), .driver_info = |
| 290 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 291 | |
Joseph Salisbury | 25b1f9a | 2016-07-06 21:18:51 -0400 | [diff] [blame] | 292 | { USB_DEVICE(0x04f3, 0x0381), .driver_info = |
| 293 | USB_QUIRK_NO_LPM }, |
| 294 | |
Adrien Vergé | df36c5b | 2015-11-24 16:02:04 +0100 | [diff] [blame] | 295 | { USB_DEVICE(0x04f3, 0x21b8), .driver_info = |
| 296 | USB_QUIRK_DEVICE_QUALIFIER }, |
| 297 | |
Oliver Neukum | b68a42b | 2008-02-04 16:34:11 +0100 | [diff] [blame] | 298 | /* Roland SC-8820 */ |
| 299 | { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 300 | |
| 301 | /* Edirol SD-20 */ |
| 302 | { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 303 | |
Oliver Neukum | bac6b03 | 2013-04-30 10:18:04 +0200 | [diff] [blame] | 304 | /* Alcor Micro Corp. Hub */ |
| 305 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 306 | |
Oliver Neukum | 90d95ef | 2008-06-17 11:56:55 -0400 | [diff] [blame] | 307 | /* appletouch */ |
| 308 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 309 | |
Kai-Heng Feng | e43a12f | 2017-11-14 01:31:15 -0500 | [diff] [blame] | 310 | /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ |
| 311 | { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, |
| 312 | |
Oliver Neukum | b9096d9 | 2017-12-12 16:11:30 +0100 | [diff] [blame] | 313 | /* ELSA MicroLink 56K */ |
| 314 | { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 315 | |
Kai-Heng Feng | 7496cfe | 2017-08-08 17:51:27 +0800 | [diff] [blame] | 316 | /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ |
| 317 | { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM }, |
| 318 | |
René Rebe | 598eff6 | 2008-05-27 09:05:46 +0200 | [diff] [blame] | 319 | /* Avision AV600U */ |
| 320 | { USB_DEVICE(0x0638, 0x0a13), .driver_info = |
| 321 | USB_QUIRK_STRING_FETCH_255 }, |
| 322 | |
Alan Stern | 1662e3a | 2009-03-18 14:28:53 -0400 | [diff] [blame] | 323 | /* Saitek Cyborg Gold Joystick */ |
| 324 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = |
| 325 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 326 | |
Oliver Neukum | 35284b3 | 2012-01-03 09:58:54 +0100 | [diff] [blame] | 327 | /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */ |
Oliver Neukum | 2394d67e | 2011-09-13 08:42:21 +0200 | [diff] [blame] | 328 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 329 | |
Oliver Neukum | 35284b3 | 2012-01-03 09:58:54 +0100 | [diff] [blame] | 330 | /* Guillemot Webcam Hercules Dualpix Exchange*/ |
| 331 | { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 332 | |
Steffen Müller | 166cb70 | 2012-04-30 13:05:34 +0200 | [diff] [blame] | 333 | /* Midiman M-Audio Keystation 88es */ |
| 334 | { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 335 | |
Harry Pan | 2f2dde6 | 2018-11-29 00:40:41 +0800 | [diff] [blame] | 336 | /* SanDisk Ultra Fit and Ultra Flair */ |
| 337 | { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM }, |
| 338 | { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, |
| 339 | |
Lamarque Vieira Souza | 8683369 | 2007-09-04 12:15:08 -0300 | [diff] [blame] | 340 | /* M-Systems Flash Disk Pioneers */ |
| 341 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 342 | |
Samuel Thibault | 3243367 | 2017-03-13 20:50:08 +0100 | [diff] [blame] | 343 | /* Baum Vario Ultra */ |
| 344 | { USB_DEVICE(0x0904, 0x6101), .driver_info = |
| 345 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, |
| 346 | { USB_DEVICE(0x0904, 0x6102), .driver_info = |
| 347 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, |
| 348 | { USB_DEVICE(0x0904, 0x6103), .driver_info = |
| 349 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, |
| 350 | |
Alan Stern | 3c18e30 | 2011-02-17 10:26:38 -0500 | [diff] [blame] | 351 | /* Keytouch QWERTY Panel keyboard */ |
| 352 | { USB_DEVICE(0x0926, 0x3333), .driver_info = |
| 353 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 354 | |
Alan Stern | 392e1d9 | 2008-03-11 10:20:12 -0400 | [diff] [blame] | 355 | /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */ |
| 356 | { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF }, |
| 357 | |
Oliver Neukum | 63ab71d | 2010-07-14 18:26:22 +0200 | [diff] [blame] | 358 | /* Broadcom BCM92035DGROM BT dongle */ |
| 359 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 360 | |
Oliver Neukum | 4294bca | 2013-10-14 16:22:40 +0200 | [diff] [blame] | 361 | /* MAYA44USB sound device */ |
| 362 | { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 363 | |
Hans de Goede | 81099f9 | 2016-05-19 17:12:19 +0200 | [diff] [blame] | 364 | /* ASUS Base Station(T100) */ |
| 365 | { USB_DEVICE(0x0b05, 0x17e0), .driver_info = |
| 366 | USB_QUIRK_IGNORE_REMOTE_WAKEUP }, |
| 367 | |
Alan Stern | 14f3546 | 2008-02-27 15:43:47 -0500 | [diff] [blame] | 368 | /* Action Semiconductor flash disk */ |
| 369 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = |
| 370 | USB_QUIRK_STRING_FETCH_255 }, |
Alan Stern | 6bc6cff | 2007-05-04 11:53:03 -0400 | [diff] [blame] | 371 | |
Daniel Drake | 8dd8d2c | 2017-10-18 15:15:01 +0800 | [diff] [blame] | 372 | /* Huawei 4G LTE module */ |
| 373 | { USB_DEVICE(0x12d1, 0x15bb), .driver_info = |
| 374 | USB_QUIRK_DISCONNECT_SUSPEND }, |
| 375 | { USB_DEVICE(0x12d1, 0x15c3), .driver_info = |
| 376 | USB_QUIRK_DISCONNECT_SUSPEND }, |
| 377 | |
Lamarque Vieira Souza | 8683369 | 2007-09-04 12:15:08 -0300 | [diff] [blame] | 378 | /* SKYMEDI USB_DRIVE */ |
| 379 | { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 380 | |
James P Michels III | cd83ce9 | 2014-07-27 13:28:04 -0400 | [diff] [blame] | 381 | /* Razer - Razer Blade Keyboard */ |
| 382 | { USB_DEVICE(0x1532, 0x0116), .driver_info = |
| 383 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, |
| 384 | |
Hans de Goede | 317149c | 2010-03-29 12:03:17 +0200 | [diff] [blame] | 385 | /* BUILDWIN Photo Frame */ |
| 386 | { USB_DEVICE(0x1908, 0x1315), .driver_info = |
| 387 | USB_QUIRK_HONOR_BNUMINTERFACES }, |
| 388 | |
Macpaul Lin | e5dff0e | 2015-01-23 14:39:02 +0800 | [diff] [blame] | 389 | /* Protocol and OTG Electrical Test Device */ |
| 390 | { USB_DEVICE(0x1a0a, 0x0200), .driver_info = |
| 391 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, |
| 392 | |
Kai-Heng Feng | 781f076 | 2018-10-19 16:14:50 +0800 | [diff] [blame] | 393 | /* Terminus Technology Inc. Hub */ |
| 394 | { USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET }, |
| 395 | |
Jack Stocker | 7a1646d | 2018-02-15 18:24:10 +0000 | [diff] [blame] | 396 | /* Corsair K70 RGB */ |
Jack Stocker | 3483254 | 2019-01-03 21:56:53 +0000 | [diff] [blame] | 397 | { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT | |
| 398 | USB_QUIRK_DELAY_CTRL_MSG }, |
Jack Stocker | 7a1646d | 2018-02-15 18:24:10 +0000 | [diff] [blame] | 399 | |
Nico Sneck | bba57ed | 2018-07-02 19:26:07 +0300 | [diff] [blame] | 400 | /* Corsair Strafe */ |
| 401 | { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT | |
| 402 | USB_QUIRK_DELAY_CTRL_MSG }, |
| 403 | |
Kai-Heng Feng | de3af5b | 2017-08-16 10:53:20 +0800 | [diff] [blame] | 404 | /* Corsair Strafe RGB */ |
Danilo Krummrich | cb88a05 | 2018-03-06 09:38:49 +0100 | [diff] [blame] | 405 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | |
| 406 | USB_QUIRK_DELAY_CTRL_MSG }, |
Kai-Heng Feng | de3af5b | 2017-08-16 10:53:20 +0800 | [diff] [blame] | 407 | |
Emmanuel Pescosta | a771125 | 2018-10-26 14:48:09 +0200 | [diff] [blame] | 408 | /* Corsair K70 LUX RGB */ |
| 409 | { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 410 | |
Bernhard Rosenkraenzer | a0fea60 | 2017-11-03 16:46:02 +0100 | [diff] [blame] | 411 | /* Corsair K70 LUX */ |
| 412 | { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 413 | |
Felipe Balbi | 2811501 | 2017-10-03 11:16:43 +0300 | [diff] [blame] | 414 | /* MIDI keyboard WORLDE MINI */ |
| 415 | { USB_DEVICE(0x1c75, 0x0204), .driver_info = |
| 416 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 417 | |
Hans de Goede | 32cb0b37 | 2016-05-19 17:12:20 +0200 | [diff] [blame] | 418 | /* Acer C120 LED Projector */ |
| 419 | { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, |
| 420 | |
Alan Stern | ad87e03 | 2015-12-10 15:27:21 -0500 | [diff] [blame] | 421 | /* Blackmagic Design Intensity Shuttle */ |
| 422 | { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM }, |
| 423 | |
| 424 | /* Blackmagic Design UltraStudio SDI */ |
| 425 | { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, |
| 426 | |
Devin Heitmueller | 6836796 | 2017-06-27 13:08:51 -0400 | [diff] [blame] | 427 | /* Hauppauge HVR-950q */ |
| 428 | { USB_DEVICE(0x2040, 0x7200), .driver_info = |
| 429 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 430 | |
Kai-Heng Feng | deefd24 | 2018-10-26 13:33:15 +0800 | [diff] [blame] | 431 | /* Raydium Touchscreen */ |
| 432 | { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM }, |
| 433 | |
| 434 | { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, |
| 435 | |
Tim Anderson | f45681f | 2018-08-09 14:55:34 -0700 | [diff] [blame] | 436 | /* DJI CineSSD */ |
| 437 | { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, |
| 438 | |
Hans de Goede | 81099f9 | 2016-05-19 17:12:19 +0200 | [diff] [blame] | 439 | /* INTEL VALUE SSD */ |
| 440 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 441 | |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 442 | { } /* terminating entry must be last */ |
| 443 | }; |
| 444 | |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 445 | static const struct usb_device_id usb_interface_quirk_list[] = { |
Laurent Pinchart | e387ef5 | 2012-07-19 12:39:14 +0200 | [diff] [blame] | 446 | /* Logitech UVC Cameras */ |
| 447 | { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0), |
| 448 | .driver_info = USB_QUIRK_RESET_RESUME }, |
| 449 | |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 450 | { } /* terminating entry must be last */ |
| 451 | }; |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 452 | |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 453 | static const struct usb_device_id usb_amd_resume_quirk_list[] = { |
| 454 | /* Lenovo Mouse with Pixart controller */ |
| 455 | { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 456 | |
| 457 | /* Pixart Mouse */ |
| 458 | { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 459 | { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 460 | { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, |
Sandeep Singh | e788787 | 2017-08-04 16:35:56 +0530 | [diff] [blame] | 461 | { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME }, |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 462 | |
| 463 | /* Logitech Optical Mouse M90/M100 */ |
| 464 | { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 465 | |
| 466 | { } /* terminating entry must be last */ |
| 467 | }; |
| 468 | |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 469 | static bool usb_match_any_interface(struct usb_device *udev, |
| 470 | const struct usb_device_id *id) |
| 471 | { |
| 472 | unsigned int i; |
| 473 | |
| 474 | for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) { |
| 475 | struct usb_host_config *cfg = &udev->config[i]; |
| 476 | unsigned int j; |
| 477 | |
| 478 | for (j = 0; j < cfg->desc.bNumInterfaces; ++j) { |
| 479 | struct usb_interface_cache *cache; |
| 480 | struct usb_host_interface *intf; |
| 481 | |
| 482 | cache = cfg->intf_cache[j]; |
| 483 | if (cache->num_altsetting == 0) |
| 484 | continue; |
| 485 | |
| 486 | intf = &cache->altsetting[0]; |
| 487 | if (usb_match_one_id_intf(udev, intf, id)) |
| 488 | return true; |
| 489 | } |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 490 | } |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 491 | |
| 492 | return false; |
| 493 | } |
| 494 | |
Fengguang Wu | 00d5f28 | 2013-09-26 11:56:50 -0700 | [diff] [blame] | 495 | static int usb_amd_resume_quirk(struct usb_device *udev) |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 496 | { |
| 497 | struct usb_hcd *hcd; |
| 498 | |
| 499 | hcd = bus_to_hcd(udev->bus); |
| 500 | /* The device should be attached directly to root hub */ |
| 501 | if (udev->level == 1 && hcd->amd_resume_bug == 1) |
| 502 | return 1; |
| 503 | |
| 504 | return 0; |
| 505 | } |
| 506 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 507 | static u32 usb_detect_static_quirks(struct usb_device *udev, |
| 508 | const struct usb_device_id *id) |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 509 | { |
| 510 | u32 quirks = 0; |
| 511 | |
| 512 | for (; id->match_flags; id++) { |
| 513 | if (!usb_match_device(udev, id)) |
| 514 | continue; |
| 515 | |
| 516 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) && |
| 517 | !usb_match_any_interface(udev, id)) |
| 518 | continue; |
| 519 | |
| 520 | quirks |= (u32)(id->driver_info); |
| 521 | } |
| 522 | |
| 523 | return quirks; |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 524 | } |
| 525 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 526 | static u32 usb_detect_dynamic_quirks(struct usb_device *udev) |
| 527 | { |
| 528 | u16 vid = le16_to_cpu(udev->descriptor.idVendor); |
| 529 | u16 pid = le16_to_cpu(udev->descriptor.idProduct); |
| 530 | int i, flags = 0; |
| 531 | |
| 532 | mutex_lock(&quirk_mutex); |
| 533 | |
| 534 | for (i = 0; i < quirk_count; i++) { |
| 535 | if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) { |
| 536 | flags = quirk_list[i].flags; |
| 537 | break; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | mutex_unlock(&quirk_mutex); |
| 542 | |
| 543 | return flags; |
| 544 | } |
| 545 | |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 546 | /* |
| 547 | * Detect any quirks the device has, and do any housekeeping for it if needed. |
| 548 | */ |
| 549 | void usb_detect_quirks(struct usb_device *udev) |
| 550 | { |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 551 | udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list); |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 552 | |
| 553 | /* |
| 554 | * Pixart-based mice would trigger remote wakeup issue on AMD |
| 555 | * Yangtze chipset, so set them as RESET_RESUME flag. |
| 556 | */ |
| 557 | if (usb_amd_resume_quirk(udev)) |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 558 | udev->quirks |= usb_detect_static_quirks(udev, |
Huang Rui | 7868943 | 2013-09-16 23:47:28 +0800 | [diff] [blame] | 559 | usb_amd_resume_quirk_list); |
| 560 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 561 | udev->quirks ^= usb_detect_dynamic_quirks(udev); |
| 562 | |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 563 | if (udev->quirks) |
| 564 | dev_dbg(&udev->dev, "USB quirks for this device: %x\n", |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 565 | udev->quirks); |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 566 | |
Julius Werner | 4f48203 | 2013-03-13 15:57:31 -0700 | [diff] [blame] | 567 | #ifdef CONFIG_USB_DEFAULT_PERSIST |
| 568 | if (!(udev->quirks & USB_QUIRK_RESET)) |
| 569 | udev->persist_enabled = 1; |
| 570 | #else |
Alan Stern | feccc30 | 2008-03-03 15:15:59 -0500 | [diff] [blame] | 571 | /* Hubs are automatically enabled for USB-PERSIST */ |
| 572 | if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) |
| 573 | udev->persist_enabled = 1; |
Julius Werner | 4f48203 | 2013-03-13 15:57:31 -0700 | [diff] [blame] | 574 | #endif /* CONFIG_USB_DEFAULT_PERSIST */ |
Oliver Neukum | 7ceec1f | 2007-01-26 14:26:21 +0100 | [diff] [blame] | 575 | } |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 576 | |
| 577 | void usb_detect_interface_quirks(struct usb_device *udev) |
| 578 | { |
| 579 | u32 quirks; |
| 580 | |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 581 | quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list); |
Laurent Pinchart | 80da2e0 | 2012-07-19 12:39:13 +0200 | [diff] [blame] | 582 | if (quirks == 0) |
| 583 | return; |
| 584 | |
| 585 | dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n", |
| 586 | quirks); |
| 587 | udev->quirks |= quirks; |
| 588 | } |
Kai-Heng Feng | 027bd6c | 2018-03-20 00:26:06 +0800 | [diff] [blame] | 589 | |
| 590 | void usb_release_quirk_list(void) |
| 591 | { |
| 592 | mutex_lock(&quirk_mutex); |
| 593 | kfree(quirk_list); |
| 594 | quirk_list = NULL; |
| 595 | mutex_unlock(&quirk_mutex); |
| 596 | } |