From 5436f59bc5bcc27ca0244ebdb02b4228bf8b1aae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 17 Aug 2020 10:21:38 +0200 Subject: 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 --- sound/usb/card.c | 133 +++++++++++++++++++++++++++++++++++++++++++---- sound/usb/quirks-table.h | 120 ------------------------------------------ sound/usb/usbaudio.h | 1 - 3 files changed, 124 insertions(+), 130 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/card.c b/sound/usb/card.c index 696e788c5d31..fa764b61fe9c 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -332,6 +332,106 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) return 0; } +/* + * Profile name preset table + */ +struct usb_audio_device_name { + u32 id; + const char *vendor_name; + const char *product_name; + const char *profile_name; /* override card->longname */ +}; + +#define PROFILE_NAME(vid, pid, vendor, product, profile) \ + { .id = USB_ID(vid, pid), .vendor_name = (vendor), \ + .product_name = (product), .profile_name = (profile) } +#define DEVICE_NAME(vid, pid, vendor, product) \ + PROFILE_NAME(vid, pid, vendor, product, NULL) + +/* vendor/product and profile name presets, sorted in device id order */ +static const struct usb_audio_device_name usb_audio_names[] = { + /* HP Thunderbolt Dock Audio Headset */ + PROFILE_NAME(0x03f0, 0x0269, "HP", "Thunderbolt Dock Audio Headset", + "HP-Thunderbolt-Dock-Audio-Headset"), + /* HP Thunderbolt Dock Audio Module */ + PROFILE_NAME(0x03f0, 0x0567, "HP", "Thunderbolt Dock Audio Module", + "HP-Thunderbolt-Dock-Audio-Module"), + + /* Two entries for Gigabyte TRX40 Aorus Master: + * TRX40 Aorus Master has two USB-audio devices, one for the front + * headphone with ESS SABRE9218 DAC chip, while another for the rest + * I/O (the rear panel and the front mic) with Realtek ALC1220-VB. + * Here we provide two distinct names for making UCM profiles easier. + */ + PROFILE_NAME(0x0414, 0xa000, "Gigabyte", "Aorus Master Front Headphone", + "Gigabyte-Aorus-Master-Front-Headphone"), + PROFILE_NAME(0x0414, 0xa001, "Gigabyte", "Aorus Master Main Audio", + "Gigabyte-Aorus-Master-Main-Audio"), + + /* Gigabyte TRX40 Aorus Pro WiFi */ + PROFILE_NAME(0x0414, 0xa002, + "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"), + + /* Creative/E-Mu devices */ + DEVICE_NAME(0x041e, 0x3010, "Creative Labs", "Sound Blaster MP3+"), + /* Creative/Toshiba Multimedia Center SB-0500 */ + DEVICE_NAME(0x041e, 0x3048, "Toshiba", "SB-0500"), + + DEVICE_NAME(0x046d, 0x0990, "Logitech, Inc.", "QuickCam Pro 9000"), + + /* Dell WD15 Dock */ + PROFILE_NAME(0x0bda, 0x4014, "Dell", "WD15 Dock", "Dell-WD15-Dock"), + /* Dell WD19 Dock */ + PROFILE_NAME(0x0bda, 0x402e, "Dell", "WD19 Dock", "Dell-WD15-Dock"), + + DEVICE_NAME(0x0ccd, 0x0028, "TerraTec", "Aureon5.1MkII"), + + /* + * The original product_name is "USB Sound Device", however this name + * is also used by the CM106 based cards, so make it unique. + */ + DEVICE_NAME(0x0d8c, 0x0102, NULL, "ICUSBAUDIO7D"), + DEVICE_NAME(0x0d8c, 0x0103, NULL, "Audio Advantage MicroII"), + + /* MSI TRX40 Creator */ + PROFILE_NAME(0x0db0, 0x0d64, + "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"), + /* MSI TRX40 */ + PROFILE_NAME(0x0db0, 0x543d, + "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"), + + /* Stanton/N2IT Final Scratch v1 device ('Scratchamp') */ + DEVICE_NAME(0x103d, 0x0100, "Stanton", "ScratchAmp"), + DEVICE_NAME(0x103d, 0x0101, "Stanton", "ScratchAmp"), + + /* aka. Serato Scratch Live DJ Box */ + DEVICE_NAME(0x13e5, 0x0001, "Rane", "SL-1"), + + /* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */ + PROFILE_NAME(0x17aa, 0x1046, "Lenovo", "ThinkStation P620 Rear", + "Lenovo-ThinkStation-P620-Rear"), + /* Lenovo ThinkStation P620 Internal Speaker + Front Headset */ + PROFILE_NAME(0x17aa, 0x104d, "Lenovo", "ThinkStation P620 Main", + "Lenovo-ThinkStation-P620-Main"), + + /* Asrock TRX40 Creator */ + PROFILE_NAME(0x26ce, 0x0a01, + "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"), + + { } /* terminator */ +}; + +static const struct usb_audio_device_name * +lookup_device_name(u32 id) +{ + static const struct usb_audio_device_name *p; + + for (p = usb_audio_names; p->id; p++) + if (p->id == id) + return p; + return NULL; +} + /* * free the chip instance * @@ -357,10 +457,16 @@ static void usb_audio_make_shortname(struct usb_device *dev, const struct snd_usb_audio_quirk *quirk) { struct snd_card *card = chip->card; - - if (quirk && quirk->product_name && *quirk->product_name) { - strlcpy(card->shortname, quirk->product_name, - sizeof(card->shortname)); + const struct usb_audio_device_name *preset; + const char *s = NULL; + + preset = lookup_device_name(chip->usb_id); + if (preset && preset->product_name) + s = preset->product_name; + else if (quirk && quirk->product_name) + s = quirk->product_name; + if (s && *s) { + strlcpy(card->shortname, s, sizeof(card->shortname)); return; } @@ -382,17 +488,26 @@ static void usb_audio_make_longname(struct usb_device *dev, const struct snd_usb_audio_quirk *quirk) { struct snd_card *card = chip->card; + const struct usb_audio_device_name *preset; + const char *s = NULL; int len; + preset = lookup_device_name(chip->usb_id); + /* shortcut - if any pre-defined string is given, use it */ - if (quirk && quirk->profile_name && *quirk->profile_name) { - strlcpy(card->longname, quirk->profile_name, - sizeof(card->longname)); + if (preset && preset->profile_name) + s = preset->profile_name; + if (s && *s) { + strlcpy(card->longname, s, sizeof(card->longname)); return; } - if (quirk && quirk->vendor_name && *quirk->vendor_name) { - len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname)); + if (preset && preset->vendor_name) + s = preset->vendor_name; + else if (quirk && quirk->vendor_name) + s = quirk->vendor_name; + if (s && *s) { + len = strlcpy(card->longname, s, sizeof(card->longname)); } else { /* retrieve the vendor and device strings as longname */ if (dev->descriptor.iManufacturer) diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index f4fb002e3ef4..978f7113bd81 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -25,33 +25,6 @@ .idProduct = prod, \ .bInterfaceClass = USB_CLASS_VENDOR_SPEC -#define QUIRK_RENAME_DEVICE(_vendor, _device) \ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ - .vendor_name = _vendor, \ - .product_name = _device, \ - .ifnum = QUIRK_NO_INTERFACE \ - } - -#define QUIRK_DEVICE_PROFILE(_vendor, _device, _profile) \ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ - .vendor_name = _vendor, \ - .product_name = _device, \ - .profile_name = _profile, \ - .ifnum = QUIRK_NO_INTERFACE \ - } - -/* HP Thunderbolt Dock Audio Headset */ -{ - USB_DEVICE(0x03f0, 0x0269), - QUIRK_DEVICE_PROFILE("HP", "Thunderbolt Dock Audio Headset", - "HP-Thunderbolt-Dock-Audio-Headset"), -}, -/* HP Thunderbolt Dock Audio Module */ -{ - USB_DEVICE(0x03f0, 0x0567), - QUIRK_DEVICE_PROFILE("HP", "Thunderbolt Dock Audio Module", - "HP-Thunderbolt-Dock-Audio-Module"), -}, /* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8), @@ -85,16 +58,6 @@ } }, -/* Creative/E-Mu devices */ -{ - USB_DEVICE(0x041e, 0x3010), - QUIRK_RENAME_DEVICE("Creative Labs", "Sound Blaster MP3+") -}, -/* Creative/Toshiba Multimedia Center SB-0500 */ -{ - USB_DEVICE(0x041e, 0x3048), - QUIRK_RENAME_DEVICE("Toshiba", "SB-0500") -}, { /* E-Mu 0202 USB */ .match_flags = USB_DEVICE_ID_MATCH_DEVICE, @@ -226,7 +189,6 @@ .idProduct = 0x0990, .bInterfaceClass = USB_CLASS_AUDIO, .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, - QUIRK_RENAME_DEVICE("Logitech, Inc.", "QuickCam Pro 9000") }, /* @@ -2609,10 +2571,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), .type = QUIRK_MIDI_STANDARD_INTERFACE } }, -{ - USB_DEVICE(0x0ccd, 0x0028), - QUIRK_RENAME_DEVICE("TerraTec", "Aureon5.1MkII") -}, { USB_DEVICE(0x0ccd, 0x0035), .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { @@ -2623,16 +2581,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, -/* Stanton/N2IT Final Scratch v1 device ('Scratchamp') */ -{ - USB_DEVICE(0x103d, 0x0100), - QUIRK_RENAME_DEVICE("Stanton", "ScratchAmp") -}, -{ - USB_DEVICE(0x103d, 0x0101), - QUIRK_RENAME_DEVICE("Stanton", "ScratchAmp") -}, - /* Novation EMS devices */ { USB_DEVICE_VENDOR_SPEC(0x1235, 0x0001), @@ -2817,26 +2765,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, -/* */ -{ - /* aka. Serato Scratch Live DJ Box */ - USB_DEVICE(0x13e5, 0x0001), - QUIRK_RENAME_DEVICE("Rane", "SL-1") -}, - -/* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */ -{ - USB_DEVICE(0x17aa, 0x1046), - QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Rear", - "Lenovo-ThinkStation-P620-Rear"), -}, -/* Lenovo ThinkStation P620 Internal Speaker + Front Headset */ -{ - USB_DEVICE(0x17aa, 0x104d), - QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Main", - "Lenovo-ThinkStation-P620-Main"), -}, - /* Native Instruments MK2 series */ { /* Komplete Audio 6 */ @@ -3295,19 +3223,6 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), } }, -/* - * The original product_name is "USB Sound Device", however this name - * is also used by the CM106 based cards, so make it unique. - */ -{ - USB_DEVICE(0x0d8c, 0x0102), - QUIRK_RENAME_DEVICE(NULL, "ICUSBAUDIO7D") -}, -{ - USB_DEVICE(0x0d8c, 0x0103), - QUIRK_RENAME_DEVICE(NULL, "Audio Advantage MicroII") -}, - /* disabled due to regression for other devices; * see https://bugzilla.kernel.org/show_bug.cgi?id=199905 */ @@ -3408,18 +3323,10 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), } } }, -/* Dell WD15 Dock */ -{ - USB_DEVICE(0x0bda, 0x4014), - QUIRK_DEVICE_PROFILE("Dell", "WD15 Dock", "Dell-WD15-Dock") -}, /* Dell WD19 Dock */ { USB_DEVICE(0x0bda, 0x402e), .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { - .vendor_name = "Dell", - .product_name = "WD19 Dock", - .profile_name = "Dell-WD15-Dock", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_SETUP_FMT_AFTER_RESUME } @@ -3645,33 +3552,6 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), } }, -#define ALC1220_VB_DESKTOP(vend, prod) { \ - USB_DEVICE(vend, prod), \ - QUIRK_DEVICE_PROFILE("Realtek", "ALC1220-VB-DT", \ - "Realtek-ALC1220-VB-Desktop") \ -} -ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */ -ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */ -ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */ -ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */ -#undef ALC1220_VB_DESKTOP - -/* Two entries for Gigabyte TRX40 Aorus Master: - * TRX40 Aorus Master has two USB-audio devices, one for the front headphone - * with ESS SABRE9218 DAC chip, while another for the rest I/O (the rear - * panel and the front mic) with Realtek ALC1220-VB. - * Here we provide two distinct names for making UCM profiles easier. - */ -{ - USB_DEVICE(0x0414, 0xa000), - QUIRK_DEVICE_PROFILE("Gigabyte", "Aorus Master Front Headphone", - "Gigabyte-Aorus-Master-Front-Headphone") -}, -{ - USB_DEVICE(0x0414, 0xa001), - QUIRK_DEVICE_PROFILE("Gigabyte", "Aorus Master Main Audio", - "Gigabyte-Aorus-Master-Main-Audio") -}, { /* * Pioneer DJ DJM-900NXS2 diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index b91c4c0807ec..2275295fe71f 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -109,7 +109,6 @@ enum quirk_type { struct snd_usb_audio_quirk { const char *vendor_name; const char *product_name; - const char *profile_name; /* override the card->longname */ int16_t ifnum; uint16_t type; bool shares_media_device; -- cgit v1.2.3 From fa10635fca359f047df6a18b3befd2f1e7304e1a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 17 Aug 2020 10:21:39 +0200 Subject: ALSA: usb-audio: Simplify quirk entries with a macro Introduce a new macro USB_AUDIO_DEVICE() for the entries matching with the pid/vid pair and the class/subclass, and remove the open-code. Link: https://lore.kernel.org/r/20200817082140.20232-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/quirks-table.h | 105 ++++++++++------------------------------------- 1 file changed, 21 insertions(+), 84 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 978f7113bd81..988bb9d00192 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -25,6 +25,16 @@ .idProduct = prod, \ .bInterfaceClass = USB_CLASS_VENDOR_SPEC +/* A standard entry matching with vid/pid and the audio class/subclass */ +#define USB_AUDIO_DEVICE(vend, prod) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ + USB_DEVICE_ID_MATCH_INT_CLASS | \ + USB_DEVICE_ID_MATCH_INT_SUBCLASS, \ + .idVendor = vend, \ + .idProduct = prod, \ + .bInterfaceClass = USB_CLASS_AUDIO, \ + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL + /* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8), @@ -127,69 +137,13 @@ * Logitech QuickCam: bDeviceClass is vendor-specific, so generic interface * class matches do not take effect without an explicit ID match. */ -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x0850, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x08ae, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x08c6, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x08f0, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x08f5, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x08f6, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -}, -{ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x046d, - .idProduct = 0x0990, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, -}, +{ USB_AUDIO_DEVICE(0x046d, 0x0850) }, +{ USB_AUDIO_DEVICE(0x046d, 0x08ae) }, +{ USB_AUDIO_DEVICE(0x046d, 0x08c6) }, +{ USB_AUDIO_DEVICE(0x046d, 0x08f0) }, +{ USB_AUDIO_DEVICE(0x046d, 0x08f5) }, +{ USB_AUDIO_DEVICE(0x046d, 0x08f6) }, +{ USB_AUDIO_DEVICE(0x046d, 0x0990) }, /* * Yamaha devices @@ -2831,13 +2785,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), */ #define AU0828_DEVICE(vid, pid, vname, pname) { \ - .idVendor = vid, \ - .idProduct = pid, \ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ - USB_DEVICE_ID_MATCH_INT_CLASS | \ - USB_DEVICE_ID_MATCH_INT_SUBCLASS, \ - .bInterfaceClass = USB_CLASS_AUDIO, \ - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, \ + USB_AUDIO_DEVICE(vid, pid), \ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { \ .vendor_name = vname, \ .product_name = pname, \ @@ -2867,13 +2815,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), /* Syntek STK1160 */ { - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x05e1, - .idProduct = 0x0408, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + USB_AUDIO_DEVICE(0x05e1, 0x0408), .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { .vendor_name = "Syntek", .product_name = "STK1160", @@ -3628,13 +3570,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), * channels to be swapped and out of phase, which is dealt with in quirks.c. */ { - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | - USB_DEVICE_ID_MATCH_INT_CLASS | - USB_DEVICE_ID_MATCH_INT_SUBCLASS, - .idVendor = 0x534d, - .idProduct = 0x2109, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + USB_AUDIO_DEVICE(0x534d, 0x2109), .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { .vendor_name = "MacroSilicon", .product_name = "MS2109", @@ -3675,3 +3611,4 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), }, #undef USB_DEVICE_VENDOR_SPEC +#undef USB_AUDIO_DEVICE -- cgit v1.2.3 From 51ab5d77dcb8a50283c0eded08c67a6d275cb910 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 17 Aug 2020 10:21:40 +0200 Subject: ALSA: usb-audio: Properly match with audio interface class There are a few entries in the quirk table that set the device ID with USB_DEVICE() macro while having an extra bInterfaceClass field. But bInterfaceClass field is never checked unless the proper match_flags is set, so those may match incorrectly with all interfaces. Introduce another macro to match with the vid/pid pair and the audio class interface, and apply it to such entries, so that they can match properly. Link: https://lore.kernel.org/r/20200817082140.20232-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/quirks-table.h | 55 +++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 988bb9d00192..7a80ef31bbe4 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -35,6 +35,14 @@ .bInterfaceClass = USB_CLASS_AUDIO, \ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL +/* Another standard entry matching with vid/pid and the audio class */ +#define USB_AUDIO_CLASS(vend, prod) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ + USB_DEVICE_ID_MATCH_INT_CLASS, \ + .idVendor = vend, \ + .idProduct = prod, \ + .bInterfaceClass = USB_CLASS_AUDIO + /* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8), @@ -68,34 +76,14 @@ } }, -{ - /* E-Mu 0202 USB */ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x041e, - .idProduct = 0x3f02, - .bInterfaceClass = USB_CLASS_AUDIO, -}, -{ - /* E-Mu 0404 USB */ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x041e, - .idProduct = 0x3f04, - .bInterfaceClass = USB_CLASS_AUDIO, -}, -{ - /* E-Mu Tracker Pre */ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x041e, - .idProduct = 0x3f0a, - .bInterfaceClass = USB_CLASS_AUDIO, -}, -{ - /* E-Mu 0204 USB */ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x041e, - .idProduct = 0x3f19, - .bInterfaceClass = USB_CLASS_AUDIO, -}, +/* E-Mu 0202 USB */ +{ USB_AUDIO_CLASS(0x041e, 0x3f02) }, +/* E-Mu 0404 USB */ +{ USB_AUDIO_CLASS(0x041e, 0x3f04) }, +/* E-Mu Tracker Pre */ +{ USB_AUDIO_CLASS(0x041e, 0x3f0a) }, +/* E-Mu 0204 USB */ +{ USB_AUDIO_CLASS(0x041e, 0x3f19) }, /* * HP Wireless Audio @@ -2751,10 +2739,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, /* KeithMcMillen Stringport */ -{ - USB_DEVICE(0x1f38, 0x0001), - .bInterfaceClass = USB_CLASS_AUDIO, -}, +{ USB_AUDIO_CLASS(0x1f38, 0x0001) }, /* Miditech devices */ { @@ -2977,10 +2962,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), }, { /* Tascam US122 MKII - playback-only support */ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, - .idVendor = 0x0644, - .idProduct = 0x8021, - .bInterfaceClass = USB_CLASS_AUDIO, + USB_AUDIO_CLASS(0x0644, 0x8021), .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { .vendor_name = "TASCAM", .product_name = "US122 MKII", @@ -3612,3 +3594,4 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), #undef USB_DEVICE_VENDOR_SPEC #undef USB_AUDIO_DEVICE +#undef USB_AUDIO_CLASS -- cgit v1.2.3 From 14b51ccd26742811ced3ee5e52ee6544f5d6105c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 23 Aug 2020 13:32:51 +0200 Subject: ALSA: usb-audio: Correct wrongly matching entries with audio class The commit 51ab5d77dcb8 ("ALSA: usb-audio: Properly match with audio interface class") converted the quirk entries that have both vid/pid pair and bInterface fields to match with all those with a new macro USB_AUDIO_CLASS(). However, it turned out that those are false conversions; all those (but the unknown KeithMcMillen device) are actually with vendor-specific interface class, hence the conversions broke the matching. This patch corrects those entries to the right one, USB_DEVICE_VENDOR_SPEC() (and USB_DEVICE() for KeithMcMillen to be sure), and drop the unused USB_AUDIO_CLASS macro again. Fixes: 51ab5d77dcb8 ("ALSA: usb-audio: Properly match with audio interface class") Reported-by: Alexander Tsoy Link: https://lore.kernel.org/r/20200823113251.10175-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/quirks-table.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 969c79d0c688..7fe9d3e75d59 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -35,14 +35,6 @@ .bInterfaceClass = USB_CLASS_AUDIO, \ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL -/* Another standard entry matching with vid/pid and the audio class */ -#define USB_AUDIO_CLASS(vend, prod) \ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ - USB_DEVICE_ID_MATCH_INT_CLASS, \ - .idVendor = vend, \ - .idProduct = prod, \ - .bInterfaceClass = USB_CLASS_AUDIO - /* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8), @@ -77,13 +69,13 @@ }, /* E-Mu 0202 USB */ -{ USB_AUDIO_CLASS(0x041e, 0x3f02) }, +{ USB_DEVICE_VENDOR_SPEC(0x041e, 0x3f02) }, /* E-Mu 0404 USB */ -{ USB_AUDIO_CLASS(0x041e, 0x3f04) }, +{ USB_DEVICE_VENDOR_SPEC(0x041e, 0x3f04) }, /* E-Mu Tracker Pre */ -{ USB_AUDIO_CLASS(0x041e, 0x3f0a) }, +{ USB_DEVICE_VENDOR_SPEC(0x041e, 0x3f0a) }, /* E-Mu 0204 USB */ -{ USB_AUDIO_CLASS(0x041e, 0x3f19) }, +{ USB_DEVICE_VENDOR_SPEC(0x041e, 0x3f19) }, /* * HP Wireless Audio @@ -2756,7 +2748,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, /* KeithMcMillen Stringport */ -{ USB_AUDIO_CLASS(0x1f38, 0x0001) }, +{ USB_DEVICE(0x1f38, 0x0001) }, /* FIXME: should be more restrictive matching */ /* Miditech devices */ { @@ -2979,7 +2971,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), }, { /* Tascam US122 MKII - playback-only support */ - USB_AUDIO_CLASS(0x0644, 0x8021), + USB_DEVICE_VENDOR_SPEC(0x0644, 0x8021), .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { .vendor_name = "TASCAM", .product_name = "US122 MKII", @@ -3611,4 +3603,3 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), #undef USB_DEVICE_VENDOR_SPEC #undef USB_AUDIO_DEVICE -#undef USB_AUDIO_CLASS -- cgit v1.2.3 From 04d0b5e3b1ba4aca95534767e47d140be1d6643f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 2 Sep 2020 16:21:27 -0500 Subject: ALSA: usb: scarless_gen2: fix endianness issue Fix Sparse warning: sound/usb/mixer_scarlett_gen2.c:1949:24: warning: cast to restricted __le32 Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200902212133.30964-13-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/usb/mixer_scarlett_gen2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/usb') diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 0ffff7640892..d33df146d6ce 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1946,7 +1946,7 @@ static void scarlett2_mixer_interrupt(struct urb *urb) goto requeue; if (len == 8) { - data = le32_to_cpu(*(u32 *)urb->transfer_buffer); + data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); if (data & SCARLETT2_USB_INTERRUPT_VOL_CHANGE) scarlett2_mixer_interrupt_vol_change(mixer); if (data & SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE) -- cgit v1.2.3 From c7d9efdff68e00350e611227ad191ce347b88ea5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 3 Sep 2020 12:41:23 +0200 Subject: ALSA: usb-audio: Replace tasklet with work The tasklet is an old API that should be deprecated, usually can be converted to another decent API. In USB-audio driver, a tasklet is still used in MIDI interface code for handling the output byte stream. It can be achieved gracefully with a work queued in the high-prio system workqueue. This patch replaces the tasklet usage in USB-audio driver with a simple work. Link: https://lore.kernel.org/r/20200903104131.21097-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/midi.c b/sound/usb/midi.c index e8287a05e36b..c8213652470c 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -142,7 +142,7 @@ struct snd_usb_midi_out_endpoint { unsigned int active_urbs; unsigned int drain_urbs; int max_transfer; /* size of urb buffer */ - struct tasklet_struct tasklet; + struct work_struct work; unsigned int next_urb; spinlock_t buffer_lock; @@ -344,9 +344,10 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint *ep) spin_unlock_irqrestore(&ep->buffer_lock, flags); } -static void snd_usbmidi_out_tasklet(struct tasklet_struct *t) +static void snd_usbmidi_out_work(struct work_struct *work) { - struct snd_usb_midi_out_endpoint *ep = from_tasklet(ep, t, tasklet); + struct snd_usb_midi_out_endpoint *ep = + container_of(work, struct snd_usb_midi_out_endpoint, work); snd_usbmidi_do_output(ep); } @@ -1177,7 +1178,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, snd_rawmidi_proceed(substream); return; } - tasklet_schedule(&port->ep->tasklet); + queue_work(system_highpri_wq, &port->ep->work); } } @@ -1440,7 +1441,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, } spin_lock_init(&ep->buffer_lock); - tasklet_setup(&ep->tasklet, snd_usbmidi_out_tasklet); + INIT_WORK(&ep->work, snd_usbmidi_out_work); init_waitqueue_head(&ep->drain_wait); for (i = 0; i < 0x10; ++i) @@ -1503,7 +1504,7 @@ void snd_usbmidi_disconnect(struct list_head *p) for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i]; if (ep->out) - tasklet_kill(&ep->out->tasklet); + cancel_work_sync(&ep->out->work); if (ep->out) { for (j = 0; j < OUTPUT_URBS; ++j) usb_kill_urb(ep->out->urbs[j].urb); -- cgit v1.2.3 From 45e4d67f8a53e713833292cc5fef3603294a5914 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 3 Sep 2020 12:41:24 +0200 Subject: ALSA: ua101: Replace tasklet with work The tasklet is an old API that should be deprecated, usually can be converted to another decent API. In UA101 driver, a tasklet is still used for handling the output URBs. It can be achieved gracefully with a work queued in the high-prio system workqueue, too. This patch replaces the tasklet usage in UA101 driver with a simple work. Link: https://lore.kernel.org/r/20200903104131.21097-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/misc/ua101.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index 3b2dce1043f5..6b30155964ec 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -96,7 +96,7 @@ struct ua101 { u8 rate_feedback[MAX_QUEUE_LENGTH]; struct list_head ready_playback_urbs; - struct tasklet_struct playback_tasklet; + struct work_struct playback_work; wait_queue_head_t alsa_capture_wait; wait_queue_head_t rate_feedback_wait; wait_queue_head_t alsa_playback_wait; @@ -188,7 +188,7 @@ static void playback_urb_complete(struct urb *usb_urb) spin_lock_irqsave(&ua->lock, flags); list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); if (ua->rate_feedback_count > 0) - tasklet_schedule(&ua->playback_tasklet); + queue_work(system_highpri_wq, &ua->playback_work); ua->playback.substream->runtime->delay -= urb->urb.iso_frame_desc[0].length / ua->playback.frame_bytes; @@ -247,9 +247,9 @@ static inline void add_with_wraparound(struct ua101 *ua, *value -= ua->playback.queue_length; } -static void playback_tasklet(struct tasklet_struct *t) +static void playback_work(struct work_struct *work) { - struct ua101 *ua = from_tasklet(ua, t, playback_tasklet); + struct ua101 *ua = container_of(work, struct ua101, playback_work); unsigned long flags; unsigned int frames; struct ua101_urb *urb; @@ -401,7 +401,7 @@ static void capture_urb_complete(struct urb *urb) } if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && !list_empty(&ua->ready_playback_urbs)) - tasklet_schedule(&ua->playback_tasklet); + queue_work(system_highpri_wq, &ua->playback_work); } spin_unlock_irqrestore(&ua->lock, flags); @@ -532,7 +532,7 @@ static void stop_usb_playback(struct ua101 *ua) kill_stream_urbs(&ua->playback); - tasklet_kill(&ua->playback_tasklet); + cancel_work_sync(&ua->playback_work); disable_iso_interface(ua, INTF_PLAYBACK); } @@ -550,7 +550,7 @@ static int start_usb_playback(struct ua101 *ua) return 0; kill_stream_urbs(&ua->playback); - tasklet_kill(&ua->playback_tasklet); + cancel_work_sync(&ua->playback_work); err = enable_iso_interface(ua, INTF_PLAYBACK); if (err < 0) @@ -1218,7 +1218,7 @@ static int ua101_probe(struct usb_interface *interface, spin_lock_init(&ua->lock); mutex_init(&ua->mutex); INIT_LIST_HEAD(&ua->ready_playback_urbs); - tasklet_setup(&ua->playback_tasklet, playback_tasklet); + INIT_WORK(&ua->playback_work, playback_work); init_waitqueue_head(&ua->alsa_capture_wait); init_waitqueue_head(&ua->rate_feedback_wait); init_waitqueue_head(&ua->alsa_playback_wait); -- cgit v1.2.3 From cdc01a1558dedcee3daee7e1802d0349a07edb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ku=C4=8Dera?= Date: Tue, 22 Sep 2020 16:42:06 +0200 Subject: ALSA: usb-audio: Add mixer support for Pioneer DJ DJM-250MK2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch extends support for DJM-250MK2 and allows mapping playback and capture channels to available sources. Configures the card through USB commands. Signed-off-by: František Kučera Link: https://lore.kernel.org/r/20200922144206.10472-1-konference@frantovo.cz Signed-off-by: Takashi Iwai --- sound/usb/mixer_quirks.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) (limited to 'sound/usb') diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 199cdbfdc761..df036a359f2f 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -2602,6 +2602,216 @@ static int snd_bbfpro_controls_create(struct usb_mixer_interface *mixer) return 0; } +/* + * Pioneer DJ DJM-250MK2 and maybe other DJM models + * + * For playback, no duplicate mapping should be set. + * There are three mixer stereo channels (CH1, CH2, AUX) + * and three stereo sources (Playback 1-2, Playback 3-4, Playback 5-6). + * Each channel should be mapped just once to one source. + * If mapped multiple times, only one source will play on given channel + * (sources are not mixed together). + * + * For recording, duplicate mapping is OK. We will get the same signal multiple times. + * + * Channels 7-8 are in both directions fixed to FX SEND / FX RETURN. + * + * See also notes in the quirks-table.h file. + */ + +struct snd_pioneer_djm_option { + const u16 wIndex; + const u16 wValue; + const char *name; +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_capture_level[] = { + { .name = "-5 dB", .wValue = 0x0300, .wIndex = 0x8003 }, + { .name = "-10 dB", .wValue = 0x0200, .wIndex = 0x8003 }, + { .name = "-15 dB", .wValue = 0x0100, .wIndex = 0x8003 }, + { .name = "-19 dB", .wValue = 0x0000, .wIndex = 0x8003 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_capture_ch12[] = { + { .name = "CH1 Control Tone PHONO", .wValue = 0x0103, .wIndex = 0x8002 }, + { .name = "CH1 Control Tone LINE", .wValue = 0x0100, .wIndex = 0x8002 }, + { .name = "Post CH1 Fader", .wValue = 0x0106, .wIndex = 0x8002 }, + { .name = "Cross Fader A", .wValue = 0x0107, .wIndex = 0x8002 }, + { .name = "Cross Fader B", .wValue = 0x0108, .wIndex = 0x8002 }, + { .name = "MIC", .wValue = 0x0109, .wIndex = 0x8002 }, + { .name = "AUX", .wValue = 0x010d, .wIndex = 0x8002 }, + { .name = "REC OUT", .wValue = 0x010a, .wIndex = 0x8002 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_capture_ch34[] = { + { .name = "CH2 Control Tone PHONO", .wValue = 0x0203, .wIndex = 0x8002 }, + { .name = "CH2 Control Tone LINE", .wValue = 0x0200, .wIndex = 0x8002 }, + { .name = "Post CH2 Fader", .wValue = 0x0206, .wIndex = 0x8002 }, + { .name = "Cross Fader A", .wValue = 0x0207, .wIndex = 0x8002 }, + { .name = "Cross Fader B", .wValue = 0x0208, .wIndex = 0x8002 }, + { .name = "MIC", .wValue = 0x0209, .wIndex = 0x8002 }, + { .name = "AUX", .wValue = 0x020d, .wIndex = 0x8002 }, + { .name = "REC OUT", .wValue = 0x020a, .wIndex = 0x8002 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_capture_ch56[] = { + { .name = "REC OUT", .wValue = 0x030a, .wIndex = 0x8002 }, + { .name = "Post CH1 Fader", .wValue = 0x0311, .wIndex = 0x8002 }, + { .name = "Post CH2 Fader", .wValue = 0x0312, .wIndex = 0x8002 }, + { .name = "Cross Fader A", .wValue = 0x0307, .wIndex = 0x8002 }, + { .name = "Cross Fader B", .wValue = 0x0308, .wIndex = 0x8002 }, + { .name = "MIC", .wValue = 0x0309, .wIndex = 0x8002 }, + { .name = "AUX", .wValue = 0x030d, .wIndex = 0x8002 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_playback_12[] = { + { .name = "CH1", .wValue = 0x0100, .wIndex = 0x8016 }, + { .name = "CH2", .wValue = 0x0101, .wIndex = 0x8016 }, + { .name = "AUX", .wValue = 0x0104, .wIndex = 0x8016 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_playback_34[] = { + { .name = "CH1", .wValue = 0x0200, .wIndex = 0x8016 }, + { .name = "CH2", .wValue = 0x0201, .wIndex = 0x8016 }, + { .name = "AUX", .wValue = 0x0204, .wIndex = 0x8016 } +}; + +static const struct snd_pioneer_djm_option snd_pioneer_djm_options_playback_56[] = { + { .name = "CH1", .wValue = 0x0300, .wIndex = 0x8016 }, + { .name = "CH2", .wValue = 0x0301, .wIndex = 0x8016 }, + { .name = "AUX", .wValue = 0x0304, .wIndex = 0x8016 } +}; + +struct snd_pioneer_djm_option_group { + const char *name; + const struct snd_pioneer_djm_option *options; + const size_t count; + const u16 default_value; +}; + +#define snd_pioneer_djm_option_group_item(_name, suffix, _default_value) { \ + .name = _name, \ + .options = snd_pioneer_djm_options_##suffix, \ + .count = ARRAY_SIZE(snd_pioneer_djm_options_##suffix), \ + .default_value = _default_value } + +static const struct snd_pioneer_djm_option_group snd_pioneer_djm_option_groups[] = { + snd_pioneer_djm_option_group_item("Master Capture Level Capture Switch", capture_level, 0), + snd_pioneer_djm_option_group_item("Capture 1-2 Capture Switch", capture_ch12, 2), + snd_pioneer_djm_option_group_item("Capture 3-4 Capture Switch", capture_ch34, 2), + snd_pioneer_djm_option_group_item("Capture 5-6 Capture Switch", capture_ch56, 0), + snd_pioneer_djm_option_group_item("Playback 1-2 Playback Switch", playback_12, 0), + snd_pioneer_djm_option_group_item("Playback 3-4 Playback Switch", playback_34, 1), + snd_pioneer_djm_option_group_item("Playback 5-6 Playback Switch", playback_56, 2) +}; + +// layout of the kcontrol->private_value: +#define SND_PIONEER_DJM_VALUE_MASK 0x0000ffff +#define SND_PIONEER_DJM_GROUP_MASK 0xffff0000 +#define SND_PIONEER_DJM_GROUP_SHIFT 16 + +static int snd_pioneer_djm_controls_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *info) +{ + u16 group_index = kctl->private_value >> SND_PIONEER_DJM_GROUP_SHIFT; + size_t count; + const char *name; + const struct snd_pioneer_djm_option_group *group; + + if (group_index >= ARRAY_SIZE(snd_pioneer_djm_option_groups)) + return -EINVAL; + + group = &snd_pioneer_djm_option_groups[group_index]; + count = group->count; + if (info->value.enumerated.item >= count) + info->value.enumerated.item = count - 1; + name = group->options[info->value.enumerated.item].name; + strlcpy(info->value.enumerated.name, name, sizeof(info->value.enumerated.name)); + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + info->count = 1; + info->value.enumerated.items = count; + return 0; +} + +static int snd_pioneer_djm_controls_update(struct usb_mixer_interface *mixer, u16 group, u16 value) +{ + int err; + + if (group >= ARRAY_SIZE(snd_pioneer_djm_option_groups) + || value >= snd_pioneer_djm_option_groups[group].count) + return -EINVAL; + + err = snd_usb_lock_shutdown(mixer->chip); + if (err) + return err; + + err = snd_usb_ctl_msg( + mixer->chip->dev, usb_sndctrlpipe(mixer->chip->dev, 0), + USB_REQ_SET_FEATURE, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + snd_pioneer_djm_option_groups[group].options[value].wValue, + snd_pioneer_djm_option_groups[group].options[value].wIndex, + NULL, 0); + + snd_usb_unlock_shutdown(mixer->chip); + return err; +} + +static int snd_pioneer_djm_controls_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *elem) +{ + elem->value.enumerated.item[0] = kctl->private_value & SND_PIONEER_DJM_VALUE_MASK; + return 0; +} + +static int snd_pioneer_djm_controls_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *elem) +{ + struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl); + struct usb_mixer_interface *mixer = list->mixer; + unsigned long private_value = kctl->private_value; + u16 group = (private_value & SND_PIONEER_DJM_GROUP_MASK) >> SND_PIONEER_DJM_GROUP_SHIFT; + u16 value = elem->value.enumerated.item[0]; + + kctl->private_value = (group << SND_PIONEER_DJM_GROUP_SHIFT) | value; + + return snd_pioneer_djm_controls_update(mixer, group, value); +} + +static int snd_pioneer_djm_controls_resume(struct usb_mixer_elem_list *list) +{ + unsigned long private_value = list->kctl->private_value; + u16 group = (private_value & SND_PIONEER_DJM_GROUP_MASK) >> SND_PIONEER_DJM_GROUP_SHIFT; + u16 value = (private_value & SND_PIONEER_DJM_VALUE_MASK); + + return snd_pioneer_djm_controls_update(list->mixer, group, value); +} + +static int snd_pioneer_djm_controls_create(struct usb_mixer_interface *mixer) +{ + int err, i; + const struct snd_pioneer_djm_option_group *group; + struct snd_kcontrol_new knew = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .index = 0, + .info = snd_pioneer_djm_controls_info, + .get = snd_pioneer_djm_controls_get, + .put = snd_pioneer_djm_controls_put + }; + + for (i = 0; i < ARRAY_SIZE(snd_pioneer_djm_option_groups); i++) { + group = &snd_pioneer_djm_option_groups[i]; + knew.name = group->name; + knew.private_value = (i << SND_PIONEER_DJM_GROUP_SHIFT) | group->default_value; + err = snd_pioneer_djm_controls_update(mixer, i, group->default_value); + if (err) + return err; + err = add_single_ctl_with_resume(mixer, 0, snd_pioneer_djm_controls_resume, + &knew, NULL); + if (err) + return err; + } + return 0; +} + int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) { int err = 0; @@ -2706,6 +2916,9 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) case USB_ID(0x2a39, 0x3fb0): /* RME Babyface Pro FS */ err = snd_bbfpro_controls_create(mixer); break; + case USB_ID(0x2b73, 0x0017): /* Pioneer DJ DJM-250MK2 */ + err = snd_pioneer_djm_controls_create(mixer); + break; } return err; -- cgit v1.2.3 From 716a0c2881938d222bde67d7edf630ea0648b8f7 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 25 Nov 2018 23:12:08 +0000 Subject: ALSA: usb-audio: fix spelling mistake "Frequence" -> "Frequency" There are spelling mistakes in equalizer name fields, fix them. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20181125231208.14350-1-colin.king@canonical.com Signed-off-by: Takashi Iwai --- sound/usb/mixer_us16x08.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound/usb') diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c index a4d4d71db55b..92b1a6d9c931 100644 --- a/sound/usb/mixer_us16x08.c +++ b/sound/usb/mixer_us16x08.c @@ -1109,7 +1109,7 @@ static const struct snd_us16x08_control_params eq_controls[] = { .control_id = SND_US16X08_ID_EQLOWFREQ, .type = USB_MIXER_U8, .num_channels = 16, - .name = "EQ Low Frequence", + .name = "EQ Low Frequency", }, { /* EQ mid low gain */ .kcontrol_new = &snd_us16x08_eq_gain_ctl, @@ -1123,7 +1123,7 @@ static const struct snd_us16x08_control_params eq_controls[] = { .control_id = SND_US16X08_ID_EQLOWMIDFREQ, .type = USB_MIXER_U8, .num_channels = 16, - .name = "EQ MidLow Frequence", + .name = "EQ MidLow Frequency", }, { /* EQ mid low Q */ .kcontrol_new = &snd_us16x08_eq_mid_width_ctl, @@ -1144,7 +1144,7 @@ static const struct snd_us16x08_control_params eq_controls[] = { .control_id = SND_US16X08_ID_EQHIGHMIDFREQ, .type = USB_MIXER_U8, .num_channels = 16, - .name = "EQ MidHigh Frequence", + .name = "EQ MidHigh Frequency", }, { /* EQ mid high Q */ .kcontrol_new = &snd_us16x08_eq_mid_width_ctl, @@ -1165,7 +1165,7 @@ static const struct snd_us16x08_control_params eq_controls[] = { .control_id = SND_US16X08_ID_EQHIGHFREQ, .type = USB_MIXER_U8, .num_channels = 16, - .name = "EQ High Frequence", + .name = "EQ High Frequency", }, }; -- cgit v1.2.3 From 0569b3d8ae17c29f8e09db2ba683be3915fe8b47 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 5 Oct 2020 12:12:44 -0700 Subject: ALSA: usb-audio: endpoint.c: fix repeated word 'there' Drop the duplicated word "there". Signed-off-by: Randy Dunlap Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Link: https://lore.kernel.org/r/20201005191244.23902-1-rdunlap@infradead.org Signed-off-by: Takashi Iwai --- sound/usb/endpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/usb') diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 5fbc8dd2f409..e2f9ce2f5b8b 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -318,7 +318,7 @@ static inline void prepare_inbound_urb(struct snd_usb_endpoint *ep, /* * Send output urbs that have been prepared previously. URBs are dequeued - * from ep->ready_playback_urbs and in case there there aren't any available + * from ep->ready_playback_urbs and in case there aren't any available * or there are no packets that have been prepared, this function does * nothing. * -- cgit v1.2.3