From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384943; b=Id6/YjjXE++BEXVgJKJI1VpgSzIudRL3y5vFORv0toR2AjrOf0A0ACccHnIe+UdjJzHQ GBGEgGbv0e6RtPM6e/n0eCtd6d5ray4yJwZhW5iHwvFv546gEXGEZcZ22MetH+tpzfGDg Zqi1qTKqVaWecXVvwYfbBQOKoxnnirrXvknuQ3Jf9xXPuugjbCHOAMFPnLs0nFFD0no61 v9JCzGjWaU3zMXIq56P3kcx9YEGPsIQFnEcIC9NkNo4xXg51joddwPGobVJYUXK7ZtxNt y/TNYbFIR+cEljE5hcMfKiCZMYnWRCJf7Ka6QpzhQK5AFhAXuG75cMoLvvco6u9fmjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384943; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=kein7p3jkpZketSkCCNKeU58Gw9FHxNX04YinVhf3Aw=; b=UFuR/FIPcYP0WHlsGx93KikICwFA4x7sFFF0ou9UxRYk4dKVk0ghh9hEbQ0xYwUeakgr hHwuqxB/hFznA9X8hVRbwFeZNUJEHx+9Ro2eSpx1zPin6CHKyvWEdbDBe+ASbRd+09IDk cSBwhJw0904HpNGcrqULHsqusnDb5rZNlAZ5QP7eWfrHben6vTyiT9t60vlBIgiDy2Ynj j8aM/ntrafRFm7s5UO4+O70J5YHPxraiJfbsJuJ74Eb5OEVwxje09DQ4+UUJHlPYAvUvf LDEUtue46VhDr7maYtFg8qG0JhphLkkdH30FpMzbsikHADsUlotTbQ+lEBizAGd1YIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fXTEYdG8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5616E606A32F; Fri, 4 Dec 2026 11:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fXTEYdG8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97BB21F00937; Fri, 4 Dec 2026 11:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384943; bh=kein7p3jkpZketSkCCNKeU58Gw9FHxNX04YinVhf3Aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fXTEYdG8RHbLiHejqtTUaMceJwBzXLbZx3qNk2DBLrXuRfgirLu/+OCYs6l3Gd66R Nk7AP2tTF2T8ouaE+DFfNerPaXyjAbjA2v1PeC/aNmGZgcw2zSyEUJ5vUMIx+spOYC UenOBGzE8TW/9LNboDyBxmmvBGBBkiTg4vkEUXVw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zipdox , Takashi Iwai , Sasha Levin Subject: [PATCH 6.6 0356/1167] ALSA: usb-audio: Fix UAC2 mixer unit request handling Date: Fri, 4 Dec 2026 18:56:23 +0900 Message-ID: <20261204100711.260906224@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai [ Upstream commit 0458d97859840506c3688a963dcd4f72b4a23083 ] For a request for a Mixer Unit on UAC2 (also UAC3), the wValue is different from UAC1 and an incompatible value must be passed. Namely, UAC1 takes a word consisting of 1-based input channel in the high byte and 1-based output channel in the low byte. Meanwhile, UAC2/3 takes UAC2_MU_MIXER in the high byte and a MCN (0-based bit position of input/output channels) in the low byte. The current driver implementation blindly assumes the UAC1 way, hence it would cause a firmware error. This patch attempts to implement the conversion to UAC2 MCN at get_ctl_value_v2() and snd_usb_mixer_set_ctl_value() for mixer units. At the points above, the old wValue containing ICN and OCN is converted to the corresponding MCN, and it's used as the proper wValue. Reported-by: Zipdox Closes: https://lore.kernel.org/d46fcac6-bd7e-4fc4-95e1-4e8d39f92ad3@zipdox.net Fixes: 23caaf19b11e ("ALSA: usb-mixer: Add support for Audio Class v2.0") Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20260930155356.348608-3-tiwai@suse.de [ sashal: Added the two new mixer.h fields without the neighbouring get_cur_broken context, which this tree lacks, and adjusted the first mixer.c hunk's context to match the older get_ctl_value_v1(). ] Signed-off-by: Sasha Levin --- sound/usb/mixer.c | 23 +++++++++++++++++++++++ sound/usb/mixer.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 5487657ece939..8229f4028db3c 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -340,6 +340,17 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, return err; } +/* convert the given UAC1 wValue (ICN|OCN) to UAC2 MCN */ +static unsigned char to_mcn(const struct usb_mixer_elem_info *cval, + unsigned int validx) +{ + unsigned char m = (validx >> 8) & 0xff; /* 1-based input channel */ + unsigned char v = validx & 0xff; /* 1-based output channel */ + + /* num_inputs * num_outputs is guaranteed to be < 256 */ + return (m - 1) * cval->num_outputs + (v - 1); +} + static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) { @@ -352,6 +363,10 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, val_size = uac2_ctl_value_size(cval->val_type); + /* correct wValue for UAC2 mixer control with MCN */ + if (cval->v2_mixer) + validx = (UAC2_MU_MIXER << 8) | to_mcn(cval, validx); + if (request == UAC_GET_CUR) { bRequest = UAC2_CS_CUR; size = val_size; @@ -476,6 +491,10 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, } request = UAC2_CS_CUR; + + /* correct wValue for UAC2 mixer control with MCN */ + if (cval->v2_mixer) + validx = (UAC2_MU_MIXER << 8) | to_mcn(cval, validx); } value_set = convert_bytes_value(cval, value_set); @@ -2203,6 +2222,10 @@ static void build_mixer_unit_ctl(struct mixer_build *state, snd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid); cval->control = in_ch + 1; /* based on 1 */ + if (state->mixer->protocol == UAC_VERSION_2 || + state->mixer->protocol == UAC_VERSION_3) + cval->v2_mixer = true; + cval->num_outputs = num_outs; cval->val_type = USB_MIXER_S16; for (i = 0; i < num_outs; i++) { __u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol); diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 36cb4f7daee58..d9e8a0453d676 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -94,6 +94,8 @@ struct usb_mixer_elem_info { int cache_val[MAX_CHANNELS]; u8 initialized; u8 min_mute; + u8 num_outputs; + bool v2_mixer; void *private_data; }; -- 2.53.0