Commit f56daafc authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: sof_nau8825: use common module for DMIC links

Use intel_board module for dmic01 and dmic16k DAI link initialization.
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20231019173411.166759-9-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a1360c45
...@@ -177,10 +177,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = { ...@@ -177,10 +177,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
SND_SOC_DAPM_SPK("Right Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL),
}; };
static const struct snd_soc_dapm_widget dmic_widgets[] = {
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
};
static const struct snd_soc_dapm_route sof_map[] = { static const struct snd_soc_dapm_route sof_map[] = {
/* HP jack connectors - unknown if we have jack detection */ /* HP jack connectors - unknown if we have jack detection */
{ "Headphone Jack", NULL, "HPOL" }, { "Headphone Jack", NULL, "HPOL" },
...@@ -190,33 +186,6 @@ static const struct snd_soc_dapm_route sof_map[] = { ...@@ -190,33 +186,6 @@ static const struct snd_soc_dapm_route sof_map[] = {
{ "MIC", NULL, "Headset Mic" }, { "MIC", NULL, "Headset Mic" },
}; };
static const struct snd_soc_dapm_route dmic_map[] = {
/* digital mics */
{"DMic", NULL, "SoC DMIC"},
};
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
int ret;
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
ARRAY_SIZE(dmic_widgets));
if (ret) {
dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
/* Don't need to add routes if widget addition failed */
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
ARRAY_SIZE(dmic_map));
if (ret)
dev_err(card->dev, "DMic map addition failed: %d\n", ret);
return ret;
}
/* sof audio machine driver for nau8825 codec */ /* sof audio machine driver for nau8825 codec */
static struct snd_soc_card sof_audio_card_nau8825 = { static struct snd_soc_card sof_audio_card_nau8825 = {
.name = "nau8825", /* the sof- prefix is added by the core */ .name = "nau8825", /* the sof- prefix is added by the core */
...@@ -238,13 +207,6 @@ static struct snd_soc_dai_link_component nau8825_component[] = { ...@@ -238,13 +207,6 @@ static struct snd_soc_dai_link_component nau8825_component[] = {
} }
}; };
static struct snd_soc_dai_link_component dmic_component[] = {
{
.name = "dmic-codec",
.dai_name = "dmic-hifi",
}
};
static struct snd_soc_dai_link * static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ssp_codec, int ssp_amp, int dmic_be_num, int ssp_codec, int ssp_amp, int dmic_be_num,
...@@ -294,29 +256,21 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -294,29 +256,21 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
/* dmic */ /* dmic */
if (dmic_be_num > 0) { if (dmic_be_num > 0) {
/* at least we have dmic01 */ /* at least we have dmic01 */
links[id].name = "dmic01"; ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
links[id].cpus = &cpus[id]; SOF_DMIC_01);
links[id].cpus->dai_name = "DMIC01 Pin"; if (ret)
links[id].init = dmic_init; return NULL;
id++;
}
if (dmic_be_num > 1) { if (dmic_be_num > 1) {
/* set up 2 BE links at most */ /* set up 2 BE links at most */
links[id + 1].name = "dmic16k"; ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
links[id + 1].cpus = &cpus[id + 1]; SOF_DMIC_16K);
links[id + 1].cpus->dai_name = "DMIC16k Pin"; if (ret)
dmic_be_num = 2; return NULL;
}
}
for (i = 0; i < dmic_be_num; i++) {
links[id].id = id;
links[id].num_cpus = 1;
links[id].codecs = dmic_component;
links[id].num_codecs = ARRAY_SIZE(dmic_component);
links[id].platforms = platform_component;
links[id].num_platforms = ARRAY_SIZE(platform_component);
links[id].ignore_suspend = 1;
links[id].dpcm_capture = 1;
links[id].no_pcm = 1;
id++; id++;
} }
...@@ -414,7 +368,6 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -414,7 +368,6 @@ static int sof_audio_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
struct sof_card_private *ctx; struct sof_card_private *ctx;
int dmic_be_num;
int ret, ssp_amp, ssp_codec; int ret, ssp_amp, ssp_codec;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
...@@ -430,7 +383,7 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -430,7 +383,7 @@ static int sof_audio_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk); dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk);
/* default number of DMIC DAI's */ /* default number of DMIC DAI's */
dmic_be_num = 2; ctx->dmic_be_num = 2;
ctx->hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >> ctx->hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >>
SOF_NAU8825_NUM_HDMIDEV_SHIFT; SOF_NAU8825_NUM_HDMIDEV_SHIFT;
/* default number of HDMI DAI's */ /* default number of HDMI DAI's */
...@@ -446,7 +399,7 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -446,7 +399,7 @@ static int sof_audio_probe(struct platform_device *pdev)
ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK; ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK;
/* compute number of dai links */ /* compute number of dai links */
sof_audio_card_nau8825.num_links = 1 + dmic_be_num + ctx->hdmi_num; sof_audio_card_nau8825.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num;
if (ctx->amp_type != CODEC_NONE) if (ctx->amp_type != CODEC_NONE)
sof_audio_card_nau8825.num_links++; sof_audio_card_nau8825.num_links++;
...@@ -455,8 +408,8 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -455,8 +408,8 @@ static int sof_audio_probe(struct platform_device *pdev)
sof_audio_card_nau8825.num_links++; sof_audio_card_nau8825.num_links++;
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
ssp_codec, ssp_amp, dmic_be_num, ssp_codec, ssp_amp,
ctx->hdmi_num, ctx->dmic_be_num, ctx->hdmi_num,
ctx->hdmi.idisp_codec); ctx->hdmi.idisp_codec);
if (!dai_links) if (!dai_links)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment