Commit 3b9e3720 authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai
Browse files

ALSA: usb-audio: scarlett2: Split up sw_hw_enum_ctl_put()



Split part of scarlett2_sw_hw_enum_ctl_put() out into
scarlett2_sw_hw_change() so that the code which actually makes the
change is available in its own function. This will be used by the
speaker switching support which needs to set the SW/HW switch to HW
when speaker switching is enabled.

Signed-off-by: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/f2cf91841ba067b490e7709bc4b14f4532b4ddd5.1624379707.git.g@b4.vu


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9cfe1276
......@@ -1904,23 +1904,12 @@ static void scarlett2_vol_ctl_set_writable(struct usb_mixer_interface *mixer,
&private->mute_ctls[index]->id);
}
static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *ucontrol)
static int scarlett2_sw_hw_change(struct usb_mixer_interface *mixer,
int ctl_index, int val)
{
struct usb_mixer_elem_info *elem = kctl->private_data;
struct usb_mixer_interface *mixer = elem->head.mixer;
struct scarlett2_data *private = mixer->private_data;
int ctl_index = elem->control;
int index = line_out_remap(private, ctl_index);
int oval, val, err = 0;
mutex_lock(&private->data_mutex);
oval = private->vol_sw_hw_switch[index];
val = !!ucontrol->value.enumerated.item[0];
if (oval == val)
goto unlock;
int err;
private->vol_sw_hw_switch[index] = val;
......@@ -1938,18 +1927,39 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
mixer, SCARLETT2_CONFIG_LINE_OUT_VOLUME,
index, private->master_vol - SCARLETT2_VOLUME_BIAS);
if (err < 0)
goto unlock;
return err;
/* Set SW mute to current HW mute */
err = scarlett2_usb_set_config(
mixer, SCARLETT2_CONFIG_MUTE_SWITCH,
index, private->dim_mute[SCARLETT2_BUTTON_MUTE]);
if (err < 0)
goto unlock;
return err;
/* Send SW/HW switch change to the device */
err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
index, val);
return scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
index, val);
}
static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *ucontrol)
{
struct usb_mixer_elem_info *elem = kctl->private_data;
struct usb_mixer_interface *mixer = elem->head.mixer;
struct scarlett2_data *private = mixer->private_data;
int ctl_index = elem->control;
int index = line_out_remap(private, ctl_index);
int oval, val, err = 0;
mutex_lock(&private->data_mutex);
oval = private->vol_sw_hw_switch[index];
val = !!ucontrol->value.enumerated.item[0];
if (oval == val)
goto unlock;
err = scarlett2_sw_hw_change(mixer, ctl_index, val);
if (err == 0)
err = 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment