From 07a238610e1887bcc5acf30ce8d1eacbfff8f6d2 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 12 Aug 2025 10:18:44 +0800 Subject: [PATCH 1/8] ASoC: SOF: Don't print the monolithic topology name if function topology may be used It may confuse people if "Topology file:" is printed but the topology file is not really used. We keep the print if the topology file is missing thus user can know what topology is missed in the file system. And increase the log level to info for the actual topology that is used. So that user can get which topology is used. Signed-off-by: Bard Liao --- sound/soc/sof/fw-file-profile.c | 7 ++++++- sound/soc/sof/topology.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c index 1c0eb13ae55768..71abd6295ca9f7 100644 --- a/sound/soc/sof/fw-file-profile.c +++ b/sound/soc/sof/fw-file-profile.c @@ -266,6 +266,7 @@ static void sof_print_profile_info(struct snd_sof_dev *sdev, enum sof_ipc_type ipc_type, struct sof_loadable_file_profile *profile) { + struct snd_sof_pdata *plat_data = sdev->pdata; struct device *dev = sdev->dev; if (ipc_type != profile->ipc_type) @@ -282,7 +283,11 @@ static void sof_print_profile_info(struct snd_sof_dev *sdev, if (profile->fw_lib_path) dev_info(dev, " Firmware lib path: %s\n", profile->fw_lib_path); - dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, profile->tplg_name); + + if(plat_data->machine->get_function_tplg_files && !plat_data->disable_function_topology) + dev_info(dev, " Topology file: function topologies\n"); + else + dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, profile->tplg_name); } int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index b6d5c8024f8cfa..3404f1306494c2 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2525,7 +2525,7 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) if (!tplg_cnt) { tplg_files[0] = file; tplg_cnt = 1; - dev_dbg(scomp->dev, "loading topology: %s\n", file); + dev_info(scomp->dev, "loading topology: %s\n", file); } else { dev_info(scomp->dev, "Using function topologies instead %s\n", file); } From 3a2fe976304a089792b18b4aef285b869192d2f4 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 29 May 2025 19:55:39 +0800 Subject: [PATCH 2/8] ASoC: soc-acpi: make some variables of acpi adr and link adr non-const Currently, we use predefined snd_soc_acpi_link_adr tables to match the link adr from ACPI table to select the machine driver and the topology. However, with the mechanism, we need to create the snd_soc_acpi_link_adr table for each audio config. The sof_sdw machine driver is used by almost all Intel platforms with SOF and we can load required topology file dynamically today. In other words, we can use sof_sdw machine driver as the default machine driver for Intel SOF SoundWire codecs and no need to create snd_soc_acpi_link_adr table for every new audio configs. To achieve it, we need to drop the const for some members and edit the link adr and acpi adr data to match the data from the ACPI table. Suggested-by: Charles Keepax Signed-off-by: Bard Liao --- include/sound/soc-acpi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h index b8af309c2683f9..90d73b9bddabee 100644 --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h @@ -114,8 +114,8 @@ struct snd_soc_acpi_endpoint { * @name_prefix: string used for codec controls */ struct snd_soc_acpi_adr_device { - const u64 adr; - const u8 num_endpoints; + u64 adr; + u8 num_endpoints; const struct snd_soc_acpi_endpoint *endpoints; const char *name_prefix; }; @@ -131,8 +131,8 @@ struct snd_soc_acpi_adr_device { */ struct snd_soc_acpi_link_adr { - const u32 mask; - const u32 num_adr; + u32 mask; + u32 num_adr; const struct snd_soc_acpi_adr_device *adr_d; }; From 2ef29479dd9a60807d92914e88072b1dd206c25e Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 May 2025 19:15:26 +0800 Subject: [PATCH 3/8] ASoC: soc_sdw_utils: add name_prefix to asoc_sdw_codec_info struct Currently, the codec name_prefix of Intel SoundWire machine driver is from the ACPI match table. We can have it in the asoc_sdw_codec_info struct as a default name_prefix of a codec if there is no corresponding audio config found in the ACPI match table. Signed-off-by: Bard Liao --- include/sound/soc_sdw_utils.h | 1 + sound/soc/sdw_utils/soc_sdw_utils.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h index 6049a5d0cfcd8e..3ce46482794fb6 100644 --- a/include/sound/soc_sdw_utils.h +++ b/include/sound/soc_sdw_utils.h @@ -68,6 +68,7 @@ struct asoc_sdw_codec_info { const int part_id; const int version_id; const char *codec_name; + const char *name_prefix; int amp_num; const u8 acpi_id[ACPI_ID_LEN]; const bool ignore_internal_dmic; diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index 1580331cd34c58..002583567975e5 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -60,6 +60,7 @@ static const struct snd_kcontrol_new rt700_controls[] = { struct asoc_sdw_codec_info codec_info_list[] = { { .part_id = 0x700, + .name_prefix = "rt700", .dais = { { .direction = {true, true}, @@ -77,6 +78,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x711, + .name_prefix = "rt711", .version_id = 3, .dais = { { @@ -97,6 +99,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x711, + .name_prefix = "rt711", .version_id = 2, .dais = { { @@ -117,6 +120,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x712, + .name_prefix = "rt712", .version_id = 3, .dais = { { @@ -158,6 +162,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1712, + .name_prefix = "rt712-dmic", .version_id = 3, .dais = { { @@ -172,6 +177,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x713, + .name_prefix = "rt713", .version_id = 3, .dais = { { @@ -199,6 +205,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1713, + .name_prefix = "rt713-dmic", .version_id = 3, .dais = { { @@ -213,6 +220,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1308, + .name_prefix = "rt1308", .acpi_id = "10EC1308", .dais = { { @@ -235,6 +243,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1316, + .name_prefix = "rt1316", .dais = { { .direction = {true, true}, @@ -255,6 +264,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1318, + .name_prefix = "rt1318", .dais = { { .direction = {true, true}, @@ -275,6 +285,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x1320, + .name_prefix = "rt1320", .dais = { { .direction = {true, false}, @@ -295,6 +306,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x714, + .name_prefix = "rt714", .version_id = 3, .ignore_internal_dmic = true, .dais = { @@ -310,6 +322,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x715, + .name_prefix = "rt715", .version_id = 3, .ignore_internal_dmic = true, .dais = { @@ -325,6 +338,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x714, + .name_prefix = "rt714", .version_id = 2, .ignore_internal_dmic = true, .dais = { @@ -340,6 +354,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x715, + .name_prefix = "rt715", .version_id = 2, .ignore_internal_dmic = true, .dais = { @@ -355,6 +370,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x721, + .name_prefix = "rt721", .version_id = 3, .dais = { { @@ -397,6 +413,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x722, + .name_prefix = "rt722", .version_id = 3, .dais = { { @@ -441,6 +458,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x8373, + .name_prefix = "Left", .dais = { { .direction = {true, true}, @@ -460,6 +478,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x8363, + .name_prefix = "Left", .dais = { { .direction = {true, false}, @@ -479,6 +498,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x5682, + .name_prefix = "rt5682", .dais = { { .direction = {true, true}, @@ -496,6 +516,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x3556, + .name_prefix = "AMP", .dais = { { .direction = {true, false}, @@ -548,6 +569,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x4242, + .name_prefix = "cs42l42", .dais = { { .direction = {true, true}, @@ -565,6 +587,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x4243, + .name_prefix = "cs42l43", .codec_name = "cs42l43-codec", .count_sidecar = asoc_sdw_bridge_cs35l56_count_sidecar, .add_sidecar = asoc_sdw_bridge_cs35l56_add_sidecar, @@ -616,6 +639,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0xaaaa, /* generic codec mockup */ + .name_prefix = "sdw_mockup_mmulti-function", .version_id = 0, .dais = { { @@ -641,6 +665,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0xaa55, /* headset codec mockup */ + .name_prefix = "sdw_mockup_headset0", .version_id = 0, .dais = { { @@ -654,6 +679,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x55aa, /* amplifier mockup */ + .name_prefix = "sdw_mockup_amp1", .version_id = 0, .dais = { { @@ -667,6 +693,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { }, { .part_id = 0x5555, + .name_prefix = "sdw_mockup_mic0", .version_id = 0, .dais = { { From 03b3e3c1afe3eb1d770681cf80127b4ce22e8473 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 7 May 2025 18:37:29 +0800 Subject: [PATCH 4/8] ASoC: Intel: export sof_sdw_get_tplg_files The sof_sdw_get_tplg_files function is a callback of snd_soc_acpi_mach. Export it to allow other modules to use it. Signed-off-by: Bard Liao --- sound/soc/intel/common/sof-function-topology-lib.c | 2 +- 1 file changed, 1 insertion(+), 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 3cc81dcf047e3a..f685c1c5c6f06d 100644 --- a/sound/soc/intel/common/sof-function-topology-lib.c +++ b/sound/soc/intel/common/sof-function-topology-lib.c @@ -133,4 +133,4 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_ return tplg_num; } - +EXPORT_SYMBOL_GPL(sof_sdw_get_tplg_files); From a28819284198bcd225c84a778d0c532c38393238 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 May 2025 19:34:56 +0800 Subject: [PATCH 5/8] ASoC: soc_sdw_utils: export asoc_sdw_get_dai_type asoc_sdw_get_dai_type() is quite useful to convert SDCA function types to SDW DAI types. It can be used by other drivers. Signed-off-by: Bard Liao --- include/sound/soc_sdw_utils.h | 1 + sound/soc/sdw_utils/soc_sdw_utils.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h index 3ce46482794fb6..12e85df62091ec 100644 --- a/include/sound/soc_sdw_utils.h +++ b/include/sound/soc_sdw_utils.h @@ -169,6 +169,7 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int * struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, const struct snd_soc_acpi_endpoint *new); +int asoc_sdw_get_dai_type(u32 type); int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, struct asoc_sdw_dailink *soc_dais, diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index 002583567975e5..ba20177a2405a1 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -1221,7 +1221,7 @@ struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks } EXPORT_SYMBOL_NS(asoc_sdw_find_dailink, "SND_SOC_SDW_UTILS"); -static int asoc_sdw_get_dai_type(u32 type) +int asoc_sdw_get_dai_type(u32 type) { switch (type) { case SDCA_FUNCTION_TYPE_SMART_AMP: @@ -1239,6 +1239,7 @@ static int asoc_sdw_get_dai_type(u32 type) return -EINVAL; } } +EXPORT_SYMBOL_NS(asoc_sdw_get_dai_type, "SND_SOC_SDW_UTILS"); /* * Check if the SDCA endpoint is present by the SDW peripheral From 215abac4935b98e1b6c561ec7a1148ca2bdeb9cf Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 11 Sep 2025 16:10:52 +0800 Subject: [PATCH 6/8] ASoC: SOF: add platform name into sof_intel_dsp_desc The platform name will be used construct the topology name. Signed-off-by: Bard Liao --- sound/soc/sof/intel/apl.c | 1 + sound/soc/sof/intel/cnl.c | 2 ++ sound/soc/sof/intel/icl.c | 1 + sound/soc/sof/intel/lnl.c | 1 + sound/soc/sof/intel/mtl.c | 2 ++ sound/soc/sof/intel/ptl.c | 2 ++ sound/soc/sof/intel/shim.h | 1 + sound/soc/sof/intel/skl.c | 1 + sound/soc/sof/intel/tgl.c | 4 ++++ 9 files changed, 15 insertions(+) diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 76a92eaa1359de..0c68ae41a8a865 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -118,4 +118,5 @@ const struct sof_intel_dsp_desc apl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_1_5_PLUS, + .platform = "apl", }; diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 385e5339f0a4b7..dfef908554b3fe 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -479,6 +479,7 @@ const struct sof_intel_dsp_desc cnl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_1_8, + .platform = "cnl", }; /* @@ -515,5 +516,6 @@ const struct sof_intel_dsp_desc jsl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_0, + .platform = "jsl", }; EXPORT_SYMBOL_NS(jsl_chip_info, "SND_SOC_SOF_INTEL_CNL"); diff --git a/sound/soc/sof/intel/icl.c b/sound/soc/sof/intel/icl.c index dad6bc72ad37a0..dbc5ad62258b19 100644 --- a/sound/soc/sof/intel/icl.c +++ b/sound/soc/sof/intel/icl.c @@ -193,4 +193,5 @@ const struct sof_intel_dsp_desc icl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_0, + .platform = "icl", }; diff --git a/sound/soc/sof/intel/lnl.c b/sound/soc/sof/intel/lnl.c index 2f3222040f98fd..c01ea7e731aabf 100644 --- a/sound/soc/sof/intel/lnl.c +++ b/sound/soc/sof/intel/lnl.c @@ -183,6 +183,7 @@ const struct sof_intel_dsp_desc lnl_chip_info = { .power_down_dsp = mtl_power_down_dsp, .disable_interrupts = lnl_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_ACE_2_0, + .platform = "lnl", }; MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_MTL"); diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c index 657c7a1626d185..5c9318f943f0be 100644 --- a/sound/soc/sof/intel/mtl.c +++ b/sound/soc/sof/intel/mtl.c @@ -789,6 +789,7 @@ const struct sof_intel_dsp_desc mtl_chip_info = { .power_down_dsp = mtl_power_down_dsp, .disable_interrupts = mtl_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_ACE_1_0, + .platform = "mtl", }; const struct sof_intel_dsp_desc arl_s_chip_info = { @@ -817,4 +818,5 @@ const struct sof_intel_dsp_desc arl_s_chip_info = { .power_down_dsp = mtl_power_down_dsp, .disable_interrupts = mtl_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_ACE_1_0, + .platform = "arl", }; diff --git a/sound/soc/sof/intel/ptl.c b/sound/soc/sof/intel/ptl.c index 1bc1f54c470df7..7e49063ed6e960 100644 --- a/sound/soc/sof/intel/ptl.c +++ b/sound/soc/sof/intel/ptl.c @@ -125,6 +125,7 @@ const struct sof_intel_dsp_desc ptl_chip_info = { .power_down_dsp = mtl_power_down_dsp, .disable_interrupts = lnl_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_ACE_3_0, + .platform = "ptl", }; const struct sof_intel_dsp_desc wcl_chip_info = { @@ -148,6 +149,7 @@ const struct sof_intel_dsp_desc wcl_chip_info = { .power_down_dsp = mtl_power_down_dsp, .disable_interrupts = lnl_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_ACE_3_0, + .platform = "wcl", }; MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_MTL"); diff --git a/sound/soc/sof/intel/shim.h b/sound/soc/sof/intel/shim.h index d4372f0bff7e75..dc6a93d05bfea6 100644 --- a/sound/soc/sof/intel/shim.h +++ b/sound/soc/sof/intel/shim.h @@ -186,6 +186,7 @@ struct sof_intel_dsp_desc { u32 sdw_alh_base; u32 d0i3_offset; u32 quirks; + const char *platform; enum sof_intel_hw_ip_version hw_ip_version; int (*read_sdw_lcount)(struct snd_sof_dev *sdev); void (*enable_sdw_irq)(struct snd_sof_dev *sdev, bool enable); diff --git a/sound/soc/sof/intel/skl.c b/sound/soc/sof/intel/skl.c index 0696bce65e33ef..90a3c2e2334cd2 100644 --- a/sound/soc/sof/intel/skl.c +++ b/sound/soc/sof/intel/skl.c @@ -113,5 +113,6 @@ const struct sof_intel_dsp_desc skl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_1_5, + .platform = "skl", }; EXPORT_SYMBOL_NS(skl_chip_info, "SND_SOC_SOF_INTEL_HDA_COMMON"); diff --git a/sound/soc/sof/intel/tgl.c b/sound/soc/sof/intel/tgl.c index df2d26b78ddc21..e68bbe685ba3d6 100644 --- a/sound/soc/sof/intel/tgl.c +++ b/sound/soc/sof/intel/tgl.c @@ -162,6 +162,7 @@ const struct sof_intel_dsp_desc tgl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_5, + .platform = "tgl", }; const struct sof_intel_dsp_desc tglh_chip_info = { @@ -191,6 +192,7 @@ const struct sof_intel_dsp_desc tglh_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_5, + .platform = "tgl", }; const struct sof_intel_dsp_desc ehl_chip_info = { @@ -220,6 +222,7 @@ const struct sof_intel_dsp_desc ehl_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_5, + .platform = "ehl", }; const struct sof_intel_dsp_desc adls_chip_info = { @@ -249,4 +252,5 @@ const struct sof_intel_dsp_desc adls_chip_info = { .power_down_dsp = hda_power_down_dsp, .disable_interrupts = hda_dsp_disable_interrupts, .hw_ip_version = SOF_INTEL_CAVS_2_5, + .platform = "adl", }; From 83b74b2f6e23a7eb1249e3e532b1e655b14bbb08 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 May 2025 19:34:56 +0800 Subject: [PATCH 7/8] ASoC: SOF: Intel: use sof_sdw as default SDW machine driver If there is no SoundWire machine matches the existing acpi match table, get the required machine data from the acpi table and construct the link adrs and endpoints. Pass the data to the default Intel SoundWire machine driver. And we don't need to add new item to the acpi match table in common cases. We will construct a dummy topology name. The dummy topology is just used to extract the platform name for function topology and should not be used. Signed-off-by: Bard Liao --- sound/soc/sof/fw-file-profile.c | 4 + sound/soc/sof/intel/hda.c | 195 +++++++++++++++++++++++++++++++- sound/soc/sof/topology.c | 5 + 3 files changed, 202 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c index 71abd6295ca9f7..0b6d071f1269dc 100644 --- a/sound/soc/sof/fw-file-profile.c +++ b/sound/soc/sof/fw-file-profile.c @@ -73,6 +73,10 @@ static int sof_test_topology_file(struct device *dev, if (!profile->tplg_path || !profile->tplg_name) return 0; + /* Dummy topology does not exist and should not be used */ + if (strstr(profile->tplg_name, "dummy")) + return 0; + tplg_filename = kasprintf(GFP_KERNEL, "%s/%s", profile->tplg_path, profile->tplg_name); if (!tplg_filename) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 52e86fa6007788..ee70ec3cc53cc5 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include "../sof-pci-dev.h" #include "../ops.h" #include "../ipc4-topology.h" +#include "../../intel/common/sof-function-topology-lib.h" #include "hda.h" #include @@ -1131,14 +1133,159 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev, #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) +static bool is_endpoint_present(struct sdw_slave *sdw_device, + struct asoc_sdw_codec_info *dai_info, int dai_type) +{ + int i; + + for (i = 0; i < sdw_device->sdca_data.num_functions; i++) { + if (dai_type == dai_info->dais[i].dai_type) + return true; + } + dev_dbg(&sdw_device->dev, "Endpoint DAI type %d not found\n", dai_type); + return false; +} + +static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev, + struct sdw_slave *sdw_device, + struct snd_soc_acpi_link_adr *link, + int *amp_index) +{ + struct snd_soc_acpi_adr_device *adr_dev; + const char *name_prefix = ""; + int index = link->num_adr; + bool is_amp = true; /* Set it to false if the codec wiah any NON-AMP DAI type */ + int ep_index = 0; + int i, j; + + link->mask = BIT(sdw_device->bus->link_id); + /* index is 0 based, we need allocate index + 1 for the array size */ + if (!index) + adr_dev = devm_kzalloc(dev, sizeof(*adr_dev), GFP_KERNEL); + else + adr_dev = devm_krealloc(dev, (struct snd_soc_acpi_adr_device *)link->adr_d, + (index + 1) * sizeof(*adr_dev), GFP_KERNEL); + + if (!adr_dev) + return NULL; + + for (i = 0; i < asoc_sdw_get_codec_info_list_count(); i++) { + struct snd_soc_acpi_endpoint *endpoints; + int amp_group_id = 1; + + if (sdw_device->id.part_id != codec_info_list[i].part_id) + continue; + + endpoints = devm_kcalloc(dev, codec_info_list[i].dai_num, + sizeof(struct snd_soc_acpi_endpoint), GFP_KERNEL); + if (!endpoints) { + dev_err(dev, "failed to allocate memory for endpoints\n"); + return NULL; + } + + name_prefix = codec_info_list[i].name_prefix; + for (j = 0; j < codec_info_list[i].dai_num; j++) { + /* Check if the endpoint is present by the SDCA DisCo table */ + if (!is_endpoint_present(sdw_device, &codec_info_list[i], + codec_info_list[i].dais[j].dai_type)) + continue; + + endpoints[ep_index].num = ep_index; + if (codec_info_list[i].dais[j].dai_type == SOC_SDW_DAI_TYPE_AMP) { + /* Assume all amp are aggregated */ + endpoints[ep_index].aggregated = 1; + endpoints[ep_index].group_id = amp_group_id; + endpoints[ep_index].group_position = *amp_index; + /* Set group id = 2 for feedback capture endpoint */ + amp_group_id++; + } else { + endpoints[ep_index].aggregated = 0; + endpoints[ep_index].group_id = 0; + endpoints[ep_index].group_position = 0; + is_amp = false; + } + ep_index++; + } + adr_dev[index].endpoints = endpoints; + adr_dev[index].num_endpoints = ep_index; + break; + } + + if (i == asoc_sdw_get_codec_info_list_count()) { + dev_err(dev, "part id %#x is not supported\n", sdw_device->id.part_id); + return NULL; + } + + adr_dev[index].adr = ((u64)sdw_device->id.class_id & 0xFF) | + ((u64)sdw_device->id.part_id & 0xFFFF) << 8 | + ((u64)sdw_device->id.mfg_id & 0xFFFF) << 24 | + ((u64)(sdw_device->id.unique_id & 0xF) << 40) | + ((u64)(sdw_device->id.sdw_version & 0xF) << 44) | + ((u64)(sdw_device->bus->link_id & 0xF) << 48); + + if (!is_amp) { + /* For non-amp codecs, get name_prefix from codec_info_list[] */ + adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s", name_prefix); + goto done_name_prefix; + } + + /* + * The name_prefix comes from codec_info_list which has a name_prefix per codec. + * And we need to give a unique name_prefix for each amp and should be backwards + * compatible to the existing acpi match tables to not break existing UCMs. + * For the common name_prefix, we append the amp index to it. However, for the + * "Left" name_prefix, we convert the second amp name_prefix to "Right" and + * for the third and further amps, we set the name_prefix to "AMP". + */ + if (!strcmp(name_prefix, "Left")) { + switch (*amp_index) { + case 1: + adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, + "%s", "Left"); + break; + case 2: + adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, + "%s", "Right"); + break; + default: + /* Set the name_fix to AMP if there are more than 2 amps */ + adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d", + "AMP", *amp_index); + break; + } + } else { + adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d", + name_prefix, + *amp_index); + } + (*amp_index)++; + +done_name_prefix: + if (!adr_dev[index].name_prefix) { + dev_err(dev, "failed to allocate memory for name_prefix\n"); + return NULL; + } + + dev_dbg(dev, "adr[%d] 0x%llx link id %d name_prefix \"%s\" is found\n", + index, adr_dev[index].adr, sdw_device->bus->link_id, adr_dev[index].name_prefix); + + link->num_adr++; + + return adr_dev; +} + static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) { struct snd_sof_pdata *pdata = sdev->pdata; const struct snd_soc_acpi_link_adr *link; + const struct sof_intel_dsp_desc *chip; + struct snd_soc_acpi_link_adr *links; struct sdw_peripherals *peripherals; struct snd_soc_acpi_mach *mach; struct sof_intel_hda_dev *hdev; - u32 link_mask; + int link_index, link_num; + int amp_index = 1; + u32 link_mask = 0; int i; hdev = pdata->hw_pdata; @@ -1215,7 +1362,50 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev peripherals->array[i]->id.part_id, peripherals->array[i]->id.sdw_version); - return NULL; + chip = get_chip_info(sdev->pdata); + + /* SDCA was not well supported in the BIOS before ACE2.0 */ + if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) + return NULL; + + if (!peripherals->num_peripherals) + return NULL; + + /* Create default SDW mach */ + mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); + if (!mach) + return NULL; + + /* Get link mask and link number */ + for (i = 0; i < peripherals->num_peripherals; i++) + link_mask |= BIT(peripherals->array[i]->bus->link_id); + + link_num = hweight32(link_mask); + links = devm_kcalloc(sdev->dev, link_num, sizeof(*links), GFP_KERNEL); + if (!links) + return NULL; + + /* Generate snd_soc_acpi_link_adr struct for each peripheral reported by the ACPI table */ + for (i = 0; i < peripherals->num_peripherals; i++) { + /* link_index = the number of used links below the current link */ + link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1)); + links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i], + &links[link_index], &_index); + } + + mach->drv_name = "sof_sdw"; + mach->mach_params.links = links; + mach->mach_params.link_mask = link_mask; + mach->mach_params.platform = dev_name(sdev->dev); + mach->get_function_tplg_files = sof_sdw_get_tplg_files; + /* + * Set mach->sof_tplg_filename as a dummy topology to avoid tplg file checking + * and being used. + */ + mach->sof_tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, "sof-%s-dummy.tplg", chip->platform); + + dev_info(sdev->dev, "Use SoundWire default machine driver with function topologies\n"); + return mach; } #else static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) @@ -1543,6 +1733,7 @@ MODULE_IMPORT_NS("SND_SOC_SOF_XTENSA"); MODULE_IMPORT_NS("SND_INTEL_SOUNDWIRE_ACPI"); MODULE_IMPORT_NS("SOUNDWIRE_INTEL_INIT"); MODULE_IMPORT_NS("SOUNDWIRE_INTEL"); +MODULE_IMPORT_NS("SND_SOC_SDW_UTILS"); MODULE_IMPORT_NS("SND_SOC_SOF_HDA_MLINK"); MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_HDA_COMMON"); MODULE_IMPORT_NS("SND_SOC_ACPI_INTEL_MATCH"); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 3404f1306494c2..72cc8983720d05 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2523,6 +2523,11 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) * callback or the callback returns 0. */ if (!tplg_cnt) { + if (strstr(file, "dummy")) { + dev_err(scomp->dev, + "Function topology is required, please upgrade sof-bin\n"); + return -EINVAL; + } tplg_files[0] = file; tplg_cnt = 1; dev_info(scomp->dev, "loading topology: %s\n", file); From 698c6291f4aa388575833c8d50d6e038224b82b2 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 19 Aug 2025 14:39:04 +0800 Subject: [PATCH 8/8] ASoC: sof-function-topology-lib: escalate the log when missing function topoplogy Function topology must be used if the ACPI match table is created based on the reported ACPI table because the monolithic topology is not picked for the audio configuration. Escalate the log and ask the user to download the latest topologies. Signed-off-by: Bard Liao --- sound/soc/intel/common/sof-function-topology-lib.c | 6 +++++- 1 file changed, 5 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 f685c1c5c6f06d..27adbad355940a 100644 --- a/sound/soc/intel/common/sof-function-topology-lib.c +++ b/sound/soc/intel/common/sof-function-topology-lib.c @@ -126,7 +126,11 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_ if (!ret) { release_firmware(fw); } else { - dev_dbg(card->dev, "Failed to open topology file: %s\n", (*tplg_files)[i]); + dev_warn(card->dev, + "Failed to open topology file: %s, you might need to\n", + (*tplg_files)[i]); + dev_warn(card->dev, + "download it from https://github.com/thesofproject/sof-bin/\n"); return 0; } }