66 * - 6i6/18i8/18i20 Gen 2
77 * - Solo/2i2/4i4/8i6/18i8/18i20 Gen 3
88 *
9- * Copyright (c) 2018-2021 by Geoffrey D. Bennett <g at b4.vu>
9+ * Copyright (c) 2018-2022 by Geoffrey D. Bennett <g at b4.vu>
1010 * Copyright (c) 2020-2021 by Vladimir Sadovnikov <sadko4u@gmail.com>
1111 *
1212 * Based on the Scarlett (Gen 1) Driver for ALSA:
@@ -195,6 +195,16 @@ static const u16 scarlett2_mixer_values[SCARLETT2_MIXER_VALUE_COUNT] = {
195195/* Maximum number of meters (sum of output port counts) */
196196#define SCARLETT2_MAX_METERS 65
197197
198+ /* There are three different sets of configuration parameters across
199+ * the devices
200+ */
201+ enum {
202+ SCARLETT2_CONFIG_SET_NO_MIXER = 0 ,
203+ SCARLETT2_CONFIG_SET_GEN_2 = 1 ,
204+ SCARLETT2_CONFIG_SET_GEN_3 = 2 ,
205+ SCARLETT2_CONFIG_SET_COUNT = 3
206+ };
207+
198208/* Hardware port types:
199209 * - None (no input to mux)
200210 * - Analogue I/O
@@ -308,10 +318,8 @@ struct scarlett2_device_info {
308318 */
309319 u8 has_msd_mode ;
310320
311- /* Gen 3 devices without a mixer have a different
312- * configuration set
313- */
314- u8 has_mixer ;
321+ /* which set of configuration parameters the device uses */
322+ u8 config_set ;
315323
316324 /* line out hw volume is sw controlled */
317325 u8 line_out_hw_vol ;
@@ -426,7 +434,7 @@ struct scarlett2_data {
426434static const struct scarlett2_device_info s6i6_gen2_info = {
427435 .usb_id = USB_ID (0x1235 , 0x8203 ),
428436
429- .has_mixer = 1 ,
437+ .config_set = SCARLETT2_CONFIG_SET_GEN_2 ,
430438 .level_input_count = 2 ,
431439 .pad_input_count = 2 ,
432440
@@ -472,7 +480,7 @@ static const struct scarlett2_device_info s6i6_gen2_info = {
472480static const struct scarlett2_device_info s18i8_gen2_info = {
473481 .usb_id = USB_ID (0x1235 , 0x8204 ),
474482
475- .has_mixer = 1 ,
483+ .config_set = SCARLETT2_CONFIG_SET_GEN_2 ,
476484 .level_input_count = 2 ,
477485 .pad_input_count = 4 ,
478486
@@ -521,7 +529,7 @@ static const struct scarlett2_device_info s18i8_gen2_info = {
521529static const struct scarlett2_device_info s18i20_gen2_info = {
522530 .usb_id = USB_ID (0x1235 , 0x8201 ),
523531
524- .has_mixer = 1 ,
532+ .config_set = SCARLETT2_CONFIG_SET_GEN_2 ,
525533 .line_out_hw_vol = 1 ,
526534
527535 .line_out_descrs = {
@@ -576,6 +584,7 @@ static const struct scarlett2_device_info solo_gen3_info = {
576584 .usb_id = USB_ID (0x1235 , 0x8211 ),
577585
578586 .has_msd_mode = 1 ,
587+ .config_set = SCARLETT2_CONFIG_SET_NO_MIXER ,
579588 .level_input_count = 1 ,
580589 .level_input_first = 1 ,
581590 .air_input_count = 1 ,
@@ -588,6 +597,7 @@ static const struct scarlett2_device_info s2i2_gen3_info = {
588597 .usb_id = USB_ID (0x1235 , 0x8210 ),
589598
590599 .has_msd_mode = 1 ,
600+ .config_set = SCARLETT2_CONFIG_SET_NO_MIXER ,
591601 .level_input_count = 2 ,
592602 .air_input_count = 2 ,
593603 .phantom_count = 1 ,
@@ -599,7 +609,7 @@ static const struct scarlett2_device_info s4i4_gen3_info = {
599609 .usb_id = USB_ID (0x1235 , 0x8212 ),
600610
601611 .has_msd_mode = 1 ,
602- .has_mixer = 1 ,
612+ .config_set = SCARLETT2_CONFIG_SET_GEN_3 ,
603613 .level_input_count = 2 ,
604614 .pad_input_count = 2 ,
605615 .air_input_count = 2 ,
@@ -645,7 +655,7 @@ static const struct scarlett2_device_info s8i6_gen3_info = {
645655 .usb_id = USB_ID (0x1235 , 0x8213 ),
646656
647657 .has_msd_mode = 1 ,
648- .has_mixer = 1 ,
658+ .config_set = SCARLETT2_CONFIG_SET_GEN_3 ,
649659 .level_input_count = 2 ,
650660 .pad_input_count = 2 ,
651661 .air_input_count = 2 ,
@@ -698,7 +708,7 @@ static const struct scarlett2_device_info s18i8_gen3_info = {
698708 .usb_id = USB_ID (0x1235 , 0x8214 ),
699709
700710 .has_msd_mode = 1 ,
701- .has_mixer = 1 ,
711+ .config_set = SCARLETT2_CONFIG_SET_GEN_3 ,
702712 .line_out_hw_vol = 1 ,
703713 .has_speaker_switching = 1 ,
704714 .level_input_count = 2 ,
@@ -768,7 +778,7 @@ static const struct scarlett2_device_info s18i20_gen3_info = {
768778 .usb_id = USB_ID (0x1235 , 0x8215 ),
769779
770780 .has_msd_mode = 1 ,
771- .has_mixer = 1 ,
781+ .config_set = SCARLETT2_CONFIG_SET_GEN_3 ,
772782 .line_out_hw_vol = 1 ,
773783 .has_speaker_switching = 1 ,
774784 .has_talkback = 1 ,
@@ -944,13 +954,11 @@ struct scarlett2_config {
944954 u8 activate ;
945955};
946956
947- /* scarlett2_config_items[0] is for devices without a mixer
948- * scarlett2_config_items[1] is for devices with a mixer
949- */
950957static const struct scarlett2_config
951- scarlett2_config_items [2 ][SCARLETT2_CONFIG_COUNT ] =
958+ scarlett2_config_items [SCARLETT2_CONFIG_SET_COUNT ]
959+ [SCARLETT2_CONFIG_COUNT ] =
952960
953- /* Devices without a mixer (Solo and 2i2 Gen 3 ) */
961+ /* Devices without a mixer (Gen 3 Solo and 2i2) */
954962{ {
955963 [SCARLETT2_CONFIG_MSD_SWITCH ] = {
956964 .offset = 0x04 , .size = 8 , .activate = 6 },
@@ -970,7 +978,27 @@ static const struct scarlett2_config
970978 [SCARLETT2_CONFIG_AIR_SWITCH ] = {
971979 .offset = 0x09 , .size = 1 , .activate = 8 },
972980
973- /* Devices with a mixer (Gen 2 and all other Gen 3) */
981+ /* Gen 2 devices: 6i6, 18i8, 18i20 */
982+ }, {
983+ [SCARLETT2_CONFIG_DIM_MUTE ] = {
984+ .offset = 0x31 , .size = 8 , .activate = 2 },
985+
986+ [SCARLETT2_CONFIG_LINE_OUT_VOLUME ] = {
987+ .offset = 0x34 , .size = 16 , .activate = 1 },
988+
989+ [SCARLETT2_CONFIG_MUTE_SWITCH ] = {
990+ .offset = 0x5c , .size = 8 , .activate = 1 },
991+
992+ [SCARLETT2_CONFIG_SW_HW_SWITCH ] = {
993+ .offset = 0x66 , .size = 8 , .activate = 3 },
994+
995+ [SCARLETT2_CONFIG_LEVEL_SWITCH ] = {
996+ .offset = 0x7c , .size = 8 , .activate = 7 },
997+
998+ [SCARLETT2_CONFIG_PAD_SWITCH ] = {
999+ .offset = 0x84 , .size = 8 , .activate = 8 },
1000+
1001+ /* Gen 3 devices: 4i4, 8i6, 18i8, 18i20 */
9741002}, {
9751003 [SCARLETT2_CONFIG_DIM_MUTE ] = {
9761004 .offset = 0x31 , .size = 8 , .activate = 2 },
@@ -1175,7 +1203,7 @@ static int scarlett2_usb_get_config(
11751203 struct scarlett2_data * private = mixer -> private_data ;
11761204 const struct scarlett2_device_info * info = private -> info ;
11771205 const struct scarlett2_config * config_item =
1178- & scarlett2_config_items [info -> has_mixer ][config_item_num ];
1206+ & scarlett2_config_items [info -> config_set ][config_item_num ];
11791207 int size , err , i ;
11801208 u8 * buf_8 ;
11811209 u8 value ;
@@ -1235,7 +1263,7 @@ static int scarlett2_usb_set_config(
12351263 struct scarlett2_data * private = mixer -> private_data ;
12361264 const struct scarlett2_device_info * info = private -> info ;
12371265 const struct scarlett2_config * config_item =
1238- & scarlett2_config_items [info -> has_mixer ][config_item_num ];
1266+ & scarlett2_config_items [info -> config_set ][config_item_num ];
12391267 struct {
12401268 __le32 offset ;
12411269 __le32 bytes ;
@@ -1692,7 +1720,7 @@ static int scarlett2_add_sync_ctl(struct usb_mixer_interface *mixer)
16921720 struct scarlett2_data * private = mixer -> private_data ;
16931721
16941722 /* devices without a mixer also don't support reporting sync status */
1695- if (! private -> info -> has_mixer )
1723+ if (private -> info -> config_set == SCARLETT2_CONFIG_SET_NO_MIXER )
16961724 return 0 ;
16971725
16981726 return scarlett2_add_new_ctl (mixer , & scarlett2_sync_ctl ,
@@ -3399,7 +3427,7 @@ static int scarlett2_add_meter_ctl(struct usb_mixer_interface *mixer)
33993427 struct scarlett2_data * private = mixer -> private_data ;
34003428
34013429 /* devices without a mixer also don't support reporting levels */
3402- if (! private -> info -> has_mixer )
3430+ if (private -> info -> config_set == SCARLETT2_CONFIG_SET_NO_MIXER )
34033431 return 0 ;
34043432
34053433 return scarlett2_add_new_ctl (mixer , & scarlett2_meter_ctl ,
@@ -3632,7 +3660,7 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
36323660 return err ;
36333661
36343662 /* the rest of the configuration is for devices with a mixer */
3635- if (! info -> has_mixer )
3663+ if (info -> config_set == SCARLETT2_CONFIG_SET_NO_MIXER )
36363664 return 0 ;
36373665
36383666 err = scarlett2_update_sync (mixer );
0 commit comments