Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp651205imm; Wed, 11 Jul 2018 08:41:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf6g91BQsOG6JmUb8T+qCN80YlRaloESa6/jffkT1+iw1e4LHGQoLnF1f2jaF5/NMf42TIn X-Received: by 2002:a62:ccd0:: with SMTP id j77-v6mr30310443pfk.22.1531323677620; Wed, 11 Jul 2018 08:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531323677; cv=none; d=google.com; s=arc-20160816; b=d+KhJYSYQvxOUQbZHAUyiFTTN+J37hqRyH/GuP23BFA5bn9MTv5+Fu86bIX+iSJtPr N3AcyWQeFPsS7Jl4BfRUZRLE2IoaZD40qP7Y+Ul3FzLKIOc7i8rr2R6+/gqrrINWMmf+ yW3zxDNnSqPdmQld6NOz+CRncDqiQUZKWIaN/pJgmssFasPf3+jvCUDrKcsT4bxOfxBg e4It53N6BSCxZfeGoufDvUmqCJSZz8H1g68gAN3xVnWejqmnGGx8IFuaikgguAlEQeHo DxMcJVZAoJ5U2W9PViYVYSeboeEgOVwhEhF1GRhaK/hAIqSFMAjJkFRrOHrtl/n2rCoY nN7A== 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=K142dB9IheH7Uyf2aaJ3VT10dsregjA5xWo0rqiacC8=; b=EuL9TWld+qVkp7Ri4iNhplOoig4r+bZuwrmKvoVVNQupQpNmdO0t+dB7xyExzR3+vV JzC4/KacMa8j5xnQheP8B8cBLKHMvmUM/0cRR/rB5Ce0BceUEQ1kMTKHCHW5Ln5XKMqw 3xXcRzvefOmrvwH/SIxewZt7J8GzmILnxKTahq1eWIL10/xSP0dhVon/RjRvs0a/IKHl fldUzhbWmRXFOd+J0mt6sxgbiiLAWIBgcK2QGTcNsEUm0uY0T4VkvUF64fqvvoBvf81q ePcoiXLsmJKxzvwGfZUXjNTjrqG/PlLI14x4PSGXXT4UTGdJguz5/8ThBUA/UPDiOOhq 9cUg== 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 y14-v6si4322334pgg.76.2018.07.11.08.41.02; Wed, 11 Jul 2018 08:41:17 -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 S2387511AbeGKMmN (ORCPT + 99 others); Wed, 11 Jul 2018 08:42:13 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:56061 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387498AbeGKMmM (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 1fdENf-00042U-3V; Wed, 11 Jul 2018 13:38:03 +0100 From: Jorge Sanjuan To: tiwai@suse.de Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] ALSA: usb-audio: Tidy up logic for Processing Unit min/max values Date: Wed, 11 Jul 2018 13:37:55 +0100 Message-Id: <20180711123755.27182-6-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 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 --- sound/usb/mixer.c | 58 +++++++++++++++++++++++++++++++++++++++---------------- 1 file 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); -- 2.11.0