From 5994d34f3ac9f781adecef29bfd4ffd904ba9a53 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 23 Nov 2026 15:29:35 +0800 Subject: [PATCH 1/3] ASoC: Intel: sof-function-topology-lib: add sof_hda_get_tplg_files Add sof_hda_get_tplg_files() callback for the skl_hda_dsp_generic machine driver. It finds the function topologies according to the dai links created by the machine driver: iDisp (HDMI), HDA analog/digital codecs, PCH DMIC, SSP BT offload and SSP HDMI IN. The analog and digital HDA codec dai links share one topology. Like the HDMI one, it has no NHLT blob and doesn't depend on the platform, so its name has no platform: sof-hda-id.tplg. When a dai link has no function topology, e.g. with 1 or 3 dmics, no function topology is used so that the monolithic topology is loaded instead, unless best effort is requested. Signed-off-by: Bard Liao --- .../intel/common/sof-function-topology-lib.c | 102 ++++++++++++++++++ .../intel/common/sof-function-topology-lib.h | 3 + 2 files changed, 105 insertions(+) diff --git a/sound/soc/intel/common/sof-function-topology-lib.c b/sound/soc/intel/common/sof-function-topology-lib.c index 57e089f8e721dc..b52ca0dead9c44 100644 --- a/sound/soc/intel/common/sof-function-topology-lib.c +++ b/sound/soc/intel/common/sof-function-topology-lib.c @@ -24,6 +24,7 @@ enum tplg_device_id { TPLG_DEVICE_SSP_BT, TPLG_DEVICE_SSP_HDMI_IN, TPLG_DEVICE_LOOPBACK_VIRTUAL, + TPLG_DEVICE_HDA, TPLG_DEVICE_MAX }; @@ -332,3 +333,104 @@ int sof_i2s_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_ return tplg_num; } EXPORT_SYMBOL_GPL(sof_i2s_get_tplg_files); + +/* + * The dai links are created by the skl_hda_dsp_generic machine driver: + * iDisp - HDMI + * Analog Playback and Capture - HDA analog codec + * Digital Playback and Capture - HDA digital codec + * dmic01/dmic16k - PCH DMIC + * SSP-BT - BT offload + * SSP-HDMI - HDMI IN, two links in one tplg + */ +int sof_hda_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_acpi_mach_params mach_params = mach->mach_params; + struct snd_soc_dai_link *dai_link; + char platform[SOF_INTEL_PLATFORM_NAME_MAX]; + unsigned long tplg_mask = 0; + u16 hdmi_in_mask = 0; + int tplg_num = 0; + char *tplg_file; + int tplg_dev; + int ret; + int i; + + ret = get_platform_name(card, mach, platform); + if (ret < 0) + return ret; + + for_each_card_prelinks(card, i, dai_link) { + 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, "iDisp")) { + tplg_dev = TPLG_DEVICE_HDMI; + tplg_dev_name = "hdmi-pcm3"; + } else if (!strcmp(dai_link->name, "Analog Playback and Capture") || + !strcmp(dai_link->name, "Digital Playback and Capture")) { + /* + * The analog and digital dai links share one tplg, named + * after the id of the first one, the analog dai link. + */ + tplg_dev = TPLG_DEVICE_HDA; + tplg_dev_name = "hda"; + } else if (strstr(dai_link->name, "dmic")) { + /* + * The machine driver creates the DMIC dai links even + * if there is no DMIC, no tplg is needed for them. + */ + if (!mach_params.dmic_num) + continue; + + if (get_dmic_tplg_dev(card->dev, mach_params.dmic_num, + &tplg_dev, &tplg_dev_name) < 0) { + /* no function topology for this number of dmics */ + if (best_effort) + continue; + + return 0; + } + } else if (strstr(dai_link->name, "SSP")) { + if (get_ssp_tplg_dev(card->dev, dai_link, &hdmi_in_mask, + &tplg_dev, &tplg_dev_name) < 0) + continue; + } 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; + } + if (tplg_mask & BIT(tplg_dev)) + continue; + + tplg_file = 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 (!tplg_files_exist(card->dev, tplg_file)) { + devm_kfree(card->dev, tplg_file); + if (best_effort) + continue; + + return 0; + } + + tplg_mask |= BIT(tplg_dev); + + (*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; +} +EXPORT_SYMBOL_GPL(sof_hda_get_tplg_files); diff --git a/sound/soc/intel/common/sof-function-topology-lib.h b/sound/soc/intel/common/sof-function-topology-lib.h index 9755e97709685e..74af7f71414b6b 100644 --- a/sound/soc/intel/common/sof-function-topology-lib.h +++ b/sound/soc/intel/common/sof-function-topology-lib.h @@ -15,4 +15,7 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_ int sof_i2s_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); +int sof_hda_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 From 0b1f45a75a224741cca055c96d11879cf1ace3a8 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 23 Nov 2026 15:29:36 +0800 Subject: [PATCH 2/3] ASoC: Intel: soc-acpi-intel-hda-match: set get_function_tplg_files Set get_function_tplg_files to sof_hda_get_tplg_files() so that the skl_hda_dsp_generic machine can use function topologies. The monolithic sof-hda-generic topologies are still used when any of the function topologies is missing. The HDA and HDMI function topologies are platform independent, so an HDA machine with only HDA codec and HDMI links uses function topologies on any platform once they are installed, the same as with the platform independent sof-hda-generic topologies. Signed-off-by: Bard Liao --- sound/soc/intel/common/soc-acpi-intel-hda-match.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/intel/common/soc-acpi-intel-hda-match.c b/sound/soc/intel/common/soc-acpi-intel-hda-match.c index e93336e27bebd7..cd43ea8222a8b2 100644 --- a/sound/soc/intel/common/soc-acpi-intel-hda-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-hda-match.c @@ -8,6 +8,7 @@ #include #include +#include "sof-function-topology-lib.h" struct snd_soc_acpi_mach snd_soc_acpi_intel_hda_machines[] = { { @@ -15,6 +16,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_hda_machines[] = { .drv_name = "skl_hda_dsp_generic", .sof_tplg_filename = "sof-hda-generic", /* the tplg suffix is added at run time */ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + .get_function_tplg_files = sof_hda_get_tplg_files, }, {}, }; From 5f3cbbe1ab5f6e39e63eb26e7e2e00fd7df4e0aa Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 24 Nov 2026 15:27:02 +0800 Subject: [PATCH 3/3] ASoC: SOF: Intel: hda: pass the platform name for function topologies The platform name is needed to form the file names of the DMIC and SSP function topologies, which depend on the platform NHLT blobs. get_platform_name() takes it from sof_tplg_filename, but the one of the HDA generic match table is platform independent, and it can't be replaced: it is also the monolithic topology that is used when the function topologies are not available, e.g. on platforms that have no function topologies or with an older sof-firmware. mach_params.platform can't be used either, it is the name of the ASoC platform component the machine drivers bind their dai links to. Add mach_params.tplg_platform, set it to the platform name in hda_generic_machine_select(), and use it in get_platform_name() when it is set. Signed-off-by: Bard Liao --- include/sound/soc-acpi.h | 3 +++ sound/soc/intel/common/sof-function-topology-lib.c | 7 +++++++ sound/soc/sof/intel/hda.c | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h index 2ee303b791dc84..2950364d1dd87e 100644 --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h @@ -74,6 +74,8 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) * @subsystem_id_set: true if a value has been written to * subsystem_vendor and subsystem_device. * @bt_link_mask: BT offload link enabled on the board + * @tplg_platform: platform name used in the function topology file names, + * when it can't be taken from the topology file name */ struct snd_soc_acpi_mach_params { u32 acpi_ipc_irq_index; @@ -90,6 +92,7 @@ struct snd_soc_acpi_mach_params { unsigned short subsystem_rev; bool subsystem_id_set; u32 bt_link_mask; + const char *tplg_platform; }; /** diff --git a/sound/soc/intel/common/sof-function-topology-lib.c b/sound/soc/intel/common/sof-function-topology-lib.c index b52ca0dead9c44..15e7308badeee6 100644 --- a/sound/soc/intel/common/sof-function-topology-lib.c +++ b/sound/soc/intel/common/sof-function-topology-lib.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "sof-function-topology-lib.h" @@ -38,6 +39,12 @@ static int get_platform_name(struct snd_soc_card *card, { int ret; + if (mach->mach_params.tplg_platform) { + strscpy(platform, mach->mach_params.tplg_platform, + SOF_INTEL_PLATFORM_NAME_MAX); + return 0; + } + ret = sscanf(mach->sof_tplg_filename, "sof-%3s-*.tplg", platform); if (ret != 1) { dev_err(card->dev, "Invalid platform name of tplg %s\n", diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 45e968fb19104b..fa4b84aa435b02 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -1047,6 +1047,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev, struct snd_soc_acpi_mach_params *mach_params; struct snd_soc_acpi_mach *hda_mach; struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_intel_dsp_desc *chip = get_chip_info(pdata); const char *tplg_filename; int codec_num = 0; int i; @@ -1092,6 +1093,14 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev, dev_info(bus->dev, "using HDA machine driver %s now\n", hda_mach->drv_name); + /* + * The platform name is needed to form the function topology + * file names, but sof_tplg_filename of the match table is + * platform independent and is kept for the monolithic + * topology fallback. + */ + hda_mach->mach_params.tplg_platform = chip->platform; + /* * topology: use the info from hda_machines since tplg file name * is not overwritten