Skip to contentSkip to conversation

ALSA: usb-audio: Scarlett mixer interface for 18i20 Gen 2

RFC PATCH New Geoffrey D. Bennett 1 participant 1 message Apr 3, 2019 Sound

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ALSA: usb-audio: Scarlett mixer interface for 18i20 Gen 2

Add mixer quirk for the Focusrite Scarlett 18i20 Gen 2 audio interface. Although the interface is USB compliant, additional hardware mixing, routing, and metering functionality is available using proprietary USB requests.

---
Hi all,

This patch adds the following controls for the Scarlett 18i20 Gen 2:
- Master volume knob indicator
- Volume controls for the 10 analogue HW outputs
- HW/SW volume switches for the 10 analogue HW outputs
- Output mux (where the sound for the HW outputs comes from; defaults to PCM outputs 1-20)
- Capture mux (where the sound for PCM recording comes from; defaults to HW inputs 1-18)
- Matrix mux (where the sound going into the mixer comes from; 18 inputs default off)
- Mixer matrix (18 inputs * 10 outputs = 180 controls)
- Mute and dim indicators
- Level meters

This is my first attempt at writing any kernel device driver code, so apologies in advance if I missed something. There's a couple of things I'm particularly unsure about:

- I added a private field to struct snd_usb_audio for storing the private mixer data. This seems wrong, but I didn't know where else I could/should put that data.

- I've #define'd the vendor-specific interface, endpoint, max_data, and interval values. Is it okay to leave these hard-coded (they match the values provided by lsusb -v; I presume they never change?), or should they be looked up at runtime instead? (and if at runtime, how?)

- I'm not sure if those snd_printk()s for unexpected responses from the hardware should be left in there? Removed? Reworded?

Comments and feedback would be very welcome.

Regards,
Geoffrey.

sound/usb/Makefile +1 -0
index d330f74c90e6..8cf7081e17cb 100644
@@ -11,6 +11,7 @@ snd-usb-audio-objs := 	card.o \
 			mixer.o \
 			mixer_quirks.o \
 			mixer_scarlett.o \
+			mixer_scarlett_gen2.o \
 			mixer_us16x08.o \
 			pcm.o \
 			power.o \
sound/usb/card.c +2 -0
index 746a72e23cf9..06bd839e9ab2 100644
@@ -354,6 +354,8 @@ static void snd_usb_audio_free(struct snd_card *card)
 	list_for_each_entry_safe(ep, n, &chip->ep_list, list)
 		snd_usb_endpoint_free(ep);
 
+	kfree(chip->private);
+
 	mutex_destroy(&chip->mutex);
 	if (!atomic_read(&chip->shutdown))
 		dev_set_drvdata(&chip->dev->dev, NULL);
sound/usb/mixer_quirks.c +5 -0
index 85ae0ff2382a..331f0596e42d 100644
@@ -45,6 +45,7 @@
 #include "mixer.h"
 #include "mixer_quirks.h"
 #include "mixer_scarlett.h"
+#include "mixer_scarlett_gen2.h"
 #include "mixer_us16x08.h"
 #include "helper.h"
 
@@ -2273,6 +2274,10 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 		err = snd_scarlett_controls_create(mixer);
 		break;
 
+	case USB_ID(0x1235, 0x8201): /* Focusrite Scarlett 18i20 2nd Gen */
+		err = snd_scarlett_gen2_controls_create(mixer);
+		break;
+
 	case USB_ID(0x041e, 0x323b): /* Creative Sound Blaster E1 */
 		err = snd_soundblaster_e1_switch_create(mixer);
 		break;
sound/usb/mixer_scarlett_gen2.c new file +1592 -0

1,592 lines not on this page · raw message

sound/usb/mixer_scarlett_gen2.h new file +7 -0
new file mode 100644
index 000000000000..52e1dad77afd
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __USB_MIXER_SCARLETT_GEN2_H
+#define __USB_MIXER_SCARLETT_GEN2_H
+
+int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer);
+
+#endif /* __USB_MIXER_SCARLETT_GEN2_H */
sound/usb/usbaudio.h +2 -0
index b9faeca645fd..1357a73c3a20 100644
@@ -66,6 +66,8 @@ struct snd_usb_audio {
 					 */
 
 	struct usb_host_interface *ctrl_intf;	/* the audio control interface */
+
+	void *private;
 };
 
 #define usb_audio_err(chip, fmt, args...) \

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel