Skip to contentSkip to conversation

ALSA: usb-audio: missing doc and quirk extensions

PATCH New Takashi Iwai 1 participant 4 messages Jul 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ALSA: usb-audio: missing doc and quirk extensions

Since the recent fix for USB-audio introduced the quirk bit 31, we need to extend the bitmap to 64bit for the future use. Also, the last fix forgot the update of the documentation, and it's updated in this series, too.

Takashi

===

Takashi Iwai (3):
ALSA: docs: Add description of usb-audio playback_urb_fixup quirk
ALSA: usb-audio: Extend quirk_flags to 64bit
ALSA: usb-audio: Make some quirk-string helpers local

 Documentation/sound/alsa-configuration.rst |  5 +++++
 sound/usb/card.c                           |  2 +-
 sound/usb/quirks.c                         | 18 +++++-------------
 sound/usb/quirks.h                         |  3 ---
 sound/usb/usbaudio.h                       |  4 ++--
 5 files changed, 13 insertions(+), 19 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/3 ALSA: docs: Add description of usb-audio playback_urb_fixup quirk

We missed the description for the recently introduced quirk bit QUIRK_FLAG_PLAYBACK_URB_FIXUP. A brief explanation is added here.

---
 Documentation/sound/alsa-configuration.rst | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/sound/alsa-configuration.rst +5 -0
index c4aef14a3147..b2171472e6cb 100644
@@ -2401,6 +2401,11 @@ quirk_flags
           disabling GET_CUR instead of the whole mixer. The current volume will
           then be provided by the internal cache that stores the last set
           volume
+        * bit 31: ``playback_urb_fixup``
+          Some devices show the stuttering at playback, and this quirk
+          works around it by enforcing the fixed max URBs (12) instead of
+          the dynamic calculation from the buffer size, and passing the
+          `URB_ISO_ASAP` URB flag.
 
 This module supports multiple devices, autoprobe and hotplugging.
 
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/3 ALSA: usb-audio: Extend quirk_flags to 64bit

In reply to Takashi Iwai

Now we reached the limit of 32bit bitmap for quirk flags. In order to be future-ready, simply extend the flag bitmap to 64bit.

---
 sound/usb/card.c     |  2 +-
 sound/usb/quirks.c   | 10 +++++-----
 sound/usb/quirks.h   |  2 +-
 sound/usb/usbaudio.h |  4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/card.c +1 -1
index b36f513dccb9..24112e491779 100644
@@ -715,7 +715,7 @@ static void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip)
 
 	/* old style option found: the position-based integer value */
 	if (quirk_flags[idx] &&
-	    !kstrtou32(quirk_flags[idx], 0, &chip->quirk_flags)) {
+	    !kstrtou64(quirk_flags[idx], 0, &chip->quirk_flags)) {
 		snd_usb_apply_flag_dbg("module param", chip, chip->quirk_flags);
 		return;
 	}
sound/usb/quirks.c +5 -5
index 52dbbdb7f9a1..77adefe4f9cb 100644
@@ -2145,7 +2145,7 @@ struct usb_string_match {
 
 struct usb_audio_quirk_flags_table {
 	u32 id;
-	u32 flags;
+	u64 flags;
 	const struct usb_string_match *usb_string_match;
 };
 
@@ -2638,7 +2638,7 @@ const char *snd_usb_quirk_flag_find_name(unsigned long index)
 	return snd_usb_audio_quirk_flag_names[index];
 }
 
-u32 snd_usb_quirk_flags_from_name(const char *name)
+u64 snd_usb_quirk_flags_from_name(const char *name)
 {
 	int i;
 
@@ -2647,7 +2647,7 @@ u32 snd_usb_quirk_flags_from_name(const char *name)
 
 	for (i = 0; snd_usb_audio_quirk_flag_names[i]; i++) {
 		if (strcasecmp(name, snd_usb_audio_quirk_flag_names[i]) == 0)
-			return BIT_U32(i);
+			return BIT_U64(i);
 	}
 
 	return 0;
@@ -2705,7 +2705,7 @@ void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip,
 {
 	u16 chip_vid = USB_ID_VENDOR(chip->usb_id);
 	u16 chip_pid = USB_ID_PRODUCT(chip->usb_id);
-	u32 mask_flags, unmask_flags, bit;
+	u64 mask_flags, unmask_flags, bit;
 	char *p, *field, *flag;
 	bool is_unmask;
 	u16 vid, pid;
@@ -2759,7 +2759,7 @@ void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip,
 				is_unmask = false;
 			}
 
-			if (!kstrtou32(flag, 16, &bit)) {
+			if (!kstrtou64(flag, 16, &bit)) {
 				if (is_unmask)
 					unmask_flags |= bit;
 				else
sound/usb/quirks.h +1 -1
index f24d6a5a197a..54f4cca8d7af 100644
@@ -57,6 +57,6 @@ void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip,
 					   const char *str);
 
 const char *snd_usb_quirk_flag_find_name(unsigned long flag);
-u32 snd_usb_quirk_flags_from_name(const char *name);
+u64 snd_usb_quirk_flags_from_name(const char *name);
 
 #endif /* __USBAUDIO_QUIRKS_H */
sound/usb/usbaudio.h +2 -2
index dc1d0c8c9c80..31e612500050 100644
@@ -44,7 +44,7 @@ struct snd_usb_audio {
 	atomic_t active;
 	atomic_t shutdown;
 	struct snd_refcount usage_count;
-	unsigned int quirk_flags;
+	u64 quirk_flags;
 	unsigned int need_delayed_register:1; /* warn for delayed registration */
 	int num_interfaces;
 	int last_iface;
@@ -298,7 +298,7 @@ enum {
 /* Please also edit snd_usb_audio_quirk_flag_names */
 };
 
-#define QUIRK_FLAG(x)	BIT_U32(QUIRK_TYPE_ ## x)
+#define QUIRK_FLAG(x)	BIT_U64(QUIRK_TYPE_ ## x)
 
 #define QUIRK_FLAG_GET_SAMPLE_RATE		QUIRK_FLAG(GET_SAMPLE_RATE)
 #define QUIRK_FLAG_SHARE_MEDIA_DEVICE		QUIRK_FLAG(SHARE_MEDIA_DEVICE)
Signature · 1 line
2.55.0
#3 lore raw

PATCH 3/3 ALSA: usb-audio: Make some quirk-string helpers local

In reply to Takashi Iwai

As snd_usb_quirk_flags_from_name() is used only locally, make it local. Also, drop the unused snd_usb_quirk_flag_find_name(), too.

Only a code cleanup, no functional changes.

---
 sound/usb/quirks.c | 10 +---------
 sound/usb/quirks.h |  3 ---
 2 files changed, 1 insertion(+), 12 deletions(-)
sound/usb/quirks.c +1 -9
index 77adefe4f9cb..3c1343da45b4 100644
@@ -2630,15 +2630,7 @@ static const char *const snd_usb_audio_quirk_flag_names[] = {
 	NULL
 };
 
-const char *snd_usb_quirk_flag_find_name(unsigned long index)
-{
-	if (index >= ARRAY_SIZE(snd_usb_audio_quirk_flag_names))
-		return NULL;
-
-	return snd_usb_audio_quirk_flag_names[index];
-}
-
-u64 snd_usb_quirk_flags_from_name(const char *name)
+static u64 snd_usb_quirk_flags_from_name(const char *name)
 {
 	int i;
 
sound/usb/quirks.h +0 -3
index 54f4cca8d7af..0a723c266bb4 100644
@@ -56,7 +56,4 @@ void snd_usb_init_quirk_flags_table(struct snd_usb_audio *chip);
 void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip,
 					   const char *str);
 
-const char *snd_usb_quirk_flag_find_name(unsigned long flag);
-u64 snd_usb_quirk_flags_from_name(const char *name);
-
 #endif /* __USBAUDIO_QUIRKS_H */
Signature · 1 line
2.55.0