[PATCH 1/2] ALSA: usb-audio: Define macros for quirk table entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Many entries in the USB-audio quirk tables have relatively complex
expressions.  For improving the readability, introduce a few macros.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
 sound/usb/quirks-table.h | 41 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index f13a8d63a019..4e920afb3d74 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -35,6 +35,47 @@
 	.bInterfaceClass = USB_CLASS_AUDIO, \
 	.bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
 
+/* Quirk .driver_info, followed by the definition of the quirk entry;
+ * use like QUIRK_DRIVER_INFO { ... } in each entry of the quirk table
+ */
+#define QUIRK_DRIVER_INFO \
+	.driver_info = (unsigned long)&(const struct snd_usb_audio_quirk)
+
+/* Quirk composite array terminator */
+#define QUIRK_COMPOSITE_END	{ .ifnum = -1 }
+
+/* Quirk data entry for composite quirks;
+ * followed by the quirk array that is terminated with QUIRK_COMPOSITE_END
+ * e.g. QUIRK_DATA_COMPOSITE { quirk1, quirk2, ..., QUIRK_COMPOSITE_END }
+ */
+#define QUIRK_DATA_COMPOSITE \
+	.type = QUIRK_COMPOSITE, \
+	.data = &(const struct snd_usb_audio_quirk[])
+
+/* Quirk data entry for a fixed audio endpoint;
+ * followed by audioformat definition
+ * e.g. QUIRK_DATA_AUDIOFORMAT { .formats = xxx, ... }
+ */
+#define QUIRK_DATA_AUDIOFORMAT \
+	.type = QUIRK_AUDIO_FIXED_ENDPOINT, \
+	.data = &(const struct audioformat)
+
+/* Quirk data entry for a fixed MIDI endpoint;
+ * followed by snd_usb_midi_endpoint_info definition
+ * e.g. QUIRK_DATA_MIDI_FIXED_ENDPOINT { .out_cables = x, .in_cables = y }
+ */
+#define QUIRK_DATA_MIDI_FIXED_ENDPOINT \
+	.type = QUIRK_MIDI_FIXED_ENDPOINT, \
+	.data = &(const struct snd_usb_midi_endpoint_info)
+/* Quirk data entry for a MIDIMAN MIDI endpoint */
+#define QUIRK_DATA_MIDI_MIDIMAN \
+	.type = QUIRK_MIDI_MIDIMAN, \
+	.data = &(const struct snd_usb_midi_endpoint_info)
+/* Quirk data entry for a EMAGIC MIDI endpoint */
+#define QUIRK_DATA_MIDI_EMAGIC \
+	.type = QUIRK_MIDI_EMAGIC, \
+	.data = &(const struct snd_usb_midi_endpoint_info)
+
 /* FTDI devices */
 {
 	USB_DEVICE(0x0403, 0xb8d8),
-- 
2.43.0


--Multipart_Tue_Aug_13_17:43:33_2024-1
Content-Type: application/octet-stream; type=patch; name="0002-ALSA-usb-audio-Replace-complex-quirk-lines-with-macr.patch"
Content-Disposition: attachment; filename="0002-ALSA-usb-audio-Replace-complex-quirk-lines-with-macr.patch"
Content-Transfer-Encoding: 7bit


[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux