From patchwork Sun Jun 20 16:46:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Geoffrey D. Bennett" X-Patchwork-Id: 12333503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 726D7C48BDF for ; Sun, 20 Jun 2021 16:50:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E827F61042 for ; Sun, 20 Jun 2021 16:50:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E827F61042 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=b4.vu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7871D16E0; Sun, 20 Jun 2021 18:49:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7871D16E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1624207837; bh=u8BY7hOnV4NnlXb93viCl3AnJS4Es0GhnGnw5TfrQ+k=; h=Date:From:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=nhAB1CimsBuNc2LMNO25OYXqCYFclbhSjg42ep8Aqaz/gTxdscoFoTlGBQKBJy7Xl GtY0J9zOV37xuaiOE8MV7G/1JosUSnlVTbKO2QXK9VwP56EcjtccgsUxf/6eLuq2OC Ysow2P9GHrotUcS0dyqaBDMxMTRETdrmXRFGtCVk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 804D0F8050F; Sun, 20 Jun 2021 18:46:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 873CFF804D2; Sun, 20 Jun 2021 18:46:46 +0200 (CEST) Received: from m.b4.vu (m.b4.vu [203.16.231.148]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC545F804C2 for ; Sun, 20 Jun 2021 18:46:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC545F804C2 Received: by m.b4.vu (Postfix, from userid 1000) id 3426061E287B; Mon, 21 Jun 2021 02:16:34 +0930 (ACST) Date: Mon, 21 Jun 2021 02:16:34 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 06/14] ALSA: usb-audio: scarlett2: Remove redundant info->button_count Message-ID: <20210620164634.GA9193@m.b4.vu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Hin-Tak Leung , Vladimir Sadovnikov X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The per-model button_count value was used to determine whether dim/mute controls should be added, but these are present iff line_out_hw_vol is true. Remove button_count and replace with SCARLETT2_BUTTON_MAX and a check for line_out_hw_vol true. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 3225ec709d98..043b0929ad9d 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -218,7 +218,6 @@ struct scarlett2_ports { struct scarlett2_device_info { u8 line_out_hw_vol; /* line out hw volume is sw controlled */ - u8 button_count; /* number of buttons */ u8 level_input_count; /* inputs with level selectable */ u8 pad_input_count; /* inputs with pad selectable */ const char * const line_out_descrs[SCARLETT2_ANALOGUE_MAX]; @@ -370,9 +369,6 @@ static const struct scarlett2_device_info s18i20_gen2_info = { */ .line_out_hw_vol = 1, - /* Mute and dim buttons */ - .button_count = 2, - .line_out_descrs = { "Monitor L", "Monitor R", @@ -1108,7 +1104,8 @@ static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer, static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) { struct scarlett2_mixer_data *private = mixer->private_data; - const struct scarlett2_ports *ports = private->info->ports; + const struct scarlett2_device_info *info = private->info; + const struct scarlett2_ports *ports = info->ports; struct scarlett2_usb_volume_status volume_status; int num_line_out = ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT]; @@ -1129,8 +1126,9 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) private->vol[i] = private->master_vol; } - for (i = 0; i < private->info->button_count; i++) - private->buttons[i] = !!volume_status.buttons[i]; + if (info->line_out_hw_vol) + for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) + private->buttons[i] = !!volume_status.buttons[i]; return 0; } @@ -1547,13 +1545,15 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer) } /* Add HW button controls */ - for (i = 0; i < private->info->button_count; i++) { - err = scarlett2_add_new_ctl(mixer, &scarlett2_button_ctl, - i, 1, scarlett2_button_names[i], - &private->button_ctls[i]); - if (err < 0) - return err; - } + if (info->line_out_hw_vol) + for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) { + err = scarlett2_add_new_ctl( + mixer, &scarlett2_button_ctl, + i, 1, scarlett2_button_names[i], + &private->button_ctls[i]); + if (err < 0) + return err; + } return 0; } @@ -1961,8 +1961,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) private->vol[i] = volume; } - for (i = 0; i < info->button_count; i++) - private->buttons[i] = !!volume_status.buttons[i]; + if (info->line_out_hw_vol) + for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) + private->buttons[i] = !!volume_status.buttons[i]; for (i = 0; i < num_mixer_out; i++) { err = scarlett2_usb_get_mix(mixer, i); @@ -2001,11 +2002,15 @@ static void scarlett2_mixer_interrupt_button_change( struct usb_mixer_interface *mixer) { struct scarlett2_mixer_data *private = mixer->private_data; + const struct scarlett2_device_info *info = private->info; int i; private->vol_updated = 1; - for (i = 0; i < private->info->button_count; i++) + if (!info->line_out_hw_vol) + return; + + for (i = 0; i < SCARLETT2_BUTTON_MAX; i++) snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &private->button_ctls[i]->id); } @@ -2109,7 +2114,7 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, return err; /* Set up the interrupt polling if there are hardware buttons */ - if (info->button_count) { + if (info->line_out_hw_vol) { err = scarlett2_mixer_status_create(mixer); if (err < 0) return err;