]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: soc-acpi / SOF: Add best_effort flag to get_function_tplg_files op
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Mon, 15 Dec 2025 10:10:35 +0000 (12:10 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 15 Dec 2025 14:08:35 +0000 (23:08 +0900)
When there is no fallback possibility available for the function topology
use it is better to try to create  a profile for the card in best effort
manner, leaving out non supported links for example.

As an example: some laptops present SSPx-BT link but we don't have fragment
yet to support this. If we only have support for functional topology
without monolithic fallback then we would fail the card creation.
The reason why the monolithic topology works on the same device is that it
does not have the SSPx-BT link handled, it is ignored.

In case when there is no fallback possibility we should try to create the
card with links that we support as best effort instead of failing and
leaving the user without a card.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://patch.msgid.link/20251215101036.9370-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-acpi.h
sound/soc/intel/common/sof-function-topology-lib.c
sound/soc/intel/common/sof-function-topology-lib.h
sound/soc/sof/topology.c

index 90d73b9bddabeef5f179c8f5794f272df28f6d4b..0519afd7217f13586be9c3f3c5196a7b84d30ea2 100644 (file)
@@ -203,6 +203,8 @@ struct snd_soc_acpi_link_adr {
  *     @mach: the pointer of the machine driver
  *     @prefix: the prefix of the topology file name. Typically, it is the path.
  *     @tplg_files: the pointer of the array of the topology file names.
+ *     @best_effort: ignore non supported links and try to build the card in best effort
+ *                   with supported links
  */
 /* Descriptor for SST ASoC machine driver */
 struct snd_soc_acpi_mach {
@@ -224,7 +226,8 @@ struct snd_soc_acpi_mach {
        const u32 tplg_quirk_mask;
        int (*get_function_tplg_files)(struct snd_soc_card *card,
                                       const struct snd_soc_acpi_mach *mach,
-                                      const char *prefix, const char ***tplg_files);
+                                      const char *prefix, const char ***tplg_files,
+                                      bool best_effort);
 };
 
 #define SND_SOC_ACPI_MAX_CODECS 3
index b10d4794159a48abf1b69db1cf684b62d5761fbd..0daa7d83808be67972bec6d4ba83515af3bbef51 100644 (file)
@@ -28,7 +28,7 @@ enum tplg_device_id {
 #define SOF_INTEL_PLATFORM_NAME_MAX 4
 
 int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
-                          const char *prefix, const char ***tplg_files)
+                          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;
@@ -87,6 +87,9 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
                        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))
index e7d0c39d07883c11877215af679307533bfc0ee7..f358f8c52d7854f5e7fb849fed5f9e376ad3607b 100644 (file)
@@ -10,6 +10,6 @@
 #define _SND_SOC_ACPI_INTEL_GET_TPLG_H
 
 int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
-                          const char *prefix, const char ***tplg_files);
+                          const char *prefix, const char ***tplg_files, bool best_effort);
 
 #endif
index c1083ea4624ad74b96d866b33a3ef193a010f036..c76545e70860ed90726ab2c992b79e4e2e8585f7 100644 (file)
@@ -2506,12 +2506,28 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
        if (!tplg_files)
                return -ENOMEM;
 
+       /* Try to use function topologies if possible */
        if (!sof_pdata->disable_function_topology && !disable_function_topology &&
            sof_pdata->machine && sof_pdata->machine->get_function_tplg_files) {
+               /*
+                * When the topology name contains 'dummy' word, it means that
+                * there is no fallback option to monolithic topology in case
+                * any of the function topologies might be missing.
+                * In this case we should use best effort to form the card,
+                * ignoring functionalities that we are missing a fragment for.
+                *
+                * Note: monolithic topologies also ignore these possibly
+                * missing functions, so the functionality of the card would be
+                * identical to the case if there would be a fallback monolithic
+                * topology created for the configuration.
+                */
+               bool no_fallback = strstr(file, "dummy");
+
                tplg_cnt = sof_pdata->machine->get_function_tplg_files(scomp->card,
                                                                       sof_pdata->machine,
                                                                       tplg_filename_prefix,
-                                                                      &tplg_files);
+                                                                      &tplg_files,
+                                                                      no_fallback);
                if (tplg_cnt < 0) {
                        kfree(tplg_files);
                        return tplg_cnt;