From patchwork Wed Jul 11 12:37:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Sanjuan X-Patchwork-Id: 10519675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65E2B600CA for ; Wed, 11 Jul 2018 12:38:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480AC28C1F for ; Wed, 11 Jul 2018 12:38:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3953928CC1; Wed, 11 Jul 2018 12:38:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B300628C1F for ; Wed, 11 Jul 2018 12:38:25 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 94A3726771A; Wed, 11 Jul 2018 14:38:12 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id B95EA267714; Wed, 11 Jul 2018 14:38:07 +0200 (CEST) Received: from imap1.codethink.co.uk (imap1.codethink.co.uk [176.9.8.82]) by alsa0.perex.cz (Postfix) with ESMTP id 254AB26770A for ; Wed, 11 Jul 2018 14:38:02 +0200 (CEST) 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 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> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH 2/5] ALSA: usb-audio: Processing Unit controls parsing in UAC2 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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);