Commit 03bdbcf0 authored by Geoffrey D. Bennett's avatar Geoffrey D. Bennett Committed by Takashi Iwai

ALSA: usb-audio: scarlett2: Remove redundant info->button_count

The per-model button_count value was used to determine whether
dim/mute controls should be added, but these are present iff
line_out_hw_vol is true. Remove button_count and replace with
SCARLETT2_BUTTON_MAX and a check for line_out_hw_vol true.
Signed-off-by: default avatarGeoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164634.GA9193@m.b4.vuSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 411b22ed
...@@ -218,7 +218,6 @@ struct scarlett2_ports { ...@@ -218,7 +218,6 @@ struct scarlett2_ports {
struct scarlett2_device_info { struct scarlett2_device_info {
u8 line_out_hw_vol; /* line out hw volume is sw controlled */ u8 line_out_hw_vol; /* line out hw volume is sw controlled */
u8 button_count; /* number of buttons */
u8 level_input_count; /* inputs with level selectable */ u8 level_input_count; /* inputs with level selectable */
u8 pad_input_count; /* inputs with pad selectable */ u8 pad_input_count; /* inputs with pad selectable */
const char * const line_out_descrs[SCARLETT2_ANALOGUE_MAX]; const char * const line_out_descrs[SCARLETT2_ANALOGUE_MAX];
...@@ -370,9 +369,6 @@ static const struct scarlett2_device_info s18i20_gen2_info = { ...@@ -370,9 +369,6 @@ static const struct scarlett2_device_info s18i20_gen2_info = {
*/ */
.line_out_hw_vol = 1, .line_out_hw_vol = 1,
/* Mute and dim buttons */
.button_count = 2,
.line_out_descrs = { .line_out_descrs = {
"Monitor L", "Monitor L",
"Monitor R", "Monitor R",
...@@ -1108,7 +1104,8 @@ static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer, ...@@ -1108,7 +1104,8 @@ static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer,
static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) static int scarlett2_update_volumes(struct usb_mixer_interface *mixer)
{ {
struct scarlett2_mixer_data *private = mixer->private_data; struct scarlett2_mixer_data *private = mixer->private_data;
const struct scarlett2_ports *ports = private->info->ports; const struct scarlett2_device_info *info = private->info;
const struct scarlett2_ports *ports = info->ports;
struct scarlett2_usb_volume_status volume_status; struct scarlett2_usb_volume_status volume_status;
int num_line_out = int num_line_out =
ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT]; ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT];
...@@ -1129,8 +1126,9 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) ...@@ -1129,8 +1126,9 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer)
private->vol[i] = private->master_vol; private->vol[i] = private->master_vol;
} }
for (i = 0; i < private->info->button_count; i++) if (info->line_out_hw_vol)
private->buttons[i] = !!volume_status.buttons[i]; for (i = 0; i < SCARLETT2_BUTTON_MAX; i++)
private->buttons[i] = !!volume_status.buttons[i];
return 0; return 0;
} }
...@@ -1547,13 +1545,15 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer) ...@@ -1547,13 +1545,15 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer)
} }
/* Add HW button controls */ /* Add HW button controls */
for (i = 0; i < private->info->button_count; i++) { if (info->line_out_hw_vol)
err = scarlett2_add_new_ctl(mixer, &scarlett2_button_ctl, for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) {
i, 1, scarlett2_button_names[i], err = scarlett2_add_new_ctl(
&private->button_ctls[i]); mixer, &scarlett2_button_ctl,
if (err < 0) i, 1, scarlett2_button_names[i],
return err; &private->button_ctls[i]);
} if (err < 0)
return err;
}
return 0; return 0;
} }
...@@ -1961,8 +1961,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) ...@@ -1961,8 +1961,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
private->vol[i] = volume; private->vol[i] = volume;
} }
for (i = 0; i < info->button_count; i++) if (info->line_out_hw_vol)
private->buttons[i] = !!volume_status.buttons[i]; for (i = 0; i < SCARLETT2_BUTTON_MAX; i++)
private->buttons[i] = !!volume_status.buttons[i];
for (i = 0; i < num_mixer_out; i++) { for (i = 0; i < num_mixer_out; i++) {
err = scarlett2_usb_get_mix(mixer, i); err = scarlett2_usb_get_mix(mixer, i);
...@@ -2001,11 +2002,15 @@ static void scarlett2_mixer_interrupt_button_change( ...@@ -2001,11 +2002,15 @@ static void scarlett2_mixer_interrupt_button_change(
struct usb_mixer_interface *mixer) struct usb_mixer_interface *mixer)
{ {
struct scarlett2_mixer_data *private = mixer->private_data; struct scarlett2_mixer_data *private = mixer->private_data;
const struct scarlett2_device_info *info = private->info;
int i; int i;
private->vol_updated = 1; private->vol_updated = 1;
for (i = 0; i < private->info->button_count; i++) if (!info->line_out_hw_vol)
return;
for (i = 0; i < SCARLETT2_BUTTON_MAX; i++)
snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
&private->button_ctls[i]->id); &private->button_ctls[i]->id);
} }
...@@ -2109,7 +2114,7 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, ...@@ -2109,7 +2114,7 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer,
return err; return err;
/* Set up the interrupt polling if there are hardware buttons */ /* Set up the interrupt polling if there are hardware buttons */
if (info->button_count) { if (info->line_out_hw_vol) {
err = scarlett2_mixer_status_create(mixer); err = scarlett2_mixer_status_create(mixer);
if (err < 0) if (err < 0)
return err; return err;
......
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