Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp625229imm; Wed, 11 Jul 2018 08:15:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdhHQY1VHRpEWzOaesrjm1aP4e3guPZJFpDMauxSaZzJnnkZ/mGKe4ScBfL29XwywDbBN0R X-Received: by 2002:a63:1063:: with SMTP id 35-v6mr26075580pgq.249.1531322145006; Wed, 11 Jul 2018 08:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531322144; cv=none; d=google.com; s=arc-20160816; b=Q76M000an0Rq1zTpykz8wclWwiOhCdJSyZ3oqy2wJarQIvNNL0Ppa2YmvTq6M2BW01 h/rkD3rx8HAfbW5kFTeHDgAz6MTcDpXdK+r7/NYP/a1r8jilwpLDe4VLItKNkOk5DArE GAoQrI2WCvAtYLvAHWoFu5v4Kx+2GCZU/PDe3YOWGPk2cIkIP7YGTrFi0cCmbaQ6sz5f +kgY+cXBor+z4e0esKroAbDiXQvUB8yA5r7GDC12VramRQO3EYGpY9YQPiL6ZXNGDARv 1BRl/w6LDerAweUbK7eBnOl8d1oIrpzmYTY+Gs3Y/j+6mkH60McKdpZgNqxYxOIjn6oo K3GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=C8iEUPAvzECKrGjqwrMWq5ry6px1P4xTkPYc5TswJnA=; b=ebeSI/fUAH2F/Up/p57I/BICuqU15OqKwLABVP6xuRY8GIEF8tSyWLXLOaq+xjpREd 7RxYXa3Y5rG92cfHgIlZDDm5V68Sfnt90tUAm/S4rGWIBtVK61ujL8esWB7JxkZf+eJH eKf+6VO32nl4tVCSH2ckKRZ3b4RINnrN/4B7604jNjwhZPkQhPbOmElFXOEuAc+RMcQt 6SooiluQKmzlA8N2HGoPQ/0eSg+R0jQgKcXdhU1Se/r/tLi+kwwA7ppHHBS6rjDCEeRR oRk1l+LK0Bct1kydnaIW+Tiw11muF4i4KCJPexdRxFbVyfJOASPb1senYgGaXJ/v7E1p Bokw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26-v6si18618500pge.679.2018.07.11.08.15.29; Wed, 11 Jul 2018 08:15:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387586AbeGKMmi (ORCPT + 99 others); Wed, 11 Jul 2018 08:42:38 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:56057 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387497AbeGKMmN (ORCPT ); Wed, 11 Jul 2018 08:42:13 -0400 Received: from [148.252.241.226] (helo=ct-lt-1121.office.codethink.co.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1fdENd-00042U-Uo; Wed, 11 Jul 2018 13:38:02 +0100 From: Jorge Sanjuan To: tiwai@suse.de Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] ALSA: usb-audio: Add support for Selector Units in UAC3 Date: Wed, 11 Jul 2018 13:37:51 +0100 Message-Id: <20180711123755.27182-2-jorge.sanjuan@codethink.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180711123755.27182-1-jorge.sanjuan@codethink.co.uk> References: <20180711123755.27182-1-jorge.sanjuan@codethink.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add support for Selector Units and Clock Selector Units defined in the new UAC3 spec. Selector Units play a really important role in the new UAC3 spec as Processing Units do not define an on/off switch control anymore. This forces topology designers to add bypass paths in the topology to enable/dissable the Processing Units. Signed-off-by: Jorge Sanjuan --- sound/usb/mixer.c | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index ca963e94ec03..a51f2320a3dd 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -940,6 +940,19 @@ static int check_input_term(struct mixer_build *state, int id, return 0; } + case UAC3_SELECTOR_UNIT: + case UAC3_CLOCK_SELECTOR: { + struct uac_selector_unit_descriptor *d = p1; + /* call recursively to retrieve the channel info */ + err = check_input_term(state, d->baSourceID[0], term); + if (err < 0) + return err; + term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->id = id; + term->name = 0; /* TODO: UAC3 Class-specific strings */ + + return 0; + } default: return -ENODEV; } @@ -2509,11 +2522,20 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, cval->res = 1; cval->initialized = 1; - if (state->mixer->protocol == UAC_VERSION_1) + switch (state->mixer->protocol) { + case UAC_VERSION_1: + default: cval->control = 0; - else /* UAC_VERSION_2 */ - cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ? - UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR; + break; + case UAC_VERSION_2: + case UAC_VERSION_3: + if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR || + desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR) + cval->control = UAC2_CX_CLOCK_SELECTOR; + else /* UAC2/3_SELECTOR_UNIT */ + cval->control = UAC2_SU_SELECTOR; + break; + } namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL); if (!namelist) { @@ -2555,12 +2577,22 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); if (!len) { /* no mapping ? */ + switch (state->mixer->protocol) { + case UAC_VERSION_1: + case UAC_VERSION_2: + default: /* if iSelector is given, use it */ - nameid = uac_selector_unit_iSelector(desc); - if (nameid) - len = snd_usb_copy_string_desc(state->chip, nameid, - kctl->id.name, - sizeof(kctl->id.name)); + nameid = uac_selector_unit_iSelector(desc); + if (nameid) + len = snd_usb_copy_string_desc(state->chip, + nameid, kctl->id.name, + sizeof(kctl->id.name)); + break; + case UAC_VERSION_3: + /* TODO: Class-Specific strings not yet supported */ + break; + } + /* ... or pick up the terminal name at next */ if (!len) len = get_term_name(state->chip, &state->oterm, @@ -2570,7 +2602,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); /* and add the proper suffix */ - if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) + if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR || + desc->bDescriptorSubtype == UAC3_CLOCK_SELECTOR) append_ctl_name(kctl, " Clock Source"); else if ((state->oterm.type & 0xff00) == 0x0100) append_ctl_name(kctl, " Capture Source"); @@ -2641,6 +2674,7 @@ static int parse_audio_unit(struct mixer_build *state, int unitid) return parse_audio_mixer_unit(state, unitid, p1); case UAC3_CLOCK_SOURCE: return parse_clock_source_unit(state, unitid, p1); + case UAC3_SELECTOR_UNIT: case UAC3_CLOCK_SELECTOR: return parse_audio_selector_unit(state, unitid, p1); case UAC3_FEATURE_UNIT: -- 2.11.0