Skip to content

Commit 2e1f8b2

Browse files
committed
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 4e064c4 commit 2e1f8b2

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

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

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