sound/usb/quirks.c

Source file repositories/reference/linux-study-clean/sound/usb/quirks.c

File Facts

System
Linux kernel
Corpus path
sound/usb/quirks.c
Extension
.c
Size
91320 bytes
Lines
2779
Domain
Driver Families
Bucket
sound/usb
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct usb_string_match {
	const char *manufacturer;
	const char *product;
};

struct usb_audio_quirk_flags_table {
	u32 id;
	u32 flags;
	const struct usb_string_match *usb_string_match;
};

#define DEVICE_FLG(vid, pid, _flags) \
	{ .id = USB_ID(vid, pid), .flags = (_flags) }
#define VENDOR_FLG(vid, _flags) DEVICE_FLG(vid, 0, _flags)

/*
 * Use as a last resort if using DEVICE_FLG() is prone to VID/PID conflicts.
 *
 * Usage:
 *   // match vid, pid, "manufacturer", and "product"
 *   DEVICE_STRING_FLG(vid, pid, "manufacturer", "product", flags)
 *
 *   // match vid, pid, "manufacturer", and any product string
 *   DEVICE_STRING_FLG(vid, pid, "manufacturer", NULL,      flags)
 *
 *   // match vid, pid, "manufacturer", and device must have no product string
 *   DEVICE_STRING_FLG(vid, pid, "manufacturer", "",        flags)
 *
 *   // match vid, pid, any manufacturer string, and "product"
 *   DEVICE_STRING_FLG(vid, pid, NULL,           "product", flags)
 *
 *   // match vid, pid, no manufacturer string, and "product"
 *   DEVICE_STRING_FLG(vid, pid, "",             "product", flags)
 *
 *   // match vid, pid, no manufacturer string, and no product string
 *   DEVICE_STRING_FLG(vid, pid, "",             "",        flags)
 */
#define DEVICE_STRING_FLG(vid, pid, _manufacturer, _product, _flags)	\
{									\
	.id = USB_ID(vid, pid),						\
	.usb_string_match = &(const struct usb_string_match) {		\
		.manufacturer = _manufacturer,				\
		.product = _product,					\
	},								\
	.flags = (_flags),						\
}

/*
 * Use as a last resort if using VENDOR_FLG() is prone to VID conflicts.
 *
 * Usage:
 *   // match vid, and "manufacturer"
 *   VENDOR_STRING_FLG(vid, "manufacturer", flags)
 *
 *   // match vid, and device must have no manufacturer string
 *   VENDOR_STRING_FLG(vid, "",             flags)
 */
#define VENDOR_STRING_FLG(vid, _manufacturer, _flags)			\
	DEVICE_STRING_FLG(vid, 0, _manufacturer, NULL, _flags)

static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
	/* Device and string descriptor matches */

	/* Device matches */
	DEVICE_FLG(0x001f, 0x0b21, /* AB13X USB Audio */
		   QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
	DEVICE_FLG(0x001f, 0x0b23, /* AB17X USB Audio */
		   QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
	DEVICE_FLG(0x0020, 0x0b21, /* GHW-123P */
		   QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY),
	DEVICE_FLG(0x03f0, 0x654a, /* HP 320 FHD Webcam */
		   QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_MIC_RES_16),
	DEVICE_FLG(0x041e, 0x3000, /* Creative SB Extigy */
		   QUIRK_FLAG_IGNORE_CTL_ERROR),
	DEVICE_FLG(0x041e, 0x4080, /* Creative Live Cam VF0610 */
		   QUIRK_FLAG_GET_SAMPLE_RATE),
	DEVICE_FLG(0x045e, 0x083c, /* MS USB Link headset */
		   QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY |
		   QUIRK_FLAG_DISABLE_AUTOSUSPEND),
	DEVICE_FLG(0x045e, 0x070f, /* MS LifeChat LX-3000 Headset */
		   QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE),
	DEVICE_FLG(0x046d, 0x0807, /* Logitech Webcam C500 */
		   QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIC_RES_384),
	DEVICE_FLG(0x046d, 0x0808, /* Logitech Webcam C600 */
		   QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIC_RES_384),
	DEVICE_FLG(0x046d, 0x0809,
		   QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIC_RES_384),
	DEVICE_FLG(0x046d, 0x0819, /* Logitech Webcam C210 */
		   QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIC_RES_384),
	DEVICE_FLG(0x046d, 0x081b, /* HD Webcam c310 */

Annotation

Implementation Notes