11
11
* - Clarett 2Pre/4Pre/8Pre USB
12
12
* - Clarett+ 2Pre/4Pre/8Pre
13
13
*
14
- * Copyright (c) 2018-2023 by Geoffrey D. Bennett <g at b4.vu>
14
+ * Copyright (c) 2018-2024 by Geoffrey D. Bennett <g at b4.vu>
15
15
* Copyright (c) 2020-2021 by Vladimir Sadovnikov <[email protected] >
16
16
* Copyright (c) 2022 by Christian Colglazier <[email protected] >
17
17
*
@@ -1253,7 +1253,7 @@ struct scarlett2_data {
1253
1253
u8 phantom_switch [SCARLETT2_PHANTOM_SWITCH_MAX ];
1254
1254
u8 phantom_persistence ;
1255
1255
u8 input_select_switch ;
1256
- u8 input_link_switch [SCARLETT2_INPUT_GAIN_MAX / 2 ];
1256
+ u8 input_link_switch [SCARLETT2_INPUT_GAIN_MAX ];
1257
1257
u8 gain [SCARLETT2_INPUT_GAIN_MAX ];
1258
1258
u8 autogain_switch [SCARLETT2_INPUT_GAIN_MAX ];
1259
1259
u8 autogain_status [SCARLETT2_INPUT_GAIN_MAX ];
@@ -1284,7 +1284,7 @@ struct scarlett2_data {
1284
1284
struct snd_kcontrol * input_mute_ctls [SCARLETT2_INPUT_MUTE_SWITCH_MAX ];
1285
1285
struct snd_kcontrol * phantom_ctls [SCARLETT2_PHANTOM_SWITCH_MAX ];
1286
1286
struct snd_kcontrol * input_select_ctl ;
1287
- struct snd_kcontrol * input_link_ctls [SCARLETT2_INPUT_GAIN_MAX / 2 ];
1287
+ struct snd_kcontrol * input_link_ctls [SCARLETT2_INPUT_GAIN_MAX ];
1288
1288
struct snd_kcontrol * input_gain_ctls [SCARLETT2_INPUT_GAIN_MAX ];
1289
1289
struct snd_kcontrol * autogain_ctls [SCARLETT2_INPUT_GAIN_MAX ];
1290
1290
struct snd_kcontrol * autogain_status_ctls [SCARLETT2_INPUT_GAIN_MAX ];
@@ -3439,7 +3439,7 @@ static void scarlett2_autogain_update_access(struct usb_mixer_interface *mixer)
3439
3439
scarlett2_set_ctl_access (private -> input_select_ctl , val );
3440
3440
if (scarlett2_has_config_item (private ,
3441
3441
SCARLETT2_CONFIG_INPUT_LINK_SWITCH ))
3442
- for (i = 0 ; i < info -> gain_input_count / 2 ; i ++ )
3442
+ for (i = 0 ; i < info -> gain_input_count ; i ++ )
3443
3443
scarlett2_set_ctl_access (private -> input_link_ctls [i ],
3444
3444
val );
3445
3445
for (i = 0 ; i < info -> gain_input_count ; i ++ )
@@ -3480,7 +3480,7 @@ static void scarlett2_autogain_notify_access(struct usb_mixer_interface *mixer)
3480
3480
& private -> input_select_ctl -> id );
3481
3481
if (scarlett2_has_config_item (private ,
3482
3482
SCARLETT2_CONFIG_INPUT_LINK_SWITCH ))
3483
- for (i = 0 ; i < info -> gain_input_count / 2 ; i ++ )
3483
+ for (i = 0 ; i < info -> gain_input_count ; i ++ )
3484
3484
snd_ctl_notify (card , SNDRV_CTL_EVENT_MASK_INFO ,
3485
3485
& private -> input_link_ctls [i ]-> id );
3486
3486
for (i = 0 ; i < info -> gain_input_count ; i ++ )
@@ -3825,7 +3825,7 @@ static int scarlett2_update_input_select(struct usb_mixer_interface *mixer)
3825
3825
{
3826
3826
struct scarlett2_data * private = mixer -> private_data ;
3827
3827
const struct scarlett2_device_info * info = private -> info ;
3828
- int link_count = info -> gain_input_count / 2 ;
3828
+ int link_count = info -> gain_input_count ;
3829
3829
int err ;
3830
3830
3831
3831
private -> input_select_updated = 0 ;
@@ -3847,10 +3847,6 @@ static int scarlett2_update_input_select(struct usb_mixer_interface *mixer)
3847
3847
if (err < 0 )
3848
3848
return err ;
3849
3849
3850
- /* simplified because no model yet has link_count > 1 */
3851
- if (private -> input_link_switch [0 ])
3852
- private -> input_select_switch = 0 ;
3853
-
3854
3850
return 0 ;
3855
3851
}
3856
3852
@@ -3887,9 +3883,9 @@ static int scarlett2_input_select_ctl_put(
3887
3883
struct usb_mixer_elem_info * elem = kctl -> private_data ;
3888
3884
struct usb_mixer_interface * mixer = elem -> head .mixer ;
3889
3885
struct scarlett2_data * private = mixer -> private_data ;
3886
+ const struct scarlett2_device_info * info = private -> info ;
3890
3887
3891
3888
int oval , val , err ;
3892
- int max_val = private -> input_link_switch [0 ] ? 0 : 1 ;
3893
3889
3894
3890
mutex_lock (& private -> data_mutex );
3895
3891
@@ -3907,19 +3903,18 @@ static int scarlett2_input_select_ctl_put(
3907
3903
3908
3904
if (val < 0 )
3909
3905
val = 0 ;
3910
- else if (val > max_val )
3911
- val = max_val ;
3906
+ else if (val >= info -> gain_input_count )
3907
+ val = info -> gain_input_count - 1 ;
3912
3908
3913
3909
if (oval == val )
3914
3910
goto unlock ;
3915
3911
3916
3912
private -> input_select_switch = val ;
3917
3913
3918
- /* Send switch change to the device if inputs not linked */
3919
- if (!private -> input_link_switch [0 ])
3920
- err = scarlett2_usb_set_config (
3921
- mixer , SCARLETT2_CONFIG_INPUT_SELECT_SWITCH ,
3922
- 1 , val );
3914
+ /* Send new value to the device */
3915
+ err = scarlett2_usb_set_config (
3916
+ mixer , SCARLETT2_CONFIG_INPUT_SELECT_SWITCH ,
3917
+ 0 , val );
3923
3918
if (err == 0 )
3924
3919
err = 1 ;
3925
3920
@@ -3936,8 +3931,7 @@ static int scarlett2_input_select_ctl_info(
3936
3931
struct scarlett2_data * private = mixer -> private_data ;
3937
3932
3938
3933
int inputs = private -> info -> gain_input_count ;
3939
- int i , j ;
3940
- int err ;
3934
+ int i , err ;
3941
3935
char * * values = kcalloc (inputs , sizeof (char * ), GFP_KERNEL );
3942
3936
3943
3937
if (!values )
@@ -3954,21 +3948,11 @@ static int scarlett2_input_select_ctl_info(
3954
3948
if (err < 0 )
3955
3949
goto unlock ;
3956
3950
3957
- /* Loop through each input
3958
- * Linked inputs have one value for the pair
3959
- */
3960
- for (i = 0 , j = 0 ; i < inputs ; i ++ ) {
3961
- if (private -> input_link_switch [i / 2 ]) {
3962
- values [j ++ ] = kasprintf (
3963
- GFP_KERNEL , "Input %d-%d" , i + 1 , i + 2 );
3964
- i ++ ;
3965
- } else {
3966
- values [j ++ ] = kasprintf (
3967
- GFP_KERNEL , "Input %d" , i + 1 );
3968
- }
3969
- }
3951
+ /* Loop through each input */
3952
+ for (i = 0 ; i < inputs ; i ++ )
3953
+ values [i ] = kasprintf (GFP_KERNEL , "Input %d" , i + 1 );
3970
3954
3971
- err = snd_ctl_enum_info (uinfo , 1 , j ,
3955
+ err = snd_ctl_enum_info (uinfo , 1 , i ,
3972
3956
(const char * const * )values );
3973
3957
3974
3958
unlock :
@@ -4077,18 +4061,8 @@ static int scarlett2_input_link_ctl_put(
4077
4061
4078
4062
private -> input_link_switch [index ] = val ;
4079
4063
4080
- /* Notify of change in input select options available */
4081
- snd_ctl_notify (mixer -> chip -> card ,
4082
- SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO ,
4083
- & private -> input_select_ctl -> id );
4084
- private -> input_select_updated = 1 ;
4085
-
4086
- /* Send switch change to the device
4087
- * Link for channels 1-2 is at index 1
4088
- * No device yet has more than 2 channels linked
4089
- */
4090
4064
err = scarlett2_usb_set_config (
4091
- mixer , SCARLETT2_CONFIG_INPUT_LINK_SWITCH , index + 1 , val );
4065
+ mixer , SCARLETT2_CONFIG_INPUT_LINK_SWITCH , index , val );
4092
4066
if (err == 0 )
4093
4067
err = 1 ;
4094
4068
@@ -6914,10 +6888,9 @@ static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer)
6914
6888
6915
6889
if (scarlett2_has_config_item (private ,
6916
6890
SCARLETT2_CONFIG_INPUT_LINK_SWITCH )) {
6917
- for (i = 0 ; i < info -> gain_input_count / 2 ; i ++ ) {
6891
+ for (i = 0 ; i < info -> gain_input_count ; i ++ ) {
6918
6892
scnprintf (s , sizeof (s ),
6919
- "Line In %d-%d Link Capture Switch" ,
6920
- (i * 2 ) + 1 , (i * 2 ) + 2 );
6893
+ "Line In %d Link Capture Switch" , i + 1 );
6921
6894
err = scarlett2_add_new_ctl (
6922
6895
mixer , & scarlett2_input_link_ctl ,
6923
6896
i , 1 , s , & private -> input_link_ctls [i ]);
@@ -8244,7 +8217,7 @@ static void scarlett2_notify_input_select(struct usb_mixer_interface *mixer)
8244
8217
SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO ,
8245
8218
& private -> input_select_ctl -> id );
8246
8219
8247
- for (i = 0 ; i < info -> gain_input_count / 2 ; i ++ )
8220
+ for (i = 0 ; i < info -> gain_input_count ; i ++ )
8248
8221
snd_ctl_notify (card , SNDRV_CTL_EVENT_MASK_VALUE ,
8249
8222
& private -> input_link_ctls [i ]-> id );
8250
8223
}
0 commit comments