ALSA: usb-audio: fix Pioneer DJM-850 control label info
authorNicolas MURE <nicolas.mure2019@gmail.com>
Mon, 1 Mar 2021 15:27:29 +0000 (16:27 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 2 Mar 2021 09:19:25 +0000 (10:19 +0100)
Unlike the other DJM, the value to set the "CD/LINE" and "LINE" capture
control options are inverted. This fix makes sure that the displayed
info label while using `alsamixer` matches the input switches label
on the DJM-850 mixer.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
Link: https://lore.kernel.org/r/20210301152729.18094-5-nicolas.mure2019@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer_quirks.c

index b325b6597d91ff4362e9416ac97bfa7c20f9c1ad..5b77e8140ba632b9ba8ed691b039d3a3d23f4461 100644 (file)
@@ -2693,7 +2693,7 @@ static const char *snd_djm_get_label_caplevel(u16 wvalue)
        }
 };
 
-static const char *snd_djm_get_label_cap(u16 wvalue)
+static const char *snd_djm_get_label_cap_common(u16 wvalue)
 {
        switch (wvalue & 0x00ff) {
        case SND_DJM_CAP_LINE:          return "Control Tone LINE";
@@ -2715,6 +2715,25 @@ static const char *snd_djm_get_label_cap(u16 wvalue)
        }
 };
 
+// The DJM-850 has different values for CD/LINE and LINE capture
+// control options than the other DJM declared in this file.
+static const char *snd_djm_get_label_cap_850(u16 wvalue)
+{
+       switch (wvalue & 0x00ff) {
+       case 0x00:              return "Control Tone CD/LINE";
+       case 0x01:              return "Control Tone LINE";
+       default:                return snd_djm_get_label_cap_common(wvalue);
+       }
+};
+
+static const char *snd_djm_get_label_cap(u8 device_idx, u16 wvalue)
+{
+       switch (device_idx) {
+       case SND_DJM_850_IDX:           return snd_djm_get_label_cap_850(wvalue);
+       default:                        return snd_djm_get_label_cap_common(wvalue);
+       }
+};
+
 static const char *snd_djm_get_label_pb(u16 wvalue)
 {
        switch (wvalue & 0x00ff) {
@@ -2725,11 +2744,11 @@ static const char *snd_djm_get_label_pb(u16 wvalue)
        }
 };
 
-static const char *snd_djm_get_label(u16 wvalue, u16 windex)
+static const char *snd_djm_get_label(u8 device_idx, u16 wvalue, u16 windex)
 {
        switch (windex) {
        case SND_DJM_WINDEX_CAPLVL:     return snd_djm_get_label_caplevel(wvalue);
-       case SND_DJM_WINDEX_CAP:        return snd_djm_get_label_cap(wvalue);
+       case SND_DJM_WINDEX_CAP:        return snd_djm_get_label_cap(device_idx, wvalue);
        case SND_DJM_WINDEX_PB:         return snd_djm_get_label_pb(wvalue);
        default:                        return NULL;
        }
@@ -2852,7 +2871,8 @@ static int snd_djm_controls_info(struct snd_kcontrol *kctl,
        if (info->value.enumerated.item >= noptions)
                info->value.enumerated.item = noptions - 1;
 
-       name = snd_djm_get_label(ctl->options[info->value.enumerated.item],
+       name = snd_djm_get_label(device_idx,
+                               ctl->options[info->value.enumerated.item],
                                ctl->wIndex);
        if (!name)
                return -EINVAL;