Skip to content

Commit 5436f59

Browse files
committed
ALSA: usb-audio: Move device rename and profile quirks to an internal table
So far we've added the devices that need vendor/product string renames or the profile setup into the standard quirk table in quirks-table.h. This table is imported into the primary USB audio device entry, hence it's all exported for the probing so that udev and co can take a look at it. OTOH, for renaming or profile setup, we don't need to expose those explicit entries because the probe itself follows the standard way. That said, we're exposing unnecessarily too many entries. This patch moves such internal quirk entries into the own table, and reduces the exported device table size. Along with the moving items, re-arrange the entries in the proper order. Link: https://lore.kernel.org/r/20200817082140.20232-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent b90b925 commit 5436f59

File tree

3 files changed

+124
-130
lines changed

3 files changed

+124
-130
lines changed

sound/usb/card.c

Lines changed: 124 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,106 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
332332
return 0;
333333
}
334334

335+
/*
336+
* Profile name preset table
337+
*/
338+
struct usb_audio_device_name {
339+
u32 id;
340+
const char *vendor_name;
341+
const char *product_name;
342+
const char *profile_name; /* override card->longname */
343+
};
344+
345+
#define PROFILE_NAME(vid, pid, vendor, product, profile) \
346+
{ .id = USB_ID(vid, pid), .vendor_name = (vendor), \
347+
.product_name = (product), .profile_name = (profile) }
348+
#define DEVICE_NAME(vid, pid, vendor, product) \
349+
PROFILE_NAME(vid, pid, vendor, product, NULL)
350+
351+
/* vendor/product and profile name presets, sorted in device id order */
352+
static const struct usb_audio_device_name usb_audio_names[] = {
353+
/* HP Thunderbolt Dock Audio Headset */
354+
PROFILE_NAME(0x03f0, 0x0269, "HP", "Thunderbolt Dock Audio Headset",
355+
"HP-Thunderbolt-Dock-Audio-Headset"),
356+
/* HP Thunderbolt Dock Audio Module */
357+
PROFILE_NAME(0x03f0, 0x0567, "HP", "Thunderbolt Dock Audio Module",
358+
"HP-Thunderbolt-Dock-Audio-Module"),
359+
360+
/* Two entries for Gigabyte TRX40 Aorus Master:
361+
* TRX40 Aorus Master has two USB-audio devices, one for the front
362+
* headphone with ESS SABRE9218 DAC chip, while another for the rest
363+
* I/O (the rear panel and the front mic) with Realtek ALC1220-VB.
364+
* Here we provide two distinct names for making UCM profiles easier.
365+
*/
366+
PROFILE_NAME(0x0414, 0xa000, "Gigabyte", "Aorus Master Front Headphone",
367+
"Gigabyte-Aorus-Master-Front-Headphone"),
368+
PROFILE_NAME(0x0414, 0xa001, "Gigabyte", "Aorus Master Main Audio",
369+
"Gigabyte-Aorus-Master-Main-Audio"),
370+
371+
/* Gigabyte TRX40 Aorus Pro WiFi */
372+
PROFILE_NAME(0x0414, 0xa002,
373+
"Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
374+
375+
/* Creative/E-Mu devices */
376+
DEVICE_NAME(0x041e, 0x3010, "Creative Labs", "Sound Blaster MP3+"),
377+
/* Creative/Toshiba Multimedia Center SB-0500 */
378+
DEVICE_NAME(0x041e, 0x3048, "Toshiba", "SB-0500"),
379+
380+
DEVICE_NAME(0x046d, 0x0990, "Logitech, Inc.", "QuickCam Pro 9000"),
381+
382+
/* Dell WD15 Dock */
383+
PROFILE_NAME(0x0bda, 0x4014, "Dell", "WD15 Dock", "Dell-WD15-Dock"),
384+
/* Dell WD19 Dock */
385+
PROFILE_NAME(0x0bda, 0x402e, "Dell", "WD19 Dock", "Dell-WD15-Dock"),
386+
387+
DEVICE_NAME(0x0ccd, 0x0028, "TerraTec", "Aureon5.1MkII"),
388+
389+
/*
390+
* The original product_name is "USB Sound Device", however this name
391+
* is also used by the CM106 based cards, so make it unique.
392+
*/
393+
DEVICE_NAME(0x0d8c, 0x0102, NULL, "ICUSBAUDIO7D"),
394+
DEVICE_NAME(0x0d8c, 0x0103, NULL, "Audio Advantage MicroII"),
395+
396+
/* MSI TRX40 Creator */
397+
PROFILE_NAME(0x0db0, 0x0d64,
398+
"Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
399+
/* MSI TRX40 */
400+
PROFILE_NAME(0x0db0, 0x543d,
401+
"Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
402+
403+
/* Stanton/N2IT Final Scratch v1 device ('Scratchamp') */
404+
DEVICE_NAME(0x103d, 0x0100, "Stanton", "ScratchAmp"),
405+
DEVICE_NAME(0x103d, 0x0101, "Stanton", "ScratchAmp"),
406+
407+
/* aka. Serato Scratch Live DJ Box */
408+
DEVICE_NAME(0x13e5, 0x0001, "Rane", "SL-1"),
409+
410+
/* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */
411+
PROFILE_NAME(0x17aa, 0x1046, "Lenovo", "ThinkStation P620 Rear",
412+
"Lenovo-ThinkStation-P620-Rear"),
413+
/* Lenovo ThinkStation P620 Internal Speaker + Front Headset */
414+
PROFILE_NAME(0x17aa, 0x104d, "Lenovo", "ThinkStation P620 Main",
415+
"Lenovo-ThinkStation-P620-Main"),
416+
417+
/* Asrock TRX40 Creator */
418+
PROFILE_NAME(0x26ce, 0x0a01,
419+
"Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
420+
421+
{ } /* terminator */
422+
};
423+
424+
static const struct usb_audio_device_name *
425+
lookup_device_name(u32 id)
426+
{
427+
static const struct usb_audio_device_name *p;
428+
429+
for (p = usb_audio_names; p->id; p++)
430+
if (p->id == id)
431+
return p;
432+
return NULL;
433+
}
434+
335435
/*
336436
* free the chip instance
337437
*
@@ -357,10 +457,16 @@ static void usb_audio_make_shortname(struct usb_device *dev,
357457
const struct snd_usb_audio_quirk *quirk)
358458
{
359459
struct snd_card *card = chip->card;
360-
361-
if (quirk && quirk->product_name && *quirk->product_name) {
362-
strlcpy(card->shortname, quirk->product_name,
363-
sizeof(card->shortname));
460+
const struct usb_audio_device_name *preset;
461+
const char *s = NULL;
462+
463+
preset = lookup_device_name(chip->usb_id);
464+
if (preset && preset->product_name)
465+
s = preset->product_name;
466+
else if (quirk && quirk->product_name)
467+
s = quirk->product_name;
468+
if (s && *s) {
469+
strlcpy(card->shortname, s, sizeof(card->shortname));
364470
return;
365471
}
366472

@@ -382,17 +488,26 @@ static void usb_audio_make_longname(struct usb_device *dev,
382488
const struct snd_usb_audio_quirk *quirk)
383489
{
384490
struct snd_card *card = chip->card;
491+
const struct usb_audio_device_name *preset;
492+
const char *s = NULL;
385493
int len;
386494

495+
preset = lookup_device_name(chip->usb_id);
496+
387497
/* shortcut - if any pre-defined string is given, use it */
388-
if (quirk && quirk->profile_name && *quirk->profile_name) {
389-
strlcpy(card->longname, quirk->profile_name,
390-
sizeof(card->longname));
498+
if (preset && preset->profile_name)
499+
s = preset->profile_name;
500+
if (s && *s) {
501+
strlcpy(card->longname, s, sizeof(card->longname));
391502
return;
392503
}
393504

394-
if (quirk && quirk->vendor_name && *quirk->vendor_name) {
395-
len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname));
505+
if (preset && preset->vendor_name)
506+
s = preset->vendor_name;
507+
else if (quirk && quirk->vendor_name)
508+
s = quirk->vendor_name;
509+
if (s && *s) {
510+
len = strlcpy(card->longname, s, sizeof(card->longname));
396511
} else {
397512
/* retrieve the vendor and device strings as longname */
398513
if (dev->descriptor.iManufacturer)

sound/usb/quirks-table.h

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,6 @@
2525
.idProduct = prod, \
2626
.bInterfaceClass = USB_CLASS_VENDOR_SPEC
2727

28-
#define QUIRK_RENAME_DEVICE(_vendor, _device) \
29-
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \
30-
.vendor_name = _vendor, \
31-
.product_name = _device, \
32-
.ifnum = QUIRK_NO_INTERFACE \
33-
}
34-
35-
#define QUIRK_DEVICE_PROFILE(_vendor, _device, _profile) \
36-
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \
37-
.vendor_name = _vendor, \
38-
.product_name = _device, \
39-
.profile_name = _profile, \
40-
.ifnum = QUIRK_NO_INTERFACE \
41-
}
42-
43-
/* HP Thunderbolt Dock Audio Headset */
44-
{
45-
USB_DEVICE(0x03f0, 0x0269),
46-
QUIRK_DEVICE_PROFILE("HP", "Thunderbolt Dock Audio Headset",
47-
"HP-Thunderbolt-Dock-Audio-Headset"),
48-
},
49-
/* HP Thunderbolt Dock Audio Module */
50-
{
51-
USB_DEVICE(0x03f0, 0x0567),
52-
QUIRK_DEVICE_PROFILE("HP", "Thunderbolt Dock Audio Module",
53-
"HP-Thunderbolt-Dock-Audio-Module"),
54-
},
5528
/* FTDI devices */
5629
{
5730
USB_DEVICE(0x0403, 0xb8d8),
@@ -85,16 +58,6 @@
8558
}
8659
},
8760

88-
/* Creative/E-Mu devices */
89-
{
90-
USB_DEVICE(0x041e, 0x3010),
91-
QUIRK_RENAME_DEVICE("Creative Labs", "Sound Blaster MP3+")
92-
},
93-
/* Creative/Toshiba Multimedia Center SB-0500 */
94-
{
95-
USB_DEVICE(0x041e, 0x3048),
96-
QUIRK_RENAME_DEVICE("Toshiba", "SB-0500")
97-
},
9861
{
9962
/* E-Mu 0202 USB */
10063
.match_flags = USB_DEVICE_ID_MATCH_DEVICE,
@@ -226,7 +189,6 @@
226189
.idProduct = 0x0990,
227190
.bInterfaceClass = USB_CLASS_AUDIO,
228191
.bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
229-
QUIRK_RENAME_DEVICE("Logitech, Inc.", "QuickCam Pro 9000")
230192
},
231193

232194
/*
@@ -2609,10 +2571,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
26092571
.type = QUIRK_MIDI_STANDARD_INTERFACE
26102572
}
26112573
},
2612-
{
2613-
USB_DEVICE(0x0ccd, 0x0028),
2614-
QUIRK_RENAME_DEVICE("TerraTec", "Aureon5.1MkII")
2615-
},
26162574
{
26172575
USB_DEVICE(0x0ccd, 0x0035),
26182576
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
@@ -2623,16 +2581,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
26232581
}
26242582
},
26252583

2626-
/* Stanton/N2IT Final Scratch v1 device ('Scratchamp') */
2627-
{
2628-
USB_DEVICE(0x103d, 0x0100),
2629-
QUIRK_RENAME_DEVICE("Stanton", "ScratchAmp")
2630-
},
2631-
{
2632-
USB_DEVICE(0x103d, 0x0101),
2633-
QUIRK_RENAME_DEVICE("Stanton", "ScratchAmp")
2634-
},
2635-
26362584
/* Novation EMS devices */
26372585
{
26382586
USB_DEVICE_VENDOR_SPEC(0x1235, 0x0001),
@@ -2817,26 +2765,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
28172765
}
28182766
},
28192767

2820-
/* */
2821-
{
2822-
/* aka. Serato Scratch Live DJ Box */
2823-
USB_DEVICE(0x13e5, 0x0001),
2824-
QUIRK_RENAME_DEVICE("Rane", "SL-1")
2825-
},
2826-
2827-
/* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */
2828-
{
2829-
USB_DEVICE(0x17aa, 0x1046),
2830-
QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Rear",
2831-
"Lenovo-ThinkStation-P620-Rear"),
2832-
},
2833-
/* Lenovo ThinkStation P620 Internal Speaker + Front Headset */
2834-
{
2835-
USB_DEVICE(0x17aa, 0x104d),
2836-
QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Main",
2837-
"Lenovo-ThinkStation-P620-Main"),
2838-
},
2839-
28402768
/* Native Instruments MK2 series */
28412769
{
28422770
/* Komplete Audio 6 */
@@ -3295,19 +3223,6 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
32953223
}
32963224
},
32973225

3298-
/*
3299-
* The original product_name is "USB Sound Device", however this name
3300-
* is also used by the CM106 based cards, so make it unique.
3301-
*/
3302-
{
3303-
USB_DEVICE(0x0d8c, 0x0102),
3304-
QUIRK_RENAME_DEVICE(NULL, "ICUSBAUDIO7D")
3305-
},
3306-
{
3307-
USB_DEVICE(0x0d8c, 0x0103),
3308-
QUIRK_RENAME_DEVICE(NULL, "Audio Advantage MicroII")
3309-
},
3310-
33113226
/* disabled due to regression for other devices;
33123227
* see https://bugzilla.kernel.org/show_bug.cgi?id=199905
33133228
*/
@@ -3408,18 +3323,10 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
34083323
}
34093324
}
34103325
},
3411-
/* Dell WD15 Dock */
3412-
{
3413-
USB_DEVICE(0x0bda, 0x4014),
3414-
QUIRK_DEVICE_PROFILE("Dell", "WD15 Dock", "Dell-WD15-Dock")
3415-
},
34163326
/* Dell WD19 Dock */
34173327
{
34183328
USB_DEVICE(0x0bda, 0x402e),
34193329
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
3420-
.vendor_name = "Dell",
3421-
.product_name = "WD19 Dock",
3422-
.profile_name = "Dell-WD15-Dock",
34233330
.ifnum = QUIRK_ANY_INTERFACE,
34243331
.type = QUIRK_SETUP_FMT_AFTER_RESUME
34253332
}
@@ -3645,33 +3552,6 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
36453552
}
36463553
},
36473554

3648-
#define ALC1220_VB_DESKTOP(vend, prod) { \
3649-
USB_DEVICE(vend, prod), \
3650-
QUIRK_DEVICE_PROFILE("Realtek", "ALC1220-VB-DT", \
3651-
"Realtek-ALC1220-VB-Desktop") \
3652-
}
3653-
ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */
3654-
ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */
3655-
ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */
3656-
ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
3657-
#undef ALC1220_VB_DESKTOP
3658-
3659-
/* Two entries for Gigabyte TRX40 Aorus Master:
3660-
* TRX40 Aorus Master has two USB-audio devices, one for the front headphone
3661-
* with ESS SABRE9218 DAC chip, while another for the rest I/O (the rear
3662-
* panel and the front mic) with Realtek ALC1220-VB.
3663-
* Here we provide two distinct names for making UCM profiles easier.
3664-
*/
3665-
{
3666-
USB_DEVICE(0x0414, 0xa000),
3667-
QUIRK_DEVICE_PROFILE("Gigabyte", "Aorus Master Front Headphone",
3668-
"Gigabyte-Aorus-Master-Front-Headphone")
3669-
},
3670-
{
3671-
USB_DEVICE(0x0414, 0xa001),
3672-
QUIRK_DEVICE_PROFILE("Gigabyte", "Aorus Master Main Audio",
3673-
"Gigabyte-Aorus-Master-Main-Audio")
3674-
},
36753555
{
36763556
/*
36773557
* Pioneer DJ DJM-900NXS2

sound/usb/usbaudio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ enum quirk_type {
109109
struct snd_usb_audio_quirk {
110110
const char *vendor_name;
111111
const char *product_name;
112-
const char *profile_name; /* override the card->longname */
113112
int16_t ifnum;
114113
uint16_t type;
115114
bool shares_media_device;

0 commit comments

Comments
 (0)