[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87qzw28v83.wl-tiwai@suse.de>
Date: Fri, 19 Sep 2025 14:47:40 +0200
From: Takashi Iwai <tiwai@...e.de>
To: cryolitia@...ontech.com
Cc: Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Jonathan Corbet <corbet@....net>,
Luis Chamberlain <mcgrof@...nel.org>,
Petr Pavlu <petr.pavlu@...e.com>,
Daniel Gomez <da.gomez@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
linux-sound@...r.kernel.org,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
Mingcong Bai <jeffbai@...c.io>,
Kexy Biscuit <kexybiscuit@...c.io>,
Nie Cheng <niecheng1@...ontech.com>,
Zhan Jun <zhanjun@...ontech.com>,
Feng Yuan <fengyuan@...ontech.com>,
qaqland <anguoli@...ontech.com>,
kernel@...ontech.com,
linux-modules@...r.kernel.org,
Takashi Iwai <tiwai@...e.de>
Subject: Re: [PATCH v4 3/5] ALSA: usb-audio: improve module param quirk_flags
On Thu, 18 Sep 2025 11:24:32 +0200,
Cryolitia PukNgae via B4 Relay wrote:
>
> From: Cryolitia PukNgae <cryolitia@...ontech.com>
>
> For apply and unapply quirk flags more flexibly though param
>
> Co-developed-by: Takashi Iwai <tiwai@...e.de>
> Signed-off-by: Cryolitia PukNgae <cryolitia@...ontech.com>
> ---
> 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..5837677effa1787ef9d7d02714c3ae43b1a8bc79 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -73,8 +73,8 @@ static bool lowlatency = 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];
>
> +char *quirk_flags[SNDRV_CARDS];
My preference is to keep this static, but pass the string value to a
function. That is, define snd_usb_init_quirk_flags() in main.c:
static void snd_usb_init_quirk_flags(struct snd_usb_audio *chip, int indx)
{
/* 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 = 0; i < ARRAY_SIZE(quirk_flags); i++) {
char *val __free(kfree) = NULL;
if (!quirk_flags[i] || !*quirk_flags[i])
continue;
val = kstrdup(quirk_flags[i], GFP_KERNEL);
if (!val)
return;
snd_usb_parse_quirk_string(chip, val);
}
}
static int snd_usb_audio_create(....)
{
....
snd_usb_init_quirk_flags(chip, idx);
....
}
The function snd_usb_parse_quirk_string() is defined in quirks.c,
void snd_usb_parse_quirk_string(struct snd_usb_audio *chip, char *val)
{
for (p = val; p && *p;) {
/* Each entry consists of VID:PID:flags */
field = strsep(&p, ":");
if (!field)
break;
.....
}
}
thanks,
Takashi
Powered by blists - more mailing lists