From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057112; b=koYWU1pyLa+4/9tD/ezdd+UvtKGTQlkcFhE/UBT2OivXaW+IR4h2L+b8prfzS3FwtQTo U4JJdMWHMpNUxVTQECnlC3KBhm3LGg18KTfGT8KXoZVBa6dhH1SdgR9A/P+hWWMG9sS9n P02w1Adm9OZiXEwONIxkgJ0S1AEN9C1ZLHrT9EWW9IARHQEQY1nwvQAlp1p5NiQjA/HKC Ym4FfljgUNsco1bE65mZKIG2nY7YvRouMhxzL9q3J4h7kmlsbVBCoQKVL+4HPEqmE/1Fc +jGBJWH4zAbJqXOuDpIEM5x+93BJy2TsFoobJitUkdY+kf6PHU/fJi3TRNqdyecFGUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057112; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=WyiQnZKauw9KYg5Q3tBZms2te2swqf4kHl30R10omdk=; b=zZVQJybol0STwXEAD9XYOa44faHrLDyXgtwT/u0pWbKpvcemvQSlWFgQIvloQDU9cKpV e9f0gaoXAF6YLytCgkRWrI33LXJvmLv4dYU/8PIPGZJN4zO6138/Ujnk6O4OG8zA6SikJ euXVo3vUFJuTlI1zbbdxnA1lRHIz2ApHEquZRwZVMK8NN7PzCbY0GHy6gwjHLGyjaA0sW av8S3tttfXInvjygfWWxkgJaSWEZctMXUV+6RwQoOXk/7GauWtakuXwRmwownD7x7XBGw 7slwWALulC2KlGMvhoAnmoCapHKmeVQgeP70sE17rvcQkuntP9fTiKuIEWe4qjhrX1g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=a0hTCJw9; arc=none smtp.remote-ip=209.85.160.42 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 033FD606A685 for ; Mon, 30 Nov 2026 16:45:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 033FD606A685 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=a0hTCJw9 Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-486f013db83so3374565fac.0 for ; Mon, 30 Nov 2026 08:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796057111; x=1796661911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WyiQnZKauw9KYg5Q3tBZms2te2swqf4kHl30R10omdk=; b=a0hTCJw9RXVBFABmpXkYPRs831bRiAaJimccuiVW++IVIFnen4pykGWglXrkdaxGbl SorrWDdWCnHmXYOY8gD4LlqGAS5vgy+1U8JZ35tb32SJYnr9w+iN2WWwE+S59/+yOgxN zzChJmxAPdOPdjBfCqHST9ce/4SxLh4AfGNwyh9dUfOzOybRv8ZCKLmA0IgwyEPdCg49 ndhSW3sPqZGssm85k6knyqhDHOSjfcgWTEv4a+t+pmEAa0LHE0eBq6hND0tRuATgWjWd 2BD9V33Gti+VczF/dMIVExLnXrV9mXzQRXmOzm8FyZw7b9Pex/6xN0NVuGm9Jsac/5Lv JfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796057111; x=1796661911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WyiQnZKauw9KYg5Q3tBZms2te2swqf4kHl30R10omdk=; b=aodt5a3OwMG5jyBrhfIQCuiF88zhaoCc3eomm28G4n8Op9v8fYTJ0tOHS4gidfht58 IKzh2NO+fNcYtylrhk2iDONdEuOH6sRRk+vIRoLdK0RFUikMYSF3ftWnp8DGcaPvvWqP AvWI0i3Ss9pmWFBqM0vjFfxEatISaoNgm0FOlv6DFLKIXsELqjo+2gDOyjNBFL6QjxF+ x3eBU/wzFv5ICWcjeEV9VjlpA4Kz6oBFTdcCLkDF9FEotVulXdVFH84ITfVVP035XTp7 BxrgbkSaeqhtL00ywmbjoSQ5fp4qBS+Hj+PmvpzaGdSfJ5EXkH4729OP8SJIIdbvmhqN nIXA== X-Forwarded-Encrypted: i=1; AL+hErHS7O0pYqqh8S3Lmfnz6Tg42D2+nZqev6d1Vv4g8vH3LgFIYbw7ERU2n6FZLDTq/WoGzokzRgZTIT3jwYA=@vger.kernel.org X-Gm-Message-State: APuU4Z8RGWhJwAU66O+2GMwa4e2J5kHYzQtvxnEx0cwshHRYcUvpaT6L vS4F6XEaXARyhv5mikqE5WbIYLGcdIH+gU0aRLrU0AYi1AzhbUJ7QNLp X-Gm-Gg: AZFdTZcg0IIERAFf5Ywg4vU4Q8V0teKfsO307CC9Vs/Txqw1L54Snm7zfs2Ulsksc6b 30+zdZKzQ0N8r0wRsMQLW0KjXv2jnpJ3AGj5wBdFySGljsPfhMS1h0oj9rvyOQFQ9L8Up0yAuS0 E6jOCM+k5dcsezZEHSCCNK/PK7Evhj8yWa6OwjUFBlfWigBVctM/fxLMOv35y72alEcwM+lnXCd qT7/fJ6zhUCik14IqgiYb4iFVWB+RmJBqNR4i9KEnBBeW02rZDxycMoOSyW93mP8/xHegV51sbs lPM1mUc9U/y2VdNxetSHpgtV7stCh0CdPgBDJOEGk/uEPo1n2UzR6UZ3u4g7WPTIR+YiGbjIz16 ql5Azx3eygf35fdFKjRw0aM2Ll3IRGLWw72fU1dU5QJz+suCNJc6K2FnuKh4wLB1C+IzNWe/XeV 4evAjC//zVBNty1c+pt0ZmqNrlKdeNcFaGzrxtHsZyOJyooP82YTMw3yARH8WTGaXKuc8MWYR4e 7HBgZAslbih2Opebw1zX8Giqbp7RXf3FxPgrWhg3ZUGJDvGQFJRR0W8gfu81CZtTAlVncQCJTbr ZOCCtC//3JmgQ2Nr9Iy5iRNO9TH7FhgBcfLYiDLMHo0hlg== X-Received: by 2002:a05:6870:e191:b0:494:84a6:cd6f with SMTP id 586e51a60fabf-4bc8434fa44mr31263275fac.41.1796057110905; Mon, 30 Nov 2026 08:45:10 -0800 (PST) Received: from localhost.localdomain ([2600:1702:4ff0:baa0:5054:ff:fe3d:4ddb]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4bc5f7ae7dcsm28002053fac.8.2026.11.30.08.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 08:45:10 -0800 (PST) From: Will Porter To: Takashi Iwai , Jaroslav Kysela Cc: Christian Ruppert , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Andrews , Nikita Tarasov Subject: [PATCH v2 07/21] ALSA: mixer_audient: clarify USB control message definition Date: Mon, 30 Nov 2026 10:44:14 -0600 Message-ID: <20261130164428.2930348-8-mrwillporter@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130164428.2930348-1-mrwillporter@gmail.com> References: <20261130164428.2930348-1-mrwillporter@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Christian Ruppert Previously, base values for wIndex and wValue were directly given in the control type. Construct them from a unit ID and selector for clarity. Signed-off-by: Christian Ruppert Signed-off-by: Will Porter --- sound/usb/mixer_audient.c | 76 +++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/sound/usb/mixer_audient.c b/sound/usb/mixer_audient.c index 2afef52a12d9a..63714d00592c7 100644 --- a/sound/usb/mixer_audient.c +++ b/sound/usb/mixer_audient.c @@ -45,15 +45,15 @@ static const struct snd_audient_ctrl_type { int integer; } max; const unsigned int *tlv; - u16 wValue; - u16 wIndex; + u8 unit; + u8 sel; } snd_audient_ctypes[SND_AUDIENT_TYPE_NCTYPES] = { [SND_AUDIENT_TYPE_MONITOR] = { .type = SNDRV_CTL_ELEM_TYPE_INTEGER, .min.integer = 0, .max.integer = 127, - .wValue = 0x0000, - .wIndex = 0x3800, + .unit = 0x38, + .sel = 0x00, /* no TLV here because we can't describe the cross-fader */ }, [SND_AUDIENT_TYPE_PHANTOM] = { @@ -61,31 +61,31 @@ static const struct snd_audient_ctrl_type { .invert = false, .min.integer = 0, .max.integer = 1, - .wValue = 0x0000, - .wIndex = 0x3A00, + .unit = 0x3A, + .sel = 0x00, }, [SND_AUDIENT_TYPE_MUTE] = { .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN, .invert = true, .min.integer = 0, .max.integer = 1, - .wValue = 0x0200, - .wIndex = 0x3A00, + .unit = 0x3A, + .sel = 0x02, }, [SND_AUDIENT_TYPE_MUTE_OUT] = { .type = SNDRV_CTL_ELEM_TYPE_BOOLEAN, .invert = true, .min.integer = 0, .max.integer = 1, - .wValue = 0x0100, - .wIndex = 0x3B00, + .unit = 0x3B, + .sel = 0x01, }, [SND_AUDIENT_TYPE_MIXER] = { .type = SNDRV_CTL_ELEM_TYPE_INTEGER, .min.integer = -128 * 256, .max.integer = 6 * 256, - .wValue = 0x0100, - .wIndex = 0x3C00, + .unit = 0x3C, + .sel = 0x01, .tlv = snd_audient_tlv_mixer, }, }; @@ -209,7 +209,7 @@ const struct snd_audient_ctrl_type *snd_audient_kctl_type(struct snd_kcontrol return &snd_audient_ctypes[kctl->private_value & 0xFF]; } -static __always_inline u16 snd_audient_kctl_valoffs(struct snd_kcontrol *kctl) +static __always_inline u16 snd_audient_kctl_cidxoffs(struct snd_kcontrol *kctl) { return (kctl->private_value >> 8) & 0xFF; } @@ -233,11 +233,16 @@ static inline u16 snd_audient_kctl_channels(struct snd_kcontrol *kctl) #define AUDIENT_REQTYPE_GET (USB_DIR_IN | USB_TYPE_CLASS \ | USB_RECIP_INTERFACE) +#define U8_U8(HI, LO) ((((u16)(HI)) << 8) | ((LO) & 0xFF)) + static inline int snd_audient_get_cur(struct usb_mixer_interface *mixer, - u16 value, u16 index, - void *buf, size_t len) + const u8 unit, const u8 sel, + const u8 cidx, + void *const buf, const size_t len) { struct usb_device *const dev = mixer->chip->dev; + const u16 value = U8_U8(sel, cidx); + const u16 index = U8_U8(unit, mixer->hostif->desc.bInterfaceNumber); return snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, AUDIENT_REQTYPE_GET, @@ -245,10 +250,13 @@ static inline int snd_audient_get_cur(struct usb_mixer_interface *mixer, } static inline int snd_audient_set_cur(struct usb_mixer_interface *mixer, - u16 value, u16 index, - void *buf, size_t len) + const u8 unit, const u8 sel, + const u8 cidx, + void *const buf, const size_t len) { struct usb_device *const dev = mixer->chip->dev; + const u16 value = U8_U8(sel, cidx); + const u16 index = U8_U8(unit, mixer->hostif->desc.bInterfaceNumber); return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, AUDIENT_REQTYPE_SET, @@ -266,8 +274,7 @@ static int snd_ctl_audient_boolean_get(struct snd_kcontrol *kctl, const unsigned int hwchan = snd_audient_kctl_hwchannels(kctl); const struct snd_audient_ctrl_type *const ctype = snd_audient_kctl_type(kctl); - const u16 value = ctype->wValue + snd_audient_kctl_valoffs(kctl); - const u16 index = ctype->wIndex; + const u8 base = snd_audient_kctl_cidxoffs(kctl); int i; @@ -279,8 +286,8 @@ static int snd_ctl_audient_boolean_get(struct snd_kcontrol *kctl, u32 buf; int ret; - ret = snd_audient_get_cur(mixer, value + i, index, - &buf, sizeof(buf)); + ret = snd_audient_get_cur(mixer, ctype->unit, ctype->sel, + base + i, &buf, sizeof(buf)); if (ret < 0) return ret; @@ -307,8 +314,7 @@ static int snd_ctl_audient_boolean_set(struct snd_kcontrol *kctl, const unsigned int hwchan = snd_audient_kctl_hwchannels(kctl); const struct snd_audient_ctrl_type *const ctype = snd_audient_kctl_type(kctl); - const u16 value = ctype->wValue + snd_audient_kctl_valoffs(kctl); - const u16 index = ctype->wIndex; + const u8 base = snd_audient_kctl_cidxoffs(kctl); int changed = 0; int i; @@ -325,15 +331,16 @@ static int snd_ctl_audient_boolean_set(struct snd_kcontrol *kctl, if (ctype->invert) buf ^= cpu_to_le32(0x1); - ret = snd_audient_get_cur(mixer, value + i, index, - &rbuf, sizeof(rbuf)); + ret = snd_audient_get_cur(mixer, ctype->unit, ctype->sel, + base + i, &rbuf, sizeof(rbuf)); if (ret < 0) return ret; if (rbuf != buf) { changed = 1; - ret = snd_audient_set_cur(mixer, value + i, index, + ret = snd_audient_set_cur(mixer, ctype->unit, + ctype->sel, base + i, &buf, sizeof(buf)); if (ret < 0) return ret; @@ -353,8 +360,7 @@ static int snd_ctl_audient_integer_get(struct snd_kcontrol *kctl, const unsigned int hwchan = snd_audient_kctl_hwchannels(kctl); const struct snd_audient_ctrl_type *const ctype = snd_audient_kctl_type(kctl); - const u16 value = ctype->wValue + snd_audient_kctl_valoffs(kctl); - const u16 index = ctype->wIndex; + const u8 base = snd_audient_kctl_cidxoffs(kctl); int i; @@ -367,8 +373,8 @@ static int snd_ctl_audient_integer_get(struct snd_kcontrol *kctl, s16 val; int ret; - ret = snd_audient_get_cur(mixer, value + i, index, - &buf, sizeof(buf)); + ret = snd_audient_get_cur(mixer, ctype->unit, ctype->sel, + base + i, &buf, sizeof(buf)); if (ret < 0) return ret; @@ -391,8 +397,7 @@ static int snd_ctl_audient_integer_set(struct snd_kcontrol *kctl, const unsigned int hwchan = snd_audient_kctl_hwchannels(kctl); const struct snd_audient_ctrl_type *const ctype = snd_audient_kctl_type(kctl); - const u16 value = ctype->wValue + snd_audient_kctl_valoffs(kctl); - const u16 index = ctype->wIndex; + const u8 base = snd_audient_kctl_cidxoffs(kctl); int changed = 0; int i; @@ -406,15 +411,16 @@ static int snd_ctl_audient_integer_set(struct snd_kcontrol *kctl, s16 buf = cpu_to_le16(ctl_val->value.integer.value[i]); int ret; - ret = snd_audient_get_cur(mixer, value + i, index, - &rbuf, sizeof(rbuf)); + ret = snd_audient_get_cur(mixer, ctype->unit, ctype->sel, + base + i, &rbuf, sizeof(rbuf)); if (ret < 0) return ret; if (rbuf != buf) { changed = 1; - ret = snd_audient_set_cur(mixer, value + i, index, + ret = snd_audient_set_cur(mixer, ctype->unit, + ctype->sel, base + i, &buf, sizeof(buf)); if (ret < 0) return ret; -- 2.47.3