From: "Geoffrey D. Bennett" <g@b4.vu>
To: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>
Cc: Hin-Tak Leung <htl10@users.sourceforge.net>,
Vladimir Sadovnikov <sadko4u@gmail.com>
Subject: [PATCH 06/14] ALSA: usb-audio: scarlett2: Remove redundant info->button_count
Date: Mon, 21 Jun 2021 02:16:34 +0930 [thread overview]
Message-ID: <20210620164634.GA9193@m.b4.vu> (raw)
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: Geoffrey D. Bennett <g@b4.vu>
---
sound/usb/mixer_scarlett_gen2.c | 41 ++++++++++++++++++---------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
index 3225ec709d98..043b0929ad9d 100644
--- a/sound/usb/mixer_scarlett_gen2.c
+++ b/sound/usb/mixer_scarlett_gen2.c
@@ -218,7 +218,6 @@ struct scarlett2_ports {
struct scarlett2_device_info {
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 pad_input_count; /* inputs with pad selectable */
const char * const line_out_descrs[SCARLETT2_ANALOGUE_MAX];
@@ -370,9 +369,6 @@ static const struct scarlett2_device_info s18i20_gen2_info = {
*/
.line_out_hw_vol = 1,
- /* Mute and dim buttons */
- .button_count = 2,
-
.line_out_descrs = {
"Monitor L",
"Monitor R",
@@ -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)
{
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;
int num_line_out =
ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT];
@@ -1129,8 +1126,9 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer)
private->vol[i] = private->master_vol;
}
- for (i = 0; i < private->info->button_count; i++)
- private->buttons[i] = !!volume_status.buttons[i];
+ if (info->line_out_hw_vol)
+ for (i = 0; i < SCARLETT2_BUTTON_MAX; i++)
+ private->buttons[i] = !!volume_status.buttons[i];
return 0;
}
@@ -1547,13 +1545,15 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer)
}
/* Add HW button controls */
- for (i = 0; i < private->info->button_count; i++) {
- err = scarlett2_add_new_ctl(mixer, &scarlett2_button_ctl,
- i, 1, scarlett2_button_names[i],
- &private->button_ctls[i]);
- if (err < 0)
- return err;
- }
+ if (info->line_out_hw_vol)
+ for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) {
+ err = scarlett2_add_new_ctl(
+ mixer, &scarlett2_button_ctl,
+ i, 1, scarlett2_button_names[i],
+ &private->button_ctls[i]);
+ if (err < 0)
+ return err;
+ }
return 0;
}
@@ -1961,8 +1961,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
private->vol[i] = volume;
}
- for (i = 0; i < info->button_count; i++)
- private->buttons[i] = !!volume_status.buttons[i];
+ if (info->line_out_hw_vol)
+ for (i = 0; i < SCARLETT2_BUTTON_MAX; i++)
+ private->buttons[i] = !!volume_status.buttons[i];
for (i = 0; i < num_mixer_out; i++) {
err = scarlett2_usb_get_mix(mixer, i);
@@ -2001,11 +2002,15 @@ static void scarlett2_mixer_interrupt_button_change(
struct usb_mixer_interface *mixer)
{
struct scarlett2_mixer_data *private = mixer->private_data;
+ const struct scarlett2_device_info *info = private->info;
int i;
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,
&private->button_ctls[i]->id);
}
@@ -2109,7 +2114,7 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer,
return err;
/* 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);
if (err < 0)
return err;
--
2.31.1
reply other threads:[~2021-06-20 16:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210620164634.GA9193@m.b4.vu \
--to=g@b4.vu \
--cc=alsa-devel@alsa-project.org \
--cc=htl10@users.sourceforge.net \
--cc=sadko4u@gmail.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox