From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93FD3375AD8; Mon, 2 Mar 2026 18:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477966; cv=pass; b=t6vjLlniGxt1vortLX70+lI1uRdtsI8sfFjza3ApL9huwayBgWgvoIC/UqRx8FIDnTLfC14UDZU/9efibDJ+ugAMp3UgxFSWSIrNvd+nSQyfWrPm9IAGS8mcQ5OW3Vfq7EjTHTFKJYcg2WX0Ji+atkiws7L1gmgieogNkPVH/kI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477966; c=relaxed/simple; bh=ZmnG1mvLC+nqfqk1ivL295tgmudCFqWeCE+Ry39YMC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hOWVJcCYCHmwhI8O2Ee0bPtVd3viE0jsRF9G1+KDkJ64wpIs9nQDsPGqt84IXTnuulIxdRGY9n2DyUl75jRMd7HYT8HzJ0QFf7Qn1XcKDNSnw6Rg8cn0GHDXdI4ApDop6Gib1eKxWSO9y3rF9gFnFbfwreSkt844T7xcH1dyM9M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=IopU1XMI; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="IopU1XMI" ARC-Seal: i=1; a=rsa-sha256; t=1772477951; cv=none; d=zohomail.com; s=zohoarc; b=aeA15Y/c+tit1VCdaK7rv78xw8PkK7x8I61+OTFYA4ti7W0u3E/K4SsucctGCU4kQsVgbsJFyfVfXu8idiVKC1GCFPg0zf9vM2Gt6bO7V5g7cYiBRFzYZTh/2/9TN0J+zgMOPz+NcKUysixZKOoZFi1/2wTVJHO2PhAuV+KHZow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477951; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=m5MkS0FlgjmLHAzJnS3KdKIY+xY7EDfUNnbvaa6b+l4=; b=Pg6/wBX9Xu0UuSDOGVY98gKe7e6CNeXqxm2zOQzb4fo/glvvF2ovlPQljVLM+QijTPW1dyMWNEtaPRgkk5gbBCaBR85cJVW5P1rBEJv4zBvkU2/tIWL+6UrnYww/5vNhAtIgm36CftLD76hDbA5K2BR/KcHf4/C4Aaq+quJTt9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477951; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=m5MkS0FlgjmLHAzJnS3KdKIY+xY7EDfUNnbvaa6b+l4=; b=IopU1XMIA+Rn5ltQhog/8UorJnmP67MUPZnrfC847Wmdpt2GcGdTnL5H40ntLpNn NMZT4xsQZ5zBxCpTs4of8GIy8w5XlHKGUmgJmfCuJ62QwHHFgMT0xX90tLpzFSPmZHn gxdSBN4rRf0jY1/rXgSRIlxj0z5D8P69JbWlSM8x+Gnyn3rIpmucfHoFI+w/oY0ngYv Y1e8UZsxgp8FVxQ9einMDopCMm8NqqpwJEubt/PHAYUtE+93YbiPKTsZ5dCV7nb8U7o z/BBk016F2i/SZUNeD4XpWKQVFCeL4bL8SRKnBMVlOHlDvtXZcrvL7gyAKp7EV0cRd3 nJbfHKCxZw== Received: by mx.zohomail.com with SMTPS id 1772477949830999.8581879892873; Mon, 2 Mar 2026 10:59:09 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng , stable@vger.kernel.org Subject: [PATCH v2 1/8] Revert "ALSA: usb: Increase volume range that triggers a warning" Date: Tue, 3 Mar 2026 02:58:52 +0800 Message-ID: <20260302185900.427415-2-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" UAC uses 2 bytes to store volume values, so the maximum volume range is 0xFFFF (65535, val =3D -32768/32767/1). The reverted commit bumpped the range of triggering the warning to > 65535, effectively making the range check a no-op. It didn't fix anything but covered any potential problems and deviated from the original intention of the range check. This reverts commit 6b971191fcfc9e3c2c0143eea22534f1f48dbb62. Fixes: 6b971191fcfc ("ALSA: usb: Increase volume range that triggers a warn= ing") Cc: stable@vger.kernel.org Signed-off-by: Rong Zhang Acked-by: Arun Raghavan --- sound/usb/mixer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index ac8c71ba94834..df0d3df9c7ece 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1813,10 +1813,11 @@ static void __build_feature_ctl(struct usb_mixer_in= terface *mixer, =20 range =3D (cval->max - cval->min) / cval->res; /* - * There are definitely devices with a range of ~20,000, so let's be - * conservative and allow for a bit more. + * Are there devices with volume range more than 255? I use a bit more + * to be sure. 384 is a resolution magic number found on Logitech + * devices. It will definitively catch all buggy Logitech devices. */ - if (range > 65535) { + if (range > 384) { usb_audio_warn(mixer->chip, "Warning! Unlikely big volume range (=3D%u), cval->res is probab= ly wrong.", range); --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 903A1373C05; Mon, 2 Mar 2026 18:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477970; cv=pass; b=k8N/IDf7jT38+pG7BJ4C8R5x2DyhRABiQeImc/XjTgViAj9IF4TO+2bPTchzaJzQ5WbZ7GOn+qeKmnjhGRche4xtSzZixVjW0pPmIBqU7ZYwAJa5IAh/HMUN3ZohqBeJmAwLXfEhpW0xf7TMa9HA5QsShVArmhA+ZAyViyI5mwI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477970; c=relaxed/simple; bh=/lQIky8CZKavwRz8u5C5zMFPyf0VvC0LS2EBXvJ14Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NvhEvX8fBlO9uGU/JMMW7nrxcBb38EL17P8OLaFJzcG+1pXWhrpmBUDKgZTIlD9kSBZ8fRq4018X2KpDuE4vnLdSymmshfjp86hUp+1HXaPP4w/p9YewHapQsxB0axswc3GpVCK4dh0TeOyITs6yK8P84MT6KjlV9fe+91OrWD8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=jiyLqlPp; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="jiyLqlPp" ARC-Seal: i=1; a=rsa-sha256; t=1772477955; cv=none; d=zohomail.com; s=zohoarc; b=U1eqRarNYQI4fg3IGAlPTvg0c2iV+amw9jUfs5Mn9kMhsAf9mMfM4CsRwEAhenisBLTy0gC53MIP14eB0YOiydQIeWu2gOOd3RSH6oWP1jBtH8nCko7ryzPLdIN2YmC4a2Crcs5HJZpqDCal9pqBsFdYhhUdKIRnlBHX9mJroqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477955; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=dfOtOj2mJ90DyMmFUn0bS67YeVG/vNESqFGEOc96Ml8=; b=MDXUkZSOpuKeKKgaq7N6c5QsHU/SL/SLmUqerwWuIJfqoTVvxHDM4wABzGkGgZuak7hAHJhef5dKjoArwI5JJrOYzznhRGdZwG0HvrfyHFnB0/j3vGOrl2QTtmWgcf5ynzqzIJ/LCsnFIThw7iHgGu5UHlo/RbamxCuSL3328AM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477955; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=dfOtOj2mJ90DyMmFUn0bS67YeVG/vNESqFGEOc96Ml8=; b=jiyLqlPpzBtkuR/9pj/T2G9cEAP7DNBM0+Qzx8Lw7pQuaQzQii+No8aMwh0wE9ru 0vNU5xVVPx1DePDpBZ87eRYLh8c3N6pAeatKJKpBBijPSqI/N7XBb1fxnxej3fPtQpi ct6P9If240gmZmIj/L5ZSdtgMyNJOqfVND8IG5REum8zjFqnspxfGeyO1GX6x3USeHP ulrZk363oy4u1x4hWogeUPvbFBv8jxa3d73ouMtFDGOtdOm+LJfPN1FsI4k3w9EvpFy 9hjjSy0Z3bEAeeVO6dyZxMvEL8h0r9qMN+eEFjA6sX3YFPIPWRUjS3XgWrdc/0tEPZ+ TqkDTlKkqA== Received: by mx.zohomail.com with SMTPS id 1772477952939128.88145861487385; Mon, 2 Mar 2026 10:59:12 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 2/8] ALSA: usb-audio: Add helper function for volume range checks Date: Tue, 3 Mar 2026 02:58:53 +0800 Message-ID: <20260302185900.427415-3-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" When a potentially insane volume range is found, the volume control parameters will be printed in WARN level instead of DEBUG level. Currently, it's done by emitting a open-coded usb_audio_warn() in the corresponding check. The following changes are about to add more checks against volumen ranges. As the first step, extract the current check logic into a helper function to improve readability. No functional change intended. Signed-off-by: Rong Zhang --- sound/usb/mixer.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index df0d3df9c7ece..f52ca0d7e6653 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1660,6 +1660,27 @@ static const struct usb_feature_control_info *get_fe= ature_control_info(int contr return NULL; } =20 +static bool check_insane_volume_range(struct usb_mixer_interface *mixer, + struct snd_kcontrol *kctl, + struct usb_mixer_elem_info *cval) +{ + int range =3D (cval->max - cval->min) / cval->res; + + /* + * Are there devices with volume range more than 255? I use a bit more + * to be sure. 384 is a resolution magic number found on Logitech + * devices. It will definitively catch all buggy Logitech devices. + */ + if (range > 384) { + usb_audio_warn(mixer->chip, + "Warning! Unlikely big volume range (=3D%u), cval->res is probab= ly wrong.", + range); + return true; + } + + return false; +} + static void __build_feature_ctl(struct usb_mixer_interface *mixer, const struct usbmix_name_map *imap, unsigned int ctl_mask, int control, @@ -1673,7 +1694,6 @@ static void __build_feature_ctl(struct usb_mixer_inte= rface *mixer, struct snd_kcontrol *kctl; struct usb_mixer_elem_info *cval; const struct usbmix_name_map *map; - unsigned int range; =20 if (control =3D=3D UAC_FU_GRAPHIC_EQUALIZER) { /* FIXME: not supported yet */ @@ -1811,25 +1831,16 @@ static void __build_feature_ctl(struct usb_mixer_in= terface *mixer, =20 snd_usb_mixer_fu_apply_quirk(mixer, cval, unitid, kctl); =20 - range =3D (cval->max - cval->min) / cval->res; - /* - * Are there devices with volume range more than 255? I use a bit more - * to be sure. 384 is a resolution magic number found on Logitech - * devices. It will definitively catch all buggy Logitech devices. - */ - if (range > 384) { - usb_audio_warn(mixer->chip, - "Warning! Unlikely big volume range (=3D%u), cval->res is probab= ly wrong.", - range); - usb_audio_warn(mixer->chip, - "[%d] FU [%s] ch =3D %d, val =3D %d/%d/%d", + if (check_insane_volume_range(mixer, kctl, cval)) { + usb_audio_warn(mixer->chip, "[%d] FU [%s] ch =3D %d, val =3D %d/%d/%d\n", cval->head.id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); + } else { + usb_audio_dbg(mixer->chip, "[%d] FU [%s] ch =3D %d, val =3D %d/%d/%d\n", + cval->head.id, kctl->id.name, cval->channels, + cval->min, cval->max, cval->res); } =20 - usb_audio_dbg(mixer->chip, "[%d] FU [%s] ch =3D %d, val =3D %d/%d/%d\n", - cval->head.id, kctl->id.name, cval->channels, - cval->min, cval->max, cval->res); snd_usb_mixer_add_control(&cval->head, kctl); } =20 --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E6E3373C17; Mon, 2 Mar 2026 18:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477971; cv=pass; b=M2Zq+tQ5IskTgFTKkv9S60HJHVROMH3oUuU6BnLG3G3k+dn5RYh+/BDGlO4zLUZHrxaNv0iKNAkX/55ouQxunVZTQZCBDPmwmuon8plWoQAhfLxUgj5rpMm5ckDvR+HskkebZAYaty/ZEbWsccMso5iIFeV/6IH9vLueWeqoTNE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477971; c=relaxed/simple; bh=bwsJSfMDmrTaxkbp/XYlbzcwS+2yEhdoPtsODrAUjJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KvEKGVlFXWPnTwUXbT8Of4x/p9HftUKvOQR1RRGWmqzPhGIsRGrbPSvlrQZyUKDZUTW9V5OFOKYgAXROUsYn7/AVpuX1jR8s14zkcXg9xeFjz8yYmyONopK+lZ5Hqeki5Mths76omrLsG3pDRk1g6lJ+P8Ld0mGUlJqEZSt7MI8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=BOWvaVyR; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="BOWvaVyR" ARC-Seal: i=1; a=rsa-sha256; t=1772477957; cv=none; d=zohomail.com; s=zohoarc; b=HZw6HfouYnHMSyPDUorLLPAD8R79kSAVY7bPGS9bG/2sEfOhcbwYPQ/S9Dxhsc7elFLUHHcPJ24YFvFhcLzyAsAht7EI7OjHc+q3KI/N124dPdOjOywhB7XVduud9RkxjFduP4MED49xB/J7ubVs2eA1YJqs2R4w18RcvGdLihw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477957; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=9lmwt1a5i7dWGlVNbXzYeTJ7RIriT+tawyy94Ui5hSg=; b=Hldu0miMK1n2bx+0MjO8RO+3KaIYar05q9cwpD8BmW5zmsl/6iAoNuAXs+Rq1yN0KLf4ZAVBA5z91lim/1mNPc/wczc20P6K60VhEjjk0OCd4NivdWO8KT/GPNcvC0PJXT0QfEd6+Fbl0p88/2JYe7wqV8BgG5stlj7NuZdS9yA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477957; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=9lmwt1a5i7dWGlVNbXzYeTJ7RIriT+tawyy94Ui5hSg=; b=BOWvaVyRsmCHEbt22mII5JeAIymbpggIJ7xjDyA2Pr2QerhmuvGq+zuml6ymIx2n faEi+QIw5f78VotOuHEANNck4mqQiOqASgHUUvVR+EYL5o1bhWZAcqozbDo2ifvOyKT 0XKdqnz0XJoIaMfYCjxHEFXhrfDIsuAEesDUxApR0icDMKJii1oKgQFhoQnBzhv9sFB F/DOcSmzxL6roNCcVskGFz/TLsBpijWO3L9mIdgUaEI2HuBUvdXzX4O7Lw7heI2RVo3 2uK2PS7JzGTRtr5ZmHTzCPc6GnNbOiYYkXCoq423HNXi5xRjDsTOOS6hoWjboO//HK8 /1KnkqmhBw== Received: by mx.zohomail.com with SMTPS id 1772477956122902.5162994222561; Mon, 2 Mar 2026 10:59:16 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 3/8] ALSA: usb-audio: Improve volume range checks Date: Tue, 3 Mar 2026 02:58:54 +0800 Message-ID: <20260302185900.427415-4-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Currently the volume range check is only meant to discover quirky microphone on webcam devices and facing these issues: - The check is only meaningful for dB volume, but it doesn't check if the TLV callback is the corresponding one - A common quirky pattern "val =3D 0/100/1" doesn't trigger any warning - Some modern devices trigger the check, but they are legit - The warning message doesn't apply to some quirky messages with linear volume - The term "range" in the warning message is confusing. At readers' first glance it should be (max - min), but it turns out to be ((max - min) / res) Solve these issues by improving the checking logic to: - Ignore mixers with non-dB TLV - Warn on unlikely small volume ranges (max - min < 256) - Add some heuristics to determine if the volume range is unlikely big - Rephrase the warning message to mention linear volume - Rephrase the warning message in correct wording Signed-off-by: Rong Zhang --- sound/usb/mixer.c | 54 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index f52ca0d7e6653..7007e0c9489b4 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1664,20 +1664,62 @@ static bool check_insane_volume_range(struct usb_mi= xer_interface *mixer, struct snd_kcontrol *kctl, struct usb_mixer_elem_info *cval) { - int range =3D (cval->max - cval->min) / cval->res; + int range, steps, threshold; =20 /* - * Are there devices with volume range more than 255? I use a bit more - * to be sure. 384 is a resolution magic number found on Logitech - * devices. It will definitively catch all buggy Logitech devices. + * If a device quirk has overrode our TLV callback, no warning should + * be generated since our checks are only meaningful for dB volume. */ - if (range > 384) { + if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) || + kctl->tlv.c !=3D snd_usb_mixer_vol_tlv) + return false; + + /* + * Meaningless volume control capability (<1dB). This should cover + * devices mapping their volume to val =3D 0/100/1, which are very likely + * to be quirky. + */ + range =3D cval->max - cval->min; + if (range < 256) { usb_audio_warn(mixer->chip, - "Warning! Unlikely big volume range (=3D%u), cval->res is probab= ly wrong.", + "Warning! Unlikely small volume range (=3D%u), linear volume or = custom curve?", range); return true; } =20 + steps =3D range / cval->res; + + /* + * There are definitely devices with ~20,000 ranges (e.g., HyperX Cloud + * III with val =3D -18944/0/1), so we use some heuristics here: + * + * min < 0 < max: Attenuator + amplifier? Likely to be sane + * + * min < 0 =3D max: DSP? Voltage attenuator with FW conversion to dB? + * Likely to be sane + * + * min < max < 0: Measured values? Neutral + * + * min =3D 0 < max: Oversimplified FW conversion? Linear volume? Likely to + * be quirky (e.g., MV-SILICON) + * + * 0 < min < max: Amplifier with fixed gains? Likely to be quirky + * (e.g., Logitech webcam) + */ + if (cval->min < 0 && 0 <=3D cval->max) + threshold =3D 24576; /* 65535 * (3 / 8) */ + else if (cval->min < cval->max && cval->max < 0) + threshold =3D 1024; + else + threshold =3D 384; + + if (steps > threshold) { + usb_audio_warn(mixer->chip, + "Warning! Unlikely big volume step count (=3D%u), linear volume = or wrong cval->res?", + steps); + return true; + } + return false; } =20 --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1E2837BE75; Mon, 2 Mar 2026 18:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477974; cv=pass; b=c3nMWxCNNtNGWqTnqT6SGrcSfUXCLCWDuSBKtLyBhNFzkN+Xc0ZuzEka8cS+wwttCnXYCxv+c/zF9osiLNxeDdpUQVllgaVGjSv88/fM3bhf0ufyh9X2eG1cxqCagWWuFmz74qLnRpRPVB3r8a++MoufBXf2LVAwURNElpZrEM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477974; c=relaxed/simple; bh=Qw0zZSYuL7MErMf7Jfleria3+Y6KnwCYVtKLkVGJ9rU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JogsAvB8SQ4SJz+6kx7DUeokAb2txVjVpmcxZXecvD89rnQ7mHYPI9wyrHgkKe0B6VFjVNqRjb+7BYWTxboyMAgVB63kbdtUJIBAd8zoUwxkUTrJ4N5QCuzrRlhZNP///Jb/V6pG10wRWzEQIyViYn1zsUP2+sqYANDKaSJiXYk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=LGdXC7TH; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="LGdXC7TH" ARC-Seal: i=1; a=rsa-sha256; t=1772477961; cv=none; d=zohomail.com; s=zohoarc; b=i/LVGNbfyX6Tc/cAJ1v7UV5ubx2H0GuyT54efVcTvG6Bz7B9jIY7G3EIaqT+I9ekwKo1gI+gl55D1sCEvQwZ7oZDh2tdDOcGN9tHmyVi7BxxALXhTbBy31EmkgersgaI+KMmTUNGrGJdW96E4NENhvqmJe4XFbQFYx4Jrs6h8NE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477961; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=dv6bdqcyhYgJyaJ0g+4K2PA4ZxzA5UgFv7aCp+89l/U=; b=Jbc6fq/rt44rhtgzslRahAJYA4+KXQdHS9bLY23RvT3UsOlIgT/4ohjlJEyrLSYsUIdTRefrivh31MmKnjDMzXiPtcU7e4KxmsqtoBRRl2+21pkSmx9PaF4sxSFokCD13QXdntLBHhfhcxpekfDIjZbMVn1fcD+iItTH0n+GcYM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477961; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=dv6bdqcyhYgJyaJ0g+4K2PA4ZxzA5UgFv7aCp+89l/U=; b=LGdXC7THBaIGzoGEdN50h+IOB/ceusHN0uUAelkifodxdmPl4N0r+OxUQG9y2a6f b9Y9T3+mBr4+mhyzTUlAZH1O80xTF0KZJvrJFRu8Xb2bVOBq1pMvWt9tEAWmj+dFfKI hMTE+am3fFTtemc1tYruUc82x9OBo8EkHK7RvUXW9xa3w1W1vgrsgH+b6MDCFV8Rn9N lywMiM8de2P4lIGnXxcuO6BUfxTH0DTSEnz8muKSoAXoJ+W1XAIhwzY9OqkzL060AT6 8AHxMgHj2ydSPRolyX52dFpyJzAqcN4V/0C5VvBAlQS6TU4fHaAlA8BdfygdoS+0IZy a5ZWG5W7dQ== Received: by mx.zohomail.com with SMTPS id 1772477959220498.95061102923967; Mon, 2 Mar 2026 10:59:19 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 4/8] ALSA: usb-audio: Support string-descriptor-based quirk table entry Date: Tue, 3 Mar 2026 02:58:55 +0800 Message-ID: <20260302185900.427415-5-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Some quirky devices do not have a unique VID/PID. Matching them using DEVICE_FLG() or VENDOR_FLG() may result in conflicts. Add two new macros DEVICE_STRING_FLG() and VENDOR_STRING_FLG() to match USB string descriptors (manufacturer and/or product) in addition to VID and/or PID, so that we can deconflict these devices safely. No functional change intended. Signed-off-by: Rong Zhang --- Changes in v2: - Alloc string buffers with kmalloc() instead of on stack (thanks Takashi Iwai) - Get string descriptors in a neater way (ditto) - Tiny differences compared to Takashi's sugeestion: - Use `IS_ERR_OR_NULL() || strcmp()' instead of `!IS_ERR_OR_NULL() && strcmp()', so failure in getting the string descriptor won't resulting in quirk flags being applied to irrelevant devices - Use trivial goto cleanup patterns instead of `__free(kfree)' as the latter can't handle ERR_PTR() - Tiny differences compared to my previous reply: - Use usb_string() as Takashi suggested instead of usb_cache_string(), so that we can retrieve the errno and print it out on failure --- sound/usb/quirks.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index c6a78efbcaa30..8deeb9d247500 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2,8 +2,10 @@ /* */ =20 +#include #include #include +#include #include #include #include @@ -2135,16 +2137,39 @@ void snd_usb_audioformat_attributes_quirk(struct sn= d_usb_audio *chip, /* * driver behavior quirk flags */ +struct usb_string_match { + const char *manufacturer; + const char *product; +}; + struct usb_audio_quirk_flags_table { u32 id; u32 flags; + const struct usb_string_match *usb_string_match; }; =20 #define DEVICE_FLG(vid, pid, _flags) \ { .id =3D USB_ID(vid, pid), .flags =3D (_flags) } #define VENDOR_FLG(vid, _flags) DEVICE_FLG(vid, 0, _flags) =20 +/* Use as a last resort if using DEVICE_FLG() is prone to VID/PID conflict= s. */ +#define DEVICE_STRING_FLG(vid, pid, _manufacturer, _product, _flags) \ +{ \ + .id =3D USB_ID(vid, pid), \ + .usb_string_match =3D &(const struct usb_string_match) { \ + .manufacturer =3D _manufacturer, \ + .product =3D _product, \ + }, \ + .flags =3D (_flags), \ +} + +/* Use as a last resort if using VENDOR_FLG() is prone to VID conflicts. */ +#define VENDOR_STRING_FLG(vid, _manufacturer, _flags) \ + DEVICE_STRING_FLG(vid, 0, _manufacturer, NULL, _flags) + static const struct usb_audio_quirk_flags_table quirk_flags_table[] =3D { + /* Device and string descriptor matches */ + /* Device matches */ DEVICE_FLG(0x001f, 0x0b21, /* AB13X USB Audio */ QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY), @@ -2414,6 +2439,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { DEVICE_FLG(0x534d, 0x2109, /* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER), =20 + /* Vendor and string descriptor matches */ + /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ QUIRK_FLAG_GET_SAMPLE_RATE), @@ -2558,19 +2585,80 @@ void snd_usb_apply_flag_dbg(const char *reason, } } =20 +#define USB_STRING_SIZE 128 + +static char *snd_usb_get_string(struct snd_usb_audio *chip, int id) +{ + char *buf; + int ret; + + /* + * Devices without the corresponding string descriptor. + * This is non-fatal as *_STRING_FLG have nothing to do in this case. + */ + if (id =3D=3D 0) + return ERR_PTR(-ENODATA); + + buf =3D kmalloc(USB_STRING_SIZE, GFP_KERNEL); + if (buf =3D=3D NULL) + return ERR_PTR(-ENOMEM); + + ret =3D usb_string(chip->dev, id, buf, USB_STRING_SIZE); + if (ret < 0) { + usb_audio_warn(chip, "failed to get string for id%d: %d\n", id, ret); + kfree(buf); + return ERR_PTR(ret); + } + + return buf; +} + void snd_usb_init_quirk_flags_table(struct snd_usb_audio *chip) { const struct usb_audio_quirk_flags_table *p; + char *manufacturer =3D NULL; + char *product =3D NULL; =20 for (p =3D quirk_flags_table; p->id; p++) { if (chip->usb_id =3D=3D p->id || (!USB_ID_PRODUCT(p->id) && USB_ID_VENDOR(chip->usb_id) =3D=3D USB_ID_VENDOR(p->id))) { - snd_usb_apply_flag_dbg("builtin table", chip, p->flags); - chip->quirk_flags |=3D p->flags; - return; + if (!p->usb_string_match) + goto apply; /* DEVICE_FLG or VENDOR_FLG */ + + /* DEVICE_STRING_FLG or VENDOR_STRING_FLG */ + if (p->usb_string_match->manufacturer) { + if (!manufacturer) { + manufacturer =3D snd_usb_get_string(chip, + chip->dev->descriptor.iManufacturer); + } + if (IS_ERR_OR_NULL(manufacturer) || + strcmp(p->usb_string_match->manufacturer, manufacturer)) + continue; + } + if (p->usb_string_match->product) { + if (!product) { + product =3D snd_usb_get_string(chip, + chip->dev->descriptor.iProduct); + } + if (IS_ERR_OR_NULL(product) || + strcmp(p->usb_string_match->product, product)) + continue; + } + goto apply; } } + goto clean; + +apply: + snd_usb_apply_flag_dbg("builtin table", chip, p->flags); + chip->quirk_flags |=3D p->flags; + +clean: + if (!IS_ERR_OR_NULL(manufacturer)) + kfree(manufacturer); + if (!IS_ERR_OR_NULL(product)) + kfree(product); } =20 void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip, --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 134D83859FD; Mon, 2 Mar 2026 18:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477977; cv=pass; b=SaxK2/gc0XdBAsshZ1ZqVzZDHD8q+B90FjjVBopDnLMJW4rMxzIGNAMhuHQVCd861EzZIU78PNFcqgVbzJUPowjaWMCzrc6PFRjKfnSlENkuk35FM8Sn3MtzW4toTGvH4/7TkUdYWQYqx3/s5WvrpYBSW2OToOYdQHSK+ffkn+s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477977; c=relaxed/simple; bh=E90wE1wuk4q4Njnn47OTbEtjKUtAuOq3F6cInIdE8Rc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uOSrccauFBes6AeB5V/WhAzWIOY9XJNQNOt+rPDtS877kgzwxmmPd6Zmst/i8/pbHLgAqzdxY8SgMPN6HiezL21DmgZasiz5yTbcoGWBFTZVdrr7pLxJv7Ib14Mle/QfhIDWu6OCtiKKVK7Tdv5ZCj3KLmHhOAvvwHPLC9mVg7c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=qshaKfVa; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="qshaKfVa" ARC-Seal: i=1; a=rsa-sha256; t=1772477963; cv=none; d=zohomail.com; s=zohoarc; b=Fk+PViuctFmzl4E29n73RX5qEl+I3CegOvnEEeFK5GdgwBkE/xwEZvhbFtNbbrYgiEWeIqlHz7YRskrTBPkF49uK/QEe7wOzE8n/j0RS2LktBlpbN1shKsJ94h7e4gW47MpcDLn3HuoOCanmtYv9jiOnA7/2o+JDvmBhVqp7hJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477963; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=8ZCcQUb9VW8DjR9aznsCaYh+9K7iFtDmGRjmJ8Tn9pw=; b=me0/ZCjGFpzpGBHqpU1Mn2ZtxyR8TjR28ky1DR8SRH801Y/PjjPoNQuyrgmTh25IzSnKU4/FIg4rXlAj1YxR4vy1wfGt7+omGHDi8zyNL0wUpZEmSvhmFmMO3IpV4kf+VGbBTJn36qtMoRWai0vAMa5Gy18XMPfQ8rwTIgNwnas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477963; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=8ZCcQUb9VW8DjR9aznsCaYh+9K7iFtDmGRjmJ8Tn9pw=; b=qshaKfVa2Jt8DycIzyA6SOrnd+7iEaHo5cBt7yo/rQ+xC0MwBZEX+R7e9n16o6pW 0W+PbqHLJw6BUmjwBrEzuI87qPZvUklAE8NYPNxk+dQSQumUMqEq9G+GxgO1XXQj+uI yCXV/yVxgruHimudooMdDOovlfWC508VtArTt3LBYC/0iIr6VY7xWVBDWoEYl1Jm+43 FRt6R+rgvwwkLA52z1Om22tiQ07wm1kEtzfHyeA7r5HXLMDwTWIdyAGkW+Fs5CCT3fg nfu4lotkrFYuDXoyWcBw3parV/rJf/gdEPG7FW7ghs+ZhMTHMBzbvDljJ+OsVt6p/Pf PNwV96dKiw== Received: by mx.zohomail.com with SMTPS id 1772477962321798.6615877962031; Mon, 2 Mar 2026 10:59:22 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 5/8] ALSA: usb-audio: Deconflict VID between Focusrite Novation & MV-SILICON Date: Tue, 3 Mar 2026 02:58:56 +0800 Message-ID: <20260302185900.427415-6-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" MV-SILICON is a SoC manufacturer producing multifunctional audio SoCs. Many budget-oriented OEM devices are built on top of them. However, some of them are just too budget-constrained that their manufacturers didn't even have a USB VID and simply picked a random VID. Some OEMs unfortunately picked the VID of Focusrite Novation (0x1235), resulting in VID conflicts as we had defined a VENDOR_FLG() for the latter. Add a VENDOR_STRING_FLG() for MV-SILICON to stop the matching procedure for these quirky devices, so that quirk flags for Focusrite Novation won't be accidentally applied on them. Quirky device samples: usb 7-1: New USB device found, idVendor=3D1235, idProduct=3D0003, bcdDevi= ce=3D 1.00 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: G1 usb 7-1: Manufacturer: MV-SILICON usb 7-1: SerialNumber: 20190808 usb 7-1: New USB device found, idVendor=3D1235, idProduct=3D0003, bcdDevi= ce=3D 1.00 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: mvsilicon B1 usb audio usb 7-1: Manufacturer: MV-SILICON usb 7-1: SerialNumber: 20190808 usb 1-1.2: New USB device found, idVendor=3D1235, idProduct=3D0002, bcdDe= vice=3D 1.00 usb 1-1.2: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D.= .. usb 1-1.2: Product: V8 usb 1-1.2: Manufacturer: MV-SILICON usb 1-1.2: SerialNumber: ... * https://github.com/linuxhw/Dmesg/blob/main/Desktop/Others/Intel/Intel%2= 0X79/96ED1CC44499/LINUXMINT-19.3/5.0.0-32-GENERIC/X86_64/5BE1E4C74C#L1122 usb 2-1.6: New USB device found, idVendor=3D1235, idProduct=3D0002, bcdDe= vice=3D 1.00 usb 2-1.6: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D.= .. usb 2-1.6: Product: V9 usb 2-1.6: Manufacturer: MV-SILICON usb 2-1.6: SerialNumber: ... * https://github.com/linuxhw/Dmesg/blob/main/Desktop/Hewlett-Packard/ProL= iant/ProLiant%20ML110%20G6/79B1D707316A/KUBUNTU-21.04/5.11.0-33-GENERIC/X86= _64/A43F59C4AB#L1009 Signed-off-by: Rong Zhang --- sound/usb/quirks.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 8deeb9d247500..c5b89d7964b48 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2440,6 +2440,9 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_ALIGN_TRANSFER), =20 /* Vendor and string descriptor matches */ + VENDOR_STRING_FLG(0x1235, /* VID conflict with Focusrite Novation */ + "MV-SILICON", + 0), /* Stop matching */ =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2B5A379ECA; Mon, 2 Mar 2026 18:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477981; cv=pass; b=hZSmzCVB54cloqNyP/eA9fUijIGg5weAFDLKj7EJEjFin1GPADz0D/U4YUekr86LYskgoDSzElrUis6V0mA04yRI4+cRQCHv5wDMkqAipJ5XpKxHGnsmWcyLgZMNQRehsiiPxBXFIEU7H6ShTaxKRZp27J4wmGHs4SAelbJJNU4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477981; c=relaxed/simple; bh=EqITlv+EbhlzAOQ3dpJsvuLTjCTSxHNxpDavAdqO8Lo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kaHNxhtGBuVK4zgyQAw9Fhlu5P4Bb9mecQkaGyXPMkydxZEw7z5J38lQKgG6xvTp7u4of9lC5ycaNyAF6O4akmoMJueAyS0+5VD4hByDhn73Aov3xeZhx+nCKDsBTbj7v8+/l1/qsGiHJlXWn7scys2TY/bloSwUCf9Qijmeheo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=BX60HLoF; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="BX60HLoF" ARC-Seal: i=1; a=rsa-sha256; t=1772477967; cv=none; d=zohomail.com; s=zohoarc; b=A6BhBzNwcEyY4Uvqaj1Ol//Ff+ZCLPcIT9fKFr8GZXBPGrh6nEJv7zv69sqO3RyfpboMptqZFfsYrdR09bxXWA6awqdzkNM0KIkwI9CFEYOwZQhrU9XiL5Yok0PmghCFYBKMQbI483/SG8rvNq8+DkkL+A7rCDSfGgrL7H2TFzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477967; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=cnvKzgd+ZrIGAomDFx05CT0ALtcmXrFrh4aUidtShoE=; b=Umjq6JaexnLvu7/XCz2OcRB3OV2P0EHE2Cts9q37VPHjd3uXsGBFqbuKEtyoPr6mp4cljTtRcYXavug1snlFS4ThlA1cTZh6LP6DnCPF0qlOvSB5i0i4+7HTuumtexr7UtYYO8TvvGO6jpxD3igmvz+ZSt78CwE6YNpA1hGXxjM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477967; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=cnvKzgd+ZrIGAomDFx05CT0ALtcmXrFrh4aUidtShoE=; b=BX60HLoFZnEs4gtbkhMj+9uqiiODiOKVfn2QQFsKJqr/bPliI07wcoGXKVnqZpsB ag58ozrAs7mh8gdC8UwaIb4xlAHjH9AoAU6MO7m1/swzxrUkji/kU104kFy3zMgvLEA 5+aDfr4BfJGlr1PM+Yxj+JKxLLf0MMAcW/ErUQOMr+Ds9GtD/2PouccUCywJvV8Vrxv xdOygAz4MPucxhibcjTJbGVWOTjg/KCUsGiM2l8SVFNyEknAKGBMNr10HP+W/Bl9N2l 8mQuTFomzie62kk5nlo+mEJov0rI/UWPp2V62BF0TbrkJNB7sgApn3or3Qf63tITx7i dv34yFKf8g== Received: by mx.zohomail.com with SMTPS id 1772477965430847.6246907547841; Mon, 2 Mar 2026 10:59:25 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 6/8] ALSA: usb-audio: Add QUIRK_FLAG_MIXER_{PLAYBACK,CAPTURE}_LINEAR_VOL Date: Tue, 3 Mar 2026 02:58:57 +0800 Message-ID: <20260302185900.427415-7-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Some quirky devices tune their volume by linearly tuning the voltage level (linear volume). In other words, such devices has a linear TLV mapping of DECLARE_TLV_DB_LINEAR(scale, TLV_DB_GAIN_MUTE, 0). Add quirk flags MIXER_PLAYBACK_LINEAR_VOL and MIXER_CAPTURE_LINEAR_VOL to represent this case respectively for playback and capture mixers. No functional change intended. Signed-off-by: Rong Zhang --- Documentation/sound/alsa-configuration.rst | 7 +++++ sound/usb/mixer_quirks.c | 34 ++++++++++++++++++++++ sound/usb/quirks.c | 2 ++ sound/usb/usbaudio.h | 12 ++++++++ 4 files changed, 55 insertions(+) diff --git a/Documentation/sound/alsa-configuration.rst b/Documentation/sou= nd/alsa-configuration.rst index 0a4eaa7d66ddd..d72ab49a783fc 100644 --- a/Documentation/sound/alsa-configuration.rst +++ b/Documentation/sound/alsa-configuration.rst @@ -2372,6 +2372,13 @@ quirk_flags audible volume * bit 25: ``mixer_capture_min_mute`` Similar to bit 24 but for capture streams + * bit 27: ``mixer_playback_linear_vol`` + Set linear volume mapping for devices where the playback volume + control value is mapped to voltage (instead of dB) level linearl= y. + In short: ``x(raw) =3D (raw - raw_min) / (raw_max - raw_min)``; + ``V(x) =3D k * x``; ``dB(x) =3D 20 * log10(x)``. Overrides bit 24 + * bit 28: ``mixer_capture_linear_vol`` + Similar to bit 27 but for capture streams. Overrides bit 25 =20 This module supports multiple devices, autoprobe and hotplugging. =20 diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 11e205da7964d..539044c0c6440 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -4634,6 +4634,25 @@ static void snd_fix_plt_name(struct snd_usb_audio *c= hip, usb_audio_dbg(chip, "something wrong in kctl name %s\n", id->name); } =20 +static void snd_usb_mixer_fu_quirk_linear_scale(struct usb_mixer_interface= *mixer, + struct usb_mixer_elem_info *cval, + struct snd_kcontrol *kctl) +{ + static const DECLARE_TLV_DB_LINEAR(scale, TLV_DB_GAIN_MUTE, 0); + + if (cval->min_mute) { + /* + * We are clearing SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, + * resulting in min_mute being a no-op. + */ + usb_audio_warn(mixer->chip, "LINEAR_VOL overrides MIN_MUTE\n"); + } + + kctl->tlv.p =3D scale; + kctl->vd[0].access |=3D SNDRV_CTL_ELEM_ACCESS_TLV_READ; + kctl->vd[0].access &=3D ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; +} + void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, struct usb_mixer_elem_info *cval, int unitid, struct snd_kcontrol *kctl) @@ -4660,6 +4679,21 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_i= nterface *mixer, "applying capture min mute quirk\n"); cval->min_mute =3D 1; } + + if (mixer->chip->quirk_flags & QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL) + if (cval->control =3D=3D UAC_FU_VOLUME && strstr(kctl->id.name, "Playbac= k")) { + usb_audio_info(mixer->chip, + "applying playback linear volume quirk\n"); + snd_usb_mixer_fu_quirk_linear_scale(mixer, cval, kctl); + } + + if (mixer->chip->quirk_flags & QUIRK_FLAG_MIXER_CAPTURE_LINEAR_VOL) + if (cval->control =3D=3D UAC_FU_VOLUME && strstr(kctl->id.name, "Capture= ")) { + usb_audio_info(mixer->chip, + "applying capture linear volume quirk\n"); + snd_usb_mixer_fu_quirk_linear_scale(mixer, cval, kctl); + } + /* ALSA-ify some Plantronics headset control names */ if (USB_ID_VENDOR(mixer->chip->usb_id) =3D=3D 0x047f && (cval->control =3D=3D UAC_FU_MUTE || cval->control =3D=3D UAC_FU_VOLU= ME)) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index c5b89d7964b48..1c7ca52c92d08 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2540,6 +2540,8 @@ static const char *const snd_usb_audio_quirk_flag_nam= es[] =3D { QUIRK_STRING_ENTRY(MIXER_PLAYBACK_MIN_MUTE), QUIRK_STRING_ENTRY(MIXER_CAPTURE_MIN_MUTE), QUIRK_STRING_ENTRY(SKIP_IFACE_SETUP), + QUIRK_STRING_ENTRY(MIXER_PLAYBACK_LINEAR_VOL), + QUIRK_STRING_ENTRY(MIXER_CAPTURE_LINEAR_VOL), NULL }; =20 diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 085530cf62d92..58fd07f8c3c97 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -228,6 +228,14 @@ extern bool snd_usb_skip_validation; * Skip the probe-time interface setup (usb_set_interface, * init_pitch, init_sample_rate); redundant with * snd_usb_endpoint_prepare() at stream-open time + * QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL + * Set linear volume mapping for devices where the playback volume control + * value is mapped to voltage (instead of dB) level linearly. In short: + * x(raw) =3D (raw - raw_min) / (raw_max - raw_min); V(x) =3D k * x; + * dB(x) =3D 20 * log10(x). Overrides QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE + * QUIRK_FLAG_MIXER_CAPTURE_LINEAR_VOL + * Similar to QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL, but for capture strea= ms. + * Overrides QUIRK_FLAG_MIXER_CAPTURE_MIN_MUTE */ =20 enum { @@ -258,6 +266,8 @@ enum { QUIRK_TYPE_MIXER_PLAYBACK_MIN_MUTE =3D 24, QUIRK_TYPE_MIXER_CAPTURE_MIN_MUTE =3D 25, QUIRK_TYPE_SKIP_IFACE_SETUP =3D 26, + QUIRK_TYPE_MIXER_PLAYBACK_LINEAR_VOL =3D 27, + QUIRK_TYPE_MIXER_CAPTURE_LINEAR_VOL =3D 28, /* Please also edit snd_usb_audio_quirk_flag_names */ }; =20 @@ -290,5 +300,7 @@ enum { #define QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE QUIRK_FLAG(MIXER_PLAYBACK_MIN_M= UTE) #define QUIRK_FLAG_MIXER_CAPTURE_MIN_MUTE QUIRK_FLAG(MIXER_CAPTURE_MIN_MUT= E) #define QUIRK_FLAG_SKIP_IFACE_SETUP QUIRK_FLAG(SKIP_IFACE_SETUP) +#define QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL QUIRK_FLAG(MIXER_PLAYBACK_LIN= EAR_VOL) +#define QUIRK_FLAG_MIXER_CAPTURE_LINEAR_VOL QUIRK_FLAG(MIXER_CAPTURE_LINEA= R_VOL) =20 #endif /* __USBAUDIO_H */ --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2AC3375ACE; Mon, 2 Mar 2026 18:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477981; cv=pass; b=Rgpo8B3F1cZIn/3oMehPnSODKFn84IJtS3H7LAk9em/JuY6rQsyT8f9G2Zp06pn+T4Gkurs7RCloS6dkS4BPiLMMfrqSEIQNDr+KhVPOqZCw7chRkYiuh3Gz0xln1Zx4Cdpp6NddBDOGr8jqN4vfBwVe/CwDLx/8njFiCL4n0TA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477981; c=relaxed/simple; bh=jkOYA2NxwZJOVf2xfldlhNIEcy3ntqlXitFNbPnDQ8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HxQgfnAyR9b//Vdl2NQ/7nKgWVWvFNtCu+3AEpp5oNdc/UPxV7ExMoInyWzqLedCzI6dMhoF36Q9LZEwVVLNQZfg8cPTjpHJB+T1uUhJ/cxqV0QzY4SETgmoJiMNA3/AsDb78JCuhOifhESAKIWfxYMyD4Qlj/b/xOk8KDSVD+c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=L8mofidm; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="L8mofidm" ARC-Seal: i=1; a=rsa-sha256; t=1772477969; cv=none; d=zohomail.com; s=zohoarc; b=UlbTrGcJIoFX6njB8HfmY5d2uKb8PnF3+NbO0Qn5Uabd/XBQy74QHI4tqFA8sx9I46FNP0Pfzwuc6/XQM4QHHqmkdsL1QLNRDijt+S1ZS02FlgdxPEkQLjB59drciaMe1zjZHoWrZazYbf5rDsPRzwIclALta5eaBnzvxfvPjJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477969; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=2vILH0Hgahd9bs8JmMib5OXj/WY5tcMeweFVJlplY/M=; b=IIcqXCYSWGHCAghNdB7nHJB2NOk5niN9SsNMkrniCUltRlPYRXk8wmlRmhR22UrzMuVweckU9Uw6gEXCrKElonqummbdNDd5zNkguEvc0n+FS2KLVTOhn3y6IWXIoY84I5WSxUbqpl2VkLlrCn/LR4hzo3JWGBqFdXoS0s2nBqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477969; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=2vILH0Hgahd9bs8JmMib5OXj/WY5tcMeweFVJlplY/M=; b=L8mofidmvBt6LwpR9HvBW9spfwRolyEBsnOWHIP/e1lrpG2XWxTaZX3wl3+nAswh DTd19LpldtSy3c6e9mWxX8B2zovbZfPZyD/448yC6p9qxrHk2OV+KBxD+C9tAlkpzG8 1aUojoif0eD8da0b1WPBRrTJvUzX8oP8ZTQMP8tunJwkJ0SWYh+orI2avzvpUtG0UeS ybCYknrXeSGEAbSixck2EMBpCmZj057XA57HmpWOvN5GTpahS91SDRjmumdeQGdTq20 3AMnH/wl86hI672qi/tsaRFFWmsuROvBeYeXBQU7ifSSyzFR3WEi8jiKs95N9pFDMJj pyTOOA90Tg== Received: by mx.zohomail.com with SMTPS id 1772477968532963.3711183766075; Mon, 2 Mar 2026 10:59:28 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 7/8] ALSA: usb-audio: Add linear volume quirk for Hotone Audio Pulze Mini Date: Tue, 3 Mar 2026 02:58:58 +0800 Message-ID: <20260302185900.427415-8-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Hotone Audio Pulze Mini is a modeling amplifier with UAC interface. Its Playback and Capture mixers use linear volume with val =3D 0/100/1. Add a quirk table entry matching VID/PID=3D0x84ef/0x0082 and applying linear volume quirk flags, so that it can work properly. Quirky device sample: usb 7-1: New USB device found, idVendor=3D84ef, idProduct=3D0082, bcdDevi= ce=3D 1.03 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: Pulze Mini usb 7-1: Manufacturer: Hotone Audio usb 7-1: SerialNumber: 20240807 Signed-off-by: Rong Zhang --- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 1c7ca52c92d08..d907b273a1cc1 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2438,6 +2438,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_ALIGN_TRANSFER), DEVICE_FLG(0x534d, 0x2109, /* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER), + DEVICE_FLG(0x84ef, 0x0082, /* Hotone Audio Pulze Mini */ + QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL | QUIRK_FLAG_MIXER_CAPTURE_LINEA= R_VOL), =20 /* Vendor and string descriptor matches */ VENDOR_STRING_FLG(0x1235, /* VID conflict with Focusrite Novation */ --=20 2.51.0 From nobody Tue Mar 3 03:38:35 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14E9C376BF1; Mon, 2 Mar 2026 18:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477987; cv=pass; b=D9PVoXZromv5iPmLSqFOocjSEz/UAtAMfb5pQjLi0gvEUa1f82DFCuLA7A/C2nxS/OQ9fzBGtwMyCCKAP+2xyfjSK33mFW4T1m0bsNWv+Z213kzQdi1LlM7CNEG2f230jS9+1xt0Wq3T5/nW0hz4c3+Uf5QxP+4fN5Mjaz8v9f4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772477987; c=relaxed/simple; bh=A5QVI4sc3toPzsBJ0eGEdjAvm937Zw+ZKOz9Z1bfWys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=utS0wAkYvZo3n4/Yh37CORoZkybvEGi4GFapltAuX18Wmr2PaXAODdCD7An5bi5afhrww7ZNMkV9hIibO2hdJV3CV4fzLD3xwbEnMGOs/zV/F0btTQTHSjzHRlfV2SuVfbeFQg6+T/6eEZ4/xP7dNWXNpSewB2JeT71ievWCudg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=FFSLnSat; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="FFSLnSat" ARC-Seal: i=1; a=rsa-sha256; t=1772477973; cv=none; d=zohomail.com; s=zohoarc; b=eaiAJK7NBboKKuN0DtvG+kkCaWfGG7qD0q+SN42lX/MlM4uEbzWqjQy4V4p/A1P2M8ME+0ZTW8y9C1H21JyKPY/P0l8/tIyfOSni6mwAXPA8D2C/ew4lbKRUE4Vv1yTY7I1+tneNxh8orHPMKWRPwUKyytYDY9JMx1VnbdJCOoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772477973; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=/BvEQBitzjedx/UMLrqh7LvNZcltcVro9BjyKn24tic=; b=fmxJkiADteJ9o8fcYJ3/gxy32GUShA5QRC5vzRFbYOn5hnj3aze52rl1SqjNZexqIwICNSzvcWn/rBETyh2u3Fj7KtYCF9NboI6psY5uMDfnY80QJSx6Z1zrNceJWQOHkzlVE5KTeiX/Jk2hi+GB6bOJWxVQEEkT33He4h9r9t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772477973; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=/BvEQBitzjedx/UMLrqh7LvNZcltcVro9BjyKn24tic=; b=FFSLnSatLUDtf3zAdZ1oTXigGelOFhP09EVndbNIBBavC1XNrL0EeTDP62xZO9pw +dwSP7imHZwOi1Yf9QP8w4i6Swj3vhATUwVup3W6XrSxWe8iAxJDm9I9tpcpLIqUSyQ FhkKzgwwHY9r78gajCXFyGD/uHl+waZscJ+AL90VBC0rNz4SGXXMDkmlSVJEq/gWxpn OC8UyA944a9cVELcE2LTH/JYXjHphxoVv0emqlucUhFr8O7iQV4iUHwMbuHoTW01CoP 2e3yntSX9F2ao40ASwA0MkiPcFiyo9haD5bPt72x7zfctQIBLCQ+Z9v+2UOQg9vtul+ jxjHNWzWbQ== Received: by mx.zohomail.com with SMTPS id 1772477972008652.7818658540505; Mon, 2 Mar 2026 10:59:32 -0800 (PST) From: Rong Zhang To: Jaroslav Kysela , Takashi Iwai Cc: Rong Zhang , Jonathan Corbet , Shuah Khan , Cryolitia PukNgae , Arun Raghavan , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Icenowy Zheng Subject: [PATCH v2 8/8] ALSA: usb-audio: Apply linear volume quirk on MV-SILICON devices Date: Tue, 3 Mar 2026 02:58:59 +0800 Message-ID: <20260302185900.427415-9-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302185900.427415-1-i@rong.moe> References: <20260302185900.427415-1-i@rong.moe> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External MV-SILICON is a SoC manufacturer producing multifunctional audio SoCs. Many devices built on top of their SDK share a common quirk that the Playback and Capture mixers use linear volume with val =3D 0/4096/1. The SDK seems to always report "MV-SILICON" for manufacturer string. Hence, match it so that we don't need to define quirk table entries separately for each devices. The "val =3D 0/4096/1" pattern is also checked against before applying the quirk, in order that the quirk won't accidentally break unseen variants. Quirky device samples: usb 7-1: New USB device found, idVendor=3D1235, idProduct=3D0003, bcdDevi= ce=3D 1.00 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: G1 usb 7-1: Manufacturer: MV-SILICON usb 7-1: SerialNumber: 20190808 usb 7-1: New USB device found, idVendor=3D1235, idProduct=3D0003, bcdDevi= ce=3D 1.00 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: mvsilicon B1 usb audio usb 7-1: Manufacturer: MV-SILICON usb 7-1: SerialNumber: 20190808 usb 5-1.4: New USB device found, idVendor=3D8888, idProduct=3D1719, bcdDe= vice=3D 1.00 usb 5-1.4: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 5-1.4: Product: HF310 USB Audio usb 5-1.4: Manufacturer: MV-SILICON usb 5-1.4: SerialNumber: 20190808 usb 7-1: New USB device found, idVendor=3D2717, idProduct=3D5086, bcdDevi= ce=3D 1.00 usb 7-1: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 7-1: Product: Redmi =E7=94=B5=E8=84=91=E9=9F=B3=E7=AE=B1 usb 7-1: Manufacturer: MV-SILICON usb 7-1: SerialNumber: 20190808 usb 2-1.2: New USB device found, idVendor=3D3142, idProduct=3Da601, bcdDe= vice=3D 1.00 usb 2-1.2: New USB device strings: Mfr=3D1, Product=3D2, SerialNumber=3D3 usb 2-1.2: Product: fifine Microphone usb 2-1.2: Manufacturer: MV-SILICON usb 2-1.2: SerialNumber: 20190808 * https://forum.ubuntu-it.org/viewtopic.php?t=3D659345 Signed-off-by: Rong Zhang --- sound/usb/mixer_quirks.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 539044c0c6440..e97814dc90259 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -4588,6 +4588,24 @@ static void snd_dragonfly_quirk_db_scale(struct usb_= mixer_interface *mixer, } } =20 +static void snd_usb_mv_silicon_quirks(struct usb_mixer_interface *mixer, + struct usb_mixer_elem_info *cval, + struct snd_kcontrol *kctl) +{ + if (cval->min =3D=3D 0 && cval->max =3D=3D 4096 && cval->res =3D=3D 1) { + /* The final effects will be printed later. */ + usb_audio_info(mixer->chip, "applying MV-SILICON quirks (0/4096/1 varian= t)\n"); + + /* Respect MIN_MUTE set by module parameters. */ + if (!(mixer->chip->quirk_flags & QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE)) + mixer->chip->quirk_flags |=3D QUIRK_FLAG_MIXER_PLAYBACK_LINEAR_VOL; + if (!(mixer->chip->quirk_flags & QUIRK_FLAG_MIXER_CAPTURE_MIN_MUTE)) + mixer->chip->quirk_flags |=3D QUIRK_FLAG_MIXER_CAPTURE_LINEAR_VOL; + } else { + usb_audio_dbg(mixer->chip, "not applying MV-SILICON quirks on unknown va= riant"); + } +} + /* * Some Plantronics headsets have control names that don't meet ALSA naming * standards. This function fixes nonstandard source names. By the time @@ -4664,6 +4682,10 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_i= nterface *mixer, break; } =20 + if (cval->control =3D=3D UAC_FU_VOLUME && + !strncmp(mixer->chip->card->longname, "MV-SILICON", 10)) + snd_usb_mv_silicon_quirks(mixer, cval, kctl); + /* lowest playback value is muted on some devices */ if (mixer->chip->quirk_flags & QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE) if (strstr(kctl->id.name, "Playback")) { --=20 2.51.0