Skip to contentSkip to conversation

ALSA: usb-audio: Scarlett Gen 2 mixer interface

RFC PATCH Superseded Geoffrey D. Bennett 1 participant 1 message Jun 30, 2019 Sound

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v3 1/1 ALSA: usb-audio: Scarlett Gen 2 mixer interface

Add mixer quirk for the Focusrite Scarlett 6i6, 18i8, and 18i20 Gen 2 audio interfaces. Although the interfaces are USB compliant, additional input/output level controls and hardware routing/mixing functionality are available using proprietary USB requests.

---
Hi all,

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

Changes since v1:
- Add support for the Scarlett 18i8 Gen 2
- Save configuration parameters to NVRAM
- Implemented feedback from Takashi's email 24/Apr/2019
- Moved private field from struct snd_usb_audio to struct usb_mixer_interface
- Added timer and buffer fields to struct usb_mixer_interface
- Other small code fixes/cleanups/improvements

Changes since v2:
- Add support for the Scarlett 6i6 Gen 2
- Add support for controlling the mute/dim switches (18i20 only)
- Implemented feedback from Takashi's email 29/Apr/2019: One pointer field private_data and one function pointer private_free. Replaced timer with delayed work (thanks for that suggestion; it makes the code a *lot* simpler!).
- The new functionality is disabled by default as there were reports of some Gen 2 devices not responding to the initialisation sequence and hanging. Added module parameter "scarlett_gen2_mixer_enable". If this parameter is not set, logs a message "Focusrite Scarlett Gen 2 Mixer Driver disabled; use options snd_usb_audio scarlett_gen2_mixer_enable=1 to enable and report any issues to [email protected]".

Outstanding issues/questions:

- Takashi, you wrote last time "Also, the delayed work needs to be canceled or flushed at PM suspend callback as well as disconnecting." I'm not sure why it should be cancelled; is it not okay to do on resume? But I tested suspending while the delayed work was waiting and it seemed like the delayed work was cancelled anyway. Probably better to do a flush on suspend though; should this be done through a hook like:

sound/usb/mixer.c +2 -0
index 2444737a14b2..1572a89267c6 100644
@@ -3547,6 +3547,8 @@ static int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
 int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer)
 {
        snd_usb_mixer_inactivate(mixer);
+       if (mixer->private_suspend)
+               mixer->private_suspend(mixer);
        return 0;
 }
 
sound/usb/mixer.h +1 -0
index fa6e216a06f0..d94c688c65f7 100644
@@ -28,6 +28,7 @@ struct usb_mixer_interface {
 
        void *private_data;
        void (*private_free)(struct usb_mixer_interface *private_data);
+       void (*private_suspend)(struct usb_mixer_interface *);
 };
 
 #define MAX_CHANNELS   16      /* max logical channels */

?

Thanks,
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/mixer.c +2 -0
index 53dccbfe392b..2444737a14b2 100644
@@ -3518,6 +3518,8 @@ void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer)
 		usb_kill_urb(mixer->urb);
 	if (mixer->rc_urb)
 		usb_kill_urb(mixer->rc_urb);
+	if (mixer->private_free)
+		mixer->private_free(mixer);
 	mixer->disconnected = true;
 }
 
sound/usb/mixer.h +3 -0
index 3d12af8bf191..fa6e216a06f0 100644
@@ -25,6 +25,9 @@ struct usb_mixer_interface {
 	u8 rc_buffer[6];
 
 	bool disconnected;
+
+	void *private_data;
+	void (*private_free)(struct usb_mixer_interface *);
 };
 
 #define MAX_CHANNELS	16	/* max logical channels */
sound/usb/mixer_quirks.c +7 -0
index a751a18ca4c2..1ae00a1e6c47 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"
 
@@ -2271,6 +2272,12 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 		err = snd_scarlett_controls_create(mixer);
 		break;
 
+	case USB_ID(0x1235, 0x8203): /* Focusrite Scarlett 6i6 2nd Gen */
+	case USB_ID(0x1235, 0x8204): /* Focusrite Scarlett 18i8 2nd Gen */
+	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 +2078 -0

2,078 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 */

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