ALSA: scarlett2: Infer standalone switch from config items
authorGeoffrey D. Bennett <g@b4.vu>
Sun, 24 Dec 2023 19:21:40 +0000 (05:51 +1030)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 Dec 2023 14:41:22 +0000 (15:41 +0100)
Rather than assuming the standalone switch is present for all devices
with a mixer, instead check for the presence of the
SCARLETT2_CONFIG_STANDALONE_SWITCH config item.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/59c30885b02d65feaab2c338cf46889d72d01813.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer_scarlett2.c

index 703cd65e42f4a7f95c47107c40079a7205584420..064d6d34a8ab8ad2044aa37891c65400f209baf0 100644 (file)
@@ -4244,7 +4244,8 @@ static int scarlett2_add_standalone_ctl(struct usb_mixer_interface *mixer)
 {
        struct scarlett2_data *private = mixer->private_data;
 
-       if (private->info->config_set == SCARLETT2_CONFIG_SET_GEN_3A)
+       if (!scarlett2_has_config_item(private,
+                                      SCARLETT2_CONFIG_STANDALONE_SWITCH))
                return 0;
 
        /* Add standalone control */
@@ -4512,11 +4513,14 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer)
        if (info->config_set == SCARLETT2_CONFIG_SET_GEN_3A)
                return 0;
 
-       err = scarlett2_usb_get_config(
-               mixer, SCARLETT2_CONFIG_STANDALONE_SWITCH,
-               1, &private->standalone_switch);
-       if (err < 0)
-               return err;
+       if (scarlett2_has_config_item(private,
+                                     SCARLETT2_CONFIG_STANDALONE_SWITCH)) {
+               err = scarlett2_usb_get_config(
+                       mixer, SCARLETT2_CONFIG_STANDALONE_SWITCH,
+                       1, &private->standalone_switch);
+               if (err < 0)
+                       return err;
+       }
 
        err = scarlett2_update_sync(mixer);
        if (err < 0)