Skip to content

Commit c8f3c9f

Browse files
ujfalusibroonie
authored andcommitted
ASoC: soc-acpi / SOF: Add best_effort flag to get_function_tplg_files op
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>
1 parent 8f0b4cc commit c8f3c9f

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

include/sound/soc-acpi.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ struct snd_soc_acpi_link_adr {
203203
* @mach: the pointer of the machine driver
204204
* @prefix: the prefix of the topology file name. Typically, it is the path.
205205
* @tplg_files: the pointer of the array of the topology file names.
206+
* @best_effort: ignore non supported links and try to build the card in best effort
207+
* with supported links
206208
*/
207209
/* Descriptor for SST ASoC machine driver */
208210
struct snd_soc_acpi_mach {
@@ -224,7 +226,8 @@ struct snd_soc_acpi_mach {
224226
const u32 tplg_quirk_mask;
225227
int (*get_function_tplg_files)(struct snd_soc_card *card,
226228
const struct snd_soc_acpi_mach *mach,
227-
const char *prefix, const char ***tplg_files);
229+
const char *prefix, const char ***tplg_files,
230+
bool best_effort);
228231
};
229232

230233
#define SND_SOC_ACPI_MAX_CODECS 3

sound/soc/intel/common/sof-function-topology-lib.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum tplg_device_id {
2828
#define SOF_INTEL_PLATFORM_NAME_MAX 4
2929

3030
int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
31-
const char *prefix, const char ***tplg_files)
31+
const char *prefix, const char ***tplg_files, bool best_effort)
3232
{
3333
struct snd_soc_acpi_mach_params mach_params = mach->mach_params;
3434
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_
8787
dev_dbg(card->dev,
8888
"dai_link %s is not supported by separated tplg yet\n",
8989
dai_link->name);
90+
if (best_effort)
91+
continue;
92+
9093
return 0;
9194
}
9295
if (tplg_mask & BIT(tplg_dev))

sound/soc/intel/common/sof-function-topology-lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
#define _SND_SOC_ACPI_INTEL_GET_TPLG_H
1111

1212
int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
13-
const char *prefix, const char ***tplg_files);
13+
const char *prefix, const char ***tplg_files, bool best_effort);
1414

1515
#endif

sound/soc/sof/topology.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,12 +2506,28 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
25062506
if (!tplg_files)
25072507
return -ENOMEM;
25082508

2509+
/* Try to use function topologies if possible */
25092510
if (!sof_pdata->disable_function_topology && !disable_function_topology &&
25102511
sof_pdata->machine && sof_pdata->machine->get_function_tplg_files) {
2512+
/*
2513+
* When the topology name contains 'dummy' word, it means that
2514+
* there is no fallback option to monolithic topology in case
2515+
* any of the function topologies might be missing.
2516+
* In this case we should use best effort to form the card,
2517+
* ignoring functionalities that we are missing a fragment for.
2518+
*
2519+
* Note: monolithic topologies also ignore these possibly
2520+
* missing functions, so the functionality of the card would be
2521+
* identical to the case if there would be a fallback monolithic
2522+
* topology created for the configuration.
2523+
*/
2524+
bool no_fallback = strstr(file, "dummy");
2525+
25112526
tplg_cnt = sof_pdata->machine->get_function_tplg_files(scomp->card,
25122527
sof_pdata->machine,
25132528
tplg_filename_prefix,
2514-
&tplg_files);
2529+
&tplg_files,
2530+
no_fallback);
25152531
if (tplg_cnt < 0) {
25162532
kfree(tplg_files);
25172533
return tplg_cnt;

0 commit comments

Comments
 (0)