From patchwork Sat Mar 24 02:25:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Chant X-Patchwork-Id: 10305851 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 4C103600CC for ; Sat, 24 Mar 2018 02:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F63628D48 for ; Sat, 24 Mar 2018 02:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3419928EE4; Sat, 24 Mar 2018 02:36:19 +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 80A1228E2A for ; Sat, 24 Mar 2018 02:36:18 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4A739266E0E; Sat, 24 Mar 2018 03:26:06 +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 3BC20266F92; Sat, 24 Mar 2018 03:26:03 +0100 (CET) Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by alsa0.perex.cz (Postfix) with ESMTP id 1A6BA266F60 for ; Sat, 24 Mar 2018 03:25:58 +0100 (CET) Received: by mail-pg0-f67.google.com with SMTP id n11so5250330pgp.4 for ; Fri, 23 Mar 2018 19:25:58 -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=5MvUoSAE06W7/5oEDpZjmnyqw6xITPNfoUtaf9V0o5E=; b=uaaMsW4ih0eCKiyPD4xqhPATUVXWwFeQs037u0aoO/a4tv0sulsYxRJ6CefamOtVA5 HPXaCVtkjMqPhOvsnCSBZfDN0ba1N4JlDeQTbKMvrCuUFQGWI8OHNeU2eaW4BgtJLs7S 3fo3G9/mmQOx784UKGiUKnZsW8KtVxun1aJ9i0MFV/vznq9lCXV/vpiCcUVhp40gIuF4 3vbiSNAbJDZJv8yxzADgDjHBN8KC6RCD9P34/kDW4ymWqxo6rgeQFF1ncGHdg2/DyOs8 3/t1JATdiKejbDy3yUCEParBTbpjv3sDxFeYccF7dG29nHEB319xNhVrSJKt41l27gZ/ Yl1A== 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=5MvUoSAE06W7/5oEDpZjmnyqw6xITPNfoUtaf9V0o5E=; b=G9Oh5huFr4widUFvqMY/fM+z0BHCv/L8C6lu/R+38vhVjDtISwGrNAgvGzT6XyJ0Kg ewFJnrU3bv3SaYpczg0kwyftKoX6iz52xwTZP7ysn0mHfsu+In4SbIDj9/ZbPuJtjO5M OiHzHnxJ0E8vwwg1vP8h2Bf+QknqEbau7DfIVcP+yuwep4/LibbooaJ0/zBT0QsGdjWQ T3XXziggVnHYIHQ6M15KJYMXAuXRh71XQykFTHhTHooT1zH0GzwybesvFVxJtdHSJmK9 RdDaplz0iDyUM+Ku0IbcEYerHeimvWPVNMLMEJBnEsMO6Q+BYwTQdPDEFO1rsaNZfCtL O3FA== X-Gm-Message-State: AElRT7FL8jlwufM4vQuy6flb0eJo9dIj1yjxHqdouOnTzUvEHUJHyofE 4hl5yjKFM2Te/v8Ap5EkPnoxnA== X-Google-Smtp-Source: AG47ELugpoE7aHk3aoE1m7hsUuM8QcvCpnjNuBTSGysE1Lqjt8nfTeALbmqIV8BvfLzKWcVal8wz9g== X-Received: by 10.99.155.2 with SMTP id r2mr16931061pgd.450.1521858357069; Fri, 23 Mar 2018 19:25:57 -0700 (PDT) Received: from achant0.mtv.corp.google.com ([2620:0:1000:1612:b1:f71a:ab27:f6ec]) by smtp.gmail.com with ESMTPSA id f6sm9624363pgo.54.2018.03.23.19.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 19:25:56 -0700 (PDT) From: Andrew Chant To: Takashi Iwai Date: Fri, 23 Mar 2018 19:25:24 -0700 Message-Id: <20180324022524.227748-3-achant@google.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog In-Reply-To: <20180324022524.227748-1-achant@google.com> References: <20180324022524.227748-1-achant@google.com> Cc: alsa-devel@alsa-project.org, Andrew Chant , Ruslan Bilovol , Benson Leung Subject: [alsa-devel] [PATCH v3 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 | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 97ed2155205d..04dab6f65535 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1235,9 +1235,9 @@ 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, - struct snd_ctl_elem_value *ucontrol) +/* 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; int val, err; @@ -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,12 +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 = 1; /* report true if any channel is connected */ 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); @@ -1576,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);