Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values

The meanings of the raw_auto_gain_status values were originally
guessed through experimentation, but the official names have now been
discovered. Update the autogain status control strings accordingly.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: 0a995e38dc44 ("ALSA: scarlett2: Add support for software-controllable input gain")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <8bd12a5e7dc714801dd9887c4bc5cb35c384e27c.1710047969.git.g@b4.vu>

authored by

Geoffrey D. Bennett and committed by
Takashi Iwai
be157c46 6ef1f08b

+34 -28
+34 -28
sound/usb/mixer_scarlett2.c
··· 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 */ ··· 2843 2835 { 2844 2836 int i; 2845 2837 2838 + /* autogain_status[] is 0 if autogain is running */ 2846 2839 for (i = 0; i < private->info->gain_input_count; i++) 2847 - if (private->autogain_status[i] == 2848 - SCARLETT2_AUTOGAIN_STATUS_RUNNING) 2840 + if (!private->autogain_status[i]) 2849 2841 return 1; 2850 2842 2851 2843 return 0; ··· 2875 2867 return err; 2876 2868 2877 2869 /* Translate autogain_switch and raw_autogain_status into 2878 - * autogain_status 2870 + * autogain_status. 2871 + * 2872 + * When autogain_switch[] is set, the status is the first 2873 + * element in scarlett2_autogain_status_texts[] (Running). The 2874 + * subsequent elements correspond to the status value from the 2875 + * device (raw_autogain_status[]) + 1. The last element is 2876 + * "Invalid", in case the device reports a status outside the 2877 + * range of scarlett2_autogain_status_texts[]. 2879 2878 */ 2880 2879 for (i = 0; i < info->gain_input_count; i++) 2881 2880 if (private->autogain_switch[i]) 2881 + private->autogain_status[i] = 0; 2882 + else if (raw_autogain_status[i] < 2883 + ARRAY_SIZE(scarlett2_autogain_status_texts) - 1) 2882 2884 private->autogain_status[i] = 2883 - SCARLETT2_AUTOGAIN_STATUS_RUNNING; 2884 - else if (raw_autogain_status[i] == 0) 2885 - private->autogain_status[i] = 2886 - SCARLETT2_AUTOGAIN_STATUS_STOPPED; 2887 - else if (raw_autogain_status[i] >= 2 && 2888 - raw_autogain_status[i] <= 5) 2889 - private->autogain_status[i] = 2890 - SCARLETT2_AUTOGAIN_STATUS_FAILED; 2891 - else if (raw_autogain_status[i] == 6) 2892 - private->autogain_status[i] = 2893 - SCARLETT2_AUTOGAIN_STATUS_CANCELLED; 2885 + raw_autogain_status[i] + 1; 2894 2886 else 2895 2887 private->autogain_status[i] = 2896 - SCARLETT2_AUTOGAIN_STATUS_UNKNOWN; 2888 + ARRAY_SIZE(scarlett2_autogain_status_texts) - 1; 2897 2889 2898 2890 return 0; 2899 2891 } ··· 3119 3111 static int scarlett2_autogain_status_ctl_info( 3120 3112 struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) 3121 3113 { 3122 - static const char *const values[SCARLETT2_AUTOGAIN_STATUS_COUNT] = { 3123 - "Stopped", "Running", "Failed", "Cancelled", "Unknown" 3124 - }; 3125 - 3126 3114 return snd_ctl_enum_info( 3127 - uinfo, 1, SCARLETT2_AUTOGAIN_STATUS_COUNT, values); 3115 + uinfo, 1, 3116 + ARRAY_SIZE(scarlett2_autogain_status_texts), 3117 + scarlett2_autogain_status_texts); 3128 3118 } 3129 3119 3130 3120 static const struct snd_kcontrol_new scarlett2_autogain_switch_ctl = {