Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz
Cc: amadeuszx.slawinski@linux.intel.com, linux-sound@vger.kernel.org,
	gregkh@linuxfoundation.org, quic_wcheng@quicinc.com,
	mathias.nyman@linux.intel.com,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [RFC 03/15] ALSA: usb: Relocate the usbaudio header file
Date: Wed,  9 Apr 2025 13:07:18 +0200	[thread overview]
Message-ID: <20250409110731.3752332-4-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20250409110731.3752332-1-cezary.rojewski@intel.com>

For ALSA and ASoC to share the symbols, common header shall be defined.
Existing usbaudio.h holds most of important stuff, with few adjustments
it can be simply relocated to include/ to satisfy needs of both
frameworks. The adjstments are:

- rename quirk_type enumeration to snd_usb_quirk_type to avoid naming
  conflits
- add quirk pointer so that quirks applied for a USB device can later be
  referred to

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/usb/usbaudio.h => include/sound/usb.h | 24 +++++++++++----------
 sound/usb/caiaq/device.h                    |  2 +-
 sound/usb/card.c                            |  2 +-
 sound/usb/clock.c                           |  2 +-
 sound/usb/endpoint.c                        |  2 +-
 sound/usb/format.c                          |  2 +-
 sound/usb/helper.c                          |  2 +-
 sound/usb/implicit.c                        |  2 +-
 sound/usb/media.c                           |  2 +-
 sound/usb/midi.c                            |  2 +-
 sound/usb/midi.h                            |  2 ++
 sound/usb/midi2.c                           |  2 +-
 sound/usb/midi2.h                           |  1 +
 sound/usb/misc/ua101.c                      |  2 +-
 sound/usb/mixer.c                           |  2 +-
 sound/usb/mixer_quirks.c                    |  2 +-
 sound/usb/mixer_s1810c.c                    |  2 +-
 sound/usb/mixer_scarlett.c                  |  2 +-
 sound/usb/mixer_scarlett2.c                 |  2 +-
 sound/usb/mixer_us16x08.c                   |  2 +-
 sound/usb/pcm.c                             |  2 +-
 sound/usb/power.c                           |  2 +-
 sound/usb/proc.c                            |  2 +-
 sound/usb/quirks.c                          |  2 +-
 sound/usb/quirks.h                          |  2 ++
 sound/usb/stream.c                          |  2 +-
 sound/usb/usx2y/us122l.c                    |  2 +-
 sound/usb/usx2y/usX2Yhwdep.c                |  1 +
 sound/usb/usx2y/usbusx2y.h                  |  2 +-
 sound/usb/validate.c                        |  2 +-
 30 files changed, 44 insertions(+), 36 deletions(-)
 rename sound/usb/usbaudio.h => include/sound/usb.h (98%)

diff --git a/sound/usb/usbaudio.h b/include/sound/usb.h
similarity index 98%
rename from sound/usb/usbaudio.h
rename to include/sound/usb.h
index 158ec053dc44..7e7a86b5c9c4 100644
--- a/sound/usb/usbaudio.h
+++ b/include/sound/usb.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef __USBAUDIO_H
-#define __USBAUDIO_H
+#ifndef __SOUND_USB_H
+#define __SOUND_USB_H
+
 /*
  *   (Tentative) USB Audio Driver for ALSA
  *
@@ -21,6 +22,14 @@ struct media_intf_devnode;
 
 #define MAX_CARD_INTERFACES	16
 
+struct snd_usb_audio_quirk {
+	const char *vendor_name;
+	const char *product_name;
+	int16_t ifnum;
+	uint16_t type;
+	const void *data;
+};
+
 /*
  * Structure holding assosiation between Audio Control Interface
  * and given Streaming or Midi Interface.
@@ -37,6 +46,7 @@ struct snd_usb_audio {
 	struct usb_interface *intf[MAX_CARD_INTERFACES];
 	u32 usb_id;
 	uint16_t quirk_type;
+	const struct snd_usb_audio_quirk *quirk;
 	struct mutex mutex;
 	unsigned int system_suspend;
 	atomic_t active;
@@ -99,7 +109,7 @@ struct snd_usb_audio {
 #define QUIRK_NO_INTERFACE		-2
 #define QUIRK_ANY_INTERFACE		-1
 
-enum quirk_type {
+enum snd_usb_quirk_type {
 	QUIRK_IGNORE_INTERFACE,
 	QUIRK_COMPOSITE,
 	QUIRK_AUTODETECT,
@@ -124,14 +134,6 @@ enum quirk_type {
 	QUIRK_TYPE_COUNT
 };
 
-struct snd_usb_audio_quirk {
-	const char *vendor_name;
-	const char *product_name;
-	int16_t ifnum;
-	uint16_t type;
-	const void *data;
-};
-
 #define combine_word(s)    ((*(s)) | ((unsigned int)(s)[1] << 8))
 #define combine_triple(s)  (combine_word(s) | ((unsigned int)(s)[2] << 16))
 #define combine_quad(s)    (combine_triple(s) | ((unsigned int)(s)[3] << 24))
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h
index 743eb0387b5f..2346dc8209c9 100644
--- a/sound/usb/caiaq/device.h
+++ b/sound/usb/caiaq/device.h
@@ -2,7 +2,7 @@
 #ifndef CAIAQ_DEVICE_H
 #define CAIAQ_DEVICE_H
 
-#include "../usbaudio.h"
+#include <sound/usb.h>
 
 #define USB_VID_NATIVEINSTRUMENTS 0x17cc
 
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 65de8e7854b6..d8794adb7a88 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -40,8 +40,8 @@
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/initval.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "midi.h"
 #include "midi2.h"
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 842ba5b801ea..fa5bc7b8c79c 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -14,8 +14,8 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/pcm.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "helper.h"
 #include "clock.h"
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a29f28eb7d0c..bdd2b75ebfed 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -12,8 +12,8 @@
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "helper.h"
 #include "card.h"
 #include "endpoint.h"
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 6049d957694c..1fa1711980ad 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -11,8 +11,8 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "quirks.h"
 #include "helper.h"
diff --git a/sound/usb/helper.c b/sound/usb/helper.c
index 72b671fb2c84..2e4da52f8d8e 100644
--- a/sound/usb/helper.c
+++ b/sound/usb/helper.c
@@ -5,8 +5,8 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/usb.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "helper.h"
 #include "quirks.h"
 
diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c
index 4727043fd745..fd0b23e7d92e 100644
--- a/sound/usb/implicit.c
+++ b/sound/usb/implicit.c
@@ -11,8 +11,8 @@
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "helper.h"
 #include "pcm.h"
diff --git a/sound/usb/media.c b/sound/usb/media.c
index b175fa820345..7060410fd1c6 100644
--- a/sound/usb/media.c
+++ b/sound/usb/media.c
@@ -24,8 +24,8 @@
 
 #include <sound/pcm.h>
 #include <sound/core.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "mixer.h"
 #include "media.h"
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 767f1948cc5a..53d327ee8014 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -54,7 +54,7 @@
 #include <sound/control.h>
 #include <sound/rawmidi.h>
 #include <sound/asequencer.h>
-#include "usbaudio.h"
+#include <sound/usb.h>
 #include "midi.h"
 #include "power.h"
 #include "helper.h"
diff --git a/sound/usb/midi.h b/sound/usb/midi.h
index 2100f1486b03..bf3561652ba8 100644
--- a/sound/usb/midi.h
+++ b/sound/usb/midi.h
@@ -2,6 +2,8 @@
 #ifndef __USBMIDI_H
 #define __USBMIDI_H
 
+#include <sound/usb.h>
+
 /* maximum number of endpoints per interface */
 #define MIDI_MAX_ENDPOINTS 2
 
diff --git a/sound/usb/midi2.c b/sound/usb/midi2.c
index 692dfc3c182f..f1d925b74692 100644
--- a/sound/usb/midi2.c
+++ b/sound/usb/midi2.c
@@ -18,7 +18,7 @@
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/ump.h>
-#include "usbaudio.h"
+#include <sound/usb.h>
 #include "midi.h"
 #include "midi2.h"
 #include "helper.h"
diff --git a/sound/usb/midi2.h b/sound/usb/midi2.h
index 94a65fcbd58b..3e66531d5e80 100644
--- a/sound/usb/midi2.h
+++ b/sound/usb/midi2.h
@@ -2,6 +2,7 @@
 #ifndef __USB_AUDIO_MIDI2_H
 #define __USB_AUDIO_MIDI2_H
 
+#include <sound/usb.h>
 #include "midi.h"
 
 #if IS_ENABLED(CONFIG_SND_USB_AUDIO_MIDI_V2)
diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
index 4f6b20ed29dd..454587cdcad7 100644
--- a/sound/usb/misc/ua101.c
+++ b/sound/usb/misc/ua101.c
@@ -13,7 +13,7 @@
 #include <sound/initval.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
-#include "../usbaudio.h"
+#include <sound/usb.h>
 #include "../midi.h"
 
 MODULE_DESCRIPTION("Edirol UA-101/1000 driver");
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index e2e0ddf1957d..f95da9368921 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -43,8 +43,8 @@
 #include <sound/hwdep.h>
 #include <sound/info.h>
 #include <sound/tlv.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "helper.h"
 #include "mixer_quirks.h"
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 23fcd680167d..54d16e0f8ac4 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -29,8 +29,8 @@
 #include <sound/hwdep.h>
 #include <sound/info.h>
 #include <sound/tlv.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "mixer_quirks.h"
 #include "mixer_scarlett.h"
diff --git a/sound/usb/mixer_s1810c.c b/sound/usb/mixer_s1810c.c
index fac4bbc6b275..d95edb1dc4d0 100644
--- a/sound/usb/mixer_s1810c.c
+++ b/sound/usb/mixer_s1810c.c
@@ -18,8 +18,8 @@
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/control.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "mixer_quirks.h"
 #include "helper.h"
diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c
index ff548041679b..f31718caa679 100644
--- a/sound/usb/mixer_scarlett.c
+++ b/sound/usb/mixer_scarlett.c
@@ -124,8 +124,8 @@
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/tlv.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "helper.h"
 #include "power.h"
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index 7f595c1752a5..a3866e9dd1ac 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -158,10 +158,10 @@
 #include <sound/control.h>
 #include <sound/tlv.h>
 #include <sound/hwdep.h>
+#include <sound/usb.h>
 
 #include <uapi/sound/scarlett2.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "helper.h"
 
diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c
index 20ac32635f1f..bdceb3b38689 100644
--- a/sound/usb/mixer_us16x08.c
+++ b/sound/usb/mixer_us16x08.c
@@ -11,8 +11,8 @@
 
 #include <sound/core.h>
 #include <sound/control.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "mixer.h"
 #include "helper.h"
 
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 08bf535ed163..ea698f061af9 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -13,8 +13,8 @@
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "quirks.h"
 #include "endpoint.h"
diff --git a/sound/usb/power.c b/sound/usb/power.c
index 66bd4daa68fd..ad847aadb4fb 100644
--- a/sound/usb/power.c
+++ b/sound/usb/power.c
@@ -8,8 +8,8 @@
 #include <linux/usb/audio.h>
 #include <linux/usb/audio-v2.h>
 #include <linux/usb/audio-v3.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "helper.h"
 #include "power.h"
 
diff --git a/sound/usb/proc.c b/sound/usb/proc.c
index e9bbaea7b2fa..b7e898722ff4 100644
--- a/sound/usb/proc.c
+++ b/sound/usb/proc.c
@@ -8,8 +8,8 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/pcm.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "helper.h"
 #include "card.h"
 #include "endpoint.h"
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 8ba0aff8be2e..2a9470ef8b5f 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -13,8 +13,8 @@
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/pcm.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "mixer.h"
 #include "mixer_quirks.h"
diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h
index f9bfd5ac7bab..0ea079688261 100644
--- a/sound/usb/quirks.h
+++ b/sound/usb/quirks.h
@@ -2,6 +2,8 @@
 #ifndef __USBAUDIO_QUIRKS_H
 #define __USBAUDIO_QUIRKS_H
 
+#include <sound/usb.h>
+
 struct audioformat;
 struct snd_usb_endpoint;
 struct snd_usb_substream;
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 4d83c95bd9a8..6beeff03d711 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -14,8 +14,8 @@
 #include <sound/pcm.h>
 #include <sound/control.h>
 #include <sound/tlv.h>
+#include <sound/usb.h>
 
-#include "usbaudio.h"
 #include "card.h"
 #include "proc.h"
 #include "quirks.h"
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 6bcf8b859ebb..3d00541a602c 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -11,9 +11,9 @@
 #include <sound/hwdep.h>
 #include <sound/pcm.h>
 #include <sound/initval.h>
+#include <sound/usb.h>
 #define MODNAME "US122L"
 #include "usb_stream.c"
-#include "../usbaudio.h"
 #include "../midi.h"
 #include "us122l.h"
 
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 9fd6a86cc08e..2d6a9c80e5bf 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -14,6 +14,7 @@
 #include <sound/memalloc.h>
 #include <sound/pcm.h>
 #include <sound/hwdep.h>
+#include <sound/usb.h>
 #include "usx2y.h"
 #include "usbusx2y.h"
 #include "usX2Yhwdep.h"
diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h
index 391fd7b4ed5e..689b565fb225 100644
--- a/sound/usb/usx2y/usbusx2y.h
+++ b/sound/usb/usx2y/usbusx2y.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef USBUSX2Y_H
 #define USBUSX2Y_H
-#include "../usbaudio.h"
+#include <sound/usb.h>
 #include "../midi.h"
 #include "usbus428ctldefs.h"
 
diff --git a/sound/usb/validate.c b/sound/usb/validate.c
index 6fe206f6e911..8a7e8fc8197e 100644
--- a/sound/usb/validate.c
+++ b/sound/usb/validate.c
@@ -9,7 +9,7 @@
 #include <linux/usb/audio-v2.h>
 #include <linux/usb/audio-v3.h>
 #include <linux/usb/midi.h>
-#include "usbaudio.h"
+#include <sound/usb.h>
 #include "helper.h"
 
 struct usb_desc_validator {
-- 
2.25.1


  parent reply	other threads:[~2025-04-09 10:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 11:07 [RFC 00/15] ALSA/ASoC: USB Audio Offload Cezary Rojewski
2025-04-09 11:07 ` [RFC 01/15] ALSA: usb: Move media-filters to the media code Cezary Rojewski
2025-04-09 11:07 ` [RFC 02/15] ALSA: usb: Drop private_free() usage for card and pcms Cezary Rojewski
2025-04-09 11:07 ` Cezary Rojewski [this message]
2025-04-09 11:07 ` [RFC 04/15] ALSA: usb: Implement two-stage quirk applying mechanism Cezary Rojewski
2025-04-09 11:07 ` [RFC 05/15] ALSA: usb: Implement two-stage stream creation mechanism Cezary Rojewski
2025-04-09 11:07 ` [RFC 06/15] ALSA: usb: Implement two-stage chip probing mechanism Cezary Rojewski
2025-04-09 11:07 ` [RFC 07/15] ALSA: usb: Switch to the two-stage chip probing Cezary Rojewski
2025-04-09 11:07 ` [RFC 08/15] ALSA: usb: Switch to the two-stage stream creation Cezary Rojewski
2025-04-09 11:07 ` [RFC 09/15] ALSA: usb: Switch to the two-stage quirk applying Cezary Rojewski
2025-04-09 11:07 ` [RFC 10/15] ALSA: usb: Export PCM operations Cezary Rojewski
2025-04-09 11:07 ` [RFC 11/15] ALSA: usb: Export usb_interface driver operations Cezary Rojewski
2025-04-09 11:07 ` [RFC 12/15] ALSA: usb: Export card-naming procedure Cezary Rojewski
2025-04-09 11:07 ` [RFC 13/15] ALSA: usb: Add getters to obtain endpoint information Cezary Rojewski
2025-04-09 11:07 ` [RFC 14/15] ASoC: codecs: Add USB-Audio driver Cezary Rojewski
2025-04-09 11:07 ` [RFC 15/15] ASoC: Intel: avs: Add USB machine board Cezary Rojewski
2025-04-09 12:10 ` [RFC 00/15] ALSA/ASoC: USB Audio Offload Greg KH
2025-04-09 13:06   ` Cezary Rojewski
2025-04-10 10:10     ` Takashi Iwai
2025-04-10 10:24 ` Takashi Iwai
2025-04-11  9:39   ` Cezary Rojewski
2025-04-15 16:15     ` Takashi Iwai
2025-04-17 10:15       ` Cezary Rojewski
2025-04-22 11:28         ` Pierre-Louis Bossart
2025-04-22 14:15           ` Cezary Rojewski
2025-04-25 16:53             ` Pierre-Louis Bossart
2025-04-11 14:04 ` Greg KH
2025-04-11 16:51   ` Cezary Rojewski

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=20250409110731.3752332-4-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=quic_wcheng@quicinc.com \
    --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