@@ -377,7 +377,7 @@ static struct snd_soc_dai_link_component max98357a_component[] = {
static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
int ssp_codec,
int ssp_amp,
- int dmic_num,
+ int dmic_be_num,
int hdmi_num)
{
struct snd_soc_dai_link_component *idisp_components;
@@ -437,20 +437,23 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
id++;
/* dmic */
- for (i = 1; i <= dmic_num; i++) {
- links[id].name = devm_kasprintf(dev, GFP_KERNEL,
- "dmic%02d", i);
- if (!links[id].name)
- goto devm_err;
+ if (dmic_be_num > 0) {
+ /* at least we have dmic01 */
+ links[id].name = "dmic01";
+ links[id].cpus = &cpus[id];
+ links[id].cpus->dai_name = "DMIC01 Pin";
+ if (dmic_be_num > 1) {
+ /* set up 2 BE links at most */
+ links[id + 1].name = "dmic16k";
+ links[id + 1].cpus = &cpus[id + 1];
+ links[id + 1].cpus->dai_name = "DMIC16k Pin";
+ dmic_be_num = 2;
+ }
+ }
+ for (i = 0; i < dmic_be_num; i++) {
links[id].id = id;
- links[id].cpus = &cpus[id];
links[id].num_cpus = 1;
- links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
- "DMIC%02d Pin", i);
- if (!links[id].cpus->dai_name)
- goto devm_err;
-
links[id].codecs = dmic_component;
links[id].num_codecs = ARRAY_SIZE(dmic_component);
links[id].platforms = platform_component;
@@ -545,7 +548,7 @@ static int sof_audio_probe(struct platform_device *pdev)
struct snd_soc_dai_link *dai_links;
struct snd_soc_acpi_mach *mach;
struct sof_card_private *ctx;
- int dmic_num, hdmi_num;
+ int dmic_be_num, hdmi_num;
int ret, ssp_amp, ssp_codec;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
@@ -554,14 +557,14 @@ static int sof_audio_probe(struct platform_device *pdev)
if (soc_intel_is_byt() || soc_intel_is_cht()) {
is_legacy_cpu = 1;
- dmic_num = 0;
+ dmic_be_num = 0;
hdmi_num = 0;
/* default quirk for legacy cpu */
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
SOF_RT5682_MCLK_BYTCHT_EN |
SOF_RT5682_SSP_CODEC(2);
} else {
- dmic_num = 1;
+ dmic_be_num = 2;
hdmi_num = 3;
}
@@ -586,13 +589,13 @@ static int sof_audio_probe(struct platform_device *pdev)
ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK;
/* compute number of dai links */
- sof_audio_card_rt5682.num_links = 1 + dmic_num + hdmi_num;
+ sof_audio_card_rt5682.num_links = 1 + dmic_be_num + hdmi_num;
if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT)
sof_audio_card_rt5682.num_links++;
dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
- dmic_num, hdmi_num);
+ dmic_be_num, hdmi_num);
if (!dai_links)
return -ENOMEM;