Skip to content

Commit cdedb94

Browse files
committed
ASoC: SOF: topology: allow user to add topologies
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>
1 parent 64d5a11 commit cdedb94

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

sound/soc/sof/topology.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ static bool disable_function_topology;
2323
module_param(disable_function_topology, bool, 0444);
2424
MODULE_PARM_DESC(disable_function_topology, "Disable function topology loading");
2525

26+
#define MAX_USER_TPLG_COUNT 5
27+
28+
static char *user_topologies[MAX_USER_TPLG_COUNT];
29+
static int user_tplg_cnt;
30+
module_param_array(user_topologies, charp, &user_tplg_cnt, 0444);
31+
MODULE_PARM_DESC(index, "Topology list for virtual loop DAI link");
32+
2633
#define COMP_ID_UNASSIGNED 0xffffffff
2734
/*
2835
* Constants used in the computation of linear volume gain
@@ -2590,6 +2597,40 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
25902597
}
25912598
}
25922599

2600+
/* Loading user defined topologies */
2601+
for (i = 0; i < user_tplg_cnt; i++) {
2602+
const char *user_topology = devm_kasprintf(scomp->dev, GFP_KERNEL, "%s/%s",
2603+
tplg_filename_prefix,
2604+
user_topologies[i]);
2605+
2606+
dev_info(scomp->dev, "loading user topology %d: %s\n", i, user_topology);
2607+
ret = request_firmware(&fw, user_topology, scomp->dev);
2608+
if (ret < 0) {
2609+
/*
2610+
* snd_soc_tplg_component_remove(scomp) will be called
2611+
* if snd_soc_tplg_component_load(scomp) failed and all
2612+
* objects in the scomp will be removed. No need to call
2613+
* snd_soc_tplg_component_remove(scomp) here.
2614+
*/
2615+
dev_err(scomp->dev, "tplg request firmware %s failed err: %d\n",
2616+
tplg_files[i], ret);
2617+
goto out;
2618+
}
2619+
2620+
if (sdev->dspless_mode_selected)
2621+
ret = snd_soc_tplg_component_load(scomp, &sof_dspless_tplg_ops, fw);
2622+
else
2623+
ret = snd_soc_tplg_component_load(scomp, &sof_tplg_ops, fw);
2624+
2625+
release_firmware(fw);
2626+
2627+
if (ret < 0) {
2628+
dev_err(scomp->dev, "tplg %s component load failed %d\n",
2629+
tplg_files[i], ret);
2630+
goto out;
2631+
}
2632+
}
2633+
25932634
/* call sof_complete when topologies are loaded successfully */
25942635
ret = sof_complete(scomp);
25952636

0 commit comments

Comments
 (0)