From patchwork Sat Mar 24 01:55:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Chant X-Patchwork-Id: 10305849 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 8AF6A600CC for ; Sat, 24 Mar 2018 01:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 814832924C for ; Sat, 24 Mar 2018 01:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7366A2926A; Sat, 24 Mar 2018 01:57:17 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 9DD922924C for ; Sat, 24 Mar 2018 01:57:16 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E53FB266EBC; Sat, 24 Mar 2018 02:57:03 +0100 (CET) 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 DE83D266F69; Sat, 24 Mar 2018 02:57:00 +0100 (CET) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by alsa0.perex.cz (Postfix) with ESMTP id 7A43D266EBC for ; Sat, 24 Mar 2018 02:56:55 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id l27so5399272pfk.12 for ; Fri, 23 Mar 2018 18:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+9MaFkNLl6Te1t9nF5qrCHHfd8ytmAZ2F2BmPFFge20=; b=TnS50hFln7kn0OFMaNicxNXuZRzpjpmhFo3cRn3JBPNIxl+1/igIwlf8LhnyzSCyft Ofkh/uXu+YOolfe589I97GwCFKdbgrEtuEhGz2cIDgpN+4+U8n1/10HiZlGLiq1lCAYy Iv85M3W6JxM0U7sfQhI2NCminYazJ29yJrwncLCnR8zx69UqPBjnSqSVWQ1tcYVLXzlN JwLcqtJIpWbEZy7X+Hc3A+SvL8HD/+aA39IkGLIDQvMXPXMmrHKJ0eL5e6UPFRINYJ0x cWk2DK35SbCB8ZV8QHQWHFGZ0k8Rdf05eNDAukyv485TYjavEJ28eImP9dWFDKRtg4hs 9txg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+9MaFkNLl6Te1t9nF5qrCHHfd8ytmAZ2F2BmPFFge20=; b=Yx+vf/ZrJqqFxOMEoCqAEZ8mixrHocWcUbM4b9KEBfPm5eFXO2nluE9AL0Jo6ZupDj s742ci1Vyk79K4wgcBSaTT+sJ46og6V5lP0Clm8yeX6zxPTgm1vPUizRzq6B4Nfwdo5v rQEBbA4swNVWk4ALyJUGMCH/kfWI1a11L11HuVBY4TL7x9BZAAoqfEl0+bGEZ31HICLZ THqJdat+cTgA23AyA7NgRMWWLQavpFe2ns2DZ0pcDvdR2kp9G8CU5bfoTA1WDR+Gj31Z uGom202wSA2DulBEc8NWknrGtyaNktLaNIkJBzJqH9mD7c50ka/6t5UJx9H1p89qPVC8 L4hw== X-Gm-Message-State: AElRT7GwgxyFp1Q6uGdSimnEQernbbetWUQmzyu3KMDX81FL6L8E0E98 ua4UcHiac4bZXU1e36RIi7DMtQ== X-Google-Smtp-Source: AG47ELsa+IPMJFr4QS6+GhAUONA95UuLSKg/PUi2aqm4j4YM97lZwvPyNDpWZ0egKL2I5rQVFgIkTw== X-Received: by 10.98.77.197 with SMTP id a188mr13182798pfb.219.1521856613852; Fri, 23 Mar 2018 18:56:53 -0700 (PDT) Received: from achant0.mtv.corp.google.com ([2620:0:1000:1612:b1:f71a:ab27:f6ec]) by smtp.gmail.com with ESMTPSA id s7sm16679924pgq.48.2018.03.23.18.56.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 18:56:53 -0700 (PDT) From: Andrew Chant To: Takashi Iwai Date: Fri, 23 Mar 2018 18:55:49 -0700 Message-Id: <20180324015549.162765-3-achant@google.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog In-Reply-To: <20180324015549.162765-1-achant@google.com> References: <20180324015549.162765-1-achant@google.com> Cc: alsa-devel@alsa-project.org, Andrew Chant , Ruslan Bilovol , Benson Leung Subject: [alsa-devel] [PATCH 2/2] ALSA: usb-audio: update clock valid control 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 Make the "clock valid" control a global control instead of a mixer so that it doesn't appear in mixer applications. Additionally, remove the check for writeability prohibited by spec, and Use common code to read the control value. Tested with a UAC2 Audio device that presents a clock validity control. The control still shows up in /proc usbmixer but not in alsamixer. Signed-off-by: Andrew Chant --- sound/usb/mixer.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 3db4185a5f96..162c10f10dd0 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1235,8 +1235,8 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, return changed; } -/* get the current value from a mixer element */ -static int mixer_ctl_connector_get(struct snd_kcontrol *kcontrol, +/* get the boolean value from the master channel of a UAC control */ +static int mixer_ctl_master_bool_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *cval = kcontrol->private_data; @@ -1267,13 +1267,16 @@ static const struct snd_kcontrol_new usb_feature_unit_ctl_ro = { .put = NULL, }; -/* A UAC connector mixer control */ -static struct snd_kcontrol_new usb_connector_ctl_ro = { +/* + * A control which shows the boolean value from reading a UAC control on + * the master channel. + */ +static struct snd_kcontrol_new usb_bool_master_control_ctl_ro = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "", /* will be filled later manually */ .access = SNDRV_CTL_ELEM_ACCESS_READ, .info = snd_ctl_boolean_mono_info, - .get = mixer_ctl_connector_get, + .get = mixer_ctl_master_bool_get, .put = NULL, }; @@ -1520,13 +1523,18 @@ static void build_connector_control(struct mixer_build *state, if (!cval) return; snd_usb_mixer_elem_init_std(&cval->head, state->mixer, term->id); + /* + * The first byte from reading the UAC2_TE_CONNECTOR control returns the + * number of channels connected. This boolean ctl will simply report + * if any channels are connected or not. + * (Audio20_final.pdf Table 5-10: Connector Control CUR Parameter Block) + */ cval->control = UAC2_TE_CONNECTOR; cval->val_type = USB_MIXER_BOOLEAN; - cval->channels = term->channels; - cval->cmask = term->chconfig; + cval->channels = 1; // only report boolean connected-or-not. cval->min = 0; cval->max = 1; - kctl = snd_ctl_new1(&usb_connector_ctl_ro, cval); + kctl = snd_ctl_new1(&usb_bool_master_control_ctl_ro, cval); if (!kctl) { usb_audio_err(state->chip, "cannot malloc kcontrol\n"); kfree(cval); @@ -1577,13 +1585,9 @@ static int parse_clock_source_unit(struct mixer_build *state, int unitid, cval->val_type = USB_MIXER_BOOLEAN; cval->control = UAC2_CS_CONTROL_CLOCK_VALID; - if (uac_v2v3_control_is_writeable(hdr->bmControls, - UAC2_CS_CONTROL_CLOCK_VALID)) - kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); - else { - cval->master_readonly = 1; - kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval); - } + cval->master_readonly = 1; + /* From UAC2 5.2.5.1.2 "Only the get request is supported." */ + kctl = snd_ctl_new1(&usb_bool_master_control_ctl_ro, cval); if (!kctl) { kfree(cval);