Skip to content

Commit 7d0d493

Browse files
bardliaolgirdwood
authored andcommitted
ASoC: Intel: sof-function-topology-lib: add I2S support for sof_sdw_get_tplg_files
The Intel SOF SDW machine drive also supports I2S interface. Add related supports for the sof_sdw_get_tplg_files() callback. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 74ece9d commit 7d0d493

1 file changed

Lines changed: 61 additions & 1 deletion

File tree

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

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ enum tplg_device_id {
1919
TPLG_DEVICE_SDCA_MIC,
2020
TPLG_DEVICE_INTEL_PCH_DMIC,
2121
TPLG_DEVICE_HDMI,
22+
TPLG_DEVICE_SSP_JACK,
23+
TPLG_DEVICE_SSP_AMP,
24+
TPLG_DEVICE_SSP_BT,
25+
TPLG_DEVICE_SSP_HDMI_IN,
2226
TPLG_DEVICE_LOOPBACK_VIRTUAL,
2327
TPLG_DEVICE_MAX
2428
};
@@ -71,11 +75,15 @@ static char *get_tplg_filename(struct device *dev, const char *prefix,
7175

7276
/*
7377
* The tplg file naming rule is sof-<platform>-<function>-id<BE id number>.tplg
74-
* where <platform> is only required for the devices that need NHLT blob like DMIC
78+
* where <platform> is required for functions that depend on NHLT blobs (e.g. DMIC/SSP)
7579
* as the nhlt blob is platform dependent.
7680
*/
7781
switch (tplg_dev) {
7882
case TPLG_DEVICE_INTEL_PCH_DMIC:
83+
case TPLG_DEVICE_SSP_JACK:
84+
case TPLG_DEVICE_SSP_AMP:
85+
case TPLG_DEVICE_SSP_BT:
86+
case TPLG_DEVICE_SSP_HDMI_IN:
7987
filename = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-%s-%s-id%d.tplg",
8088
prefix, platform, tplg_dev_name, dai_link_id);
8189
break;
@@ -109,6 +117,53 @@ static int get_dmic_tplg_dev(struct device *dev, int dmic_num,
109117
return 0;
110118
}
111119

120+
static int get_ssp_tplg_dev(struct device *dev, struct snd_soc_dai_link *dai_link,
121+
u16 *hdmi_in_mask, int *tplg_dev, char **tplg_dev_name)
122+
{
123+
unsigned int ssp_port;
124+
125+
if (sscanf(dai_link->name, "SSP%d", &ssp_port) != 1) {
126+
dev_err(dev, "Can't get SSP port from dai_link->name %s\n", dai_link->name);
127+
return -EINVAL;
128+
}
129+
if (strstr(dai_link->name, "Codec")) {
130+
/*
131+
* Assume DAI link 0 is jack which is true in all existing
132+
* machine drivers
133+
*/
134+
if (dai_link->id == 0) {
135+
*tplg_dev = TPLG_DEVICE_SSP_JACK;
136+
*tplg_dev_name = devm_kasprintf(dev, GFP_KERNEL,
137+
"ssp%d-jack", ssp_port);
138+
} else {
139+
*tplg_dev = TPLG_DEVICE_SSP_AMP;
140+
*tplg_dev_name = devm_kasprintf(dev, GFP_KERNEL,
141+
"ssp%d-amp", ssp_port);
142+
}
143+
} else if (strstr(dai_link->name, "BT")) {
144+
*tplg_dev = TPLG_DEVICE_SSP_BT;
145+
*tplg_dev_name = devm_kasprintf(dev, GFP_KERNEL,
146+
"ssp%d-bt", ssp_port);
147+
} else if (strstr(dai_link->name, "HDMI")) {
148+
*hdmi_in_mask |= BIT(ssp_port);
149+
/* The number of HDMI in dai link is always 2 right now */
150+
if (hweight16(*hdmi_in_mask) != 2)
151+
return -EINVAL;
152+
153+
*tplg_dev = TPLG_DEVICE_SSP_HDMI_IN;
154+
*tplg_dev_name = devm_kasprintf(dev, GFP_KERNEL,
155+
"ssp%x-hdmiin", *hdmi_in_mask);
156+
} else {
157+
dev_warn(dev,
158+
"unsupported SSP link %s\n", dai_link->name);
159+
return -EINVAL;
160+
}
161+
if (!*tplg_dev_name)
162+
return -ENOMEM;
163+
164+
return 0;
165+
}
166+
112167
int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_mach *mach,
113168
const char *prefix, const char ***tplg_files, bool best_effort)
114169
{
@@ -121,6 +176,7 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
121176
struct snd_soc_dai_link *dai_link;
122177
char platform[SOF_INTEL_PLATFORM_NAME_MAX];
123178
unsigned long tplg_mask = 0;
179+
u16 hdmi_in_mask = 0;
124180
int tplg_num = 0;
125181
char *tplg_file;
126182
int tplg_dev;
@@ -154,6 +210,10 @@ int sof_sdw_get_tplg_files(struct snd_soc_card *card, const struct snd_soc_acpi_
154210
} else if (strstr(dai_link->name, "iDisp")) {
155211
tplg_dev = TPLG_DEVICE_HDMI;
156212
tplg_dev_name = "hdmi-pcm5";
213+
} else if (strstr(dai_link->name, "SSP")) {
214+
if (get_ssp_tplg_dev(card->dev, dai_link, &hdmi_in_mask,
215+
&tplg_dev, &tplg_dev_name) < 0)
216+
continue;
157217
} else if (strstr(dai_link->name, "Loopback_Virtual")) {
158218
tplg_dev = TPLG_DEVICE_LOOPBACK_VIRTUAL;
159219
/*

0 commit comments

Comments
 (0)