public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ASoC: SOF: topology: allow user to add topologies
@ 2026-04-16  5:35 Bard Liao
  2026-04-16  5:35 ` [PATCH v2 1/2] ASoC: sof-function-topology-lib: add virtual loop dai support Bard Liao
  2026-04-16  5:35 ` [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
  0 siblings, 2 replies; 4+ messages in thread
From: Bard Liao @ 2026-04-16  5:35 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

This series adds a module parameter array to allow users to load specific
feature topologies.

v2: add a out of memory check.

Bard Liao (2):
  ASoC: sof-function-topology-lib: add virtual loop dai support
  ASoC: SOF: topology: allow user to add topologies

 .../intel/common/sof-function-topology-lib.c  | 11 +++-
 sound/soc/sof/topology.c                      | 55 +++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] ASoC: sof-function-topology-lib: add virtual loop dai support
  2026-04-16  5:35 [PATCH v2 0/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
@ 2026-04-16  5:35 ` Bard Liao
  2026-04-16  5:35 ` [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
  1 sibling, 0 replies; 4+ messages in thread
From: Bard Liao @ 2026-04-16  5:35 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

The virtual loop dai link is created by the machine driver and no
topology is needed for the dai link. Handle it to avoid the dai_link
is not supported error.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/intel/common/sof-function-topology-lib.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/common/sof-function-topology-lib.c b/sound/soc/intel/common/sof-function-topology-lib.c
index 0daa7d83808b..2f2c902ef90c 100644
--- a/sound/soc/intel/common/sof-function-topology-lib.c
+++ b/sound/soc/intel/common/sof-function-topology-lib.c
@@ -19,6 +19,7 @@ enum tplg_device_id {
 	TPLG_DEVICE_SDCA_MIC,
 	TPLG_DEVICE_INTEL_PCH_DMIC,
 	TPLG_DEVICE_HDMI,
+	TPLG_DEVICE_LOOPBACK_VIRTUAL,
 	TPLG_DEVICE_MAX
 };
 
@@ -81,7 +82,15 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
 		} else if (strstr(dai_link->name, "iDisp")) {
 			tplg_dev = TPLG_DEVICE_HDMI;
 			tplg_dev_name = "hdmi-pcm5";
-
+		} else if (strstr(dai_link->name, "Loopback_Virtual")) {
+			tplg_dev = TPLG_DEVICE_LOOPBACK_VIRTUAL;
+			/*
+			 * Mark the LOOPBACK_VIRTUAL device but no need to create the
+			 * LOOPBACK_VIRTUAL topology. Just to avoid the dai_link is not supported
+			 * error.
+			 */
+			tplg_mask |= BIT(tplg_dev);
+			continue;
 		} else {
 			/* The dai link is not supported by separated tplg yet */
 			dev_dbg(card->dev,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies
  2026-04-16  5:35 [PATCH v2 0/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
  2026-04-16  5:35 ` [PATCH v2 1/2] ASoC: sof-function-topology-lib: add virtual loop dai support Bard Liao
@ 2026-04-16  5:35 ` Bard Liao
  2026-04-16  9:43   ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Bard Liao @ 2026-04-16  5:35 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: linux-sound, pierre-louis.bossart, bard.liao, peter.ujfalusi

Currently, the function topology provides the basic audio function. The
commit allow the users add their topologies to the topology list. So
they can add their own features.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/sof/topology.c | 55 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 63d582c65891..2c3b756aebcc 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -23,6 +23,13 @@ static bool disable_function_topology;
 module_param(disable_function_topology, bool, 0444);
 MODULE_PARM_DESC(disable_function_topology, "Disable function topology loading");
 
+#define MAX_FEATURE_TPLG_COUNT 16
+
+static char *feature_topologies[MAX_FEATURE_TPLG_COUNT];
+static int feature_tplg_cnt;
+module_param_array(feature_topologies, charp, &feature_tplg_cnt, 0444);
+MODULE_PARM_DESC(index, "Topology list for virtual loop DAI link");
+
 #define COMP_ID_UNASSIGNED		0xffffffff
 /*
  * Constants used in the computation of linear volume gain
@@ -2575,6 +2582,54 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
 		}
 	}
 
+	/* Loading user defined topologies */
+	for (i = 0; i < feature_tplg_cnt; i++) {
+		const char *feature_topology = devm_kasprintf(scomp->dev, GFP_KERNEL, "%s/%s",
+							   tplg_filename_prefix,
+							   feature_topologies[i]);
+
+		if (!feature_topology) {
+			ret = -ENOMEM;
+			goto out;
+		}
+		dev_info(scomp->dev, "loading feature topology %d: %s\n", i, feature_topology);
+		ret = request_firmware(&fw, feature_topology, scomp->dev);
+		if (ret < 0) {
+			/*
+			 * snd_soc_tplg_component_remove(scomp) will be called
+			 * if snd_soc_tplg_component_load(scomp) failed and all
+			 * objects in the scomp will be removed. No need to call
+			 * snd_soc_tplg_component_remove(scomp) here.
+			 */
+			dev_warn(scomp->dev, "feature tplg request firmware %s failed err: %d\n",
+				 feature_topologies[i], ret);
+			/*
+			 * We don't return error here because we can still have the basic
+			 * audio feature when the function topology load complete. No need
+			 * to convert the error code because we will get new 'ret' out of the
+			 * loop.
+			 */
+			continue;
+		}
+
+		if (sdev->dspless_mode_selected)
+			ret = snd_soc_tplg_component_load(scomp, &sof_dspless_tplg_ops, fw);
+		else
+			ret = snd_soc_tplg_component_load(scomp, &sof_tplg_ops, fw);
+
+		release_firmware(fw);
+
+		if (ret < 0) {
+			dev_err(scomp->dev, "feature tplg %s component load failed %d\n",
+				feature_topologies[i], ret);
+			/*
+			 * We need to return error here because it may lead to kernel NULL pointer
+			 * dereference if we continue the remaining tasks.
+			 */
+			goto out;
+		}
+	}
+
 	/* call sof_complete when topologies are loaded successfully */
 	ret = sof_complete(scomp);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies
  2026-04-16  5:35 ` [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
@ 2026-04-16  9:43   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-16  9:43 UTC (permalink / raw)
  To: Bard Liao
  Cc: tiwai, linux-sound, pierre-louis.bossart, bard.liao,
	peter.ujfalusi

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

On Thu, Apr 16, 2026 at 01:35:52PM +0800, Bard Liao wrote:

> +static char *feature_topologies[MAX_FEATURE_TPLG_COUNT];
> +static int feature_tplg_cnt;
> +module_param_array(feature_topologies, charp, &feature_tplg_cnt, 0444);
> +MODULE_PARM_DESC(index, "Topology list for virtual loop DAI link");

The description here still references index not feature_topologies?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-16  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16  5:35 [PATCH v2 0/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
2026-04-16  5:35 ` [PATCH v2 1/2] ASoC: sof-function-topology-lib: add virtual loop dai support Bard Liao
2026-04-16  5:35 ` [PATCH v2 2/2] ASoC: SOF: topology: allow user to add topologies Bard Liao
2026-04-16  9:43   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox