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 15/15] ASoC: Intel: avs: Add USB machine board
Date: Wed, 9 Apr 2025 13:07:30 +0200 [thread overview]
Message-ID: <20250409110731.3752332-16-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20250409110731.3752332-1-cezary.rojewski@intel.com>
Provide machine board driver that represents USB Audio sound card. The
card connects ASoC USB codec driver with Intel AudioDSP avs-driver
driver so that user can enjoy streaming over USB device without engaging
their CPU - transfer is offloaded onto DSP instead.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/boards/Kconfig | 8 ++
sound/soc/intel/avs/boards/Makefile | 2 +
sound/soc/intel/avs/boards/usb.c | 115 ++++++++++++++++++++++++++++
3 files changed, 125 insertions(+)
create mode 100644 sound/soc/intel/avs/boards/usb.c
diff --git a/sound/soc/intel/avs/boards/Kconfig b/sound/soc/intel/avs/boards/Kconfig
index 7938e6d6e44d..f036cb96c48f 100644
--- a/sound/soc/intel/avs/boards/Kconfig
+++ b/sound/soc/intel/avs/boards/Kconfig
@@ -244,4 +244,12 @@ config SND_SOC_INTEL_AVS_MACH_TDF8532
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".
+config SND_SOC_INTEL_AVS_MACH_USB
+ tristate "USB-Audio board"
+ depends on USB_XHCI_PCI || COMPILE_TEST
+ select SND_SOC_USB_CODEC
+ help
+ This allows Intel AVS driver to pair with xHCI Audio Sideband.
+ If unsure select "N".
+
endmenu
diff --git a/sound/soc/intel/avs/boards/Makefile b/sound/soc/intel/avs/boards/Makefile
index 7c718c0ce120..4fdea026a216 100644
--- a/sound/soc/intel/avs/boards/Makefile
+++ b/sound/soc/intel/avs/boards/Makefile
@@ -24,6 +24,7 @@ snd-soc-avs-rt5663-y := rt5663.o
snd-soc-avs-rt5682-y := rt5682.o
snd-soc-avs-ssm4567-y := ssm4567.o
snd-soc-avs-tdf8532-y := tdf8532.o
+snd-soc-avs-usb-y := usb.o
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_DA7219) += snd-soc-avs-da7219.o
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_DMIC) += snd-soc-avs-dmic.o
@@ -49,3 +50,4 @@ obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT5663) += snd-soc-avs-rt5663.o
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT5682) += snd-soc-avs-rt5682.o
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_SSM4567) += snd-soc-avs-ssm4567.o
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_TDF8532) += snd-soc-avs-tdf8532.o
+obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_USB) += snd-soc-avs-usb.o
diff --git a/sound/soc/intel/avs/boards/usb.c b/sound/soc/intel/avs/boards/usb.c
new file mode 100644
index 000000000000..d103a8a5474b
--- /dev/null
+++ b/sound/soc/intel/avs/boards/usb.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright(c) 2025 Intel Corporation
+//
+// Author: Cezary Rojewski <cezary.rojewski@intel.com>
+//
+
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/usb.h>
+#include <sound/soc.h>
+#include <sound/soc-card.h>
+#include <sound/usb.h>
+
+static int uao_create_dai_links(struct device *dev, struct snd_usb_audio *chip,
+ struct snd_soc_dai_link **links, int *num_links)
+{
+ struct snd_soc_dai_link *dl;
+ int i;
+
+ dl = devm_kcalloc(dev, chip->pcm_devs, sizeof(*dl), GFP_KERNEL);
+ if (!dl)
+ return -ENOMEM;
+
+ for (i = 0; i < chip->pcm_devs; i++) {
+ dl[i].name = devm_kasprintf(dev, GFP_KERNEL, "uao-be-link%d", i);
+ if (!dl[i].name)
+ return -ENOMEM;
+ dl[i].stream_name = dl[i].name;
+
+ dl[i].no_pcm = 1;
+ dl[i].num_cpus = 1;
+ dl[i].num_codecs = 1;
+ dl[i].nonatomic = 1;
+ dl[i].codecs = devm_kzalloc(dev, sizeof(*dl[i].codecs), GFP_KERNEL);
+ dl[i].cpus = devm_kzalloc(dev, sizeof(*dl[i].cpus), GFP_KERNEL);
+ if (!dl[i].codecs || !dl[i].cpus)
+ return -ENOMEM;
+ dl[i].codecs->name = "usb-codec";
+ dl[i].codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "usb-codec-dai%d", i);
+ if (!dl[i].codecs->dai_name)
+ return -ENOMEM;
+ dl[i].cpus->dai_name = "uaol-cpu0";
+ }
+
+ *links = dl;
+ *num_links = chip->pcm_devs;
+ return 0;
+}
+
+static int uao_board_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct snd_usb_audio *chip;
+ struct snd_soc_card *card;
+ struct usb_device *udev;
+ char shortname[32];
+ char longname[80];
+ int ret;
+
+ chip = dev_get_drvdata(dev->parent);
+ udev = chip->dev;
+
+ switch (udev->speed) {
+ case USB_SPEED_FULL:
+ case USB_SPEED_HIGH:
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
+ if (!card)
+ return -ENOMEM;
+
+ ret = uao_create_dai_links(dev, chip, &card->dai_link, &card->num_links);
+ if (ret)
+ return ret;
+
+ card->dev = dev;
+ card->owner = THIS_MODULE;
+ card->fully_routed = true;
+ card->driver_name = "USB-Audio";
+
+ snd_usb_make_card_names(chip, shortname, longname);
+ /* card->driver/shortname/longname set by ASoC. */
+ /* card->private_data/free redundant for ASoC-based. */
+ card->name = devm_kstrdup(dev, shortname, GFP_KERNEL);
+ card->long_name = devm_kstrdup(dev, longname, GFP_KERNEL);
+ card->components = devm_kasprintf(dev, GFP_KERNEL, "USB%04x:%04x",
+ usb_device_vid(udev), usb_device_pid(udev));
+ if (!card->name || !card->long_name || !card->components)
+ return -ENOMEM;
+
+ return devm_snd_soc_register_card(dev, card);
+}
+
+static const struct platform_device_id uao_board_driver_ids[] = {
+ { .name = "uao_board", },
+ { },
+};
+
+static struct platform_driver uao_board_driver = {
+ .probe = uao_board_probe,
+ .driver = {
+ .name = "uao_board",
+ .pm = &snd_soc_pm_ops,
+ },
+ .id_table = uao_board_driver_ids,
+};
+
+module_platform_driver(uao_board_driver);
+
+MODULE_DESCRIPTION("USB Audio Offload machine driver");
+MODULE_LICENSE("GPL");
--
2.25.1
next prev 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 ` [RFC 03/15] ALSA: usb: Relocate the usbaudio header file Cezary Rojewski
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 ` Cezary Rojewski [this message]
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-16-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