ALSA: scarlett2: Scarlett 4th Gen fixes for 6.8
Subsystems (2)
Geoffrey D. Bennett
maintainerPATCH 1/3 ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
In reply to Geoffrey D. BennettThe value currently being read to determine the low-voltage state is actually the front panel state. Fix the code to use the correct offset for the low-voltage state.
--- sound/usb/mixer_scarlett2.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
sound/usb/mixer_scarlett2.c +7 -8
@@ -415,7 +415,7 @@ enum {SCARLETT2_CONFIG_INPUT_SELECT_SWITCH ,SCARLETT2_CONFIG_INPUT_LINK_SWITCH ,SCARLETT2_CONFIG_POWER_EXT , -SCARLETT2_CONFIG_POWER_STATUS , +SCARLETT2_CONFIG_POWER_LOW ,SCARLETT2_CONFIG_PCM_INPUT_SWITCH ,SCARLETT2_CONFIG_DIRECT_MONITOR_GAIN ,SCARLETT2_CONFIG_COUNT
@@ -723,8 +723,8 @@ static const struct scarlett2_config_set scarlett2_config_set_gen4_4i4 = { [SCARLETT2_CONFIG_POWER_EXT ] = { .offset = 0x168 }, - [SCARLETT2_CONFIG_POWER_STATUS ] = { - .offset =0x66 } + [SCARLETT2_CONFIG_POWER_LOW ] = { + .offset =0x16d } } };
@@ -6294,8 +6294,7 @@ static int scarlett2_update_power_status(struct usb_mixer_interface *mixer) {struct scarlett2_data *private = mixer->private_data;int err; -u8 power_ext; -u8 power_status; +u8 power_ext, power_low; private->power_status_updated =0 ;
@@ -6304,12 +6303,12 @@ static int scarlett2_update_power_status(struct usb_mixer_interface *mixer)if (err <0 )return err; - err =scarlett2_usb_get_config (mixer,SCARLETT2_CONFIG_POWER_STATUS , -1 , &power_status); + err =scarlett2_usb_get_config (mixer,SCARLETT2_CONFIG_POWER_LOW , +1 , &power_low);if (err <0 )return err; -if (power_status >1 ) +if (power_low) private->power_status =SCARLETT2_POWER_STATUS_FAIL ;else if (power_ext) private->power_status =SCARLETT2_POWER_STATUS_EXT ;
Signature · 1 line
2.43.0
Geoffrey D. Bennett
maintainerPATCH 2/3 ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
In reply to Geoffrey D. BennettThe 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.
--- sound/usb/mixer_scarlett2.c | 62 ++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 28 deletions(-)
sound/usb/mixer_scarlett2.c +34 -28
@@ -284,14 +284,22 @@ static const char *const scarlett2_dim_mute_names[SCARLETT2_DIM_MUTE_COUNT] = { "Mute Playback Switch", "Dim Playback Switch" }; -/* Autogain Status Values */ -enum { -SCARLETT2_AUTOGAIN_STATUS_STOPPED , -SCARLETT2_AUTOGAIN_STATUS_RUNNING , -SCARLETT2_AUTOGAIN_STATUS_FAILED , -SCARLETT2_AUTOGAIN_STATUS_CANCELLED , -SCARLETT2_AUTOGAIN_STATUS_UNKNOWN , -SCARLETT2_AUTOGAIN_STATUS_COUNT +/* The autogain_status is set based on the autogain_switch and +* raw_autogain_status values. +* +* If autogain_switch is set, autogain_status is set to 0 (Running). +* The other status values are from the raw_autogain_status value + 1. +*/ +static const char *const scarlett2_autogain_status_texts[] = { +"Running" , +"Success" , +"SuccessDRover" , +"WarnMinGainLimit" , +"FailDRunder" , +"FailMaxGainLimit" , +"FailClipped" , +"Cancelled" , +"Invalid" };/* Power Status Values */
@@ -2835,9 +2843,9 @@ static int scarlett2_autogain_is_running(struct scarlett2_data *private) {int i; +/* autogain_status[] is 0 if autogain is running */ for (i =0 ; i < private->info->gain_input_count; i++) -if (private->autogain_status[i] == -SCARLETT2_AUTOGAIN_STATUS_RUNNING ) +if (!private->autogain_status[i])return 1 ;return 0 ;
@@ -2867,25 +2875,25 @@ static int scarlett2_update_autogain(struct usb_mixer_interface *mixer)return err;/* Translate autogain_switch and raw_autogain_status into -* autogain_status +* autogain_status. +* +* When autogain_switch[] is set, the status is the first +* element in scarlett2_autogain_status_texts[] (Running). The +* subsequent elements correspond to the status value from the +* device (raw_autogain_status[]) + 1. The last element is +* "Invalid", in case the device reports a status outside the +* range of scarlett2_autogain_status_texts[]. */ for (i =0 ; i < info->gain_input_count; i++)if (private->autogain_switch[i]) + private->autogain_status[i] =0 ; +else if (raw_autogain_status[i] < +ARRAY_SIZE (scarlett2_autogain_status_texts) -1 ) private->autogain_status[i] = -SCARLETT2_AUTOGAIN_STATUS_RUNNING ; -else if (raw_autogain_status[i] ==0 ) - private->autogain_status[i] = -SCARLETT2_AUTOGAIN_STATUS_STOPPED ; -else if (raw_autogain_status[i] >=2 && - raw_autogain_status[i] <=5 ) - private->autogain_status[i] = -SCARLETT2_AUTOGAIN_STATUS_FAILED ; -else if (raw_autogain_status[i] ==6 ) - private->autogain_status[i] = -SCARLETT2_AUTOGAIN_STATUS_CANCELLED ; + raw_autogain_status[i] +1 ;else private->autogain_status[i] = -SCARLETT2_AUTOGAIN_STATUS_UNKNOWN ; +ARRAY_SIZE (scarlett2_autogain_status_texts) -1 ;return 0 ; }
@@ -3111,12 +3119,10 @@ static int scarlett2_autogain_switch_ctl_put(static int scarlett2_autogain_status_ctl_info (struct snd_kcontrol *kctl,struct snd_ctl_elem_info *uinfo) { -static const char *const values[SCARLETT2_AUTOGAIN_STATUS_COUNT ] = { -"Stopped" ,"Running" ,"Failed" ,"Cancelled" ,"Unknown" - }; -return snd_ctl_enum_info ( - uinfo,1 ,SCARLETT2_AUTOGAIN_STATUS_COUNT , values); + uinfo,1 , +ARRAY_SIZE (scarlett2_autogain_status_texts), + scarlett2_autogain_status_texts); }static const struct snd_kcontrol_new scarlett2_autogain_switch_ctl = {
Signature · 1 line
2.43.0
Geoffrey D. Bennett
maintainerPATCH 3/3 ALSA: scarlett2: Fix Scarlett 4th Gen input gain range
In reply to Geoffrey D. BennettThe input gain range TLV was declared as -70dB to 0dB, but the preamp gain range is actually 0dB to +70dB. Rename SCARLETT2_GAIN_BIAS to SCARLETT2_MAX_GAIN and update the TLV to fix.
--- sound/usb/mixer_scarlett2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/usb/mixer_scarlett2.c +5 -3
@@ -173,7 +173,9 @@/* some gui mixers can't handle negative ctl values */ #define SCARLETT2_VOLUME_BIAS 127 -#define SCARLETT2_GAIN_BIAS 70 + +/* maximum preamp input gain */ +#define SCARLETT2_MAX_GAIN 70/* mixer range from -80dB to +6dB in 0.5dB steps */ #define SCARLETT2_MIXER_MIN_DB -80
@@ -3464,7 +3466,7 @@ static int scarlett2_input_gain_ctl_info(struct snd_kcontrol *kctl, uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; uinfo->count = elem->channels; uinfo->value.integer.min =0 ; - uinfo->value.integer.max =SCARLETT2_GAIN_BIAS ; + uinfo->value.integer.max =SCARLETT2_MAX_GAIN ; uinfo->value.integer.step =1 ; unlock:
@@ -3541,7 +3543,7 @@ static int scarlett2_input_gain_ctl_put(struct snd_kcontrol *kctl, }static const DECLARE_TLV_DB_MINMAX ( - db_scale_scarlett2_gain, -SCARLETT2_GAIN_BIAS * 100, 0 + db_scale_scarlett2_gain, 0, SCARLETT2_MAX_GAIN * 100 );static const struct snd_kcontrol_new scarlett2_input_gain_ctl = {
Signature · 1 line
2.43.0
Geoffrey D. Bennett
maintainercover ALSA: scarlett2: Scarlett 4th Gen fixes for 6.8
Hi Takashi,
I have three minor fixes for the Scarlett 4th Gen driver in 6.8:
- The low-voltage indication is now being read from the correct offset
- The autogain status values are now all correctly interpreted
- The input gain range is now correct
Regards,
Geoffrey.
Geoffrey D. Bennett (3):
ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
ALSA: scarlett2: Fix Scarlett 4th Gen input gain range
sound/usb/mixer_scarlett2.c | 85 ++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 39 deletions(-)
Signature · 1 line
2.43.0
Takashi Iwai
AppliedQuoted 8 lines · Geoffrey D. Bennett
Hi Takashi,
I have three minor fixes for the Scarlett 4th Gen driver in 6.8:
- The low-voltage indication is now being read from the correct offset
- The autogain status values are now all correctly interpreted
- The input gain range is now correct
Quoted 7 lines
Regards,
Geoffrey.Geoffrey D. Bennett (3):
ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
ALSA: scarlett2: Fix Scarlett 4th Gen input gain range
Applied all patches now. Thanks.
Takashi
Geoffrey D. Bennett
maintainerQuoted 13 lines · Takashi Iwai
Quoted 11 lines · Geoffrey D. Bennett
Hi Takashi,
I have three minor fixes for the Scarlett 4th Gen driver in 6.8:
- The low-voltage indication is now being read from the correct offset
- The autogain status values are now all correctly interpreted
- The input gain range is now correctRegards,
Geoffrey.
Quoted 6 lines
Quoted 4 lines
Geoffrey D. Bennett (3):
ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
ALSA: scarlett2: Fix Scarlett 4th Gen input gain rangeApplied all patches now. Thanks.
Hi Takashi,
Sorry for the inconvience, I have a v2 of the 3rd patch "Fix Scarlett 4th Gen input gain range" which I will send in a moment. Please let me know if you prefer a patch on top of the above rather than a replacement patch.
Thanks,
Geoffrey.
Quoted 20 lines · Geoffrey D. Bennett
Quoted 18 lines · Takashi Iwai
Quoted 15 lines · Geoffrey D. Bennett
Hi Takashi,
I have three minor fixes for the Scarlett 4th Gen driver in 6.8:
- The low-voltage indication is now being read from the correct offset
- The autogain status values are now all correctly interpreted
- The input gain range is now correctRegards,
Geoffrey.Geoffrey D. Bennett (3):
ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
ALSA: scarlett2: Fix Scarlett 4th Gen input gain range
Quoted 8 lines
Quoted 1 line
Applied all patches now. Thanks.
Hi Takashi,
Sorry for the inconvience, I have a v2 of the 3rd patch "Fix Scarlett 4th Gen input gain range" which I will send in a moment. Please let me know if you prefer a patch on top of the above rather than a replacement patch.
Yes, please send an incremental fix.
You can get the commits in for-linus branch of sound.git tree.
thanks,
Takashi
Geoffrey D. Bennett
maintainerQuoted 26 lines · Takashi Iwai
Quoted 24 lines · Geoffrey D. Bennett
Quoted 13 lines · Takashi Iwai
Quoted 11 lines · Geoffrey D. Bennett
Hi Takashi,
I have three minor fixes for the Scarlett 4th Gen driver in 6.8:
- The low-voltage indication is now being read from the correct offset
- The autogain status values are now all correctly interpreted
- The input gain range is now correctRegards,
Geoffrey.Quoted 6 lines
Quoted 4 lines
Geoffrey D. Bennett (3):
ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
ALSA: scarlett2: Fix Scarlett 4th Gen input gain rangeApplied all patches now. Thanks.
Hi Takashi,
Quoted 7 lines
Quoted 4 lines
Sorry for the inconvience, I have a v2 of the 3rd patch "Fix Scarlett 4th Gen input gain range" which I will send in a moment. Please let me know if you prefer a patch on top of the above rather than a replacement patch.
Yes, please send an incremental fix.
You can get the commits in for-linus branch of sound.git tree.
Thanks for your patience. I have submitted an incremental fix, hopefully correct this time!