1111 * - Clarett 2Pre/4Pre/8Pre USB
1212 * - Clarett+ 2Pre/4Pre/8Pre
1313 *
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>
1515 * Copyright (c) 2020-2021 by Vladimir Sadovnikov <[email protected] > 1616 * Copyright (c) 2022 by Christian Colglazier <[email protected] > 1717 *
@@ -1253,7 +1253,7 @@ struct scarlett2_data {
12531253 u8 phantom_switch [SCARLETT2_PHANTOM_SWITCH_MAX ];
12541254 u8 phantom_persistence ;
12551255 u8 input_select_switch ;
1256- u8 input_link_switch [SCARLETT2_INPUT_GAIN_MAX / 2 ];
1256+ u8 input_link_switch [SCARLETT2_INPUT_GAIN_MAX ];
12571257 u8 gain [SCARLETT2_INPUT_GAIN_MAX ];
12581258 u8 autogain_switch [SCARLETT2_INPUT_GAIN_MAX ];
12591259 u8 autogain_status [SCARLETT2_INPUT_GAIN_MAX ];
@@ -1284,7 +1284,7 @@ struct scarlett2_data {
12841284 struct snd_kcontrol * input_mute_ctls [SCARLETT2_INPUT_MUTE_SWITCH_MAX ];
12851285 struct snd_kcontrol * phantom_ctls [SCARLETT2_PHANTOM_SWITCH_MAX ];
12861286 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 ];
12881288 struct snd_kcontrol * input_gain_ctls [SCARLETT2_INPUT_GAIN_MAX ];
12891289 struct snd_kcontrol * autogain_ctls [SCARLETT2_INPUT_GAIN_MAX ];
12901290 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)
34393439 scarlett2_set_ctl_access (private -> input_select_ctl , val );
34403440 if (scarlett2_has_config_item (private ,
34413441 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 ++ )
34433443 scarlett2_set_ctl_access (private -> input_link_ctls [i ],
34443444 val );
34453445 for (i = 0 ; i < info -> gain_input_count ; i ++ )
@@ -3480,7 +3480,7 @@ static void scarlett2_autogain_notify_access(struct usb_mixer_interface *mixer)
34803480 & private -> input_select_ctl -> id );
34813481 if (scarlett2_has_config_item (private ,
34823482 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 ++ )
34843484 snd_ctl_notify (card , SNDRV_CTL_EVENT_MASK_INFO ,
34853485 & private -> input_link_ctls [i ]-> id );
34863486 for (i = 0 ; i < info -> gain_input_count ; i ++ )
@@ -3825,7 +3825,7 @@ static int scarlett2_update_input_select(struct usb_mixer_interface *mixer)
38253825{
38263826 struct scarlett2_data * private = mixer -> private_data ;
38273827 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 ;
38293829 int err ;
38303830
38313831 private -> input_select_updated = 0 ;
@@ -3847,10 +3847,6 @@ static int scarlett2_update_input_select(struct usb_mixer_interface *mixer)
38473847 if (err < 0 )
38483848 return err ;
38493849
3850- /* simplified because no model yet has link_count > 1 */
3851- if (private -> input_link_switch [0 ])
3852- private -> input_select_switch = 0 ;
3853-
38543850 return 0 ;
38553851}
38563852
@@ -3887,9 +3883,9 @@ static int scarlett2_input_select_ctl_put(
38873883 struct usb_mixer_elem_info * elem = kctl -> private_data ;
38883884 struct usb_mixer_interface * mixer = elem -> head .mixer ;
38893885 struct scarlett2_data * private = mixer -> private_data ;
3886+ const struct scarlett2_device_info * info = private -> info ;
38903887
38913888 int oval , val , err ;
3892- int max_val = private -> input_link_switch [0 ] ? 0 : 1 ;
38933889
38943890 mutex_lock (& private -> data_mutex );
38953891
@@ -3907,19 +3903,18 @@ static int scarlett2_input_select_ctl_put(
39073903
39083904 if (val < 0 )
39093905 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 ;
39123908
39133909 if (oval == val )
39143910 goto unlock ;
39153911
39163912 private -> input_select_switch = val ;
39173913
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 );
39233918 if (err == 0 )
39243919 err = 1 ;
39253920
@@ -3936,8 +3931,7 @@ static int scarlett2_input_select_ctl_info(
39363931 struct scarlett2_data * private = mixer -> private_data ;
39373932
39383933 int inputs = private -> info -> gain_input_count ;
3939- int i , j ;
3940- int err ;
3934+ int i , err ;
39413935 char * * values = kcalloc (inputs , sizeof (char * ), GFP_KERNEL );
39423936
39433937 if (!values )
@@ -3954,21 +3948,11 @@ static int scarlett2_input_select_ctl_info(
39543948 if (err < 0 )
39553949 goto unlock ;
39563950
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 );
39703954
3971- err = snd_ctl_enum_info (uinfo , 1 , j ,
3955+ err = snd_ctl_enum_info (uinfo , 1 , i ,
39723956 (const char * const * )values );
39733957
39743958unlock :
@@ -4077,18 +4061,8 @@ static int scarlett2_input_link_ctl_put(
40774061
40784062 private -> input_link_switch [index ] = val ;
40794063
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- */
40904064 err = scarlett2_usb_set_config (
4091- mixer , SCARLETT2_CONFIG_INPUT_LINK_SWITCH , index + 1 , val );
4065+ mixer , SCARLETT2_CONFIG_INPUT_LINK_SWITCH , index , val );
40924066 if (err == 0 )
40934067 err = 1 ;
40944068
@@ -6914,10 +6888,9 @@ static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer)
69146888
69156889 if (scarlett2_has_config_item (private ,
69166890 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 ++ ) {
69186892 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 );
69216894 err = scarlett2_add_new_ctl (
69226895 mixer , & scarlett2_input_link_ctl ,
69236896 i , 1 , s , & private -> input_link_ctls [i ]);
@@ -8244,7 +8217,7 @@ static void scarlett2_notify_input_select(struct usb_mixer_interface *mixer)
82448217 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO ,
82458218 & private -> input_select_ctl -> id );
82468219
8247- for (i = 0 ; i < info -> gain_input_count / 2 ; i ++ )
8220+ for (i = 0 ; i < info -> gain_input_count ; i ++ )
82488221 snd_ctl_notify (card , SNDRV_CTL_EVENT_MASK_VALUE ,
82498222 & private -> input_link_ctls [i ]-> id );
82508223}
0 commit comments