Commit 06250c89 authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai

ALSA: usb-audio: scarlett2: Add scarlett2_vol_ctl_write() helper

Add helper function for setting the read/write status of a volume
control. This will simplify the upcoming mute control support.
Signed-off-by: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/00dd57e1abb3fa379fb51d4ac8537dbddc09f0ea.1624294591.git.g@b4.vuSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 904e6da1
......@@ -1344,6 +1344,24 @@ static int scarlett2_sw_hw_enum_ctl_get(struct snd_kcontrol *kctl,
return 0;
}
static void scarlett2_vol_ctl_set_writable(struct usb_mixer_interface *mixer,
int index, int value)
{
struct scarlett2_data *private = mixer->private_data;
/* Set/Clear write bit */
if (value)
private->vol_ctls[index]->vd[0].access |=
SNDRV_CTL_ELEM_ACCESS_WRITE;
else
private->vol_ctls[index]->vd[0].access &=
~SNDRV_CTL_ELEM_ACCESS_WRITE;
/* Notify of write bit change */
snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_INFO,
&private->vol_ctls[index]->id);
}
static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *ucontrol)
{
......@@ -1367,12 +1385,7 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
/* Change access mode to RO (hardware controlled volume)
* or RW (software controlled volume)
*/
if (val)
private->vol_ctls[index]->vd[0].access &=
~SNDRV_CTL_ELEM_ACCESS_WRITE;
else
private->vol_ctls[index]->vd[0].access |=
SNDRV_CTL_ELEM_ACCESS_WRITE;
scarlett2_vol_ctl_set_writable(mixer, index, !val);
/* Reset volume to master volume */
private->vol[index] = private->master_vol;
......@@ -1384,10 +1397,6 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl,
if (err < 0)
goto unlock;
/* Notify of RO/RW change */
snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_INFO,
&private->vol_ctls[index]->id);
/* Send SW/HW switch change to the device */
err = scarlett2_usb_set_config(mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
index, val);
......@@ -1620,8 +1629,7 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer)
/* Make the fader read-only if the SW/HW switch is set to HW */
if (private->vol_sw_hw_switch[i])
private->vol_ctls[i]->vd[0].access &=
~SNDRV_CTL_ELEM_ACCESS_WRITE;
scarlett2_vol_ctl_set_writable(mixer, i, 0);
/* SW/HW Switch */
if (info->line_out_hw_vol) {
......
Markdown is supported
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