Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp624443imm; Wed, 11 Jul 2018 08:15:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc1V1etnmva1KOMYWwSyla6f7yykcZh1a3v5QLuDRCsuUK1VPdjzIkqPIjZbwoTk85Wt2Zw X-Received: by 2002:a63:5463:: with SMTP id e35-v6mr27486645pgm.115.1531322100486; Wed, 11 Jul 2018 08:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531322100; cv=none; d=google.com; s=arc-20160816; b=qCf/5VUAJ6rnp/rh97Q7hfHb/PCekjrNkHloCc9GmBz7O1oTaFx2SBdY6V/MlvpEsD dwjYlSG3hQ2vqq7i+seGJ0OOXRBmJObwiQ2uO+dmRbX3mqjHxyXcKAZVc3FtSAo4swHA IjK7ILZDF3GC+8ZFTSP9bR5Tvr7jiDKv5Q6TkaBjJP+Zs2p47jgf35yEQ+TUEHIYCiX1 sHvAj4JGJZ7ziYZmIW307rXd8bjvrupV/2Iwsfl+ptYpZ/cL0vtaGu6pPE1tIgHOU/Hd X0PzSSPiuDk1dRYW/ZTjPqKBmHaOjKsli0CpGIFVK1ieExONyMXf02Kufh+D2HCwCqhK /GzQ== 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=ysDlm59dJj2R++K5h8JI50OyJFx62LD0y/4lGmn3TI8=; b=lZ1XQE33Ag8RnqkNMUXvcEa3TZ72XvyaHOzgOwQRanUIxH5VT3qqieXMOzwBXadbXA p7vWogpBkCNrb3thonbkvQRsoQSyWApXHRPEUEPDTnpdxFOzAvWrmjMZFszkh0dK6zoM 5KIQ+Wmirn0cFYLcz5Z6CHX2NcbAfcYABSGea5rDaVkUf6C/BqR8gbjYPTh058y/2aR0 /CDSZwssgXOBwIrsXlqNM5hIuAnvSy/iwnm5ftSPO3pso/7d3GKi0R3CiQFW4i38nOH9 lbIL8Y4lLtzs8EBz2Rtp2aBc9wXgvs6v0A/sG4KMCPcCfWZ5I2eSmBPtRwAT2xQxZR/k sMHg== 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 z20-v6si21799095pfj.337.2018.07.11.08.14.45; Wed, 11 Jul 2018 08:15:00 -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 S2387550AbeGKMmO (ORCPT + 99 others); Wed, 11 Jul 2018 08:42:14 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:56056 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732808AbeGKMmM (ORCPT ); Wed, 11 Jul 2018 08:42:12 -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 1fdENe-00042U-Q3; 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 4/5] ALSA: usb-audio: Unify virtual type units type to UAC3 values Date: Wed, 11 Jul 2018 13:37:54 +0100 Message-Id: <20180711123755.27182-5-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 The Audio Control interface descriptor subtypes do not match across all the UAC versions. That makes reusability of the "virtual type" (Mixer, Processors, Selectors, etc) terminals difficult. It also makes the mixer get the default names for the virtual terminals wrong due to the overlap. This patch proposes an unified approach by always using the most comprehensive spec version to define them all (in this case UAC3). Signed-off-by: Jorge Sanjuan --- sound/usb/mixer.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 39fde49e8749..87f18cb74ca3 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -675,16 +675,16 @@ static int get_term_name(struct snd_usb_audio *chip, struct usb_audio_term *iter if (term_only) return 0; switch (iterm->type >> 16) { - case UAC_SELECTOR_UNIT: + case UAC3_SELECTOR_UNIT: strcpy(name, "Selector"); return 8; - case UAC1_PROCESSING_UNIT: + case UAC3_PROCESSING_UNIT: strcpy(name, "Process Unit"); return 12; - case UAC1_EXTENSION_UNIT: + case UAC3_EXTENSION_UNIT: strcpy(name, "Ext Unit"); return 8; - case UAC_MIXER_UNIT: + case UAC3_MIXER_UNIT: strcpy(name, "Mixer"); return 5; default: @@ -832,7 +832,7 @@ static int check_input_term(struct mixer_build *state, int id, case UAC_MIXER_UNIT: { struct uac_mixer_unit_descriptor *d = p1; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_MIXER_UNIT << 16; /* virtual type */ term->channels = uac_mixer_unit_bNrChannels(d); term->chconfig = uac_mixer_unit_wChannelConfig(d, protocol); term->name = uac_mixer_unit_iMixer(d); @@ -845,15 +845,23 @@ static int check_input_term(struct mixer_build *state, int id, err = check_input_term(state, d->baSourceID[0], term); if (err < 0) return err; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */ term->id = id; term->name = uac_selector_unit_iSelector(d); return 0; } case UAC1_PROCESSING_UNIT: + /* UAC2_EFFECT_UNIT */ + if (protocol == UAC_VERSION_1) + term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ + else /* UAC_VERSION_2 */ + term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */ case UAC1_EXTENSION_UNIT: /* UAC2_PROCESSING_UNIT_V2 */ - /* UAC2_EFFECT_UNIT */ + if (protocol == UAC_VERSION_1 && !term->type) + term->type = UAC3_EXTENSION_UNIT << 16; /* virtual type */ + else if (protocol == UAC_VERSION_2 && !term->type) + term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ case UAC2_EXTENSION_UNIT_V2: { struct uac_processing_unit_descriptor *d = p1; @@ -869,7 +877,9 @@ static int check_input_term(struct mixer_build *state, int id, id = d->baSourceID[0]; break; /* continue to parse */ } - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + if (!term->type) + term->type = UAC3_EXTENSION_UNIT << 16; /* virtual type */ + term->channels = uac_processing_unit_bNrChannels(d); term->chconfig = uac_processing_unit_wChannelConfig(d, protocol); term->name = uac_processing_unit_iProcessing(d, protocol); @@ -878,7 +888,7 @@ static int check_input_term(struct mixer_build *state, int id, case UAC2_CLOCK_SOURCE: { struct uac_clock_source_descriptor *d = p1; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ term->id = id; term->name = d->iClockSource; return 0; @@ -923,7 +933,7 @@ static int check_input_term(struct mixer_build *state, int id, case UAC3_CLOCK_SOURCE: { struct uac3_clock_source_descriptor *d = p1; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ term->id = id; term->name = le16_to_cpu(d->wClockSourceStr); return 0; @@ -936,7 +946,7 @@ static int check_input_term(struct mixer_build *state, int id, return err; term->channels = err; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_MIXER_UNIT << 16; /* virtual type */ return 0; } @@ -947,7 +957,7 @@ static int check_input_term(struct mixer_build *state, int id, err = check_input_term(state, d->baSourceID[0], term); if (err < 0) return err; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_SELECTOR_UNIT << 16; /* virtual type */ term->id = id; term->name = 0; /* TODO: UAC3 Class-specific strings */ @@ -964,7 +974,7 @@ static int check_input_term(struct mixer_build *state, int id, if (err < 0) return err; - term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->type = UAC3_PROCESSING_UNIT << 16; /* virtual type */ term->id = id; term->name = 0; /* TODO: UAC3 Class-specific strings */ -- 2.11.0