Skip to content

Commit f46c3d3

Browse files
bardliaolgirdwood
authored andcommitted
ASoC: Intel: sof-function-topology-lib: add get_function_topology for I2S machines
Add sof_i2s_get_tplg_files() callback for Intel SOF I2S machines. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 7d0d493 commit f46c3d3

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,75 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
261261
return tplg_num;
262262
}
263263
EXPORT_SYMBOL_GPL(sof_sdw_get_tplg_files);
264+
265+
int sof_i2s_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
266+
const char *prefix, const char ***tplg_files, bool best_effort)
267+
{
268+
struct snd_soc_acpi_mach_params mach_params = mach->mach_params;
269+
struct snd_soc_dai_link *dai_link;
270+
char platform[SOF_INTEL_PLATFORM_NAME_MAX];
271+
unsigned long tplg_mask = 0;
272+
u16 hdmi_in_mask = 0;
273+
int tplg_num = 0;
274+
char *tplg_file;
275+
int tplg_dev;
276+
int ret;
277+
int i;
278+
279+
ret = get_platform_name(card, mach, platform);
280+
if (ret < 0)
281+
return ret;
282+
283+
for_each_card_prelinks(card, i, dai_link) {
284+
char *tplg_dev_name;
285+
286+
dev_dbg(card->dev, "dai_link %s id %d\n", dai_link->name, dai_link->id);
287+
if (strstr(dai_link->name, "SSP")) {
288+
if (get_ssp_tplg_dev(card->dev, dai_link, &hdmi_in_mask,
289+
&tplg_dev, &tplg_dev_name) < 0)
290+
continue;
291+
} else if (strstr(dai_link->name, "dmic")) {
292+
if (get_dmic_tplg_dev(card->dev, mach_params.dmic_num,
293+
&tplg_dev, &tplg_dev_name) < 0)
294+
continue;
295+
} else if (strstr(dai_link->name, "iDisp")) {
296+
tplg_dev = TPLG_DEVICE_HDMI;
297+
tplg_dev_name = "hdmi-pcm5";
298+
} else {
299+
/* The dai link is not supported by separated tplg yet */
300+
dev_dbg(card->dev,
301+
"dai_link %s is not supported by separated tplg yet\n",
302+
dai_link->name);
303+
if (best_effort)
304+
continue;
305+
306+
return 0;
307+
}
308+
if (tplg_mask & BIT(tplg_dev))
309+
continue;
310+
311+
tplg_file = get_tplg_filename(card->dev, prefix, platform, tplg_dev_name,
312+
dai_link->id, tplg_dev);
313+
if (!tplg_file)
314+
return -ENOMEM;
315+
316+
/* Check presence of sub-topologies */
317+
if (!tplg_files_exist(card->dev, tplg_file)) {
318+
devm_kfree(card->dev, tplg_file);
319+
if (best_effort)
320+
continue;
321+
322+
return 0;
323+
}
324+
325+
tplg_mask |= BIT(tplg_dev);
326+
327+
(*tplg_files)[tplg_num] = tplg_file;
328+
tplg_num++;
329+
}
330+
331+
dev_dbg(card->dev, "tplg_mask %#lx tplg_num %d\n", tplg_mask, tplg_num);
332+
333+
return tplg_num;
334+
}
335+
EXPORT_SYMBOL_GPL(sof_i2s_get_tplg_files);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
1313
const char *prefix, const char ***tplg_files, bool best_effort);
1414

15+
int sof_i2s_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
16+
const char *prefix, const char ***tplg_files, bool best_effort);
17+
1518
#endif

0 commit comments

Comments
 (0)