public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Phil Willoughby <willerz@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Phil Willoughby <willerz@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Subject: [PATCH] ALSA: usb-audio: tidy up the AF16Rig quirks
Date: Sat, 28 Mar 2026 16:02:58 +0000	[thread overview]
Message-ID: <20260328160326.23665-1-willerz@gmail.com> (raw)

Use macros to make the AF16Rig quirk table smaller.

Add a disabled block containing the theoretical quirks for the other
clock sources that the AF16Rig has. It's disabled because I cannot test
it.

Tested-By: Phil Willoughby <willerz@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Phil Willoughby <willerz@gmail.com>
---
 sound/usb/quirks-table.h | 200 ++++++++++-----------------------------
 1 file changed, 50 insertions(+), 150 deletions(-)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 8f79a15055a6..b6dfe3b63c67 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3900,6 +3900,44 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 QUIRK_RME_DIGIFACE(0x3f8c),
 QUIRK_RME_DIGIFACE(0x3fa0),
 
+#define QUIRK_AF16RIG(channel_count_, alt_setting_,			\
+	              low_rate_, high_rate_, pack_size_,		\
+		      clock_, interface_, endpoint_)			\
+	{ 								\
+		QUIRK_DATA_AUDIOFORMAT(interface_) {			\
+			.formats = SNDRV_PCM_FMTBIT_S32_LE,   		\
+			.channels = channel_count_,			\
+			.fmt_type = UAC_FORMAT_TYPE_I_PCM,		\
+			.fmt_bits = 24,					\
+			.fmt_sz = 4,					\
+			.iface = interface_,				\
+			.altsetting = alt_setting_,			\
+			.altset_idx = alt_setting_,			\
+			.endpoint = endpoint_,				\
+			.ep_attr = USB_ENDPOINT_XFER_ISOC |		\
+					USB_ENDPOINT_SYNC_ASYNC,	\
+			.datainterval = 1,				\
+			.protocol = UAC_VERSION_2,			\
+			.maxpacksize = pack_size_,			\
+			.rates = SNDRV_PCM_RATE_##low_rate_ |		\
+					SNDRV_PCM_RATE_##high_rate_,	\
+			.rate_min = low_rate_,				\
+			.rate_max = high_rate_,				\
+			.nr_rates = 2,					\
+			.rate_table = (unsigned int[]) {		\
+					low_rate_, high_rate_ },	\
+			.clock = clock_,				\
+		}							\
+	}
+
+#define QUIRK_AF16RIG_CLOCK(clock)					\
+	QUIRK_AF16RIG(34, 1,  44100,  48000, 0x3b8, clock, 1, 0x01),	\
+	QUIRK_AF16RIG(34, 1,  44100,  48000, 0x3b8, clock, 2, 0x81),	\
+	QUIRK_AF16RIG(18, 2,  88200,  96000, 0x3a8, clock, 1, 0x01),	\
+	QUIRK_AF16RIG(18, 2,  88200,  96000, 0x3a8, clock, 2, 0x81),	\
+	QUIRK_AF16RIG(10, 3, 176400, 192000, 0x3e8, clock, 1, 0x01),	\
+	QUIRK_AF16RIG(10, 3, 176400, 192000, 0x3e8, clock, 2, 0x81)
+
 /* Arturia AudioFuse 16Rig Audio */
 /* AF16Rig MIDI has USB PID 0xaf21 and appears to work OK without quirks */
 {
@@ -3909,161 +3947,23 @@ QUIRK_RME_DIGIFACE(0x3fa0),
 		.product_name = "AF16Rig",
 		QUIRK_DATA_COMPOSITE {
 			{ QUIRK_DATA_STANDARD_MIXER(0) },
-			{
-				QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 34,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 1,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.endpoint = 0x01,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03b8,
-					.rates = SNDRV_PCM_RATE_44100|
-						 SNDRV_PCM_RATE_48000,
-					.rate_min = 44100,
-					.rate_max = 48000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 44100, 48000 },
-					.clock = 41,
-				}
-			},
-			{
-				QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 18,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 1,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.endpoint = 0x01,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03a8,
-					.rates = SNDRV_PCM_RATE_88200|
-						 SNDRV_PCM_RATE_96000,
-					.rate_min = 88200,
-					.rate_max = 96000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 88200, 96000 },
-					.clock = 41,
-				}
-			},
-			{
-				QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 10,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 1,
-					.altsetting = 3,
-					.altset_idx = 3,
-					.endpoint = 0x01,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03e8,
-					.rates = SNDRV_PCM_RATE_176400|
-						 SNDRV_PCM_RATE_192000,
-					.rate_min = 176400,
-					.rate_max = 192000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 176400, 192000 },
-					.clock = 41,
-				}
-			},
-			{
-				QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 34,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 2,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.endpoint = 0x81,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03b8,
-					.rates = SNDRV_PCM_RATE_44100|
-						 SNDRV_PCM_RATE_48000,
-					.rate_min = 44100,
-					.rate_max = 48000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 44100, 48000 },
-					.clock = 41,
-				}
-			},
-			{
-				QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 18,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 2,
-					.altsetting = 2,
-					.altset_idx = 2,
-					.endpoint = 0x81,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03a8,
-					.rates = SNDRV_PCM_RATE_88200|
-						 SNDRV_PCM_RATE_96000,
-					.rate_min = 88200,
-					.rate_max = 96000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 88200, 96000 },
-					.clock = 41,
-				}
-			},
-			{
-				QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 10,
-					.fmt_type = UAC_FORMAT_TYPE_I_PCM,
-					.fmt_bits = 24,
-					.fmt_sz = 4,
-					.iface = 2,
-					.altsetting = 3,
-					.altset_idx = 3,
-					.endpoint = 0x81,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC|
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.datainterval = 1,
-					.protocol = UAC_VERSION_2,
-					.maxpacksize = 0x03e8,
-					.rates = SNDRV_PCM_RATE_176400|
-						 SNDRV_PCM_RATE_192000,
-					.rate_min = 176400,
-					.rate_max = 192000,
-					.nr_rates = 2,
-					.rate_table = (unsigned int[]) { 176400, 192000 },
-					.clock = 41,
-				}
-			},
+			QUIRK_AF16RIG_CLOCK(41), /* Internal clock */
+#if 0
+/* These are disabled because I don't have the required hardware to test
+ * them. I suspect that the ADAT clock might not follow 176400 or 192000
+ * because the AF16Rig won't accept ADAT audio data at those rates.
+ */
+			QUIRK_AF16RIG_CLOCK(43), /* ADAT clock */
+			QUIRK_AF16RIG_CLOCK(44), /* BNC word clock */
+#endif
 			{ QUIRK_DATA_IGNORE(3) }, /* Firmware update */
 			QUIRK_COMPOSITE_END
 		}
 	}
 },
 
+#undef QUIRK_AF16RIG_CLOCK
+#undef QUIRK_AF16RIG
+
 #undef USB_DEVICE_VENDOR_SPEC
 #undef USB_AUDIO_DEVICE
-- 
2.53.0


             reply	other threads:[~2026-03-28 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-28 16:02 Phil Willoughby [this message]
2026-03-29  9:06 ` [PATCH] ALSA: usb-audio: tidy up the AF16Rig quirks Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260328160326.23665-1-willerz@gmail.com \
    --to=willerz@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox