Commit 90d8fef8 authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai

ALSA: scarlett2: Allow for interfaces without per-channel volume

Currently-supported interfaces with a mixer have per-channel volume
controls, but this changes in Gen 4. Add a check so that the Playback
Volume and associated controls don't get created unless the
SCARLETT2_CONFIG_LINE_OUT_VOLUME config item is present.
Signed-off-by: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/30f68cb311e27f2cc1351cb846218f7248a90263.1703444932.git.g@b4.vuSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c6b3e71e
......@@ -3726,6 +3726,13 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer)
return err;
}
/* Remaining controls are only applicable if the device
* has per-channel line-out volume controls.
*/
if (!scarlett2_has_config_item(private,
SCARLETT2_CONFIG_LINE_OUT_VOLUME))
return 0;
/* Add volume controls */
for (i = 0; i < private->num_line_out; i++) {
int index = line_out_remap(private, i);
......@@ -4569,7 +4576,6 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
{
struct scarlett2_data *private = mixer->private_data;
int err, i;
s16 sw_vol[SCARLETT2_ANALOGUE_MAX];
if (scarlett2_has_config_item(private, SCARLETT2_CONFIG_MSD_SWITCH)) {
err = scarlett2_usb_get_config(
......@@ -4608,41 +4614,47 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
if (err < 0)
return err;
/* read SW line out volume */
err = scarlett2_usb_get_config(
mixer, SCARLETT2_CONFIG_LINE_OUT_VOLUME,
private->num_line_out, &sw_vol);
if (err < 0)
return err;
for (i = 0; i < private->num_line_out; i++)
private->vol[i] = clamp(
sw_vol[i] + SCARLETT2_VOLUME_BIAS,
0, SCARLETT2_VOLUME_BIAS);
if (scarlett2_has_config_item(private,
SCARLETT2_CONFIG_LINE_OUT_VOLUME)) {
s16 sw_vol[SCARLETT2_ANALOGUE_MAX];
/* read SW mute */
err = scarlett2_usb_get_config(
mixer, SCARLETT2_CONFIG_MUTE_SWITCH,
private->num_line_out, &private->mute_switch);
if (err < 0)
return err;
/* read SW line out volume */
err = scarlett2_usb_get_config(
mixer, SCARLETT2_CONFIG_LINE_OUT_VOLUME,
private->num_line_out, &sw_vol);
if (err < 0)
return err;
for (i = 0; i < private->num_line_out; i++)
private->mute_switch[i] =
!!private->mute_switch[i];
for (i = 0; i < private->num_line_out; i++)
private->vol[i] = clamp(
sw_vol[i] + SCARLETT2_VOLUME_BIAS,
0, SCARLETT2_VOLUME_BIAS);
/* read SW/HW switches */
if (scarlett2_has_config_item(private,
SCARLETT2_CONFIG_SW_HW_SWITCH)) {
/* read SW mute */
err = scarlett2_usb_get_config(
mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
private->num_line_out, &private->vol_sw_hw_switch);
mixer, SCARLETT2_CONFIG_MUTE_SWITCH,
private->num_line_out, &private->mute_switch);
if (err < 0)
return err;
for (i = 0; i < private->num_line_out; i++)
private->vol_sw_hw_switch[i] =
!!private->vol_sw_hw_switch[i];
private->mute_switch[i] =
!!private->mute_switch[i];
/* read SW/HW switches */
if (scarlett2_has_config_item(private,
SCARLETT2_CONFIG_SW_HW_SWITCH)) {
err = scarlett2_usb_get_config(
mixer, SCARLETT2_CONFIG_SW_HW_SWITCH,
private->num_line_out,
&private->vol_sw_hw_switch);
if (err < 0)
return err;
for (i = 0; i < private->num_line_out; i++)
private->vol_sw_hw_switch[i] =
!!private->vol_sw_hw_switch[i];
}
}
err = scarlett2_update_volumes(mixer);
......
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