From patchwork Sun Jun 6 17:45:19 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: 12302093 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=-15.3 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,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 60C50C47096 for ; Sun, 6 Jun 2021 17:46:24 +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 C3162613C8 for ; Sun, 6 Jun 2021 17:46:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3162613C8 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 457D41711; Sun, 6 Jun 2021 19:45:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 457D41711 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001581; bh=yUxMOU+PPPSsh3u4Cb0TxFVp4HMn/ou6rpeH9BD7Drk=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZLdtfosLt5/NW9QNcvDCeFvFjurXUWxSpx6YPpBUBueSiE1U/1TefDqOdV1MBYnwb TZhv2NS7j8Df11x/4Vy4ckkDarhpZ5jGQFfOhKeY5x9mHSJ2fnUO6b3hhV9J7nCSYA ksTjkKdiNxqCA9Jmg/MJZyBSqZ8ippJOMFZ5ziw8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D432CF80218; Sun, 6 Jun 2021 19:45:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9C611F80256; Sun, 6 Jun 2021 19:45:29 +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 F02C5F8019B for ; Sun, 6 Jun 2021 19:45:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F02C5F8019B Received: by m.b4.vu (Postfix, from userid 1000) id 70D14612FB14; Mon, 7 Jun 2021 03:15:19 +0930 (ACST) Date: Mon, 7 Jun 2021 03:15:19 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 1/8] ALSA: usb-audio: scarlett2: Remove incorrect S/PDIF comment Message-ID: <9706655aeb5c357c8e7fe4f9549404013c6c86c5.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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 18i8 Gen 2 S/PDIF outputs are available at 192kHz, unlike the 18i20 Gen 2. Remove the comment that says otherwise. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 48cf3e1954e0..54d7ac9b0c66 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -338,10 +338,6 @@ static const struct scarlett2_device_info s18i8_gen2_info = { }, [SCARLETT2_PORT_TYPE_SPDIF] = { .id = 0x180, - /* S/PDIF outputs aren't available at 192kHz - * but are included in the USB mux I/O - * assignment message anyway - */ .num = { 2, 2, 2, 2, 2 }, .src_descr = "S/PDIF %d", .src_num_offset = 1, From patchwork Sun Jun 6 17:45:37 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: 12302095 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.5 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 DBCC8C47096 for ; Sun, 6 Jun 2021 17:46: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 9FCC761246 for ; Sun, 6 Jun 2021 17:46:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FCC761246 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 42B8116EF; Sun, 6 Jun 2021 19:45:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 42B8116EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001597; bh=9Wc2dgQDpVAJF8ubyCXn731vfLol525FR+aXkO3PuAE=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dQHUyPN53e+5qfUWCCMOddwGiPnpKbk3F406clHkVzy6lPGLLVYpAZnJ6btF36mhI JgW9V7d5AvuwRu7VtOhTB+mxtRmp8qhOJt4/MO2cOQfj36Has83ml71x4+oMgCljY2 Ak3V0jfZQ838t3pkyEk23HAWWUmXRp9DF6NHkC1Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7FF4FF804AB; Sun, 6 Jun 2021 19:45:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2424CF804AC; Sun, 6 Jun 2021 19:45:43 +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 2D08AF800D0 for ; Sun, 6 Jun 2021 19:45:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2D08AF800D0 Received: by m.b4.vu (Postfix, from userid 1000) id B0BD4612FB14; Mon, 7 Jun 2021 03:15:37 +0930 (ACST) Date: Mon, 7 Jun 2021 03:15:37 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 2/8] ALSA: usb-audio: scarlett2: Coding style improvements Message-ID: <15ec0a3a5274347ad5a48f23bc948056e6ecb6df.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" Improve alignment and readability with: - Whitespace fixes - Add leading zeros to 32-bit flag values - Rename SCARLETT2_USB_GET_METER_LEVELS to SCARLETT2_USB_GET_METER - Rename SCARLETT2_PORT_DIRECTIONS to SCARLETT2_PORT_DIRNS Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 53 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 54d7ac9b0c66..2ebc8d6a9e6f 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -175,23 +175,23 @@ static const u16 scarlett2_mixer_values[SCARLETT2_MIXER_VALUE_COUNT] = { * - PCM I/O */ enum { - SCARLETT2_PORT_TYPE_NONE = 0, + SCARLETT2_PORT_TYPE_NONE = 0, SCARLETT2_PORT_TYPE_ANALOGUE = 1, - SCARLETT2_PORT_TYPE_SPDIF = 2, - SCARLETT2_PORT_TYPE_ADAT = 3, - SCARLETT2_PORT_TYPE_MIX = 4, - SCARLETT2_PORT_TYPE_PCM = 5, - SCARLETT2_PORT_TYPE_COUNT = 6, + SCARLETT2_PORT_TYPE_SPDIF = 2, + SCARLETT2_PORT_TYPE_ADAT = 3, + SCARLETT2_PORT_TYPE_MIX = 4, + SCARLETT2_PORT_TYPE_PCM = 5, + SCARLETT2_PORT_TYPE_COUNT = 6, }; /* Count of total I/O and number available at each sample rate */ enum { - SCARLETT2_PORT_IN = 0, - SCARLETT2_PORT_OUT = 1, - SCARLETT2_PORT_OUT_44 = 2, - SCARLETT2_PORT_OUT_88 = 3, + SCARLETT2_PORT_IN = 0, + SCARLETT2_PORT_OUT = 1, + SCARLETT2_PORT_OUT_44 = 2, + SCARLETT2_PORT_OUT_88 = 3, SCARLETT2_PORT_OUT_176 = 4, - SCARLETT2_PORT_DIRECTIONS = 5, + SCARLETT2_PORT_DIRNS = 5, }; /* Hardware buttons on the 18i20 */ @@ -210,7 +210,7 @@ static const char *const scarlett2_button_names[SCARLETT2_BUTTON_MAX] = { */ struct scarlett2_ports { u16 id; - int num[SCARLETT2_PORT_DIRECTIONS]; + int num[SCARLETT2_PORT_DIRNS]; const char * const src_descr; int src_num_offset; const char * const dst_descr; @@ -458,22 +458,23 @@ static int scarlett2_get_port_start_num(const struct scarlett2_ports *ports, #define SCARLETT2_USB_INTERRUPT_INTERVAL 3 /* Interrupt flags for volume and mute/dim button changes */ -#define SCARLETT2_USB_INTERRUPT_VOL_CHANGE 0x400000 -#define SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE 0x200000 +#define SCARLETT2_USB_INTERRUPT_VOL_CHANGE 0x00400000 +#define SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE 0x00200000 /* Commands for sending/receiving requests/responses */ -#define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_REQ 2 +#define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_REQ 2 #define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_RESP 3 -#define SCARLETT2_USB_INIT_SEQ 0x00000000 -#define SCARLETT2_USB_GET_METER_LEVELS 0x00001001 -#define SCARLETT2_USB_GET_MIX 0x00002001 -#define SCARLETT2_USB_SET_MIX 0x00002002 -#define SCARLETT2_USB_GET_MUX 0x00003001 -#define SCARLETT2_USB_SET_MUX 0x00003002 -#define SCARLETT2_USB_GET_DATA 0x00800000 -#define SCARLETT2_USB_SET_DATA 0x00800001 -#define SCARLETT2_USB_DATA_CMD 0x00800002 +#define SCARLETT2_USB_INIT_SEQ 0x00000000 +#define SCARLETT2_USB_GET_METER 0x00001001 +#define SCARLETT2_USB_GET_MIX 0x00002001 +#define SCARLETT2_USB_SET_MIX 0x00002002 +#define SCARLETT2_USB_GET_MUX 0x00003001 +#define SCARLETT2_USB_SET_MUX 0x00003002 +#define SCARLETT2_USB_GET_DATA 0x00800000 +#define SCARLETT2_USB_SET_DATA 0x00800001 +#define SCARLETT2_USB_DATA_CMD 0x00800002 + #define SCARLETT2_USB_CONFIG_SAVE 6 #define SCARLETT2_USB_VOLUME_STATUS_OFFSET 0x31 @@ -835,7 +836,7 @@ static int scarlett2_usb_get_mix(struct usb_mixer_interface *mixer, * (values obtained from private->mix[]) */ static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer, - int mix_num) + int mix_num) { struct scarlett2_mixer_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; @@ -1056,7 +1057,7 @@ static int scarlett2_usb_get_meter_levels(struct usb_mixer_interface *mixer, req.pad = 0; req.num_meters = cpu_to_le16(SCARLETT2_NUM_METERS); req.magic = cpu_to_le32(SCARLETT2_USB_METER_LEVELS_GET_MAGIC); - err = scarlett2_usb(mixer, SCARLETT2_USB_GET_METER_LEVELS, + err = scarlett2_usb(mixer, SCARLETT2_USB_GET_METER, &req, sizeof(req), resp, sizeof(resp)); if (err < 0) return err; From patchwork Sun Jun 6 17:45:54 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: 12302097 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.5 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 D26A2C47096 for ; Sun, 6 Jun 2021 17:47:13 +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 26C4A60238 for ; Sun, 6 Jun 2021 17:47:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26C4A60238 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 AE2F51743; Sun, 6 Jun 2021 19:46:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AE2F51743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001631; bh=10QxXFokLPcfgLLMbdADOEG7iCv56S4BrPK4nfvEId8=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rHA+oeYxpT8ONQmWKIZtbP+hz0L1V4IqM0+gvr8R0fPNC6E1cI9xqfdra5UG9nhK8 JwFdbgz3GiUJtyHvtba9nfulOeqMg4xNwyZKU+4hcsCZjC5KBALazUCr9hEBHio5KM Kts5rVLa0a4mNmOmXB+t/yZBTQtyqlgEBIyDqpy0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A0311F804C3; Sun, 6 Jun 2021 19:46:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8377FF804CB; Sun, 6 Jun 2021 19:46:04 +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 C208FF800D0 for ; Sun, 6 Jun 2021 19:45:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C208FF800D0 Received: by m.b4.vu (Postfix, from userid 1000) id 1879B612FB14; Mon, 7 Jun 2021 03:15:54 +0930 (ACST) Date: Mon, 7 Jun 2021 03:15:54 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 3/8] ALSA: usb-audio: scarlett2: Remove unused/useless code Message-ID: <23a9a93d98566b5df7561103dfd62b51ce18d43b.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" Remove #define not used. Remove useless assignments and copies. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 2ebc8d6a9e6f..b134663f331a 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -271,7 +271,6 @@ static const struct scarlett2_device_info s6i6_gen2_info = { .id = 0x000, .num = { 1, 0, 8, 8, 8 }, .src_descr = "Off", - .src_num_offset = 0, }, [SCARLETT2_PORT_TYPE_ANALOGUE] = { .id = 0x080, @@ -327,7 +326,6 @@ static const struct scarlett2_device_info s18i8_gen2_info = { .id = 0x000, .num = { 1, 0, 8, 8, 4 }, .src_descr = "Off", - .src_num_offset = 0, }, [SCARLETT2_PORT_TYPE_ANALOGUE] = { .id = 0x080, @@ -393,7 +391,6 @@ static const struct scarlett2_device_info s18i20_gen2_info = { .id = 0x000, .num = { 1, 0, 8, 8, 6 }, .src_descr = "Off", - .src_num_offset = 0, }, [SCARLETT2_PORT_TYPE_ANALOGUE] = { .id = 0x080, @@ -571,8 +568,6 @@ struct scarlett2_usb_packet { u8 data[]; }; -#define SCARLETT2_USB_PACKET_LEN (sizeof(struct scarlett2_usb_packet)) - static void scarlett2_fill_request_header(struct scarlett2_mixer_data *private, struct scarlett2_usb_packet *req, u32 cmd, u16 req_size) @@ -595,8 +590,8 @@ static int scarlett2_usb( struct scarlett2_mixer_data *private = mixer->private_data; u16 req_buf_size = sizeof(struct scarlett2_usb_packet) + req_size; u16 resp_buf_size = sizeof(struct scarlett2_usb_packet) + resp_size; - struct scarlett2_usb_packet *req = NULL, *resp = NULL; - int err = 0; + struct scarlett2_usb_packet *req, *resp = NULL; + int err; req = kmalloc(req_buf_size, GFP_KERNEL); if (!req) { @@ -1026,10 +1021,6 @@ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer) ports, private->mux[j] ) << 12 ); - - /* skip private->mux[j] entries not output */ - j += ports[port_type].num[SCARLETT2_PORT_OUT] - - ports[port_type].num[port_dir_rate]; } err = scarlett2_usb(mixer, SCARLETT2_USB_SET_MUX, @@ -1925,8 +1916,6 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT]; int num_mixer_out = ports[SCARLETT2_PORT_TYPE_MIX].num[SCARLETT2_PORT_IN]; - u8 level_switches[SCARLETT2_LEVEL_SWITCH_MAX]; - u8 pad_switches[SCARLETT2_PAD_SWITCH_MAX]; struct scarlett2_usb_volume_status volume_status; int err, i; @@ -1935,11 +1924,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) mixer, SCARLETT2_CONFIG_LEVEL_SWITCH, info->level_input_count, - level_switches); + private->level_switch); if (err < 0) return err; - for (i = 0; i < info->level_input_count; i++) - private->level_switch[i] = level_switches[i]; } if (info->pad_input_count) { @@ -1947,11 +1934,9 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) mixer, SCARLETT2_CONFIG_PAD_SWITCH, info->pad_input_count, - pad_switches); + private->pad_switch); if (err < 0) return err; - for (i = 0; i < info->pad_input_count; i++) - private->pad_switch[i] = pad_switches[i]; } err = scarlett2_usb_get_volume_status(mixer, &volume_status); From patchwork Sun Jun 6 17:46:05 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: 12302099 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=-15.3 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,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 8A253C47096 for ; Sun, 6 Jun 2021 17:47:33 +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 EBCEF60238 for ; Sun, 6 Jun 2021 17:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBCEF60238 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 90D671717; Sun, 6 Jun 2021 19:46:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 90D671717 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001651; bh=kuJT+E4zwOz8JIv72PobnK414Vn/vTzvTSICT9O8o6M=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gJHNQZz+bkvZCk1PuJoXyQ3rX8HkGj+wStlS1PYerBPjXJgbXtGNybBQtfd9rXOhN I+d0HX1KWpwtc/2ZJCpAPM8pBua4cHsVSegR491VrfUmD8mvzH+hXcAOzsLYplw/Ob rXvCUR1jBa/hgb+TWY3PMKdDeEWKevfRBa9EZFa8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3CB4EF804CF; Sun, 6 Jun 2021 19:46:12 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C2B0F804D1; Sun, 6 Jun 2021 19:46:10 +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 CEDCDF804CF for ; Sun, 6 Jun 2021 19:46:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CEDCDF804CF Received: by m.b4.vu (Postfix, from userid 1000) id 5C87E612FB14; Mon, 7 Jun 2021 03:16:05 +0930 (ACST) Date: Mon, 7 Jun 2021 03:16:05 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 4/8] ALSA: usb-audio: scarlett2: Remove interrupt debug message Message-ID: <26c68450810d6cd3770bc895feb105a7eb94618a.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" Just ignore instead of printing an error if the interrupt data is not the expected length. This check was for development and the condition has not been observed. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index b134663f331a..3f1148bc0883 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -2019,19 +2019,14 @@ static void scarlett2_mixer_interrupt(struct urb *urb) int ustatus = urb->status; u32 data; - if (ustatus != 0) + if (ustatus != 0 || len != 8) goto requeue; - if (len == 8) { - data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); - if (data & SCARLETT2_USB_INTERRUPT_VOL_CHANGE) - scarlett2_mixer_interrupt_vol_change(mixer); - if (data & SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE) - scarlett2_mixer_interrupt_button_change(mixer); - } else { - usb_audio_err(mixer->chip, - "scarlett mixer interrupt length %d\n", len); - } + data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); + if (data & SCARLETT2_USB_INTERRUPT_VOL_CHANGE) + scarlett2_mixer_interrupt_vol_change(mixer); + if (data & SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE) + scarlett2_mixer_interrupt_button_change(mixer); requeue: if (ustatus != -ENOENT && From patchwork Sun Jun 6 17:46:24 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: 12302101 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.5 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 73800C47096 for ; Sun, 6 Jun 2021 17:47:52 +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 E1F52613D4 for ; Sun, 6 Jun 2021 17:47:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1F52613D4 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 7BD1B1752; Sun, 6 Jun 2021 19:47:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7BD1B1752 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001670; bh=RlB7uGiPREaHSyH5l+otpxIMNLfM9e0zrGEGRDoKVfw=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YNZOmORI/v6HS6ZjukQ9vPmcgC76uQRwUuQbzJL4kDgHgHbeq7nDiSXZVgz1DGMcL MBNvnxWGWA7XBdsaY1rPYfBpyULQGRfVRK6yppa4megbt1JpvPVGaEZ6Xr6EMmr+aL tHV3y1Q3swLiQh/1YM9hCnp6UhVkdZJLqdlBjXmQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C43D3F80218; Sun, 6 Jun 2021 19:46:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD788F804AD; Sun, 6 Jun 2021 19:46:33 +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 B14FFF80218 for ; Sun, 6 Jun 2021 19:46:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B14FFF80218 Received: by m.b4.vu (Postfix, from userid 1000) id 3E0DC61956CD; Mon, 7 Jun 2021 03:16:24 +0930 (ACST) Date: Mon, 7 Jun 2021 03:16:24 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 5/8] ALSA: usb-audio: scarlett2: Rename buttons/interrupts Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" To match the vendor's terminology, change #defines, function names, and comments: - hardware buttons are now called dim/mute - mixer status/interrupt is now notify - vol is now monitor Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 3f1148bc0883..d240fa9a4b59 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -194,7 +194,7 @@ enum { SCARLETT2_PORT_DIRNS = 5, }; -/* Hardware buttons on the 18i20 */ +/* Dim/Mute buttons on the 18i20 */ #define SCARLETT2_BUTTON_MAX 2 static const char *const scarlett2_button_names[SCARLETT2_BUTTON_MAX] = { @@ -218,7 +218,7 @@ 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 button_count; /* number of dim/mute 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]; @@ -454,9 +454,9 @@ static int scarlett2_get_port_start_num(const struct scarlett2_ports *ports, #define SCARLETT2_USB_INTERRUPT_MAX_DATA 64 #define SCARLETT2_USB_INTERRUPT_INTERVAL 3 -/* Interrupt flags for volume and mute/dim button changes */ -#define SCARLETT2_USB_INTERRUPT_VOL_CHANGE 0x00400000 -#define SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE 0x00200000 +/* Interrupt flags for mute/dim button and monitor changes */ +#define SCARLETT2_USB_NOTIFY_DIM_MUTE 0x00200000 +#define SCARLETT2_USB_NOTIFY_MONITOR 0x00400000 /* Commands for sending/receiving requests/responses */ #define SCARLETT2_USB_VENDOR_SPECIFIC_CMD_REQ 2 @@ -1546,7 +1546,7 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer) } } - /* Add HW button controls */ + /* Add dim/mute 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], @@ -1974,8 +1974,8 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) return scarlett2_usb_get_mux(mixer); } -/* Notify on volume change */ -static void scarlett2_mixer_interrupt_vol_change( +/* Notify on monitor change */ +static void scarlett2_notify_monitor( struct usb_mixer_interface *mixer) { struct scarlett2_mixer_data *private = mixer->private_data; @@ -1997,8 +1997,8 @@ static void scarlett2_mixer_interrupt_vol_change( } } -/* Notify on button change */ -static void scarlett2_mixer_interrupt_button_change( +/* Notify on dim/mute change */ +static void scarlett2_notify_dim_mute( struct usb_mixer_interface *mixer) { struct scarlett2_mixer_data *private = mixer->private_data; @@ -2012,7 +2012,7 @@ static void scarlett2_mixer_interrupt_button_change( } /* Interrupt callback */ -static void scarlett2_mixer_interrupt(struct urb *urb) +static void scarlett2_notify(struct urb *urb) { struct usb_mixer_interface *mixer = urb->context; int len = urb->actual_length; @@ -2023,10 +2023,10 @@ static void scarlett2_mixer_interrupt(struct urb *urb) goto requeue; data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); - if (data & SCARLETT2_USB_INTERRUPT_VOL_CHANGE) - scarlett2_mixer_interrupt_vol_change(mixer); - if (data & SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE) - scarlett2_mixer_interrupt_button_change(mixer); + if (data & SCARLETT2_USB_NOTIFY_MONITOR) + scarlett2_notify_monitor(mixer); + if (data & SCARLETT2_USB_NOTIFY_DIM_MUTE) + scarlett2_notify_dim_mute(mixer); requeue: if (ustatus != -ENOENT && @@ -2037,7 +2037,7 @@ static void scarlett2_mixer_interrupt(struct urb *urb) } } -static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) +static int scarlett2_init_notify(struct usb_mixer_interface *mixer) { struct usb_device *dev = mixer->chip->dev; unsigned int pipe = usb_rcvintpipe(dev, @@ -2063,7 +2063,7 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer) usb_fill_int_urb(mixer->urb, dev, pipe, transfer_buffer, SCARLETT2_USB_INTERRUPT_MAX_DATA, - scarlett2_mixer_interrupt, mixer, + scarlett2_notify, mixer, SCARLETT2_USB_INTERRUPT_INTERVAL); return usb_submit_urb(mixer->urb, GFP_KERNEL); @@ -2111,7 +2111,7 @@ static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer, /* Set up the interrupt polling if there are hardware buttons */ if (info->button_count) { - err = scarlett2_mixer_status_create(mixer); + err = scarlett2_init_notify(mixer); if (err < 0) return err; } From patchwork Sun Jun 6 17:46:37 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: 12302103 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.5 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 38A95C47096 for ; Sun, 6 Jun 2021 17:48:08 +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 B2BA760238 for ; Sun, 6 Jun 2021 17:48:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2BA760238 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 4A9761744; Sun, 6 Jun 2021 19:47:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4A9761744 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001686; bh=Ve0V8LTW311YGER1/PcO8bHJm+ckQPmtdUKCU3lqClA=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LbHaI7eHeC59+udnw3yyZOf3X4KgEZIxSThSIEKucNDR92FZAvb3bCNn+Twn9rWgb LPbyrUgbelDzVdoTxwH+lRGdRT+s+1mrr0BaRpGkHm4tMZtKtS2GQTce5df+YeKrE7 Rm7VtocnjS/ADDOxDT/2jrUwUBIdJo11kTmN5mQA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 55C99F804BD; Sun, 6 Jun 2021 19:46:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05140F804C2; Sun, 6 Jun 2021 19:46:44 +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 49BA9F80256 for ; Sun, 6 Jun 2021 19:46:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 49BA9F80256 Received: by m.b4.vu (Postfix, from userid 1000) id CE0CB612FB14; Mon, 7 Jun 2021 03:16:37 +0930 (ACST) Date: Mon, 7 Jun 2021 03:16:37 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 6/8] ALSA: usb-audio: scarlett2: Rename struct scarlett2_mixer_data Message-ID: <3816cbfd3a39198e9c74edff5e61c39a94041d35.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" Rename struct scarlett2_mixer_data to struct scarlett2_data. A less-wordy name is better because it is used everywhere, and although this is a mixer driver, it also controls other vendor-specific features. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 80 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index d240fa9a4b59..81c59463b693 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -225,7 +225,7 @@ struct scarlett2_device_info { struct scarlett2_ports ports[SCARLETT2_PORT_TYPE_COUNT]; }; -struct scarlett2_mixer_data { +struct scarlett2_data { struct usb_mixer_interface *mixer; struct mutex usb_mutex; /* prevent sending concurrent USB requests */ struct mutex data_mutex; /* lock access to this data */ @@ -568,7 +568,7 @@ struct scarlett2_usb_packet { u8 data[]; }; -static void scarlett2_fill_request_header(struct scarlett2_mixer_data *private, +static void scarlett2_fill_request_header(struct scarlett2_data *private, struct scarlett2_usb_packet *req, u32 cmd, u16 req_size) { @@ -587,7 +587,7 @@ static int scarlett2_usb( struct usb_mixer_interface *mixer, u32 cmd, void *req_data, u16 req_size, void *resp_data, u16 resp_size) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; u16 req_buf_size = sizeof(struct scarlett2_usb_packet) + req_size; u16 resp_buf_size = sizeof(struct scarlett2_usb_packet) + resp_size; struct scarlett2_usb_packet *req, *resp = NULL; @@ -697,8 +697,8 @@ static void scarlett2_config_save(struct usb_mixer_interface *mixer) /* Delayed work to save config */ static void scarlett2_config_save_work(struct work_struct *work) { - struct scarlett2_mixer_data *private = - container_of(work, struct scarlett2_mixer_data, work.work); + struct scarlett2_data *private = + container_of(work, struct scarlett2_data, work.work); scarlett2_config_save(private->mixer); } @@ -719,7 +719,7 @@ static int scarlett2_usb_set_config( } __packed req; __le32 req2; int err; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; /* Cancel any pending NVRAM save */ cancel_delayed_work_sync(&private->work); @@ -790,7 +790,7 @@ static int scarlett2_usb_get_volume_status( static int scarlett2_usb_get_mix(struct usb_mixer_interface *mixer, int mix_num) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; int num_mixer_in = @@ -833,7 +833,7 @@ static int scarlett2_usb_get_mix(struct usb_mixer_interface *mixer, static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer, int mix_num) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; struct { @@ -899,7 +899,7 @@ static u32 scarlett2_mux_id_to_num(const struct scarlett2_ports *ports, } /* Convert one mux entry from the interface and load into private->mux[] */ -static void scarlett2_usb_populate_mux(struct scarlett2_mixer_data *private, +static void scarlett2_usb_populate_mux(struct scarlett2_data *private, u32 mux_entry) { const struct scarlett2_device_info *info = private->info; @@ -937,7 +937,7 @@ static void scarlett2_usb_populate_mux(struct scarlett2_mixer_data *private, /* Send USB message to get mux inputs and then populate private->mux[] */ static int scarlett2_usb_get_mux(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int count = private->num_mux_dsts; int err, i; @@ -966,7 +966,7 @@ static int scarlett2_usb_get_mux(struct usb_mixer_interface *mixer) /* Send USB messages to set mux inputs */ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; const struct scarlett2_ports *ports = info->ports; int rate, port_dir_rate; @@ -1107,7 +1107,7 @@ 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; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_ports *ports = private->info->ports; struct scarlett2_usb_volume_status volume_status; int num_line_out = @@ -1153,7 +1153,7 @@ static int scarlett2_master_volume_ctl_get(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; if (private->vol_updated) { mutex_lock(&private->data_mutex); @@ -1170,7 +1170,7 @@ static int scarlett2_volume_ctl_get(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; if (private->vol_updated) { @@ -1188,7 +1188,7 @@ static int scarlett2_volume_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1254,7 +1254,7 @@ static int scarlett2_sw_hw_enum_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; ucontrol->value.enumerated.item[0] = private->vol_sw_hw_switch[elem->control]; @@ -1266,7 +1266,7 @@ static int scarlett2_sw_hw_enum_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1338,7 +1338,7 @@ static int scarlett2_level_enum_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; ucontrol->value.enumerated.item[0] = private->level_switch[elem->control]; @@ -1350,7 +1350,7 @@ static int scarlett2_level_enum_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1388,7 +1388,7 @@ static int scarlett2_pad_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; ucontrol->value.enumerated.item[0] = private->pad_switch[elem->control]; @@ -1400,7 +1400,7 @@ static int scarlett2_pad_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1439,7 +1439,7 @@ static int scarlett2_button_ctl_get(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; if (private->vol_updated) { mutex_lock(&private->data_mutex); @@ -1456,7 +1456,7 @@ static int scarlett2_button_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1492,7 +1492,7 @@ static const struct snd_kcontrol_new scarlett2_button_ctl = { static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; const struct scarlett2_ports *ports = info->ports; int num_line_out = @@ -1562,7 +1562,7 @@ static int scarlett2_add_line_out_ctls(struct usb_mixer_interface *mixer) static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; int err, i; char s[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; @@ -1607,7 +1607,7 @@ static int scarlett2_mixer_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; ucontrol->value.integer.value[0] = private->mix[elem->control]; return 0; @@ -1618,7 +1618,7 @@ static int scarlett2_mixer_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; const struct scarlett2_ports *ports = info->ports; int oval, val, num_mixer_in, mix_num, err = 0; @@ -1663,7 +1663,7 @@ static const struct snd_kcontrol_new scarlett2_mixer_ctl = { static int scarlett2_add_mixer_ctls(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_ports *ports = private->info->ports; int err, i, j; int index; @@ -1693,7 +1693,7 @@ static int scarlett2_mux_src_enum_ctl_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; const struct scarlett2_ports *ports = private->info->ports; unsigned int item = uinfo->value.enumerated.item; int items = private->num_mux_srcs; @@ -1725,7 +1725,7 @@ static int scarlett2_mux_src_enum_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_elem_info *elem = kctl->private_data; - struct scarlett2_mixer_data *private = elem->head.mixer->private_data; + struct scarlett2_data *private = elem->head.mixer->private_data; ucontrol->value.enumerated.item[0] = private->mux[elem->control]; return 0; @@ -1736,7 +1736,7 @@ static int scarlett2_mux_src_enum_ctl_put(struct snd_kcontrol *kctl, { struct usb_mixer_elem_info *elem = kctl->private_data; struct usb_mixer_interface *mixer = elem->head.mixer; - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int index = elem->control; int oval, val, err = 0; @@ -1769,7 +1769,7 @@ static const struct snd_kcontrol_new scarlett2_mux_src_enum_ctl = { static int scarlett2_add_mux_enums(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_ports *ports = private->info->ports; int port_type, channel, i; @@ -1848,7 +1848,7 @@ static int scarlett2_add_meter_ctl(struct usb_mixer_interface *mixer) static void scarlett2_private_free(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; cancel_delayed_work_sync(&private->work); kfree(private); @@ -1857,7 +1857,7 @@ static void scarlett2_private_free(struct usb_mixer_interface *mixer) static void scarlett2_private_suspend(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; if (cancel_delayed_work_sync(&private->work)) scarlett2_config_save(private->mixer); @@ -1865,7 +1865,7 @@ static void scarlett2_private_suspend(struct usb_mixer_interface *mixer) /*** Initialisation ***/ -static void scarlett2_count_mux_io(struct scarlett2_mixer_data *private) +static void scarlett2_count_mux_io(struct scarlett2_data *private) { const struct scarlett2_ports *ports = private->info->ports; int port_type, srcs = 0, dsts = 0; @@ -1885,8 +1885,8 @@ static void scarlett2_count_mux_io(struct scarlett2_mixer_data *private) static int scarlett2_init_private(struct usb_mixer_interface *mixer, const struct scarlett2_device_info *info) { - struct scarlett2_mixer_data *private = - kzalloc(sizeof(struct scarlett2_mixer_data), GFP_KERNEL); + struct scarlett2_data *private = + kzalloc(sizeof(struct scarlett2_data), GFP_KERNEL); if (!private) return -ENOMEM; @@ -1909,7 +1909,7 @@ static int scarlett2_init_private(struct usb_mixer_interface *mixer, /* Read configuration from the interface on start */ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_device_info *info = private->info; const struct scarlett2_ports *ports = info->ports; int num_line_out = @@ -1978,7 +1978,7 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) static void scarlett2_notify_monitor( struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; const struct scarlett2_ports *ports = private->info->ports; int num_line_out = ports[SCARLETT2_PORT_TYPE_ANALOGUE].num[SCARLETT2_PORT_OUT]; @@ -2001,7 +2001,7 @@ static void scarlett2_notify_monitor( static void scarlett2_notify_dim_mute( struct usb_mixer_interface *mixer) { - struct scarlett2_mixer_data *private = mixer->private_data; + struct scarlett2_data *private = mixer->private_data; int i; private->vol_updated = 1; From patchwork Sun Jun 6 17:46:44 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: 12302105 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=-15.3 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,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 CAE38C47096 for ; Sun, 6 Jun 2021 17:48:32 +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 3E81A61246 for ; Sun, 6 Jun 2021 17:48:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E81A61246 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 CFC781749; Sun, 6 Jun 2021 19:47:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CFC781749 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001710; bh=69wiy1i+pp/18NrJlzJ2QLL+E/PfDCEqe0PWijKrc4I=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sJUVi84/6MOra6RhXUWXvGKpe5xyl5a1xCEEJMiiy4SbJrhlasKhZlqQRdj6ggVrR 62YRoaenXdBd21kiVnCU3kfu33XJslYN3Q1Q2lE2pt8yS/vIT7XNkeFFS2X7vGakZm bGZ9xGDq4DHcvSbE8QEDEA8rVy1ll26JDTL4q+ic= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 40610F804CC; Sun, 6 Jun 2021 19:46:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7E5BDF804C2; Sun, 6 Jun 2021 19:46:49 +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 D9CDFF804AB for ; Sun, 6 Jun 2021 19:46:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D9CDFF804AB Received: by m.b4.vu (Postfix, from userid 1000) id 66C91612FB14; Mon, 7 Jun 2021 03:16:44 +0930 (ACST) Date: Mon, 7 Jun 2021 03:16:44 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 7/8] ALSA: usb-audio: scarlett2: Add temp variable for consistency Message-ID: <198b38f091b40e59d40dfafa3024c97a3ea202f0.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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" Add index temporary variable to scarlett2_mixer_ctl_put() for consistency with the other *_ctl_put() functions. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 81c59463b693..8a4aa16cc364 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1622,18 +1622,19 @@ static int scarlett2_mixer_ctl_put(struct snd_kcontrol *kctl, const struct scarlett2_device_info *info = private->info; const struct scarlett2_ports *ports = info->ports; int oval, val, num_mixer_in, mix_num, err = 0; + int index = elem->control; mutex_lock(&private->data_mutex); - oval = private->mix[elem->control]; + oval = private->mix[index]; val = ucontrol->value.integer.value[0]; num_mixer_in = ports[SCARLETT2_PORT_TYPE_MIX].num[SCARLETT2_PORT_OUT]; - mix_num = elem->control / num_mixer_in; + mix_num = index / num_mixer_in; if (oval == val) goto unlock; - private->mix[elem->control] = val; + private->mix[index] = val; err = scarlett2_usb_set_mix(mixer, mix_num); if (err == 0) err = 1; From patchwork Sun Jun 6 17:47:10 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: 12302107 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.5 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 B4446C47096 for ; Sun, 6 Jun 2021 17:49:04 +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 2E4B561380 for ; Sun, 6 Jun 2021 17:49:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E4B561380 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 C38F6175B; Sun, 6 Jun 2021 19:48:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C38F6175B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623001742; bh=fi178R9ffMna3eVs1cJODLRngk94dUkVwexDTMjNtu8=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SgGaFMfEc1BsshWqZpIqJ7yKfkFwhzrZSuu9YC4B5ULBkcYhUzT9xpNXhe0JNn7H+ stEUJKtKhjWwQAj0aTeSKhBsHXm37ZT5vXeEPnYkQ6orwti2lSuV3O1qpA/NCBHJJ5 2gWHCUgayaIxkxvwQWcTHnwamMPu8f/qMv9YE1fE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 73ADCF800D0; Sun, 6 Jun 2021 19:47:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2B22FF804C3; Sun, 6 Jun 2021 19:47:15 +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 8589EF8019B for ; Sun, 6 Jun 2021 19:47:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8589EF8019B Received: by m.b4.vu (Postfix, from userid 1000) id 1618E61956CD; Mon, 7 Jun 2021 03:17:10 +0930 (ACST) Date: Mon, 7 Jun 2021 03:17:10 +0930 From: "Geoffrey D. Bennett" To: alsa-devel@alsa-project.org, Takashi Iwai Subject: [PATCH 8/8] ALSA: usb-audio: scarlett2: Fix data_mutex lock Message-ID: <4d7ad2f3eea76a09c400c4f04d02d31da9cd7cea.1622999147.git.g@b4.vu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 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 private->vol_updated flag was being checked outside of the mutex_lock/unlock() of private->data_mutex leading to the volume data being fetched twice from the device unnecessarily or old volume data being returned. Update scarlett2_*_ctl_get() and include the private->vol_updated flag check inside the critical region. Signed-off-by: Geoffrey D. Bennett --- sound/usb/mixer_scarlett_gen2.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 8a4aa16cc364..9ea6abded26e 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -1155,11 +1155,10 @@ static int scarlett2_master_volume_ctl_get(struct snd_kcontrol *kctl, struct usb_mixer_interface *mixer = elem->head.mixer; struct scarlett2_data *private = mixer->private_data; - if (private->vol_updated) { - mutex_lock(&private->data_mutex); + mutex_lock(&private->data_mutex); + if (private->vol_updated) scarlett2_update_volumes(mixer); - mutex_unlock(&private->data_mutex); - } + mutex_unlock(&private->data_mutex); ucontrol->value.integer.value[0] = private->master_vol; return 0; @@ -1173,11 +1172,10 @@ static int scarlett2_volume_ctl_get(struct snd_kcontrol *kctl, struct scarlett2_data *private = mixer->private_data; int index = elem->control; - if (private->vol_updated) { - mutex_lock(&private->data_mutex); + mutex_lock(&private->data_mutex); + if (private->vol_updated) scarlett2_update_volumes(mixer); - mutex_unlock(&private->data_mutex); - } + mutex_unlock(&private->data_mutex); ucontrol->value.integer.value[0] = private->vol[index]; return 0; @@ -1441,11 +1439,10 @@ static int scarlett2_button_ctl_get(struct snd_kcontrol *kctl, struct usb_mixer_interface *mixer = elem->head.mixer; struct scarlett2_data *private = mixer->private_data; - if (private->vol_updated) { - mutex_lock(&private->data_mutex); + mutex_lock(&private->data_mutex); + if (private->vol_updated) scarlett2_update_volumes(mixer); - mutex_unlock(&private->data_mutex); - } + mutex_unlock(&private->data_mutex); ucontrol->value.enumerated.item[0] = private->buttons[elem->control]; return 0;