From 83a9c36a55537917d679fd20fc3c8b474fa6571f Mon Sep 17 00:00:00 2001 From: Laurentiu Mihalcea Date: Wed, 26 Mar 2025 16:13:01 +0200 Subject: [PATCH] ASoC: SOF: core: re-introduce the 'tplg-name' DT property Currently, SOF topology name is fetched based on the machine type with the option to override it using module parameters. For instance, i.MX8QM MEK should use the 'sof-imx8-wm8960.tplg' topology, i.MX8MP EVK should use the 'sof-imx8m-wm8960.tplg' topology and so on. The assumption that each machine has a topology associated with it holds just fine unless additional boards are attached to the machine. For instance, one may attach the IMX-AUD-IO card (with CS42888) to the i.MX8QM MEK machine. In this particular case, the machine stays the same but the topology needs to be changed so that the new codec is also supported in SOF. To serve these particular cases, re-introduce the 'tplg-name' DT property. The property is optional and, if not specified, the topology will be still be chosen based on the machine type. Signed-off-by: Laurentiu Mihalcea --- sound/soc/sof/core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 84a9ef15593e3d..45c2aac74e78af 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -185,16 +185,31 @@ static struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) struct snd_sof_pdata *sof_pdata = sdev->pdata; const struct sof_dev_desc *desc = sof_pdata->desc; struct snd_sof_of_mach *mach = desc->of_machines; + const char *tplg_name; + int ret; if (!mach) return NULL; for (; mach->compatible; mach++) { if (of_machine_is_compatible(mach->compatible)) { - sof_pdata->tplg_filename = mach->sof_tplg_filename; + if (mach->fw_filename) sof_pdata->fw_filename = mach->fw_filename; + ret = of_property_read_string(sdev->dev->of_node, + "tplg-name", + &tplg_name); + if (ret < 0 && ret != -EINVAL) { + dev_err(sdev->dev, "failed to fetch topology name: %d\n", ret); + return NULL; + } + + if (ret == -EINVAL) + sof_pdata->tplg_filename = mach->sof_tplg_filename; + else + sof_pdata->tplg_filename = tplg_name; + return mach; } }