diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-12-19 12:40:38 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-12-19 12:40:45 +0100 |
commit | 50947fb04f3a8a5dbc355893c5bf25acaff71e86 (patch) | |
tree | b90b1717b692d0650b68aa398c52c0c637c9af6f /sound/usb/mixer.c | |
parent | ALSA: usb-audio: Change the semantics of the enable option (diff) | |
parent | ALSA: usb-audio: Fix the missing ctl name suffix at parsing SU (diff) | |
download | linux-50947fb04f3a8a5dbc355893c5bf25acaff71e86.tar.xz linux-50947fb04f3a8a5dbc355893c5bf25acaff71e86.zip |
Merge branch 'for-linus' into for-next
Back-merge of 4.15-rc development branch for further development of
USB-audio stuff.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/mixer.c')
-rw-r--r-- | sound/usb/mixer.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 61b348383de8..2b4ceda36291 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -204,6 +204,10 @@ static int snd_usb_copy_string_desc(struct mixer_build *state, int index, char *buf, int maxlen) { int len = usb_string(state->chip->dev, index, buf, maxlen - 1); + + if (len < 0) + return 0; + buf[len] = 0; return len; } @@ -2169,19 +2173,25 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, kctl->private_value = (unsigned long)namelist; kctl->private_free = usb_mixer_selector_elem_free; - nameid = uac_selector_unit_iSelector(desc); + /* check the static mapping table at first */ len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); - if (len) - ; - else if (nameid) - snd_usb_copy_string_desc(state, nameid, kctl->id.name, - sizeof(kctl->id.name)); - else { - len = get_term_name(state, &state->oterm, + if (!len) { + /* no mapping ? */ + /* if iSelector is given, use it */ + nameid = uac_selector_unit_iSelector(desc); + if (nameid) + len = snd_usb_copy_string_desc(state, nameid, + kctl->id.name, + sizeof(kctl->id.name)); + /* ... or pick up the terminal name at next */ + if (!len) + len = get_term_name(state, &state->oterm, kctl->id.name, sizeof(kctl->id.name), 0); + /* ... or use the fixed string "USB" as the last resort */ if (!len) strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); + /* and add the proper suffix */ if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) append_ctl_name(kctl, " Clock Source"); else if ((state->oterm.type & 0xff00) == 0x0100) |