[PATCH 10/15] ALSA: usb-audio: Move rate validation quirk into quirk_flags

Takashi Iwai tiwai at suse.de
Thu Jul 29 09:43:59 CEST 2021


The rate validation at the device probe is applied only to the
specific devices (currently only for MOTU devices), and this check can
be moved to quirk_flags gracefully, too.

Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
 sound/usb/format.c   | 6 +-----
 sound/usb/quirks.c   | 2 ++
 sound/usb/usbaudio.h | 3 +++
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sound/usb/format.c b/sound/usb/format.c
index eb216fef4ba7..50efccbffb8a 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -472,12 +472,8 @@ static int validate_sample_rate_table_v2v3(struct snd_usb_audio *chip,
 	 * behavior afterwards by some unknown reason.  Do this only for the
 	 * known devices.
 	 */
-	switch (USB_ID_VENDOR(chip->usb_id)) {
-	case 0x07fd: /* MOTU */
-		break;
-	default:
+	if (!(chip->quirk_flags & QUIRK_FLAG_VALIDATE_RATES))
 		return 0; /* don't perform the validation as default */
-	}
 
 	table = kcalloc(fp->nr_rates, sizeof(*table), GFP_KERNEL);
 	if (!table)
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index f47078209bcc..dc667b8c92f2 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1907,6 +1907,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY),
 	VENDOR_FLG(0x0644, /* TEAC Corp. */
 		   QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY),
+	VENDOR_FLG(0x07fd, /* MOTU */
+		   QUIRK_FLAG_VALIDATE_RATES),
 	VENDOR_FLG(0x1de7, /* Phoenix Audio */
 		   QUIRK_FLAG_GET_SAMPLE_RATE),
 	VENDOR_FLG(0x23ba, /* Playback Design */
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 57b5dcf211d4..ea0e3deb2a23 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -155,6 +155,8 @@ extern bool snd_usb_skip_validation;
  *  Add a delay of 5-6ms at each control message handling
  * QUIRK_FLAG_IFACE_DELAY:
  *  Add a delay of 50ms at each interface setup
+ * QUIRK_FLAG_VALIDATE_RATES:
+ *  Perform sample rate validations at probe
  */
 
 #define QUIRK_FLAG_GET_SAMPLE_RATE	(1U << 0)
@@ -169,5 +171,6 @@ extern bool snd_usb_skip_validation;
 #define QUIRK_FLAG_CTL_MSG_DELAY_1M	(1U << 9)
 #define QUIRK_FLAG_CTL_MSG_DELAY_5M	(1U << 10)
 #define QUIRK_FLAG_IFACE_DELAY		(1U << 11)
+#define QUIRK_FLAG_VALIDATE_RATES	(1U << 12)
 
 #endif /* __USBAUDIO_H */
-- 
2.26.2



More information about the Alsa-devel mailing list