Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp624510imm; Wed, 11 Jul 2018 08:15:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc+8L+KabqHEwszXG8ttHwQRZ42lZMrRKxDlE90Fk1ZpBGfa0yXiXJvXg2HW2nn7P2ZQUns X-Received: by 2002:aa7:86d7:: with SMTP id h23-v6mr30496694pfo.132.1531322104985; Wed, 11 Jul 2018 08:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531322104; cv=none; d=google.com; s=arc-20160816; b=FGsg4+p1cDh9AHgNHz2gloXtT3MlhqLUr9V7g+9dC8U3l9WyG/oS/XY4zHfy/DDrny 5nQqI5w2wzS+uamipGVtPKrHtDI1x0P+ACWoJyJ9Nk3CfsfwSRbSLKJ06YCx2yeErFMX aIcJcmR95WVkKCk5lvGflnHHastpfbN+BpDOK9eSa2J3OKBvwVMTKn7ccZ4eh7IfyoLm n1pXP2tcVkOpaEM3nX0kea1/9KSj0zhXJFLCemeIPd3uMNHIkTZPFz8PfHmp/72OVxGa HhvibZbYvHHkT0LHJPlPUygi5sVYbBU2mmvYGkx5ncsSXaaDVk+8XFJ2sFytlPXBlvtM 9xxA== 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=HELhErGKTxA/LuHvUg3larSZbMM/Wq+8U4ug0pVWeU0=; b=DxN9k8kElSEEvN+c5n+YmyYCRyFDf6PBNdyNrmSpyMLtNxyvt5h8x4npNOzUcFVFyY /aOtiHanedRZyABy4ZMh9Fk6RuZFw40/1jolLyYGLRkvWijAiHj53VF2u6PWxaqpX3le V4MtuOqpD1gsvjMDF4iySrzYyDCFh9EJm4UHP1Ln7OGnVs/FA6bWE4lF6tZ9rNrt3fco 4FBZELKjDCDQ25wIerQs+UohEIj9JyDpRNltS83hS3oG7U07FGm1KF/n26wefQqrbIdT DYJ+vN/JrNf+VRDkeW1oy6TtceujcQwYRD6AKLzhL+D+SaTLVYnocmvNR7lJtsE4VKj7 2ypQ== 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 l8-v6si17778120pgq.432.2018.07.11.08.14.49; Wed, 11 Jul 2018 08:15:04 -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 S2387524AbeGKMmN (ORCPT + 99 others); Wed, 11 Jul 2018 08:42:13 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:56058 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387501AbeGKMmM (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-7W; 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 2/5] ALSA: usb-audio: Processing Unit controls parsing in UAC2 Date: Wed, 11 Jul 2018 13:37:52 +0100 Message-Id: <20180711123755.27182-3-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 Current support for UAC2 Processing Units does the parsing as one control per bit in the bitmap. However, the UAC2 spec defines the controls as bit pairs where b01 means read-only and b11 means read/write control. This patch fixes that and uses the helper functions for checking controls readability/writability when the control is defined as bit pairs (UAC2 and UAC3). Signed-off-by: Jorge Sanjuan --- sound/usb/mixer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index a51f2320a3dd..bfb3484096a6 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -2300,8 +2300,16 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, for (valinfo = info->values; valinfo->control; valinfo++) { __u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol); - if (!(controls[valinfo->control / 8] & (1 << ((valinfo->control % 8) - 1)))) - continue; + if (state->mixer->protocol == UAC_VERSION_1) { + if (!(controls[valinfo->control / 8] & + (1 << ((valinfo->control % 8) - 1)))) + continue; + } else { /* UAC_VERSION_2/3 */ + if (!uac_v2v3_control_is_readable(controls[valinfo->control / 8], + valinfo->control)) + continue; + } + map = find_map(state->map, unitid, valinfo->control); if (check_ignored_ctl(map)) continue; @@ -2313,6 +2321,11 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, cval->val_type = valinfo->val_type; cval->channels = 1; + if (state->mixer->protocol > UAC_VERSION_1 && + !uac_v2v3_control_is_writeable(controls[valinfo->control / 8], + valinfo->control)) + 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); -- 2.11.0