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

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.vu


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c6b3e71e
Loading
Loading
Loading
Loading
+40 −28
Original line number Diff line number Diff line
@@ -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,6 +4614,10 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
	if (err < 0)
		return err;

	if (scarlett2_has_config_item(private,
				      SCARLETT2_CONFIG_LINE_OUT_VOLUME)) {
		s16 sw_vol[SCARLETT2_ANALOGUE_MAX];

		/* read SW line out volume */
		err = scarlett2_usb_get_config(
			mixer, SCARLETT2_CONFIG_LINE_OUT_VOLUME,
@@ -4636,7 +4646,8 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
					      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);
				private->num_line_out,
				&private->vol_sw_hw_switch);
			if (err < 0)
				return err;

@@ -4644,6 +4655,7 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
				private->vol_sw_hw_switch[i] =
					!!private->vol_sw_hw_switch[i];
		}
	}

	err = scarlett2_update_volumes(mixer);
	if (err < 0)