From nobody Thu Apr 9 13:32:58 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 1048937C932; Tue, 3 Mar 2026 19:48: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=1772567318; cv=pass; b=i0mde5XSm8zcjmogTSEaFPD6L71gsfrPJLbqDylXYw84uc5eT/qEyzluweAvDrVB6/PFXYuJnOweEhIQTg3Xw+5q9cfT0jnrGb59cAWxpaAtezHTQW0xa+hJFo9RYgdWyjI1/cMvdAOQWJH4Nhef8OMkQjbdqGJeuJ+I53e6Rwg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567318; c=relaxed/simple; bh=Ol5wfXidt2YBtsIvhP73Xs9hMxo3bigYItyn+32vSZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XQyTWRKD51fQ8u++Z+hDiGw3FE5kyg+9LI/4hv5dTZFFhE3UWi4Pr1IRgL+EnUWqOAQasgA0pvVV1RRnJr+tIWrXT0O/Jo7/CyMagWxFOfGG1lcTLwbC4Jpa7WaZNWTTJSEhaNRrOz6Mq/PFhpgqrOu/sQ7nu93fFRDH/cuYBl4= 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=JaX5wAbm; 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="JaX5wAbm" ARC-Seal: i=1; a=rsa-sha256; t=1772567297; cv=none; d=zohomail.com; s=zohoarc; b=g76eAs3aVQHdB+1PIKmssuAXwIsNRripgKtt+l7YeeNu64AT+rbsAx38RebFCs9+D7PG3NjZSlrF/DarkekPaNWais7Kf10Y9JGdkTeZAEQuARKp9RAuCeaeEu02IM4uLHaMdXS5f8hhPq2weRADM0z+ENfUrbxKFpKFyoTRcgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567297; 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=nsa1pQ/g85W+rCXtSixQQwz2hYzHYiKCiOFYkThsOOQ=; b=fEgD7FFeOul+2ZT62/z8KDBsJ6jyzxNw84HE7rPRSEj9PyVgx46ixguLjvBIwJocU59bF9RFr/+J5zVNQL2clnBSE0DYApVGyhSqmfGMa/lmu1nFkkglHqNn54e14BND7RG1kvA6z2CApUpxzam+6EIN/2x8d8lUPHuzMCe6170= 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=1772567297; 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=nsa1pQ/g85W+rCXtSixQQwz2hYzHYiKCiOFYkThsOOQ=; b=JaX5wAbmTTHKNvMB/xXGAdzFZSgo4E2+uiC+zqLSr1Awa57WMyxpC5GVBsk2z5Oo UUm4P9z7pLbUhDUJ3NrkMU0ibFNyX5ZbTKZD+4kVZXZK8LbUzPw4yoYKzx4FuEGPb4w ZZtQfPTHfufuNjotrVpvP8T8oFMQJs7IHKr6A/A4FrcfmJmb45qtlrRhsW/+kH+k3Vl xLwVlghf2aaV1lgULsyPwwWbhFq8ffZm+e3qpdtwMH6H768OeyKW+mzrRcs7T+2fUG9 N+KgZwIC8/Ifrpx9UERYTmtd/2LVTSHHAQtMqcKpzOXgZVDWwdKmp1/1YLqbr2BNsEg A3H5mJ2wuA== Received: by mx.zohomail.com with SMTPS id 1772567295942497.5492576939479; Tue, 3 Mar 2026 11:48:15 -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 v3 1/8] Revert "ALSA: usb: Increase volume range that triggers a warning" Date: Wed, 4 Mar 2026 03:47:56 +0800 Message-ID: <20260303194805.266158-2-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 ac8c71ba9483..df0d3df9c7ec 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.53.0 From nobody Thu Apr 9 13:32:58 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 08E2937C923; Tue, 3 Mar 2026 19:48: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=1772567318; cv=pass; b=qX6rVJ5FiD8P5Hubjo4PCL5z6Mx793OPTIBJVuf/bPO9IC6rUZceSzTzWyeZJiJlRP4uQsJgghzSMAbQ5jx72TR7GU+6pN1hwE6aEejRtKJjh9y3tKft08zV4UOoaT/P3s24KdDjJuXFnMwVydJM4bNkp7yz5q118nX4Znpdk5A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567318; c=relaxed/simple; bh=8IidKWQb6PDv+9QcRgdnroqcQT1ZJ9HF+prpfNElgMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JDXCnv/JUutFXKB5wA46FK6sOqiChSx36U8MG0K9m96P8pUHiQmOa70EwpZ9b2uglZLULE+hrNGwZyLmp9G56z4uFA6XcoYQtbafQ7SNNcZ+EGSOH01Jg5s8cHHNisx+leYD2y0DG6E/nieZk6MLBaIaa48YrfWrHl9r+3PGW8s= 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=jck1I5FK; 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="jck1I5FK" ARC-Seal: i=1; a=rsa-sha256; t=1772567301; cv=none; d=zohomail.com; s=zohoarc; b=TRVnT9O1NZ4kl3laP7/rfXlROieRI1JH+UOdhqObv2LttClc+KCRZfIb0rJIdsBbF7ZGnQF0E9qpXz1LhQXly77AOR3L/FCtG8qZUZxnqyBiDF3vOT1ecNlejTsGqvbLUvvbAs3X6HW9VU1/uj7IcfauDVsoAUquYB0Lwh1EO2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567301; 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=cWKW70CzyWRfKpXpZuWrqBeuXkIL34U6KH4X/AyoKE4=; b=Gky2nH140Z+yM1IJ1LEdu6501lJ040MTNgabun8xAbBt928cAhLbaP2NEPVxRNl2eU73Et1uAzGxc4kynYJDes8oAGPFbaGQlaxIW8cbaJBS9fz7fbebEtM4PjJw8Y1hUf3ENaXyE21kwhjtQS0bDA/WdOKNUXGY5AuDUBmSpcE= 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=1772567301; 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=cWKW70CzyWRfKpXpZuWrqBeuXkIL34U6KH4X/AyoKE4=; b=jck1I5FK5F6A0TF5PndDAXXW2EnJTdWUFQd/XW7oFR2gKGqS0F2bCbYkRqyeEB7p l6nunYz4B0oFtSqKa/xwR3+rBMKQpL3vsQpLRUVmG37F72C3hSwjPgYF6EbYQzLjNSg p1yL/jjfjIveDkqPzcBNJh0LeJ9DKrLCBUeX0HfPk5hjAmIYWUr7PCPPuXpBIt5/kOQ jG/1JjZfM0X0MFnNRqjmFTAYrf0l0pOjVbXmj68+94IE3EMRWPN7OJLZNTJQoR1aN54 mpHe6ejnGGzS2+aSkfCnr0EdnjY0Q0aeCicBinq6Gbt2tk0UeYXvvrRzqPPrOzN3RFP KrrZnOIrUA== Received: by mx.zohomail.com with SMTPS id 1772567299007644.4348995233211; Tue, 3 Mar 2026 11:48: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 v3 2/8] ALSA: usb-audio: Add helper function for volume range checks Date: Wed, 4 Mar 2026 03:47:57 +0800 Message-ID: <20260303194805.266158-3-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 df0d3df9c7ec..f52ca0d7e665 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.53.0 From nobody Thu Apr 9 13:32:58 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 545DC37C912; Tue, 3 Mar 2026 19:48:36 +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=1772567318; cv=pass; b=NCKunhXMs8PVM7t3NE+heMB2CBVEkhjrXbAVqqWkVynjKs9TI66pfNJm06yxXT9fHNCvGy1U5IVJcet0SDqevZwdZCPegNcAO5D0I9UnMyraSFo/4mgmCLwxWKmc9BwK2XeXMqh/AY93saFtHbNpiEfNyiyc6yp05ZbJ08OWVUM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567318; c=relaxed/simple; bh=AbS0Laa3PMhA2cGG17Y9UVqeePxJAoKfQVa1o9qaOkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SyWF+nhvXKvo7x75O3hClSxf9JifBN6JudrE3SjA0kfdUvfSsxknY6CSSHuxp+Y5lGVIOKpzT37IV4WPWr1Rwa4YM7ZHtgRHmuL1xR6SpE08KLWLScQgxjHhqicGlxX8pddMEy/hfDdy4pu7I/mAznFEVPDMGxBQto8OJ77m6Bw= 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=jypmRCNq; 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="jypmRCNq" ARC-Seal: i=1; a=rsa-sha256; t=1772567303; cv=none; d=zohomail.com; s=zohoarc; b=iBzT/AZno74q9ufaUVldZ1FszURfmWbic8HTEAyLemzzpR1ddhgstTACoUOXV1L8HhDMmx9pwMU/MXuuVG1a25925WezY5gy2zjj0o6zFHiynkbwMGeZtOT1NxGh+CKi/tJ0jFXG1JsvyW2IN1vYVxqboCOMjUBnj8jCvS5HEW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567303; 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=CjpiuMqQ+GrYPxeQjDMei6mX77ZcbG7JJyof4dyGRqc=; b=TZ2zrraT8ZovKop8cC8vURXG1e6kJc36Am7pytnUBuMqU0v/MVmEUI9681+fgf1ocd60JcOTX/5x7d6CMFmBH/aXFo4ko094S3DBz7Vb6usLALRrbD+D4AGP14MgLO6BPwlAyyQDEIGMc5CaqN1SFvDCQ6KpY3ajA2AcT2h/o/k= 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=1772567303; 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=CjpiuMqQ+GrYPxeQjDMei6mX77ZcbG7JJyof4dyGRqc=; b=jypmRCNqJHH05/rf4xUKgq1M1yPjlCDGz1YR+B77yeVO7FKewd3WmvcJHQgyKdWM 8cZVgTEMKARVeoXL+bYsQAqlCF4hEF7Hub864DnEBECfyHMNfgCDQqAV7qH7//Tv/LT lCtKfRusC2k9qEoKJ0TRTmQTq3KC4spmS5+wvt3ctDh2JDOsQjoouqLD73wbKPRuggG BBppYHLiZKwFODZO8tReCmY4BEfmpOWGv76OEV6bkB9el8HaEcf6GVyLmw6mxrZ+zt8 3li3qry9rlUoKI6V031kF0wCo57t0hBXtt9kFMjWoIn3ZLKPTXLgI78D2ZzjUHGe6m+ 6UFtDbF1ww== Received: by mx.zohomail.com with SMTPS id 1772567302126470.82438079468477; Tue, 3 Mar 2026 11:48: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 v3 3/8] ALSA: usb-audio: Improve volume range checks Date: Wed, 4 Mar 2026 03:47:58 +0800 Message-ID: <20260303194805.266158-4-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 f52ca0d7e665..7007e0c9489b 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.53.0 From nobody Thu Apr 9 13:32:58 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 5E6AC38424A; Tue, 3 Mar 2026 19:50:42 +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=1772567443; cv=pass; b=ayuxqKhmM9eixF5FnUP/MGrrahasA+bULzf8+epfnZRtEXrqF0Qj7KgL2ccjqdGhFFfMgKJN57GWQ8eGOAtp6uttV35S5N/RCCjejA9ILl4nPCWmAZLMYOxh8Y/rK8O86pCYiM34i+kXiYrdx32sr6YlbkCHwHdlq93xeROCx5I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567443; c=relaxed/simple; bh=0801/FI/5xMaRDfLzwS0NFqPx/02hgHq1ma1CnB6P78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G/5OeIW2iFvyo4iOmRslbzDyxV69fy6R1vXka/RbBbnChdCCckNcOVNrb+ARVQJ6XEm9XtxGxpCszph3hRCaCE/raH2V7VLFMbNN+nhl/PDGGU3oTOOmuyyYfWmYYNJjVAjPaHwXNN2kSDCCTVOlKTEtw4thigqrahTVdFm5leg= 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=H2INVYKI; 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="H2INVYKI" ARC-Seal: i=1; a=rsa-sha256; t=1772567307; cv=none; d=zohomail.com; s=zohoarc; b=iy4lQydsmf/AwaAsRcFnosqOhOzvOsBZtVbKLCjiZmcmeoRSiVEew8tHXj/AO6AG2g1DAsxxUjyB1/dmW0kab+jJ5Mn+PM/+LJ2NYMeo//vRczKhRFt3CQlwdEt17VQDAfNr/8uCuJgQOziE4F67VNs+zsTi3nQwwHnd1lWuX8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567307; 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=R8KS6/FH3KrJv34wKtYsvLvuU8TATeZzz2GsOY4pegA=; b=iYMmQ80zV7Ln+W9Rremqe6eJY/4yFA2s6w0G6LvNd0WZpaTG3L1ZWhnxEJlZV3gzPpC1g8dExcW3BH46Wt6KmBDAKK8O+lCdq6LIec/MFI3byNukAWNz0Gf2YEbG65pWdBRCHUGCL9CgeIPvwSlSxOIDf0+oXdqe4FhCbZf8+54= 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=1772567307; 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=R8KS6/FH3KrJv34wKtYsvLvuU8TATeZzz2GsOY4pegA=; b=H2INVYKIwT66q07XWORI/8ONMWfS5MzByIyvLXdUah9Ke20vkqnh6XnYth5hkyvN RryFK02XEc5ujuXHHOsIyRloD0I0adjevFsSfPGUxO2dKRrUwXqtqCE9hRfoFVGqF34 j2nfR+IzuFwCa5Rb3hQpPGQLA/0eG7skWhZ/kVxC0qKQCYuYa6foFn6Bc8XG3CzK/wt FGq08DaZYQHU8woFdVkxuVIeh2B6yUZeKk48loVch/d0SFXQdac+W8w29VlmnYCZqM9 jJ8gjKaLjEESGsyHaXmJGG33utJH/sD4TN0Vtu8BRY5UAzr4QLS5PrSCGDatHpRyXuy WB5iqkoYNQ== Received: by mx.zohomail.com with SMTPS id 177256730526758.31359118481839; Tue, 3 Mar 2026 11:48: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 v3 4/8] ALSA: usb-audio: Support string-descriptor-based quirk table entry Date: Wed, 4 Mar 2026 03:47:59 +0800 Message-ID: <20260303194805.266158-5-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 v3: - Adopt __free(kfree) on string buffers as it turns out to be able to handle ERR_PTR() gracefully (thanks Takashi Iwai) - Improve readability by replacing the goto pattern with `p->usb_string_match && p->usb_string_match->*'. The compiler should generate equivalent control paths thanks to the optimizer 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 | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index d54a1a44a69b..d365eb41910a 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2,8 +2,11 @@ /* */ =20 +#include +#include #include #include +#include #include #include #include @@ -2135,16 +2138,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), @@ -2416,6 +2442,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), @@ -2560,14 +2588,64 @@ 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 __free(kfree) =3D NULL; + char *product __free(kfree) =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))) { + /* Handle DEVICE_STRING_FLG/VENDOR_STRING_FLG. */ + if (p->usb_string_match && 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 && 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; + } + snd_usb_apply_flag_dbg("builtin table", chip, p->flags); chip->quirk_flags |=3D p->flags; return; --=20 2.53.0 From nobody Thu Apr 9 13:32:58 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 AC2EB37C932; Tue, 3 Mar 2026 19:48:44 +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=1772567325; cv=pass; b=LQunq5WE21J61U6/3i0UDIOqE/FgOQGpb7U5gvLck+M2c9zXJplf/03xrmla6t/jX7aswwkdnnikXhpgU7OVMEdLsBZJNJjB2fsj3KAXkrZn6hKsqLeagEa4cJ7aTa2aq/YkYUMOzJmH5Tv9wloY2zZCrFrkcibhjYHAACK1zPM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567325; c=relaxed/simple; bh=Gt1pwsGJPq7luoF4wZqMPto7/GcBrVpk5nSnpRgW9W8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RlN3FD9MGb/RY1/WuQO64kjmW43PZdeaFey3WwjPlHZ6KCugre/XSoxOm8jEGRHW2Du3IAcWgtVvxQqJUGjWfrkG1I/qJ8J9u4kZKiXOo6tvBogKffKGKLYamXwuMo2aoTDwNNKvhajnyzBAexVPT0OTTdyGSYXwI9KoKryH2zc= 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=gOnhMWoI; 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="gOnhMWoI" ARC-Seal: i=1; a=rsa-sha256; t=1772567309; cv=none; d=zohomail.com; s=zohoarc; b=D/ojVr+9IA5gfH/F4TH+Y9trGwRx03ibzEt0rKPCcBPyGe/M0ibUfDykF3By4gHGEbgxUrkrlyYiJWC58xhpZlp/IRzTZJ/FfCPRnZlSsZnwGyW6cNmdlWg4s0gDirBC+eWdQS+FJnP2p5TIGbD+aCNtXGNO5GECSlYilWFHtlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567309; 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=GdODKBTj69CoOEfVAMgHkBpJL6zX0edZTyHBVBanc6s=; b=hL9zo0MDE7iP8es1m/MjIRwsOKHsYX4haAH19Mvjbwcf4sUxka8x3SFdSyhFhd8YPr+LfhmUU01yIDHsVeRjju90HH10xZgMZNzedSYyXdTnFBNQ+ilfLDi0vuMih07wHQ8Itr/J1r7T5u7IHHuA3Y4a/jz06n+Tzk49HE1wEaU= 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=1772567309; 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=GdODKBTj69CoOEfVAMgHkBpJL6zX0edZTyHBVBanc6s=; b=gOnhMWoIL3t/s3bk2OuK8zR2g7QU/mQPu7VufiBE8KlDnGNnhClrFwIvm0nYU9lE pimhjKuzvvDM1NFpj8Fmk41YBzXW4ANj6nS2dkVwa+y+jxhC1bOmdjRja0E54gAephV FxC+8Yr9YJ105zdezcqLzGWlVr+FDVJ2zUPHyKK9/1306bU4oNPA2SRzJh9Dt8NcIzG gxmWUvraMSntvDWTOWQMiXIhIXnEsE0cAyW01WBuY1+Y1xH6YkO03qS+G0j/6e5f6c5 YzLEIji/yAY78AigzR1nBNzhTt1TNL7r/1D4NV7znRIhLZaovJ5QvSpMLrLP9C7wU7k BSJVB8FFiQ== Received: by mx.zohomail.com with SMTPS id 1772567308326261.20672561756817; Tue, 3 Mar 2026 11:48: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 v3 5/8] ALSA: usb-audio: Deconflict VID between Focusrite Novation & MV-SILICON Date: Wed, 4 Mar 2026 03:48:00 +0800 Message-ID: <20260303194805.266158-6-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 d365eb41910a..00d1a7c2260e 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2443,6 +2443,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, /* Conflict with Focusrite Novation */ + "MV-SILICON", + 0), /* Stop matching */ =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ --=20 2.53.0 From nobody Thu Apr 9 13:32:58 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 04FDA389116; Tue, 3 Mar 2026 19:48:46 +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=1772567328; cv=pass; b=rtcHlWfzihpHAqYkbkXdCG4cG3+x64YrONWH5oUMR+1Tg/ev62saCayY5ygcyewSm9JqSRgJJDp5+8U/yF5CelmFVgsRD/eEkQWvVKBfDqt2JwzFRAvvw0v85EPILJRb5qB5rvcuwGdOhW+AyeuNSucDQPHtDHjweR6BWp6NLh0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567328; c=relaxed/simple; bh=cwrPFFLfgEd/BbZv/7+Er7fk1mrkKj/RUMlA/CKVpiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uJONzQa+UtOj6nu+CJwaO+LQurnT4Ik6W1gBw8oNTVBfAYpqtqg0ObrMwhLZPuUJMfLFKWUewRiE+c/sGjhuQiqUdaTgQfQA43ceLtWUFeXAgYmthRoytaIeWVDIjfG7qvvrsBPIiODnaoy5E47fXbtOiIDHunCvtKhLOfnFSeQ= 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=jl2RKlSw; 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="jl2RKlSw" ARC-Seal: i=1; a=rsa-sha256; t=1772567313; cv=none; d=zohomail.com; s=zohoarc; b=H3vQrkHVqJZSHsAhP37TpfTT2wFzGES1kzAEcNFRseKcXQhFKr5AcasUp/k2RfPWnCKMwdliciFUsyHo/yElp1NjpVejLFLgUOntn6N2tOQLNKF2tL0i8BB33A5nw+z+85CHc9sjusSKuqnNAFULGZ0YuOVK2iqadR3UjZZKa8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567313; 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=vAa44iPTvGsMU0au10ZpUPQiARs0Sq3EUeZdJvl8agE=; b=cnLGBBtOngtyTldWPvzaMpV09IH0KcYgWDQnHgT8chJsTJAjNl5rfKCNR6uZjK8zhMdKsgY16j8jdCRD4Yk/oE3VGBzWG8Z5IzZwPmmn0S6qTGHKzHEPesrPWOd5PXbfp6JdVSomfj6Vd0lWN2ORL2sD507Fa9+pqX4InsxuOF0= 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=1772567313; 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=vAa44iPTvGsMU0au10ZpUPQiARs0Sq3EUeZdJvl8agE=; b=jl2RKlSwOWcwJPbYrLfUSHvLEPUjF+Rmptor3gtLUVdMi5MqF+ieMtmFuLGil7Or Rwd/zp+KIoyVcBkkZhyBpOlkTLsvrYQcjFop6Z5uydJBIJFFt+XBVvtLVIiEnBKf5va j0wlhtyhrZej6bbpt1WKhv3y0JN1+OdjaeamhHYavd4xmKRbQz0dxePdJPiE79kt/Ec M9rAgkJeBAQAVUR3SEGdl5Gj1Z9/qqQBsOvNerXyaM/w2WglJmup4USOR8cs/XsJXdd 6XGqbqi8pY1i76TquIdwR+hdKtgUbn7UTEdnqDd/iJTyXFywDzWom+TeoRZpKBh7Dkz FHkV7orPxQ== Received: by mx.zohomail.com with SMTPS id 1772567311871121.75501291221087; Tue, 3 Mar 2026 11:48:31 -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 v3 6/8] ALSA: usb-audio: Add QUIRK_FLAG_MIXER_{PLAYBACK,CAPTURE}_LINEAR_VOL Date: Wed, 4 Mar 2026 03:48:01 +0800 Message-ID: <20260303194805.266158-7-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 55b845d38236..f75f08763941 100644 --- a/Documentation/sound/alsa-configuration.rst +++ b/Documentation/sound/alsa-configuration.rst @@ -2376,6 +2376,13 @@ quirk_flags Skip the probe-time interface setup (usb_set_interface, init_pitch, init_sample_rate); redundant with snd_usb_endpoint_prepare() at stream-open time + * 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 11e205da7964..539044c0c644 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 00d1a7c2260e..7a5cec9cc4bd 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2543,6 +2543,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 085530cf62d9..58fd07f8c3c9 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.53.0 From nobody Thu Apr 9 13:32:58 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 14437390CAB; Tue, 3 Mar 2026 19:48:49 +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=1772567331; cv=pass; b=Nm71gYuXr0NDStbE46YymDjM11HSj6FsRHxWZCbgY0qvx04QSxOScLnqIVoHQmuDS8mJTWiId3AKa4/js4X/WPMosLl+slsO4qvJeW8d2hNhkvhv8GuhPXEnnZPtSlVogQAn/DAv6QXekxIm53zzjqpunDg2nRv8iuXgoXpTbZg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567331; c=relaxed/simple; bh=+aoBBw0QAYw/VgMz6vdFpjOKSBM3Sq5nzN/0DB0JSZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PT92mWwfVpUcnUgOFvUUn/H1IPyylIibwn1QFgrkD0JM1NDmylKRMp/2H4rc523BUko2gJmcPpp1pUXGZ3MpSI5s4IbNidLHFeQI+LbVWNr2EMu+zgwlY7ocwK84J6oWyDYBq4L4ghVV+PqfhEtJPHBweuYk2rtfn4x96Nx7A2Y= 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=b80oSsBn; 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="b80oSsBn" ARC-Seal: i=1; a=rsa-sha256; t=1772567317; cv=none; d=zohomail.com; s=zohoarc; b=FhLxnO4OPCYdWDVmVoZtc4giOyRdEVFrYUy3zbGnE/H/XCJMD2CXVToSicpMC9cKQVdBcwgwH1gKrsi7klQ7iWMwwdqGXmfO9MCYHih854XVYa0wLAnibT1HOtq12lF7IhAyo8eghj8k3MLy7pSOn1jVMzPEGPB6RbSjGz+AIuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567317; 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=dcL1ZYaSNXXOVvluiLbCfveAHnn1GXtTsMNzhPO8ZVI=; b=NYTLPLBFNC3AwZ9p+sHq2sby7oMY9AQU8JqBV7jX+sNyPOt+7dy0VAkgkhij4LGbTrWJy3y7zu0ykUkfurds0aN0KV/IyEtm20zMTEIZTryMwLZrroCty8PiLua9LvxFGdB95xIVoS66JjpBwknSelHSsL4Rahz+dTHDBrEw/H0= 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=1772567317; 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=dcL1ZYaSNXXOVvluiLbCfveAHnn1GXtTsMNzhPO8ZVI=; b=b80oSsBnf9ufNrDeDzc5eTMg6HEW/4uig/Ojd53rIGE1+zQotpRym4cy2mtzoQCu e6N1rtosfpN/77S3Wwbw0M7lsLEQElxD67CHdMf+0vZLBCMB4LqPEW4su8o+Ueo0HHA 0oM2SCye08JrGaNkgYEIUbZKROvDyApf48QJ9iyUJxLTARJuzPsamP2G5LyAA0wHOu/ nz2nhFIy0NLhLtEukmuD78eMgxTOOENNYjtLt3rz59iC+iboC0lUuh8Tcu0UkXdO9SB RGjEc3bxLhhd1NuiDKkbfdqDlhxbDUPm+FER+TyJ/4NdeSJ0Uf2DlSfyOLkZ0y+eR5K 11FYvaAWQw== Received: by mx.zohomail.com with SMTPS id 1772567314904489.6854365407455; Tue, 3 Mar 2026 11:48:34 -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 v3 7/8] ALSA: usb-audio: Add linear volume quirk for Hotone Audio Pulze Mini Date: Wed, 4 Mar 2026 03:48:02 +0800 Message-ID: <20260303194805.266158-8-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 7a5cec9cc4bd..17f6be4d2350 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2441,6 +2441,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, /* Conflict with Focusrite Novation */ --=20 2.53.0 From nobody Thu Apr 9 13:32:58 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 A85CC42EEBD; Tue, 3 Mar 2026 19:48:52 +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=1772567334; cv=pass; b=fylGDKkSdE01xkJdqqWMjuQb6ii4zBacmr0aVQTj7+rIqDeYarS0ppHWGC6f0xJDIjAF0+al83XPPJPL1XCFPd+43GgOqy8PmprCXxX4VpVHyol5RqttW6CCxrxITs/GbbeYBZeDfanPJO/vKANikzoLaLf9WyDOgHk8cSHGQH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772567334; c=relaxed/simple; bh=k/j1dDb0TiBV30wnb9DVBj+O831fHg6SEj20fhuUzMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S9/C11B/GpmJwS82pjaeZRoviVngIcpPCtLk3+QRwqBxtpy6iG2m2MGc9EO3CJRUzt05nAFsAgkPgVnbN00gD6n5VRfdwtWK2wMhcKJmSRxlrv5hc33i7m3noH+V8Nph6WkItcowE8d2StU7LuhjJIK7rRyM9dsNiuzbSULiB1M= 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=YB4g8/Kj; 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="YB4g8/Kj" ARC-Seal: i=1; a=rsa-sha256; t=1772567319; cv=none; d=zohomail.com; s=zohoarc; b=UX6LKg1Y84bUd2W/D2GnnKswTubIoMEehjSVCwfzMd1AnzirWE5cuHcJ37U7RkihTQVoIztwgOPfOHsvQuJd7avztmL/baxWnYq0mOeg8pBe2GLisgv/+O64jE6lsGhH3ghoo0kTHkCHsmIAhIUrgBM8YQv/CxYzHvxVWthrKhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772567319; 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=n4Vn0pbl99xPEiHHtN8VjnR2w8nLax2cHEruMeH3bIU=; b=TBRguYeQLavV4MUxG60OfgnKeaMLAE3VGaITDeOXwMpv4J9VhyZReMFJOShXtUkLHd4yMMPsRmzI1dPnVnq6u1U3aIb5q6+HN25GXrytiTtJ2rT/0mHh365nbhuCbGX93uWTa+dfeK5Nf+KKPr5/KTZhFHPpn51WBybwe4w6opc= 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=1772567319; 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=n4Vn0pbl99xPEiHHtN8VjnR2w8nLax2cHEruMeH3bIU=; b=YB4g8/KjdgrccMje16DtArdtxqF9Is9kY3OEQRL2qDHLw8/XV5n+/7D3a1ozvSfE HzEQRSrdjD9ZY9FvEEix5hNSmLRP9YXPxzw8xxV/HGqPeAjkJHLycW035tV7ez8K72o vKVM+3QZBiKYCaZX/k7jf+LcF4ABHGMGD1cZ/yxAnNKFb3ey8QBe62aACXVyCDekJRT VYwNjbx/cENPhVG7ATrttynG5smWUJbdtwYCGvc4w3FPwYjvvcX7WC09VspS2r58OEc 0RltZp4JMGwgvgceiwXtQOeAhtnHHmpT0d1SS3yDemKaE1q6K4DKcBJFB1VIyyk/xA/ 3gZWYtqnvw== Received: by mx.zohomail.com with SMTPS id 1772567318377252.90102794541485; Tue, 3 Mar 2026 11:48:38 -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 v3 8/8] ALSA: usb-audio: Apply linear volume quirk on MV-SILICON devices Date: Wed, 4 Mar 2026 03:48:03 +0800 Message-ID: <20260303194805.266158-9-i@rong.moe> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303194805.266158-1-i@rong.moe> References: <20260303194805.266158-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 539044c0c644..e97814dc9025 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.53.0