Skip to content

Commit 2190b9a

Browse files
geoffreybennetttiwai
authored andcommitted
ALSA: scarlett2: Allow passing any output to line_out_remap()
Line outputs 3 & 4 on the Gen 3 18i8 are internally the analogue 7 and 8 outputs, and this renumbering is hidden from the user by line_out_remap(). By allowing higher values (representing non-analogue outputs) to be passed to line_out_remap(), repeated code from scarlett2_mux_src_enum_ctl_get() and scarlett2_mux_src_enum_ctl_put() can be removed. Signed-off-by: Geoffrey D. Bennett <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 701949c commit 2190b9a

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

sound/usb/mixer_scarlett2.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,9 +2026,16 @@ static int scarlett2_master_volume_ctl_get(struct snd_kcontrol *kctl,
20262026
static int line_out_remap(struct scarlett2_data *private, int index)
20272027
{
20282028
const struct scarlett2_device_info *info = private->info;
2029+
const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count;
2030+
int line_out_count =
2031+
port_count[SCARLETT2_PORT_TYPE_ANALOGUE][SCARLETT2_PORT_OUT];
20292032

20302033
if (!info->line_out_remap_enable)
20312034
return index;
2035+
2036+
if (index >= line_out_count)
2037+
return index;
2038+
20322039
return info->line_out_remap[index];
20332040
}
20342041

@@ -3513,14 +3520,7 @@ static int scarlett2_mux_src_enum_ctl_get(struct snd_kcontrol *kctl,
35133520
struct usb_mixer_elem_info *elem = kctl->private_data;
35143521
struct usb_mixer_interface *mixer = elem->head.mixer;
35153522
struct scarlett2_data *private = mixer->private_data;
3516-
const struct scarlett2_device_info *info = private->info;
3517-
const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count;
3518-
int line_out_count =
3519-
port_count[SCARLETT2_PORT_TYPE_ANALOGUE][SCARLETT2_PORT_OUT];
3520-
int index = elem->control;
3521-
3522-
if (index < line_out_count)
3523-
index = line_out_remap(private, index);
3523+
int index = line_out_remap(private, elem->control);
35243524

35253525
mutex_lock(&private->data_mutex);
35263526
if (private->mux_updated)
@@ -3537,16 +3537,9 @@ static int scarlett2_mux_src_enum_ctl_put(struct snd_kcontrol *kctl,
35373537
struct usb_mixer_elem_info *elem = kctl->private_data;
35383538
struct usb_mixer_interface *mixer = elem->head.mixer;
35393539
struct scarlett2_data *private = mixer->private_data;
3540-
const struct scarlett2_device_info *info = private->info;
3541-
const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count;
3542-
int line_out_count =
3543-
port_count[SCARLETT2_PORT_TYPE_ANALOGUE][SCARLETT2_PORT_OUT];
3544-
int index = elem->control;
3540+
int index = line_out_remap(private, elem->control);
35453541
int oval, val, err = 0;
35463542

3547-
if (index < line_out_count)
3548-
index = line_out_remap(private, index);
3549-
35503543
mutex_lock(&private->data_mutex);
35513544

35523545
oval = private->mux[index];

0 commit comments

Comments
 (0)