summaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorJorge Sanjuan <jorge.sanjuan@codethink.co.uk>2018-07-11 13:37:55 +0100
committerTakashi Iwai <tiwai@suse.de>2018-07-16 16:36:15 +0200
commit55b8cb46a71137aa19eba2ae5a4be384500db89e (patch)
tree5adfd2e429c8f82af43d0d4d4685728eed28f94c /sound/usb
parent8b3a087f7f6580e685a4f1ac980d07f96ad250a5 (diff)
downloadlinux-55b8cb46a71137aa19eba2ae5a4be384500db89e.tar.bz2
ALSA: usb-audio: Tidy up logic for Processing Unit min/max values
This patch refactors the processing units min/max calculation logic for the mixer controls and fixes an issue where the Mode Select checking of the Up/Down mixers doesn't differentiate between the UAC1 and UAC2 Control Selector (0x02) and the UAC3 one which is different (0x01). Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/mixer.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 87f18cb74ca3..73e811f86a95 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2376,25 +2376,49 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
cval->master_readonly = 1;
/* get min/max values */
- if (type == UAC_PROCESS_UP_DOWNMIX && cval->control == UAC_UD_MODE_SELECT) {
- __u8 *control_spec = uac_processing_unit_specific(desc, state->mixer->protocol);
- /* FIXME: hard-coded */
- cval->min = 1;
- cval->max = control_spec[0];
- cval->res = 1;
- cval->initialized = 1;
- } else {
- if (type == USB_XU_CLOCK_RATE) {
- /*
- * E-Mu USB 0404/0202/TrackerPre/0204
- * samplerate control quirk
- */
- cval->min = 0;
- cval->max = 5;
+ switch (type) {
+ case UAC_PROCESS_UP_DOWNMIX: {
+ bool mode_sel = false;
+
+ switch (state->mixer->protocol) {
+ case UAC_VERSION_1:
+ case UAC_VERSION_2:
+ default:
+ if (cval->control == UAC_UD_MODE_SELECT)
+ mode_sel = true;
+ break;
+ case UAC_VERSION_3:
+ if (cval->control == UAC3_UD_MODE_SELECT)
+ mode_sel = true;
+ break;
+ }
+
+ if (mode_sel) {
+ __u8 *control_spec = uac_processing_unit_specific(desc,
+ state->mixer->protocol);
+ cval->min = 1;
+ cval->max = control_spec[0];
cval->res = 1;
cval->initialized = 1;
- } else
- get_min_max(cval, valinfo->min_value);
+ break;
+ }
+
+ get_min_max(cval, valinfo->min_value);
+ break;
+ }
+ case USB_XU_CLOCK_RATE:
+ /*
+ * E-Mu USB 0404/0202/TrackerPre/0204
+ * samplerate control quirk
+ */
+ cval->min = 0;
+ cval->max = 5;
+ cval->res = 1;
+ cval->initialized = 1;
+ break;
+ default:
+ get_min_max(cval, valinfo->min_value);
+ break;
}
kctl = snd_ctl_new1(&mixer_procunit_ctl, cval);