Linux Audio

Check our new training course

Loading...
v3.1
 
  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
 
 14#include <linux/usb.h>
 15#include <linux/usb/quirks.h>
 
 16#include "usb.h"
 17
 18/* List of quirky USB devices.  Please keep this list ordered by:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 19 * 	1) Vendor ID
 20 * 	2) Product ID
 21 * 	3) Class ID
 22 *
 23 * as we want specific devices to be overridden first, and only after that, any
 24 * class specific quirks.
 25 *
 26 * Right now the logic aborts if it finds a valid device in the table, we might
 27 * want to change that in the future if it turns out that a whole class of
 28 * devices is broken...
 29 */
 30static const struct usb_device_id usb_quirk_list[] = {
 31	/* CBM - Flash disk */
 32	{ USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
 33
 
 
 
 
 
 
 
 
 34	/* HP 5300/5370C scanner */
 35	{ USB_DEVICE(0x03f0, 0x0701), .driver_info =
 36			USB_QUIRK_STRING_FETCH_255 },
 37
 
 
 
 38	/* Creative SB Audigy 2 NX */
 39	{ USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
 40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 41	/* Logitech Harmony 700-series */
 42	{ USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
 43
 44	/* Philips PSC805 audio device */
 45	{ USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
 46
 
 
 
 
 
 
 47	/* Artisman Watchdog Dongle */
 48	{ USB_DEVICE(0x04b4, 0x0526), .driver_info =
 49			USB_QUIRK_CONFIG_INTF_STRINGS },
 50
 
 
 
 
 
 
 
 
 
 
 51	/* Samsung Android phone modem - ID conflict with SPH-I500 */
 52	{ USB_DEVICE(0x04e8, 0x6601), .driver_info =
 53			USB_QUIRK_CONFIG_INTF_STRINGS },
 54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 55	/* Roland SC-8820 */
 56	{ USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
 57
 58	/* Edirol SD-20 */
 59	{ USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
 60
 
 
 
 61	/* appletouch */
 62	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 63
 
 
 
 
 
 
 
 
 
 64	/* Avision AV600U */
 65	{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
 66	  USB_QUIRK_STRING_FETCH_255 },
 67
 68	/* Saitek Cyborg Gold Joystick */
 69	{ USB_DEVICE(0x06a3, 0x0006), .driver_info =
 70			USB_QUIRK_CONFIG_INTF_STRINGS },
 71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 72	/* M-Systems Flash Disk Pioneers */
 73	{ USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
 74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 75	/* Keytouch QWERTY Panel keyboard */
 76	{ USB_DEVICE(0x0926, 0x3333), .driver_info =
 77			USB_QUIRK_CONFIG_INTF_STRINGS },
 78
 
 
 
 79	/* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
 80	{ USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
 81
 
 
 
 82	/* Broadcom BCM92035DGROM BT dongle */
 83	{ USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
 84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 85	/* Action Semiconductor flash disk */
 86	{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
 87			USB_QUIRK_STRING_FETCH_255 },
 88
 
 
 
 
 
 
 
 
 
 89	/* SKYMEDI USB_DRIVE */
 90	{ USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
 91
 
 
 
 
 
 
 
 
 
 
 
 92	/* BUILDWIN Photo Frame */
 93	{ USB_DEVICE(0x1908, 0x1315), .driver_info =
 94			USB_QUIRK_HONOR_BNUMINTERFACES },
 95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 96	/* INTEL VALUE SSD */
 97	{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
 98
 99	{ }  /* terminating entry must be last */
100};
101
102static const struct usb_device_id *find_id(struct usb_device *udev)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103{
104	const struct usb_device_id *id = usb_quirk_list;
 
105
106	for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||
107			id->driver_info; id++) {
108		if (usb_match_device(udev, id))
109			return id;
 
 
 
 
 
 
110	}
111	return NULL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112}
113
114/*
115 * Detect any quirks the device has, and do any housekeeping for it if needed.
116 */
117void usb_detect_quirks(struct usb_device *udev)
118{
119	const struct usb_device_id *id = usb_quirk_list;
 
 
 
 
 
 
 
 
 
 
120
121	id = find_id(udev);
122	if (id)
123		udev->quirks = (u32)(id->driver_info);
124	if (udev->quirks)
125		dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
126				udev->quirks);
127
128	/* For the present, all devices default to USB-PERSIST enabled */
129#if 0		/* was: #ifdef CONFIG_PM */
 
 
130	/* Hubs are automatically enabled for USB-PERSIST */
131	if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
132		udev->persist_enabled = 1;
 
 
133
134#else
135	/* In the absence of PM, we can safely enable USB-PERSIST
136	 * for all devices.  It will affect things like hub resets
137	 * and EMF-related port disables.
138	 */
139	if (!(udev->quirks & USB_QUIRK_RESET_MORPHS))
140		udev->persist_enabled = 1;
141#endif	/* CONFIG_PM */
 
 
 
 
 
 
 
 
 
 
 
142}
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0
  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>
 
 
 
 
 
 
  7 */
  8
  9#include <linux/moduleparam.h>
 10#include <linux/usb.h>
 11#include <linux/usb/quirks.h>
 12#include <linux/usb/hcd.h>
 13#include "usb.h"
 14
 15struct quirk_entry {
 16	u16 vid;
 17	u16 pid;
 18	u32 flags;
 19};
 20
 21static DEFINE_MUTEX(quirk_mutex);
 22
 23static struct quirk_entry *quirk_list;
 24static unsigned int quirk_count;
 25
 26static char quirks_param[128];
 27
 28static int quirks_param_set(const char *value, const struct kernel_param *kp)
 29{
 30	char *val, *p, *field;
 31	u16 vid, pid;
 32	u32 flags;
 33	size_t i;
 34	int err;
 35
 36	val = kstrdup(value, GFP_KERNEL);
 37	if (!val)
 38		return -ENOMEM;
 39
 40	err = param_set_copystring(val, kp);
 41	if (err) {
 42		kfree(val);
 43		return err;
 44	}
 45
 46	mutex_lock(&quirk_mutex);
 47
 48	if (!*val) {
 49		quirk_count = 0;
 50		kfree(quirk_list);
 51		quirk_list = NULL;
 52		goto unlock;
 53	}
 54
 55	for (quirk_count = 1, i = 0; val[i]; i++)
 56		if (val[i] == ',')
 57			quirk_count++;
 58
 59	if (quirk_list) {
 60		kfree(quirk_list);
 61		quirk_list = NULL;
 62	}
 63
 64	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
 65			     GFP_KERNEL);
 66	if (!quirk_list) {
 67		quirk_count = 0;
 68		mutex_unlock(&quirk_mutex);
 69		kfree(val);
 70		return -ENOMEM;
 71	}
 72
 73	for (i = 0, p = val; p && *p;) {
 74		/* Each entry consists of VID:PID:flags */
 75		field = strsep(&p, ":");
 76		if (!field)
 77			break;
 78
 79		if (kstrtou16(field, 16, &vid))
 80			break;
 81
 82		field = strsep(&p, ":");
 83		if (!field)
 84			break;
 85
 86		if (kstrtou16(field, 16, &pid))
 87			break;
 88
 89		field = strsep(&p, ",");
 90		if (!field || !*field)
 91			break;
 92
 93		/* Collect the flags */
 94		for (flags = 0; *field; field++) {
 95			switch (*field) {
 96			case 'a':
 97				flags |= USB_QUIRK_STRING_FETCH_255;
 98				break;
 99			case 'b':
100				flags |= USB_QUIRK_RESET_RESUME;
101				break;
102			case 'c':
103				flags |= USB_QUIRK_NO_SET_INTF;
104				break;
105			case 'd':
106				flags |= USB_QUIRK_CONFIG_INTF_STRINGS;
107				break;
108			case 'e':
109				flags |= USB_QUIRK_RESET;
110				break;
111			case 'f':
112				flags |= USB_QUIRK_HONOR_BNUMINTERFACES;
113				break;
114			case 'g':
115				flags |= USB_QUIRK_DELAY_INIT;
116				break;
117			case 'h':
118				flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL;
119				break;
120			case 'i':
121				flags |= USB_QUIRK_DEVICE_QUALIFIER;
122				break;
123			case 'j':
124				flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP;
125				break;
126			case 'k':
127				flags |= USB_QUIRK_NO_LPM;
128				break;
129			case 'l':
130				flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL;
131				break;
132			case 'm':
133				flags |= USB_QUIRK_DISCONNECT_SUSPEND;
134				break;
135			case 'n':
136				flags |= USB_QUIRK_DELAY_CTRL_MSG;
137				break;
138			case 'o':
139				flags |= USB_QUIRK_HUB_SLOW_RESET;
140				break;
141			/* Ignore unrecognized flag characters */
142			}
143		}
144
145		quirk_list[i++] = (struct quirk_entry)
146			{ .vid = vid, .pid = pid, .flags = flags };
147	}
148
149	if (i < quirk_count)
150		quirk_count = i;
151
152unlock:
153	mutex_unlock(&quirk_mutex);
154	kfree(val);
155
156	return 0;
157}
158
159static const struct kernel_param_ops quirks_param_ops = {
160	.set = quirks_param_set,
161	.get = param_get_string,
162};
163
164static struct kparam_string quirks_param_string = {
165	.maxlen = sizeof(quirks_param),
166	.string = quirks_param,
167};
168
169device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
170MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
171
172/* Lists of quirky USB devices, split in device quirks and interface quirks.
173 * Device quirks are applied at the very beginning of the enumeration process,
174 * right after reading the device descriptor. They can thus only match on device
175 * information.
176 *
177 * Interface quirks are applied after reading all the configuration descriptors.
178 * They can match on both device and interface information.
179 *
180 * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
181 * interface quirks, as they only influence the enumeration process which is run
182 * before processing the interface quirks.
183 *
184 * Please keep the lists ordered by:
185 * 	1) Vendor ID
186 * 	2) Product ID
187 * 	3) Class ID
 
 
 
 
 
 
 
188 */
189static const struct usb_device_id usb_quirk_list[] = {
190	/* CBM - Flash disk */
191	{ USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
192
193	/* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
194	{ USB_DEVICE(0x0218, 0x0201), .driver_info =
195			USB_QUIRK_CONFIG_INTF_STRINGS },
196
197	/* WORLDE easy key (easykey.25) MIDI controller  */
198	{ USB_DEVICE(0x0218, 0x0401), .driver_info =
199			USB_QUIRK_CONFIG_INTF_STRINGS },
200
201	/* HP 5300/5370C scanner */
202	{ USB_DEVICE(0x03f0, 0x0701), .driver_info =
203			USB_QUIRK_STRING_FETCH_255 },
204
205	/* HP v222w 16GB Mini USB Drive */
206	{ USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
207
208	/* Creative SB Audigy 2 NX */
209	{ USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
210
211	/* USB3503 */
212	{ USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
213
214	/* Microsoft Wireless Laser Mouse 6000 Receiver */
215	{ USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
216
217	/* Microsoft LifeCam-VX700 v2.0 */
218	{ USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
219
220	/* Microsoft Surface Dock Ethernet (RTL8153 GigE) */
221	{ USB_DEVICE(0x045e, 0x07c6), .driver_info = USB_QUIRK_NO_LPM },
222
223	/* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */
224	{ USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME },
225
226	/* Logitech HD Webcam C270 */
227	{ USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME },
228
229	/* Logitech HD Pro Webcams C920, C920-C, C922, C925e and C930e */
230	{ USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
231	{ USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
232	{ USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
233	{ USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
234	{ USB_DEVICE(0x046d, 0x085c), .driver_info = USB_QUIRK_DELAY_INIT },
235
236	/* Logitech ConferenceCam CC3000e */
237	{ USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
238	{ USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
239
240	/* Logitech PTZ Pro Camera */
241	{ USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
242
243	/* Logitech Screen Share */
244	{ USB_DEVICE(0x046d, 0x086c), .driver_info = USB_QUIRK_NO_LPM },
245
246	/* Logitech Quickcam Fusion */
247	{ USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
248
249	/* Logitech Quickcam Orbit MP */
250	{ USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
251
252	/* Logitech Quickcam Pro for Notebook */
253	{ USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
254
255	/* Logitech Quickcam Pro 5000 */
256	{ USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
257
258	/* Logitech Quickcam OEM Dell Notebook */
259	{ USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
260
261	/* Logitech Quickcam OEM Cisco VT Camera II */
262	{ USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
263
264	/* Logitech Harmony 700-series */
265	{ USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
266
267	/* Philips PSC805 audio device */
268	{ USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
269
270	/* Plantronic Audio 655 DSP */
271	{ USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
272
273	/* Plantronic Audio 648 USB */
274	{ USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
275
276	/* Artisman Watchdog Dongle */
277	{ USB_DEVICE(0x04b4, 0x0526), .driver_info =
278			USB_QUIRK_CONFIG_INTF_STRINGS },
279
280	/* Microchip Joss Optical infrared touchboard device */
281	{ USB_DEVICE(0x04d8, 0x000c), .driver_info =
282			USB_QUIRK_CONFIG_INTF_STRINGS },
283
284	/* CarrolTouch 4000U */
285	{ USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
286
287	/* CarrolTouch 4500U */
288	{ USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
289
290	/* Samsung Android phone modem - ID conflict with SPH-I500 */
291	{ USB_DEVICE(0x04e8, 0x6601), .driver_info =
292			USB_QUIRK_CONFIG_INTF_STRINGS },
293
294	/* Elan Touchscreen */
295	{ USB_DEVICE(0x04f3, 0x0089), .driver_info =
296			USB_QUIRK_DEVICE_QUALIFIER },
297
298	{ USB_DEVICE(0x04f3, 0x009b), .driver_info =
299			USB_QUIRK_DEVICE_QUALIFIER },
300
301	{ USB_DEVICE(0x04f3, 0x010c), .driver_info =
302			USB_QUIRK_DEVICE_QUALIFIER },
303
304	{ USB_DEVICE(0x04f3, 0x0125), .driver_info =
305			USB_QUIRK_DEVICE_QUALIFIER },
306
307	{ USB_DEVICE(0x04f3, 0x016f), .driver_info =
308			USB_QUIRK_DEVICE_QUALIFIER },
309
310	{ USB_DEVICE(0x04f3, 0x0381), .driver_info =
311			USB_QUIRK_NO_LPM },
312
313	{ USB_DEVICE(0x04f3, 0x21b8), .driver_info =
314			USB_QUIRK_DEVICE_QUALIFIER },
315
316	/* Roland SC-8820 */
317	{ USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
318
319	/* Edirol SD-20 */
320	{ USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
321
322	/* Alcor Micro Corp. Hub */
323	{ USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
324
325	/* appletouch */
326	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
327
328	/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
329	{ USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
330
331	/* ELSA MicroLink 56K */
332	{ USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
333
334	/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
335	{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
336
337	/* Avision AV600U */
338	{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
339	  USB_QUIRK_STRING_FETCH_255 },
340
341	/* Saitek Cyborg Gold Joystick */
342	{ USB_DEVICE(0x06a3, 0x0006), .driver_info =
343			USB_QUIRK_CONFIG_INTF_STRINGS },
344
345	/* Agfa SNAPSCAN 1212U */
346	{ USB_DEVICE(0x06bd, 0x0001), .driver_info = USB_QUIRK_RESET_RESUME },
347
348	/* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
349	{ USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
350
351	/* Guillemot Webcam Hercules Dualpix Exchange*/
352	{ USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
353
354	/* Guillemot Hercules DJ Console audio card (BZ 208357) */
355	{ USB_DEVICE(0x06f8, 0xb000), .driver_info =
356			USB_QUIRK_ENDPOINT_IGNORE },
357
358	/* Midiman M-Audio Keystation 88es */
359	{ USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
360
361	/* SanDisk Ultra Fit and Ultra Flair */
362	{ USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM },
363	{ USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM },
364
365	/* M-Systems Flash Disk Pioneers */
366	{ USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
367
368	/* Baum Vario Ultra */
369	{ USB_DEVICE(0x0904, 0x6101), .driver_info =
370			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
371	{ USB_DEVICE(0x0904, 0x6102), .driver_info =
372			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
373	{ USB_DEVICE(0x0904, 0x6103), .driver_info =
374			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
375
376	/* Sound Devices USBPre2 */
377	{ USB_DEVICE(0x0926, 0x0202), .driver_info =
378			USB_QUIRK_ENDPOINT_IGNORE },
379
380	/* Sound Devices MixPre-D */
381	{ USB_DEVICE(0x0926, 0x0208), .driver_info =
382			USB_QUIRK_ENDPOINT_IGNORE },
383
384	/* Keytouch QWERTY Panel keyboard */
385	{ USB_DEVICE(0x0926, 0x3333), .driver_info =
386			USB_QUIRK_CONFIG_INTF_STRINGS },
387
388	/* Kingston DataTraveler 3.0 */
389	{ USB_DEVICE(0x0951, 0x1666), .driver_info = USB_QUIRK_NO_LPM },
390
391	/* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
392	{ USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
393
394	/* ELMO L-12F document camera */
395	{ USB_DEVICE(0x09a1, 0x0028), .driver_info = USB_QUIRK_DELAY_CTRL_MSG },
396
397	/* Broadcom BCM92035DGROM BT dongle */
398	{ USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
399
400	/* MAYA44USB sound device */
401	{ USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
402
403	/* ASUS Base Station(T100) */
404	{ USB_DEVICE(0x0b05, 0x17e0), .driver_info =
405			USB_QUIRK_IGNORE_REMOTE_WAKEUP },
406
407	/* Realtek hub in Dell WD19 (Type-C) */
408	{ USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM },
409
410	/* Generic RTL8153 based ethernet adapters */
411	{ USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM },
412
413	/* SONiX USB DEVICE Touchpad */
414	{ USB_DEVICE(0x0c45, 0x7056), .driver_info =
415			USB_QUIRK_IGNORE_REMOTE_WAKEUP },
416
417	/* Action Semiconductor flash disk */
418	{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
419			USB_QUIRK_STRING_FETCH_255 },
420
421	/* novation SoundControl XL */
422	{ USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME },
423
424	/* Huawei 4G LTE module */
425	{ USB_DEVICE(0x12d1, 0x15bb), .driver_info =
426			USB_QUIRK_DISCONNECT_SUSPEND },
427	{ USB_DEVICE(0x12d1, 0x15c3), .driver_info =
428			USB_QUIRK_DISCONNECT_SUSPEND },
429
430	/* SKYMEDI USB_DRIVE */
431	{ USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
432
433	/* Razer - Razer Blade Keyboard */
434	{ USB_DEVICE(0x1532, 0x0116), .driver_info =
435			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
436
437	/* Lenovo ThinkCenter A630Z TI024Gen3 usb-audio */
438	{ USB_DEVICE(0x17ef, 0xa012), .driver_info =
439			USB_QUIRK_DISCONNECT_SUSPEND },
440
441	/* Lenovo ThinkPad USB-C Dock Gen2 Ethernet (RTL8153 GigE) */
442	{ USB_DEVICE(0x17ef, 0xa387), .driver_info = USB_QUIRK_NO_LPM },
443
444	/* BUILDWIN Photo Frame */
445	{ USB_DEVICE(0x1908, 0x1315), .driver_info =
446			USB_QUIRK_HONOR_BNUMINTERFACES },
447
448	/* Protocol and OTG Electrical Test Device */
449	{ USB_DEVICE(0x1a0a, 0x0200), .driver_info =
450			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
451
452	/* Terminus Technology Inc. Hub */
453	{ USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET },
454
455	/* Corsair K70 RGB */
456	{ USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT |
457	  USB_QUIRK_DELAY_CTRL_MSG },
458
459	/* Corsair Strafe */
460	{ USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
461	  USB_QUIRK_DELAY_CTRL_MSG },
462
463	/* Corsair Strafe RGB */
464	{ USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
465	  USB_QUIRK_DELAY_CTRL_MSG },
466
467	/* Corsair K70 LUX RGB */
468	{ USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT },
469
470	/* Corsair K70 LUX */
471	{ USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
472
473	/* Corsair K70 RGB RAPDIFIRE */
474	{ USB_DEVICE(0x1b1c, 0x1b38), .driver_info = USB_QUIRK_DELAY_INIT |
475	  USB_QUIRK_DELAY_CTRL_MSG },
476
477	/* MIDI keyboard WORLDE MINI */
478	{ USB_DEVICE(0x1c75, 0x0204), .driver_info =
479			USB_QUIRK_CONFIG_INTF_STRINGS },
480
481	/* Acer C120 LED Projector */
482	{ USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
483
484	/* Blackmagic Design Intensity Shuttle */
485	{ USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
486
487	/* Blackmagic Design UltraStudio SDI */
488	{ USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
489
490	/* Hauppauge HVR-950q */
491	{ USB_DEVICE(0x2040, 0x7200), .driver_info =
492			USB_QUIRK_CONFIG_INTF_STRINGS },
493
494	/* Raydium Touchscreen */
495	{ USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
496
497	{ USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
498
499	{ USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
500
501	/* DJI CineSSD */
502	{ USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
503
504	/* INTEL VALUE SSD */
505	{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
506
507	{ }  /* terminating entry must be last */
508};
509
510static const struct usb_device_id usb_interface_quirk_list[] = {
511	/* Logitech UVC Cameras */
512	{ USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
513	  .driver_info = USB_QUIRK_RESET_RESUME },
514
515	{ }  /* terminating entry must be last */
516};
517
518static const struct usb_device_id usb_amd_resume_quirk_list[] = {
519	/* Lenovo Mouse with Pixart controller */
520	{ USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
521
522	/* Pixart Mouse */
523	{ USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
524	{ USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
525	{ USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
526	{ USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
527
528	/* Logitech Optical Mouse M90/M100 */
529	{ USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
530
531	{ }  /* terminating entry must be last */
532};
533
534/*
535 * Entries for endpoints that should be ignored when parsing configuration
536 * descriptors.
537 *
538 * Matched for devices with USB_QUIRK_ENDPOINT_IGNORE.
539 */
540static const struct usb_device_id usb_endpoint_ignore[] = {
541	{ USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x01 },
542	{ USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x81 },
543	{ USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 },
544	{ USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 },
545	{ }
546};
547
548bool usb_endpoint_is_ignored(struct usb_device *udev,
549			     struct usb_host_interface *intf,
550			     struct usb_endpoint_descriptor *epd)
551{
552	const struct usb_device_id *id;
553	unsigned int address;
554
555	for (id = usb_endpoint_ignore; id->match_flags; ++id) {
556		if (!usb_match_device(udev, id))
557			continue;
558
559		if (!usb_match_one_id_intf(udev, intf, id))
560			continue;
561
562		address = id->driver_info;
563		if (address == epd->bEndpointAddress)
564			return true;
565	}
566
567	return false;
568}
569
570static bool usb_match_any_interface(struct usb_device *udev,
571				    const struct usb_device_id *id)
572{
573	unsigned int i;
574
575	for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
576		struct usb_host_config *cfg = &udev->config[i];
577		unsigned int j;
578
579		for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
580			struct usb_interface_cache *cache;
581			struct usb_host_interface *intf;
582
583			cache = cfg->intf_cache[j];
584			if (cache->num_altsetting == 0)
585				continue;
586
587			intf = &cache->altsetting[0];
588			if (usb_match_one_id_intf(udev, intf, id))
589				return true;
590		}
591	}
592
593	return false;
594}
595
596static int usb_amd_resume_quirk(struct usb_device *udev)
597{
598	struct usb_hcd *hcd;
599
600	hcd = bus_to_hcd(udev->bus);
601	/* The device should be attached directly to root hub */
602	if (udev->level == 1 && hcd->amd_resume_bug == 1)
603		return 1;
604
605	return 0;
606}
607
608static u32 usb_detect_static_quirks(struct usb_device *udev,
609				    const struct usb_device_id *id)
610{
611	u32 quirks = 0;
612
613	for (; id->match_flags; id++) {
614		if (!usb_match_device(udev, id))
615			continue;
616
617		if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
618		    !usb_match_any_interface(udev, id))
619			continue;
620
621		quirks |= (u32)(id->driver_info);
622	}
623
624	return quirks;
625}
626
627static u32 usb_detect_dynamic_quirks(struct usb_device *udev)
628{
629	u16 vid = le16_to_cpu(udev->descriptor.idVendor);
630	u16 pid = le16_to_cpu(udev->descriptor.idProduct);
631	int i, flags = 0;
632
633	mutex_lock(&quirk_mutex);
634
635	for (i = 0; i < quirk_count; i++) {
636		if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) {
637			flags = quirk_list[i].flags;
638			break;
639		}
640	}
641
642	mutex_unlock(&quirk_mutex);
643
644	return flags;
645}
646
647/*
648 * Detect any quirks the device has, and do any housekeeping for it if needed.
649 */
650void usb_detect_quirks(struct usb_device *udev)
651{
652	udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list);
653
654	/*
655	 * Pixart-based mice would trigger remote wakeup issue on AMD
656	 * Yangtze chipset, so set them as RESET_RESUME flag.
657	 */
658	if (usb_amd_resume_quirk(udev))
659		udev->quirks |= usb_detect_static_quirks(udev,
660				usb_amd_resume_quirk_list);
661
662	udev->quirks ^= usb_detect_dynamic_quirks(udev);
663
 
 
 
664	if (udev->quirks)
665		dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
666			udev->quirks);
667
668#ifdef CONFIG_USB_DEFAULT_PERSIST
669	if (!(udev->quirks & USB_QUIRK_RESET))
670		udev->persist_enabled = 1;
671#else
672	/* Hubs are automatically enabled for USB-PERSIST */
673	if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
674		udev->persist_enabled = 1;
675#endif	/* CONFIG_USB_DEFAULT_PERSIST */
676}
677
678void usb_detect_interface_quirks(struct usb_device *udev)
679{
680	u32 quirks;
681
682	quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list);
683	if (quirks == 0)
684		return;
685
686	dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
687		quirks);
688	udev->quirks |= quirks;
689}
690
691void usb_release_quirk_list(void)
692{
693	mutex_lock(&quirk_mutex);
694	kfree(quirk_list);
695	quirk_list = NULL;
696	mutex_unlock(&quirk_mutex);
697}