From: Syed Saba Kareem <syed.sabakareem@amd.com>
To: <broonie@kernel.org>
Cc: <Sunil-kumar.Dommati@amd.com>, <vijendar.mukunda@amd.com>,
<Mario.Limonciello@amd.com>, <venkataprasad.potturu@amd.com>,
"Syed Saba Kareem" <Syed.SabaKareem@amd.com>,
Siva Subramanian Ravi Saravanan <sravisar@amd.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
"Liam Girdwood" <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, "Takashi Iwai" <tiwai@suse.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
open list <linux-kernel@vger.kernel.org>,
"open list:AMD ASoC DRIVERS" <linux-sound@vger.kernel.org>
Subject: [PATCH v2 4/6] ASoC: amd: acp: add SOF function topology support
Date: Sun, 8 Nov 2026 00:57:00 +0530 [thread overview]
Message-ID: <20261107192744.2027264-5-syed.sabakareem@amd.com> (raw)
In-Reply-To: <20261107192744.2027264-1-syed.sabakareem@amd.com>
From: Syed Saba Kareem <Syed.SabaKareem@amd.com>
From: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Add amd_sof_sdw_get_tplg_files() to build the list of SOF function
topologies from the card DAI links, so that a card can be formed from
per-function topologies instead of one monolithic topology per codec
configuration.
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com>
---
sound/soc/amd/acp/Makefile | 3 +-
.../amd/acp/amd-sof-function-topology-lib.c | 129 ++++++++++++++++++
.../amd/acp/amd-sof-function-topology-lib.h | 19 +++
3 files changed, 150 insertions(+), 1 deletion(-)
create mode 100644 sound/soc/amd/acp/amd-sof-function-topology-lib.c
create mode 100644 sound/soc/amd/acp/amd-sof-function-topology-lib.h
diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile
index 42e2bd34da06..91bbbeef5b8a 100644
--- a/sound/soc/amd/acp/Makefile
+++ b/sound/soc/amd/acp/Makefile
@@ -23,7 +23,8 @@ snd-acp70-y := acp70.o
snd-acp-mach-y := acp-mach-common.o
snd-acp-legacy-mach-y := acp-legacy-mach.o acp3x-es83xx/acp3x-es83xx.o
snd-acp-sof-mach-y := acp-sof-mach.o
-snd-soc-acpi-amd-match-y := amd-acp63-acpi-match.o amd-acp70-acpi-match.o amd-acp7x-acpi-match.o
+snd-soc-acpi-amd-match-y := amd-acp63-acpi-match.o amd-acp70-acpi-match.o amd-acp7x-acpi-match.o \
+ amd-sof-function-topology-lib.o
snd-soc-acpi-amd-match-$(CONFIG_SND_SOC_ACPI_AMD_SDCA_QUIRKS) += soc-acpi-amd-sdca-quirks.o
snd-acp-sdw-mach-y := acp-sdw-mach-common.o
snd-acp-sdw-sof-mach-y += acp-sdw-sof-mach.o
diff --git a/sound/soc/amd/acp/amd-sof-function-topology-lib.c b/sound/soc/amd/acp/amd-sof-function-topology-lib.c
new file mode 100644
index 000000000000..8d70d46d769e
--- /dev/null
+++ b/sound/soc/amd/acp/amd-sof-function-topology-lib.c
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright(c) 2026 Advanced Micro Devices, Inc.
+//
+
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <sound/soc.h>
+#include <sound/soc-acpi.h>
+#include "amd-sof-function-topology-lib.h"
+
+#define SOF_AMD_PLATFORM_NAME_MAX 8
+#define SOF_AMD_SDW_MAX_LINKS 4
+
+static int get_sdw_link_num(struct device *dev, struct snd_soc_dai_link *dai_link,
+ unsigned int *link_num)
+{
+ if (sscanf(dai_link->name, "SDW%u", link_num) != 1 ||
+ *link_num >= SOF_AMD_SDW_MAX_LINKS) {
+ dev_err(dev, "Can't get SDW link from dai_link->name %s\n", dai_link->name);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int amd_sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
+ const char *prefix, const char ***tplg_files, bool best_effort)
+{
+ struct snd_soc_dai_link *dai_link;
+ char platform[SOF_AMD_PLATFORM_NAME_MAX];
+ unsigned long tplg_mask = 0;
+ int tplg_num = 0;
+ char *tplg_file;
+ int tplg_bit;
+ int tplg_dev;
+ int ret;
+ int i;
+
+ /* ACP SoundWire and PDM DAI configuration is platform dependent */
+ ret = snd_soc_acpi_get_platform_name(card, mach, platform);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * ACP SoundWire DAI index and stream names in the topologies are
+ * specific to the SoundWire link, so the link number is part of the
+ * SoundWire function names.
+ */
+ for_each_card_prelinks(card, i, dai_link) {
+ unsigned int link_num = 0;
+ const char *tplg_dev_name;
+
+ dev_dbg(card->dev, "dai_link %s id %d\n", dai_link->name, dai_link->id);
+ if (strstr(dai_link->name, "SimpleJack")) {
+ ret = get_sdw_link_num(card->dev, dai_link, &link_num);
+ if (ret)
+ return ret;
+
+ tplg_dev = TPLG_DEVICE_ACP_SDW_JACK;
+ tplg_dev_name = devm_kasprintf(card->dev, GFP_KERNEL, "jack-l%u", link_num);
+ if (!tplg_dev_name)
+ return -ENOMEM;
+ } else if (strstr(dai_link->name, "SmartAmp")) {
+ ret = get_sdw_link_num(card->dev, dai_link, &link_num);
+ if (ret)
+ return ret;
+
+ tplg_dev = TPLG_DEVICE_ACP_SDW_AMP;
+ tplg_dev_name = devm_kasprintf(card->dev, GFP_KERNEL, "%damp-l%u",
+ dai_link->num_cpus, link_num);
+ if (!tplg_dev_name)
+ return -ENOMEM;
+ } else if (strstr(dai_link->name, "SmartMic")) {
+ ret = get_sdw_link_num(card->dev, dai_link, &link_num);
+ if (ret)
+ return ret;
+
+ tplg_dev = TPLG_DEVICE_ACP_SDW_MIC;
+ tplg_dev_name = devm_kasprintf(card->dev, GFP_KERNEL, "mic-l%u", link_num);
+ if (!tplg_dev_name)
+ return -ENOMEM;
+ } else if (strstr(dai_link->name, "dmic")) {
+ /* ACP PDM DMIC is always stereo */
+ tplg_dev = TPLG_DEVICE_ACP_DMIC;
+ tplg_dev_name = "dmic-2ch";
+ } else {
+ /* The dai link is not supported by separated tplg yet */
+ dev_dbg(card->dev,
+ "dai_link %s is not supported by separated tplg yet\n",
+ dai_link->name);
+ if (best_effort)
+ continue;
+
+ return 0;
+ }
+
+ /* the same function on different links needs its own topology */
+ tplg_bit = (tplg_dev - TPLG_DEVICE_ACP_SDW_JACK) * SOF_AMD_SDW_MAX_LINKS + link_num;
+ if (tplg_mask & BIT(tplg_bit))
+ continue;
+
+ tplg_file = snd_soc_acpi_get_tplg_filename(card->dev, prefix, platform,
+ tplg_dev_name, dai_link->id, tplg_dev);
+ if (!tplg_file)
+ return -ENOMEM;
+
+ /* Check presence of sub-topologies */
+ if (!snd_soc_acpi_tplg_files_exist(card->dev, tplg_file)) {
+ devm_kfree(card->dev, tplg_file);
+ if (best_effort)
+ continue;
+
+ return 0;
+ }
+
+ tplg_mask |= BIT(tplg_bit);
+
+ (*tplg_files)[tplg_num] = tplg_file;
+ tplg_num++;
+ }
+
+ dev_dbg(card->dev, "tplg_mask %#lx tplg_num %d\n", tplg_mask, tplg_num);
+
+ return tplg_num;
+}
diff --git a/sound/soc/amd/acp/amd-sof-function-topology-lib.h b/sound/soc/amd/acp/amd-sof-function-topology-lib.h
new file mode 100644
index 000000000000..cea49aa9c200
--- /dev/null
+++ b/sound/soc/amd/acp/amd-sof-function-topology-lib.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * amd-sof-function-topology-lib.h - get-tplg-files ops
+ *
+ * Copyright(c) 2026 Advanced Micro Devices, Inc.
+ */
+
+#ifndef __AMD_SOF_FUNCTION_TOPOLOGY_LIB_H
+#define __AMD_SOF_FUNCTION_TOPOLOGY_LIB_H
+
+#include <linux/types.h>
+
+struct snd_soc_acpi_mach;
+struct snd_soc_card;
+
+int amd_sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
+ const char *prefix, const char ***tplg_files, bool best_effort);
+
+#endif
--
2.43.0
next prev parent reply other threads:[~2026-11-07 19:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261107192744.2027264-1-syed.sabakareem@amd.com>
2026-11-07 19:26 ` [PATCH v2 1/6] ASoC: amd: acp: add Cirrus SoundWire configs for ACP7.F Syed Saba Kareem
2026-11-07 19:26 ` [PATCH v2 2/6] ASoC: amd: acp: add SoundWire speaker quirks for Dell platforms Syed Saba Kareem
2026-11-07 19:26 ` [PATCH v2 3/6] ASoC: soc-acpi: move common function topology helpers Syed Saba Kareem
2026-11-08 16:23 ` kernel test robot
2026-11-07 19:27 ` Syed Saba Kareem [this message]
2026-11-07 19:27 ` [PATCH v2 5/6] ASoC: amd: acp: always append the DAI type to SoundWire DAI link names Syed Saba Kareem
2026-11-07 19:27 ` [PATCH v2 6/6] ASoC: amd: acp: enable function topologies for ACP7.F SoundWire Syed Saba Kareem
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=20261107192744.2027264-5-syed.sabakareem@amd.com \
--to=syed.sabakareem@amd.com \
--cc=Mario.Limonciello@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.dev \
--cc=sravisar@amd.com \
--cc=tiwai@suse.com \
--cc=venkataprasad.potturu@amd.com \
--cc=vijendar.mukunda@amd.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
all inboxes | Powered by JetHome®