@@ -284,14 +284,22 @@ static const char *const scarlett2_dim_mute_names[SCARLETT2_DIM_MUTE_COUNT] = {
284
284
"Mute Playback Switch" , "Dim Playback Switch"
285
285
};
286
286
287
- /* Autogain Status Values */
288
- enum {
289
- SCARLETT2_AUTOGAIN_STATUS_STOPPED ,
290
- SCARLETT2_AUTOGAIN_STATUS_RUNNING ,
291
- SCARLETT2_AUTOGAIN_STATUS_FAILED ,
292
- SCARLETT2_AUTOGAIN_STATUS_CANCELLED ,
293
- SCARLETT2_AUTOGAIN_STATUS_UNKNOWN ,
294
- SCARLETT2_AUTOGAIN_STATUS_COUNT
287
+ /* The autogain_status is set based on the autogain_switch and
288
+ * raw_autogain_status values.
289
+ *
290
+ * If autogain_switch is set, autogain_status is set to 0 (Running).
291
+ * The other status values are from the raw_autogain_status value + 1.
292
+ */
293
+ static const char * const scarlett2_autogain_status_texts [] = {
294
+ "Running" ,
295
+ "Success" ,
296
+ "SuccessDRover" ,
297
+ "WarnMinGainLimit" ,
298
+ "FailDRunder" ,
299
+ "FailMaxGainLimit" ,
300
+ "FailClipped" ,
301
+ "Cancelled" ,
302
+ "Invalid"
295
303
};
296
304
297
305
/* Power Status Values */
@@ -2835,9 +2843,9 @@ static int scarlett2_autogain_is_running(struct scarlett2_data *private)
2835
2843
{
2836
2844
int i ;
2837
2845
2846
+ /* autogain_status[] is 0 if autogain is running */
2838
2847
for (i = 0 ; i < private -> info -> gain_input_count ; i ++ )
2839
- if (private -> autogain_status [i ] ==
2840
- SCARLETT2_AUTOGAIN_STATUS_RUNNING )
2848
+ if (!private -> autogain_status [i ])
2841
2849
return 1 ;
2842
2850
2843
2851
return 0 ;
@@ -2867,25 +2875,25 @@ static int scarlett2_update_autogain(struct usb_mixer_interface *mixer)
2867
2875
return err ;
2868
2876
2869
2877
/* Translate autogain_switch and raw_autogain_status into
2870
- * autogain_status
2878
+ * autogain_status.
2879
+ *
2880
+ * When autogain_switch[] is set, the status is the first
2881
+ * element in scarlett2_autogain_status_texts[] (Running). The
2882
+ * subsequent elements correspond to the status value from the
2883
+ * device (raw_autogain_status[]) + 1. The last element is
2884
+ * "Invalid", in case the device reports a status outside the
2885
+ * range of scarlett2_autogain_status_texts[].
2871
2886
*/
2872
2887
for (i = 0 ; i < info -> gain_input_count ; i ++ )
2873
2888
if (private -> autogain_switch [i ])
2889
+ private -> autogain_status [i ] = 0 ;
2890
+ else if (raw_autogain_status [i ] <
2891
+ ARRAY_SIZE (scarlett2_autogain_status_texts ) - 1 )
2874
2892
private -> autogain_status [i ] =
2875
- SCARLETT2_AUTOGAIN_STATUS_RUNNING ;
2876
- else if (raw_autogain_status [i ] == 0 )
2877
- private -> autogain_status [i ] =
2878
- SCARLETT2_AUTOGAIN_STATUS_STOPPED ;
2879
- else if (raw_autogain_status [i ] >= 2 &&
2880
- raw_autogain_status [i ] <= 5 )
2881
- private -> autogain_status [i ] =
2882
- SCARLETT2_AUTOGAIN_STATUS_FAILED ;
2883
- else if (raw_autogain_status [i ] == 6 )
2884
- private -> autogain_status [i ] =
2885
- SCARLETT2_AUTOGAIN_STATUS_CANCELLED ;
2893
+ raw_autogain_status [i ] + 1 ;
2886
2894
else
2887
2895
private -> autogain_status [i ] =
2888
- SCARLETT2_AUTOGAIN_STATUS_UNKNOWN ;
2896
+ ARRAY_SIZE ( scarlett2_autogain_status_texts ) - 1 ;
2889
2897
2890
2898
return 0 ;
2891
2899
}
@@ -3111,12 +3119,10 @@ static int scarlett2_autogain_switch_ctl_put(
3111
3119
static int scarlett2_autogain_status_ctl_info (
3112
3120
struct snd_kcontrol * kctl , struct snd_ctl_elem_info * uinfo )
3113
3121
{
3114
- static const char * const values [SCARLETT2_AUTOGAIN_STATUS_COUNT ] = {
3115
- "Stopped" , "Running" , "Failed" , "Cancelled" , "Unknown"
3116
- };
3117
-
3118
3122
return snd_ctl_enum_info (
3119
- uinfo , 1 , SCARLETT2_AUTOGAIN_STATUS_COUNT , values );
3123
+ uinfo , 1 ,
3124
+ ARRAY_SIZE (scarlett2_autogain_status_texts ),
3125
+ scarlett2_autogain_status_texts );
3120
3126
}
3121
3127
3122
3128
static const struct snd_kcontrol_new scarlett2_autogain_switch_ctl = {
0 commit comments