From nobody Thu Oct 2 09:22:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 81A1F2F9DB2; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; cv=none; b=kNcV93E6Oi81kbpiI8Sp7NemDSQJAozua6ner4x9TpqZgjrVWw1X6M6hwGs6hgVf0ElliboJRvZrOwYRVZstrGvp9iKZUz5H5yXMi71tx4v/ozvWJHwOSXSCDo3ErQH9n7OWdpsZs7Omz6qjywRT9d+Ilt5f6liNwpIx2ntOWBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; c=relaxed/simple; bh=AfD1lGXGhBJ72syghpA4tAQn0Om1/q15shkj744ZzgI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WRNRcZXNnRKgDH1EC1M/kU+gW4Qrv17UakdTp026LEPNJEGfc3WGRqvsdLrpF07o5ev9ucWgRwj6ibTkrw1e/fXRB0MAlladK4/P9LCM/9DAmCMM5HIl7DcK+57V+8Lycv4MZS9KyAHDuIzczWvj1Sl+x4G/MB2bZZ+SPMbk28M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zi232eHB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zi232eHB" Received: by smtp.kernel.org (Postfix) with ESMTPS id 272A9C4CEF0; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758187475; bh=AfD1lGXGhBJ72syghpA4tAQn0Om1/q15shkj744ZzgI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Zi232eHBJL/77M/MsFI38Er8c6rcyACQDDObvhBui9YBsE0y0RYyNxGKDPt95NP0p 5inzEXn+hTk12Ja9IPrNDjGzVczdBOwekT7QwCdHxFNX/xKLUtyddr0RI5gOIF9zov PX0lZqgYJjyYxvWzys9V+rFQAeJLdJ5fBv0XQFv377kjxYGoRG78PHvrxjHNo4A5Rn R7ELpdUqYe8fcnweFv9cw0VUqXR25Hg46bmtRz7GEB7n15YVqY3pBf7Z82ZPbgJ3HZ 7F8h7bmlTq/z2lI0q/fx2vSs5suCj91ILRvD+WIza8s2OidObWrd//jvMmYJdtlYBk Wj/nLJbwFYDyQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16E21CAC5A8; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) From: Cryolitia PukNgae via B4 Relay Date: Thu, 18 Sep 2025 17:24:30 +0800 Subject: [PATCH v4 1/5] ALSA: usb-audio: add two-way convert between name and bit for QUIRK_FLAG_* 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 Message-Id: <20250918-sound-v4-1-82cf8123d61c@uniontech.com> References: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> In-Reply-To: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> To: Jaroslav Kysela , Takashi Iwai , Jonathan Corbet , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Nie Cheng , Zhan Jun , Feng Yuan , qaqland , kernel@uniontech.com, linux-modules@vger.kernel.org, Cryolitia PukNgae X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758187473; l=4063; i=cryolitia@uniontech.com; s=20250730; h=from:subject:message-id; bh=/BXquMWJMNiFdz+nh5s6GogPhAqR6jecE2iPTQLfG8w=; b=NG/5R3jQX8kpdaMuykUIawwyLiNFHUTU0wCQTg5C2J+0eFQApormifbECybPieuDu+7oVQmNZ xItgiMQhCVhAdGaLUEtc7sRFrEn0rbeUlRsBWE6PlpIymkC1ay9La8P X-Developer-Key: i=cryolitia@uniontech.com; a=ed25519; pk=tZ+U+kQkT45GRGewbMSB4VPmvpD+KkHC/Wv3rMOn/PU= X-Endpoint-Received: by B4 Relay for cryolitia@uniontech.com/20250730 with auth_id=474 X-Original-From: Cryolitia PukNgae Reply-To: cryolitia@uniontech.com From: Cryolitia PukNgae Also improve debug logs for applied quirks Signed-off-by: Cryolitia PukNgae --- sound/usb/quirks.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++= +--- sound/usb/quirks.h | 3 ++ sound/usb/usbaudio.h | 1 + 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index d736a4750356597bfb0f9d5ab01cdaeaac0f907c..94854f352b1702b491e1bf3c8b7= 69f7088e03976 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2446,6 +2446,62 @@ static const struct usb_audio_quirk_flags_table quir= k_flags_table[] =3D { {} /* terminator */ }; =20 +static const char *const snd_usb_audio_quirk_flag_names[] =3D { + "get_sample_rate", + "share_media_device", + "align_transfer", + "tx_length", + "playback_first", + "skip_clock_selector", + "ignore_clock_source", + "itf_usb_dsd_dac", + "ctl_msg_delay", + "ctl_msg_delay_1m", + "ctl_msg_delay_5m", + "iface_delay", + "validate_rates", + "disable_autosuspend", + "ignore_ctl_error", + "dsd_raw", + "set_iface_first", + "generic_implicit_fb", + "skip_implicit_fb", + "iface_skip_close", + "force_iface_reset", + "fixed_rate", + "mic_res_16", + "mic_res_384", + "mixer_playback_min_mute", + "mixer_capture_min_mute", + NULL +}; + +const char *snd_usb_quirk_flag_find_name(unsigned long index) +{ + if (index >=3D ARRAY_SIZE(snd_usb_audio_quirk_flag_names)) + return NULL; + + return snd_usb_audio_quirk_flag_names[index]; +} + +u32 snd_usb_quirk_flags_from_name(char *name) +{ + u32 flag =3D 0; + u32 i; + + if (!name || !*name) + return 0; + + for (i =3D 0; snd_usb_audio_quirk_flag_names[i]; i++) { + if (strcmp(name, snd_usb_audio_quirk_flag_names[i]) =3D=3D 0) { + flag =3D (1U << i); + break; + } + } + + return flag; +} + void snd_usb_init_quirk_flags(struct snd_usb_audio *chip) { const struct usb_audio_quirk_flags_table *p; @@ -2454,10 +2510,28 @@ void snd_usb_init_quirk_flags(struct snd_usb_audio = *chip) 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))) { - usb_audio_dbg(chip, - "Set quirk_flags 0x%x for device %04x:%04x\n", - p->flags, USB_ID_VENDOR(chip->usb_id), - USB_ID_PRODUCT(chip->usb_id)); + unsigned long flags =3D p->flags; + unsigned long bit; + + for_each_set_bit(bit, &flags, + BYTES_TO_BITS(sizeof(p->flags))) { + const char *name =3D + snd_usb_audio_quirk_flag_names[bit]; + + if (name) + usb_audio_dbg(chip, + "Set quirk flag %s for device %04x:%04x\n", + name, + USB_ID_VENDOR(chip->usb_id), + USB_ID_PRODUCT(chip->usb_id)); + else + usb_audio_warn(chip, + "Set unknown quirk flag 0x%lx for device %04x:%04x\n", + bit, + USB_ID_VENDOR(chip->usb_id), + USB_ID_PRODUCT(chip->usb_id)); + } + chip->quirk_flags |=3D p->flags; return; } diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index f9bfd5ac7bab01717de3a76227482a128bf73165..bd5baf2b193a1985f3a0e52bf4a= 77ca741364769 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -50,4 +50,7 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_= audio *chip, =20 void snd_usb_init_quirk_flags(struct snd_usb_audio *chip); =20 +const char *snd_usb_quirk_flag_find_name(unsigned long flag); +u32 snd_usb_quirk_flags_from_name(char *name); + #endif /* __USBAUDIO_QUIRKS_H */ diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 30b5102e3caed01eeb86d0075c41338104c58950..0a22cb4a02344b2dcf4009c560a= 759f2da25ca67 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -252,5 +252,6 @@ extern bool snd_usb_skip_validation; #define QUIRK_FLAG_MIC_RES_384 (1U << 23) #define QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE (1U << 24) #define QUIRK_FLAG_MIXER_CAPTURE_MIN_MUTE (1U << 25) +/* Please also edit snd_usb_audio_quirk_flag_names */ =20 #endif /* __USBAUDIO_H */ --=20 2.51.0 From nobody Thu Oct 2 09:22:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 81AB52FF648; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; cv=none; b=HdgQIKGW2shnOMeogb5N93C9noCX6wA5NxaWW5nyRmL7k2Kk0d8CuJsZPKbc8ASt7OIlEfnpEVZteuoNJXG8VPsa/Nb8OcUL6JZDkr10mlU5P9q5h5/xhDF8T8qsIvREflyYUAihooS3TQ+9dROVtHFNNZjrkb5QpW9EeK08Jh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; c=relaxed/simple; bh=0AYh4Kq94+K9Q9GhBTgVtjkUCdxvjg6DMvyhydU1efM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gsWctnX47qmTGQwd03YnaG0uJsTzXEUgVm39B9MwG4cV8gkBAUiX2BtKoss6L1zUCwVtWC5X1rJE9TnpvUOBLoEosmr2DeNdDQwVN698SrpBnrMm9Pa2FhlxPsDlqnnRpJ3Ce0lyY6mD5pYzoCl/UYs8ai4ZlJDlLecKuW3HXOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MtZ198vA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MtZ198vA" Received: by smtp.kernel.org (Postfix) with ESMTPS id 34B5CC4CEF1; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758187475; bh=0AYh4Kq94+K9Q9GhBTgVtjkUCdxvjg6DMvyhydU1efM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MtZ198vATguRK+2UeXGZbJqYzEBrMUJMBApVO7hMkHFtp3fJrzZdlGjmkW3u5j+AH 7yWgCgs+vFDAwWrlXzJrHPFXj41IKrcOnxeH3uouxkkjJAV4PbCvAOBWPhyvyUeci6 1tUf7ya/rpszQwfW4Kakpagb36NxPW8pIeI1pXYtByt7L+Or4RSJKFkMP4A2Yu6exi yvgvbxmbs+px+x7PMVU16VpQkHRU3Hf7+QUzO3bvVnZI4eLsN+cU0MKS+MpA3XRv/s fd1V1c2F7fmbOjKl6dPr1sy9gvlC81naL4U22Gvee7Xjbma9qQH6MOBx0Tx8t6zCSx WFXFqSfQtSVgw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25160CAC5A9; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) From: Cryolitia PukNgae via B4 Relay Date: Thu, 18 Sep 2025 17:24:31 +0800 Subject: [PATCH v4 2/5] param: export param_array related functions 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 Message-Id: <20250918-sound-v4-2-82cf8123d61c@uniontech.com> References: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> In-Reply-To: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> To: Jaroslav Kysela , Takashi Iwai , Jonathan Corbet , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Nie Cheng , Zhan Jun , Feng Yuan , qaqland , kernel@uniontech.com, linux-modules@vger.kernel.org, Cryolitia PukNgae X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758187473; l=2799; i=cryolitia@uniontech.com; s=20250730; h=from:subject:message-id; bh=Iu09dllz6TNtY0M5KhKHic/tph0IN8w4KA3fww/CJfM=; b=T3cSpNzBi5jROvwC1BFCwr4GCxzo9h8GL1HRhwx+jcUK2ExVvywIBhzmIOST4WRL8Jq+pGBa0 NEnITolOir5CyxS2jYR7UCfLP0zx2ELqJhR2JgKDVYJMe9nju/rZ23N X-Developer-Key: i=cryolitia@uniontech.com; a=ed25519; pk=tZ+U+kQkT45GRGewbMSB4VPmvpD+KkHC/Wv3rMOn/PU= X-Endpoint-Received: by B4 Relay for cryolitia@uniontech.com/20250730 with auth_id=474 X-Original-From: Cryolitia PukNgae Reply-To: cryolitia@uniontech.com From: Cryolitia PukNgae - int param_array_set(const char *val, const struct kernel_param *kp); - int param_array_get(char *buffer, const struct kernel_param *kp); - void param_array_free(void *arg); It would be helpful for the new module param we designed in snd_usb_audio, in order to run additional custom codes when params are set in runtime, and re-use the extisted codes in param.c Signed-off-by: Cryolitia PukNgae --- include/linux/moduleparam.h | 3 +++ kernel/params.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 3a25122d83e2802e6e6a1475a52816251498b26a..4ef09ad2004789855bd21783029= c653fac94b9dd 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -593,6 +593,9 @@ enum hwparam_type { =20 =20 extern const struct kernel_param_ops param_array_ops; +extern int param_array_set(const char *val, const struct kernel_param *kp); +extern int param_array_get(char *buffer, const struct kernel_param *kp); +extern void param_array_free(void *arg); =20 extern const struct kernel_param_ops param_ops_string; extern int param_set_copystring(const char *val, const struct kernel_param= *); diff --git a/kernel/params.c b/kernel/params.c index b96cfd693c9968012d42acb85611fee1acd47790..a936e018a1c6d0bf2b6b4566f80= 751840366f652 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -462,7 +462,7 @@ static int param_array(struct module *mod, return 0; } =20 -static int param_array_set(const char *val, const struct kernel_param *kp) +int param_array_set(const char *val, const struct kernel_param *kp) { const struct kparam_array *arr =3D kp->arr; unsigned int temp_num; @@ -471,8 +471,9 @@ static int param_array_set(const char *val, const struc= t kernel_param *kp) arr->elemsize, arr->ops->set, kp->level, arr->num ?: &temp_num); } +EXPORT_SYMBOL(param_array_set); =20 -static int param_array_get(char *buffer, const struct kernel_param *kp) +int param_array_get(char *buffer, const struct kernel_param *kp) { int i, off, ret; const struct kparam_array *arr =3D kp->arr; @@ -492,8 +493,9 @@ static int param_array_get(char *buffer, const struct k= ernel_param *kp) buffer[off] =3D '\0'; return off; } +EXPORT_SYMBOL(param_array_get); =20 -static void param_array_free(void *arg) +void param_array_free(void *arg) { unsigned int i; const struct kparam_array *arr =3D arg; @@ -502,6 +504,7 @@ static void param_array_free(void *arg) for (i =3D 0; i < (arr->num ? *arr->num : arr->max); i++) arr->ops->free(arr->elem + arr->elemsize * i); } +EXPORT_SYMBOL(param_array_free); =20 const struct kernel_param_ops param_array_ops =3D { .set =3D param_array_set, --=20 2.51.0 From nobody Thu Oct 2 09:22:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 81BEB2FFDF6; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; cv=none; b=t210QE9tsfrpM16uNirq83R/Log2oBJpylja9ZebX1oiXjc0U4jOrVidwDKlZ697WIMtuERPTdIf1OshuZoKRCtpLCR2ZVyxwzE/w000Qis2i+QtLd7kRKNsKv9EPxoc6uhOR8v9QjJnvvHfXUKFjxCS8HHi6t7UDyGF0y58ZjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; c=relaxed/simple; bh=JOZL5aKeUQhPAF06ngc+zti+EoNjmnWL/H0POmJ6+t0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u3daI+qVHeCcmAK9FR3fBLJQTGcAXf+x2dku2W6a4f+0VZE9V9NxeF0Tpm53guXQW4+3W6NuE3jy5VtXdkgmNFDZtnEaeAYuUVndKQ4mcOdPPXiTRJWDBdfvtvEBlCkOupnj8mAkZrYQlegFnqjCiiLVwt3vaSyu6KcMTZLnpJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QJX4H8Gf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QJX4H8Gf" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4002AC4CEFC; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758187475; bh=JOZL5aKeUQhPAF06ngc+zti+EoNjmnWL/H0POmJ6+t0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=QJX4H8GfhNfSv24n8Gmm3caIv8OYFghO7g8VXR0LhMaRYnltDt0I/21mGuF7HsFiK 3+FwU7RcgOOaZBplnu/uqU57HspHnjEL8rRLqAEXFQahItgAxIe6ipIyoDpWS1Zrma mborJE4Xp/mCAmTpyt0KGrsG/QLo4GVce9XxK0SsqLGcnvJEdekP3iqdPEUOiwc3kN fTP6U76dVvHliuBWp6gJEza3X2flN8Ac4CI2XxyAiuzqrgPGutCdIO5FeF0LJxvSh5 4Rm55ILqtnNtoFbjYxwMQPTpWvdtGdnYeCgpGNxPgHO9PfbZBNforv6IkYkNfwggto gBJzyt+UWem7A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C88CAC59A; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) From: Cryolitia PukNgae via B4 Relay Date: Thu, 18 Sep 2025 17:24:32 +0800 Subject: [PATCH v4 3/5] ALSA: usb-audio: improve module param quirk_flags 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 Message-Id: <20250918-sound-v4-3-82cf8123d61c@uniontech.com> References: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> In-Reply-To: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> To: Jaroslav Kysela , Takashi Iwai , Jonathan Corbet , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Nie Cheng , Zhan Jun , Feng Yuan , qaqland , kernel@uniontech.com, linux-modules@vger.kernel.org, Cryolitia PukNgae , Takashi Iwai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758187473; l=6882; i=cryolitia@uniontech.com; s=20250730; h=from:subject:message-id; bh=q+HMwyqe4+9HaNuLRBYI9H0ocDi9G5hhy1QWgS3l+Dk=; b=Lk79LX0opB34NbnQqKcphq22zcwFWuPVg1e5CQkFwZwYawmOXd/t4jdE0SAolNjf8Ru2M6hqb guN5zMX7USFDZl5s+LFw84U/F76u+MtAnM5AP4SlXFrgBwDM6WoGFCA X-Developer-Key: i=cryolitia@uniontech.com; a=ed25519; pk=tZ+U+kQkT45GRGewbMSB4VPmvpD+KkHC/Wv3rMOn/PU= X-Endpoint-Received: by B4 Relay for cryolitia@uniontech.com/20250730 with auth_id=474 X-Original-From: Cryolitia PukNgae Reply-To: cryolitia@uniontech.com From: Cryolitia PukNgae For apply and unapply quirk flags more flexibly though param Co-developed-by: Takashi Iwai Signed-off-by: Cryolitia PukNgae --- sound/usb/card.c | 9 ++-- sound/usb/quirks.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++= +++- sound/usb/quirks.h | 3 +- sound/usb/usbaudio.h | 3 ++ 4 files changed, 126 insertions(+), 8 deletions(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 0265206a8e8cf31133e8463c98fe0497d8ace89e..5837677effa1787ef9d7d02714c= 3ae43b1a8bc79 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -73,8 +73,8 @@ static bool lowlatency =3D true; static char *quirk_alias[SNDRV_CARDS]; static char *delayed_register[SNDRV_CARDS]; static bool implicit_fb[SNDRV_CARDS]; -static unsigned int quirk_flags[SNDRV_CARDS]; =20 +char *quirk_flags[SNDRV_CARDS]; bool snd_usb_use_vmalloc =3D true; bool snd_usb_skip_validation; =20 @@ -103,7 +103,7 @@ module_param_array(delayed_register, charp, NULL, 0444); MODULE_PARM_DESC(delayed_register, "Quirk for delayed registration, given = by id:iface, e.g. 0123abcd:4."); module_param_array(implicit_fb, bool, NULL, 0444); MODULE_PARM_DESC(implicit_fb, "Apply generic implicit feedback sync mode."= ); -module_param_array(quirk_flags, uint, NULL, 0444); +module_param_array(quirk_flags, charp, NULL, 0444); MODULE_PARM_DESC(quirk_flags, "Driver quirk bit flags."); module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444); MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (d= efault: yes)."); @@ -750,10 +750,7 @@ static int snd_usb_audio_create(struct usb_interface *= intf, INIT_LIST_HEAD(&chip->midi_v2_list); INIT_LIST_HEAD(&chip->mixer_list); =20 - if (quirk_flags[idx]) - chip->quirk_flags =3D quirk_flags[idx]; - else - snd_usb_init_quirk_flags(chip); + snd_usb_init_quirk_flags(idx, chip); =20 card->private_free =3D snd_usb_audio_free; =20 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 94854f352b1702b491e1bf3c8b769f7088e03976..4dc2464133e934e48b1fa613884= a8a0ebdaff91d 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2502,7 +2502,7 @@ u32 snd_usb_quirk_flags_from_name(char *name) return flag; } =20 -void snd_usb_init_quirk_flags(struct snd_usb_audio *chip) +void snd_usb_init_quirk_flags_table(struct snd_usb_audio *chip) { const struct usb_audio_quirk_flags_table *p; =20 @@ -2537,3 +2537,120 @@ void snd_usb_init_quirk_flags(struct snd_usb_audio = *chip) } } } + +void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip) +{ + u16 chip_vid =3D USB_ID_VENDOR(chip->usb_id); + u16 chip_pid =3D USB_ID_PRODUCT(chip->usb_id); + u32 mask_flags, unmask_flags, bit; + char *val, *p, *field, *flag; + bool is_unmask; + u16 vid, pid; + size_t i; + + /* old style option found: the position-based integer value */ + if (quirk_flags[idx] && + !kstrtou32(quirk_flags[idx], 0, &chip->quirk_flags)) { + usb_audio_dbg(chip, + "Set quirk flags 0x%x from param based on position %d for device = %04x:%04x\n", + chip->quirk_flags, idx, + USB_ID_VENDOR(chip->usb_id), + USB_ID_PRODUCT(chip->usb_id)); + return; + } + + /* take the default quirk from the quirk table */ + snd_usb_init_quirk_flags_table(chip); + + /* add or correct quirk bits from options */ + for (i =3D 0; i < ARRAY_SIZE(quirk_flags); i++) { + if (!quirk_flags[i] || !*quirk_flags[i]) + break; + + val =3D kstrdup(quirk_flags[i], GFP_KERNEL); + + if (!val) { + pr_err("snd_usb_audio: Error allocating memory while parsing quirk_flag= s\n"); + return; + } + + for (p =3D val; p && *p;) { + /* Each entry consists of VID:PID:flags */ + field =3D strsep(&p, ":"); + if (!field) + break; + + if (strcmp(field, "*") =3D=3D 0) + vid =3D 0; + else if (kstrtou16(field, 16, &vid)) + break; + + field =3D strsep(&p, ":"); + if (!field) + break; + + if (strcmp(field, "*") =3D=3D 0) + pid =3D 0; + else if (kstrtou16(field, 16, &pid)) + break; + + field =3D strsep(&p, ";"); + if (!field || !*field) + break; + + if ((vid !=3D 0 && vid !=3D chip_vid) || + (pid !=3D 0 && pid !=3D chip_pid)) + continue; + + /* Collect the flags */ + mask_flags =3D 0; + unmask_flags =3D 0; + while (field && *field) { + flag =3D strsep(&field, "|"); + + if (!flag) + break; + + if (*flag =3D=3D '!') { + is_unmask =3D true; + flag++; + } else { + is_unmask =3D false; + } + + if (!kstrtou32(flag, 16, &bit)) { + if (is_unmask) + unmask_flags |=3D bit; + else + mask_flags |=3D bit; + + break; + } + + bit =3D snd_usb_quirk_flags_from_name(flag); + + if (bit) { + if (is_unmask) + unmask_flags |=3D bit; + else + mask_flags |=3D bit; + } else { + pr_warn("snd_usb_audio: unknown flag %s while parsing param quirk_fla= gs\n", + field); + } + } + + chip->quirk_flags &=3D ~unmask_flags; + chip->quirk_flags |=3D mask_flags; + usb_audio_dbg(chip, + "Set quirk flags (mask 0x%x, unmask 0x%x, finally 0x%x) from par= am for device %04x:%04x\n", + mask_flags, + unmask_flags, + chip->quirk_flags, + USB_ID_VENDOR(chip->usb_id), + USB_ID_PRODUCT(chip->usb_id)); + } + + kfree(val); + } +} diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index bd5baf2b193a1985f3a0e52bf4a77ca741364769..0dc8c04afeffe76e1219c71a8fe= 2e4b66624b48f 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -48,7 +48,8 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_= audio *chip, struct audioformat *fp, int stream); =20 -void snd_usb_init_quirk_flags(struct snd_usb_audio *chip); +void snd_usb_init_quirk_flags_table(struct snd_usb_audio *chip); +void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip); =20 const char *snd_usb_quirk_flag_find_name(unsigned long flag); u32 snd_usb_quirk_flags_from_name(char *name); diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 0a22cb4a02344b2dcf4009c560a759f2da25ca67..73564cd68ebf101291440d0171e= b81c220c6f5e2 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -7,6 +7,8 @@ * Copyright (c) 2002 by Takashi Iwai */ =20 + #include + /* handling of USB vendor/product ID pairs as 32-bit numbers */ #define USB_ID(vendor, product) (((unsigned int)(vendor) << 16) | (product= )) #define USB_ID_VENDOR(id) ((id) >> 16) @@ -162,6 +164,7 @@ DEFINE_CLASS(snd_usb_lock, struct __snd_usb_lock, __snd_usb_unlock_shutdown(&(_T)), __snd_usb_lock_shutdown(chip), struct snd_usb_audio *chip) =20 +extern char *quirk_flags[SNDRV_CARDS]; extern bool snd_usb_use_vmalloc; extern bool snd_usb_skip_validation; =20 --=20 2.51.0 From nobody Thu Oct 2 09:22:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A018B2FFDF7; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; cv=none; b=AtXNrze27LoWEmk1GasEoH1/qoeeRs45w3MHLa8hZVTpb7y8iY9KDk5lKAgCosprLSajyRn0U28xcGaje2eR5drn5UQty7GSO9bU8I81rX7+LCXlgg8LIeA1pru6OfPcdpppFd9HvyzMUMb/ZIwQHwjaTinnDhneej/gwBC6BmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187475; c=relaxed/simple; bh=cZj0X4uXKE82QrzbmJRGUCqeyeFL4fGaR+wQomjtqLk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nxs62QwMCQygRmgNDueGQ81ZYe+Zf4YfDNqB2TCxKfZB34sqUhijIiRT35HhSQP7wjjp/D/zQUOBviWhXUHk9DSRUw5Ifmj810gjLmzxqvO+d20JeCGc9VOj1WkvqsHTQUYc4p3yGcD2vbwbsnT8U7vy8mxqcZ1PWBROq7FGxH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cSTi7WEb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cSTi7WEb" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4EA61C4CEFE; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758187475; bh=cZj0X4uXKE82QrzbmJRGUCqeyeFL4fGaR+wQomjtqLk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cSTi7WEbP3Iwi0bs6Z4ZTf5RMlYcB/lBRdkOdiL+CirGUiN0yaJ4Bgy1aNjH4jkus Zk6WTm5+POD8lRVIeHrNYocVuQuK+xFYTny2if9eta0qFm83b/wgKEdK+nPjdw+be+ rqyHFdKaCwnon31oVFuuNNV5ZWxDQvXuCdMKu0EiTA92u5RA4Cgy50Gmtv6XVCoIoU ljcGORpWebqPdTbxM7w5v83VFKZnuKX2WjWqyX8IGGCZ4CpWeCi4bnVx8jCKfHL/BF PC2ATxCTbHTkTJwfHUBM0Gx8VWdWPAFdXDytBEBq0qyIixMPn4/rmZUMtCZvKCiL+2 5jlzKYM9sA9YA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4331FCAC5AA; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) From: Cryolitia PukNgae via B4 Relay Date: Thu, 18 Sep 2025 17:24:33 +0800 Subject: [PATCH v4 4/5] ALSA: usb-audio: make param quirk_flags change-able in runtime 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 Message-Id: <20250918-sound-v4-4-82cf8123d61c@uniontech.com> References: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> In-Reply-To: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> To: Jaroslav Kysela , Takashi Iwai , Jonathan Corbet , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Nie Cheng , Zhan Jun , Feng Yuan , qaqland , kernel@uniontech.com, linux-modules@vger.kernel.org, Cryolitia PukNgae , Takashi Iwai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758187473; l=4510; i=cryolitia@uniontech.com; s=20250730; h=from:subject:message-id; bh=STeoGU+UtGOLSx8KmIDY0kU8k2ZAF7sipS6bLUIP9L4=; b=csi4J0NfBu9l3xWhCmiJYM3fyuFHZKpjb/whezESt9l9YSV6By4OYlEFKPQjoO9H6gFDpXdoe ngZikcAmm6PDBh29OexAfHPwugVCpd5xT9LBq2egvILVec5rjLaUUU/ X-Developer-Key: i=cryolitia@uniontech.com; a=ed25519; pk=tZ+U+kQkT45GRGewbMSB4VPmvpD+KkHC/Wv3rMOn/PU= X-Endpoint-Received: by B4 Relay for cryolitia@uniontech.com/20250730 with auth_id=474 X-Original-From: Cryolitia PukNgae Reply-To: cryolitia@uniontech.com From: Cryolitia PukNgae Developers now can change it during sysfs, without rebooting, for debugging new buggy devices. Co-developed-by: Takashi Iwai Signed-off-by: Cryolitia PukNgae --- sound/usb/card.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++= ++-- sound/usb/quirks.c | 9 +++++++-- sound/usb/usbaudio.h | 2 ++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 5837677effa1787ef9d7d02714c3ae43b1a8bc79..fd99df5949df826d97b3d2bc6d3= 137923ab4295d 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -103,13 +103,65 @@ module_param_array(delayed_register, charp, NULL, 044= 4); MODULE_PARM_DESC(delayed_register, "Quirk for delayed registration, given = by id:iface, e.g. 0123abcd:4."); module_param_array(implicit_fb, bool, NULL, 0444); MODULE_PARM_DESC(implicit_fb, "Apply generic implicit feedback sync mode."= ); -module_param_array(quirk_flags, charp, NULL, 0444); -MODULE_PARM_DESC(quirk_flags, "Driver quirk bit flags."); module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444); MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (d= efault: yes)."); module_param_named(skip_validation, snd_usb_skip_validation, bool, 0444); MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (defaul= t: no)."); =20 +/* protects quirk_flags */ +DEFINE_MUTEX(quirk_flags_mutex); + +static int quirk_flags_param_set(const char *value, + const struct kernel_param *kp) +{ + int err; + + mutex_lock(&quirk_flags_mutex); + + memset(quirk_flags, 0, sizeof(quirk_flags)); + err =3D param_array_set(value, kp); + + mutex_unlock(&quirk_flags_mutex); + + return err; +} + +static int quirk_flags_param_get(char *buffer, const struct kernel_param *= kp) +{ + int err; + + mutex_lock(&quirk_flags_mutex); + err =3D param_array_get(buffer, kp); + mutex_unlock(&quirk_flags_mutex); + + return err; +} + +static void quirk_flags_param_free(void *arg) +{ + mutex_lock(&quirk_flags_mutex); + param_array_free(arg); + mutex_unlock(&quirk_flags_mutex); +} + +static const struct kernel_param_ops quirk_flags_param_ops =3D { + .set =3D quirk_flags_param_set, + .get =3D quirk_flags_param_get, + .free =3D quirk_flags_param_free, +}; + +static struct kparam_array quirk_flags_param_array =3D { + .max =3D SNDRV_CARDS, + .elemsize =3D sizeof(char *), + .num =3D NULL, + .ops =3D ¶m_ops_charp, + .elem =3D &quirk_flags, +}; + +device_param_cb(quirk_flags, &quirk_flags_param_ops, &quirk_flags_param_ar= ray, + 0644); +MODULE_PARM_DESC(quirk_flags, "Add/modify USB audio quirks"); + /* * we keep the snd_usb_audio_t instances by ourselves for merging * the all interfaces on the same card as one sound device. diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 4dc2464133e934e48b1fa613884a8a0ebdaff91d..ba9ea94399e5a6e7e1711b2a914= 8c90f991f05cd 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -2548,6 +2548,8 @@ void snd_usb_init_quirk_flags(int idx, struct snd_usb= _audio *chip) u16 vid, pid; size_t i; =20 + mutex_lock(&quirk_flags_mutex); + /* old style option found: the position-based integer value */ if (quirk_flags[idx] && !kstrtou32(quirk_flags[idx], 0, &chip->quirk_flags)) { @@ -2556,7 +2558,7 @@ void snd_usb_init_quirk_flags(int idx, struct snd_usb= _audio *chip) chip->quirk_flags, idx, USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id)); - return; + goto unlock; } =20 /* take the default quirk from the quirk table */ @@ -2571,7 +2573,7 @@ void snd_usb_init_quirk_flags(int idx, struct snd_usb= _audio *chip) =20 if (!val) { pr_err("snd_usb_audio: Error allocating memory while parsing quirk_flag= s\n"); - return; + goto unlock; } =20 for (p =3D val; p && *p;) { @@ -2653,4 +2655,7 @@ void snd_usb_init_quirk_flags(int idx, struct snd_usb= _audio *chip) =20 kfree(val); } + +unlock: + mutex_unlock(&quirk_flags_mutex); } diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 73564cd68ebf101291440d0171eb81c220c6f5e2..40551946c20df8c17d306fddd82= 95ca3a2bfa702 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -168,6 +168,8 @@ extern char *quirk_flags[SNDRV_CARDS]; extern bool snd_usb_use_vmalloc; extern bool snd_usb_skip_validation; =20 +extern struct mutex quirk_flags_mutex; + /* * Driver behavior quirk flags, stored in chip->quirk_flags * --=20 2.51.0 From nobody Thu Oct 2 09:22:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D73823019CE; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187476; cv=none; b=FdcPISy3/Xq4ysT7/7EXpYnMfLIv9Yd+uH98TBFyZ5ynwDN5oaAlO69oZchLeCXnSifH/j53COG3KH/FUsxf3MkNi3LEDMP7ZQ27lX0VacIcv3wCU2zrV1hFjHWT5K+i8QDYbpae156OaYYdEZ8xyxoHsNsWia545zYkWz0uM8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758187476; c=relaxed/simple; bh=9E6Z92AOi+KdNts18MJdP6mLHSc2LaCN1iJmxhy0MmE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Gxajv1cBrgaNgoM+UebKz3HlEy1lT7XLM5g7O4w8bd3Sfa4dHwC1preYbkYRknzLmPuzvTNJOFL5vkxHOHw7yfnrG5ni+X6UE3nX1DieqtrIvFjdAXnJ1BEcaIfSSwNB3vcSQdjK6C6UgYhcydzaLc57ZwkYyfnEtKPceo5EdMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oBjC3d2y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oBjC3d2y" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5AD8EC113CF; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758187475; bh=9E6Z92AOi+KdNts18MJdP6mLHSc2LaCN1iJmxhy0MmE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oBjC3d2y/sD+A1TF8p5R4/HlXs8nXNIDuY5DE4K7v3GH62Q9Pd8VLJvthKKn9JB73 Ia0DK3MvMCKumOPl4ZgI+hKAk6VxtzWH5gey+mgka3GdOth8HeTpYsRZSVBqq88uSx 3WGLodAqEGfrXdu69BHBL8aGzyN79zcXHCkY6CfcyGKb8gFvRXkSg4vn7tKGmyW0EN Zn+AjMlBdlblAy8hZsVARCRSTegjvzHWGFoNmtzsmr81hSYvU9QLadjmCyiUiEu9Jj Sb9TDuNvIWF+GkYxHGVxVdaEDV2ViaGasmo4Hs/TXZHLG6Bku9rnYUF2bf5mh8jnQ1 5rjCO0UFuvr9Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5246CCAC597; Thu, 18 Sep 2025 09:24:35 +0000 (UTC) From: Cryolitia PukNgae via B4 Relay Date: Thu, 18 Sep 2025 17:24:34 +0800 Subject: [PATCH v4 5/5] ALSA: doc: add docs about improved quirk_flags in snd-usb-audio 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 Message-Id: <20250918-sound-v4-5-82cf8123d61c@uniontech.com> References: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> In-Reply-To: <20250918-sound-v4-0-82cf8123d61c@uniontech.com> To: Jaroslav Kysela , Takashi Iwai , Jonathan Corbet , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Nie Cheng , Zhan Jun , Feng Yuan , qaqland , kernel@uniontech.com, linux-modules@vger.kernel.org, Cryolitia PukNgae X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758187473; l=6710; i=cryolitia@uniontech.com; s=20250730; h=from:subject:message-id; bh=q9YL4dfxFW+wi9X8O0Or99A8F8YKo075b5AcBcYqJxY=; b=uCg6M3hiY8Wd7YpIvXBnafcDsWT6B8dy07XMZfeLqvpIyqE/wG1BT3+czVunfGCP32HJ/3n5W 0qgvBmcU2+nDkrs3HY9g9h307cGRCly7B0lU2sHpq/snHw0sxHilKfo X-Developer-Key: i=cryolitia@uniontech.com; a=ed25519; pk=tZ+U+kQkT45GRGewbMSB4VPmvpD+KkHC/Wv3rMOn/PU= X-Endpoint-Received: by B4 Relay for cryolitia@uniontech.com/20250730 with auth_id=474 X-Original-From: Cryolitia PukNgae Reply-To: cryolitia@uniontech.com From: Cryolitia PukNgae Just briefly described about the option. Signed-off-by: Cryolitia PukNgae --- Documentation/sound/alsa-configuration.rst | 108 ++++++++++++++++++++-----= ---- 1 file changed, 75 insertions(+), 33 deletions(-) diff --git a/Documentation/sound/alsa-configuration.rst b/Documentation/sou= nd/alsa-configuration.rst index a2fb8ed251dd0294e7a62209ca15d5c32c6adfae..efffe3d534beeddcb6a47ac27a2= 4defb6879f534 100644 --- a/Documentation/sound/alsa-configuration.rst +++ b/Documentation/sound/alsa-configuration.rst @@ -2297,39 +2297,81 @@ skip_validation of the unit descriptor instead of a driver probe error, so that we can check its details. quirk_flags - Contains the bit flags for various device specific workarounds. - Applied to the corresponding card index. - - * bit 0: Skip reading sample rate for devices - * bit 1: Create Media Controller API entries - * bit 2: Allow alignment on audio sub-slot at transfer - * bit 3: Add length specifier to transfers - * bit 4: Start playback stream at first in implement feedback mode - * bit 5: Skip clock selector setup - * bit 6: Ignore errors from clock source search - * bit 7: Indicates ITF-USB DSD based DACs - * bit 8: Add a delay of 20ms at each control message handling - * bit 9: Add a delay of 1-2ms at each control message handling - * bit 10: Add a delay of 5-6ms at each control message handling - * bit 11: Add a delay of 50ms at each interface setup - * bit 12: Perform sample rate validations at probe - * bit 13: Disable runtime PM autosuspend - * bit 14: Ignore errors for mixer access - * bit 15: Support generic DSD raw U32_BE format - * bit 16: Set up the interface at first like UAC1 - * bit 17: Apply the generic implicit feedback sync mode - * bit 18: Don't apply implicit feedback sync mode - * bit 19: Don't closed interface during setting sample rate - * bit 20: Force an interface reset whenever stopping & restarting - a stream - * bit 21: Do not set PCM rate (frequency) when only one rate is - available for the given endpoint. - * bit 22: Set the fixed resolution 16 for Mic Capture Volume - * bit 23: Set the fixed resolution 384 for Mic Capture Volume - * bit 24: Set minimum volume control value as mute for devices - where the lowest playback value represents muted state instead - of minimum audible volume - * bit 25: Be similar to bit 24 but for capture streams + The option provides a refined and flexible control for applying quirk + flags. It allows to specify the quirk flags for each device, and could + be modified dynamically via sysfs. + The old usage accepts an array of integers, each of which apply quirk + flags on the device in the order of probing. + e.g. ``quirk_flags=3D0x01,0x02`` applies get_sample_rate to the first + device, and share_media_device to the second device. + The new usage accepts a string in the format of + ``VID1:PID1:FLAGS1;VID2:PID2:FLAGS2;...``, where ``VIDx`` and ``PIDx`` + specify the device, and ``FLAGSx`` specify the flags to be applied. + ``VIDx`` and ``PIDx`` are 4-digit hexadecimal numbers, and could be + specified as ``*`` to match any value. ``FLAGSx`` could be a set of + flags given by name, separated by ``|``, or a hexadecimal number + representing the bit flags. The available flag names are listed above. + An exclamation mark could be prefixed to a flag name to negate the fla= g. + For example, ``1234:abcd:mixer_playback_min_mute|!ignore_ctl_error;*:*= :0x01;`` + applies the ``mixer_playback_min_mute`` flag and clears the + ``ignore_ctl_error`` flag for the device 1234:abcd, and applies the + ``skip_sample_rate`` flag for all devices. + + * bit 0: ``get_sample_rate`` + Skip reading sample rate for devices + * bit 1: ``share_media_device`` + Create Media Controller API entries + * bit 2: ``align_transfer`` + Allow alignment on audio sub-slot at transfer + * bit 3: ``tx_length`` + Add length specifier to transfers + * bit 4: ``playback_first`` + Start playback stream at first in implement feedback mode + * bit 5: ``skip_clock_selector`` + Skip clock selector setup + * bit 6: ``ignore_clock_source`` + Ignore errors from clock source search + * bit 7: ``itf_usb_dsd_dac`` + Indicates ITF-USB DSD based DACs + * bit 8: ``ctl_msg_delay`` + Add a delay of 20ms at each control message handling + * bit 9: ``ctl_msg_delay_1m`` + Add a delay of 1-2ms at each control message handling + * bit 10: ``ctl_msg_delay_5m`` + Add a delay of 5-6ms at each control message handling + * bit 11: ``iface_delay`` + Add a delay of 50ms at each interface setup + * bit 12: ``validate_rates`` + Perform sample rate validations at probe + * bit 13: ``disable_autosuspend`` + Disable runtime PM autosuspend + * bit 14: ``ignore_ctl_error`` + Ignore errors for mixer access + * bit 15: ``dsd_raw`` + Support generic DSD raw U32_BE format + * bit 16: ``set_iface_first`` + Set up the interface at first like UAC1 + * bit 17: ``generic_implicit_fb`` + Apply the generic implicit feedback sync mode + * bit 18: ``skip_implicit_fb`` + Don't apply implicit feedback sync mode + * bit 19: ``iface_skip_close`` + Don't closed interface during setting sample rate + * bit 20: ``force_iface_reset`` + Force an interface reset whenever stopping & restarting a stream + * bit 21: ``fixed_rate`` + Do not set PCM rate (frequency) when only one rate is available + for the given endpoint + * bit 22: ``mic_res_16`` + Set the fixed resolution 16 for Mic Capture Volume + * bit 23: ``mic_res_384`` + Set the fixed resolution 384 for Mic Capture Volume + * bit 24: ``mixer_playback_min_mute`` + Set minimum volume control value as mute for devices where the + lowest playback value represents muted state instead of minimum + audible volume + * bit 25: ``mixer_capture_min_mute`` + Be similar to bit 24 but for capture streams =20 This module supports multiple devices, autoprobe and hotplugging. =20 --=20 2.51.0