Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/sound/soc-acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
* @subsystem_id_set: true if a value has been written to
* subsystem_vendor and subsystem_device.
* @bt_link_mask: BT offload link enabled on the board
* @tplg_platform: platform name used in the function topology file names,
* when it can't be taken from the topology file name
*/
struct snd_soc_acpi_mach_params {
u32 acpi_ipc_irq_index;
Expand All @@ -90,6 +92,7 @@ struct snd_soc_acpi_mach_params {
unsigned short subsystem_rev;
bool subsystem_id_set;
u32 bt_link_mask;
const char *tplg_platform;
};

/**
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/intel/common/soc-acpi-intel-hda-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

#include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h>
#include "sof-function-topology-lib.h"

struct snd_soc_acpi_mach snd_soc_acpi_intel_hda_machines[] = {
{
/* .id is not used in this file */
.drv_name = "skl_hda_dsp_generic",
.sof_tplg_filename = "sof-hda-generic", /* the tplg suffix is added at run time */
.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
.get_function_tplg_files = sof_hda_get_tplg_files,
},
{},
};
Expand Down
109 changes: 109 additions & 0 deletions sound/soc/intel/common/sof-function-topology-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/firmware.h>
#include <linux/string.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "sof-function-topology-lib.h"
Expand All @@ -24,6 +25,7 @@ enum tplg_device_id {
TPLG_DEVICE_SSP_BT,
TPLG_DEVICE_SSP_HDMI_IN,
TPLG_DEVICE_LOOPBACK_VIRTUAL,
TPLG_DEVICE_HDA,
TPLG_DEVICE_MAX
};

Expand All @@ -37,6 +39,12 @@ static int get_platform_name(struct snd_soc_card *card,
{
int ret;

if (mach->mach_params.tplg_platform) {
strscpy(platform, mach->mach_params.tplg_platform,
SOF_INTEL_PLATFORM_NAME_MAX);
return 0;
}

ret = sscanf(mach->sof_tplg_filename, "sof-%3s-*.tplg", platform);
if (ret != 1) {
dev_err(card->dev, "Invalid platform name of tplg %s\n",
Expand Down Expand Up @@ -332,3 +340,104 @@ int sof_i2s_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
return tplg_num;
}
EXPORT_SYMBOL_GPL(sof_i2s_get_tplg_files);

/*
* The dai links are created by the skl_hda_dsp_generic machine driver:
* iDisp<n> - HDMI
* Analog Playback and Capture - HDA analog codec
* Digital Playback and Capture - HDA digital codec
* dmic01/dmic16k - PCH DMIC
* SSP<n>-BT - BT offload

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How HDMI-IN and UAOL can be added here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HDMI-IN is already supported by get_ssp_tplg_dev(). Regarding UAOL, we need to add a new tplg_device_id and add a else if (strstr(dai_link->name, "<UAOL link name>")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this:
63c7689

and will work on hda as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this: 63c7689

and will work on hda as well?

It only works for SDW, but the same approach will work on HDA, too.

* SSP<n>-HDMI - HDMI IN, two links in one tplg
*/
int sof_hda_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
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;
char platform[SOF_INTEL_PLATFORM_NAME_MAX];
unsigned long tplg_mask = 0;
u16 hdmi_in_mask = 0;
int tplg_num = 0;
char *tplg_file;
int tplg_dev;
int ret;
int i;

ret = get_platform_name(card, mach, platform);
if (ret < 0)
return ret;

for_each_card_prelinks(card, i, dai_link) {
char *tplg_dev_name;

dev_dbg(card->dev, "dai_link %s id %d\n", dai_link->name, dai_link->id);
if (strstr(dai_link->name, "iDisp")) {
tplg_dev = TPLG_DEVICE_HDMI;
tplg_dev_name = "hdmi-pcm3";
} else if (!strcmp(dai_link->name, "Analog Playback and Capture") ||
!strcmp(dai_link->name, "Digital Playback and Capture")) {
/*
* The analog and digital dai links share one tplg, named
* after the id of the first one, the analog dai link.
*/
tplg_dev = TPLG_DEVICE_HDA;
tplg_dev_name = "hda";
} else if (strstr(dai_link->name, "dmic")) {
/*
* The machine driver creates the DMIC dai links even
* if there is no DMIC, no tplg is needed for them.
*/
if (!mach_params.dmic_num)
continue;

if (get_dmic_tplg_dev(card->dev, mach_params.dmic_num,
&tplg_dev, &tplg_dev_name) < 0) {
/* no function topology for this number of dmics */
if (best_effort)
continue;

return 0;
}
} else if (strstr(dai_link->name, "SSP")) {
if (get_ssp_tplg_dev(card->dev, dai_link, &hdmi_in_mask,
&tplg_dev, &tplg_dev_name) < 0)
continue;
Comment on lines +403 to +405
} else {
/* The dai link is not supported by separated tplg yet */
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))
continue;

tplg_file = get_tplg_filename(card->dev, prefix, platform, tplg_dev_name,
dai_link->id, tplg_dev);
if (!tplg_file)
return -ENOMEM;

/* Check presence of sub-topologies */
if (!tplg_files_exist(card->dev, tplg_file)) {
devm_kfree(card->dev, tplg_file);
if (best_effort)
continue;

return 0;
}

tplg_mask |= BIT(tplg_dev);

(*tplg_files)[tplg_num] = tplg_file;
tplg_num++;
}

dev_dbg(card->dev, "tplg_mask %#lx tplg_num %d\n", tplg_mask, tplg_num);

return tplg_num;
}
EXPORT_SYMBOL_GPL(sof_hda_get_tplg_files);
3 changes: 3 additions & 0 deletions sound/soc/intel/common/sof-function-topology-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
int sof_i2s_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
const char *prefix, const char ***tplg_files, bool best_effort);

int sof_hda_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
const char *prefix, const char ***tplg_files, bool best_effort);

#endif
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
struct snd_soc_acpi_mach_params *mach_params;
struct snd_soc_acpi_mach *hda_mach;
struct snd_sof_pdata *pdata = sdev->pdata;
const struct sof_intel_dsp_desc *chip = get_chip_info(pdata);
const char *tplg_filename;
int codec_num = 0;
int i;
Expand Down Expand Up @@ -1092,6 +1093,14 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,
dev_info(bus->dev, "using HDA machine driver %s now\n",
hda_mach->drv_name);

/*
* The platform name is needed to form the function topology
* file names, but sof_tplg_filename of the match table is
* platform independent and is kept for the monolithic
* topology fallback.
*/
hda_mach->mach_params.tplg_platform = chip->platform;

/*
* topology: use the info from hda_machines since tplg file name
* is not overwritten
Expand Down
Loading