Skip to content

Commit d8c01d5

Browse files
brentluplbossart
authored andcommitted
ASoC: Intel: sof_nau8825: use common module for DMIC links
Use intel_board module for dmic01 and dmic16k DAI link initialization. Signed-off-by: Brent Lu <brent.lu@intel.com>
1 parent be191aa commit d8c01d5

1 file changed

Lines changed: 17 additions & 64 deletions

File tree

sound/soc/intel/boards/sof_nau8825.c

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
177177
SND_SOC_DAPM_SPK("Right Spk", NULL),
178178
};
179179

180-
static const struct snd_soc_dapm_widget dmic_widgets[] = {
181-
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
182-
};
183-
184180
static const struct snd_soc_dapm_route sof_map[] = {
185181
/* HP jack connectors - unknown if we have jack detection */
186182
{ "Headphone Jack", NULL, "HPOL" },
@@ -190,33 +186,6 @@ static const struct snd_soc_dapm_route sof_map[] = {
190186
{ "MIC", NULL, "Headset Mic" },
191187
};
192188

193-
static const struct snd_soc_dapm_route dmic_map[] = {
194-
/* digital mics */
195-
{"DMic", NULL, "SoC DMIC"},
196-
};
197-
198-
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
199-
{
200-
struct snd_soc_card *card = rtd->card;
201-
int ret;
202-
203-
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
204-
ARRAY_SIZE(dmic_widgets));
205-
if (ret) {
206-
dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
207-
/* Don't need to add routes if widget addition failed */
208-
return ret;
209-
}
210-
211-
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
212-
ARRAY_SIZE(dmic_map));
213-
214-
if (ret)
215-
dev_err(card->dev, "DMic map addition failed: %d\n", ret);
216-
217-
return ret;
218-
}
219-
220189
/* sof audio machine driver for nau8825 codec */
221190
static struct snd_soc_card sof_audio_card_nau8825 = {
222191
.name = "nau8825", /* the sof- prefix is added by the core */
@@ -238,13 +207,6 @@ static struct snd_soc_dai_link_component nau8825_component[] = {
238207
}
239208
};
240209

241-
static struct snd_soc_dai_link_component dmic_component[] = {
242-
{
243-
.name = "dmic-codec",
244-
.dai_name = "dmic-hifi",
245-
}
246-
};
247-
248210
static struct snd_soc_dai_link *
249211
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
250212
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,
294256
/* dmic */
295257
if (dmic_be_num > 0) {
296258
/* at least we have dmic01 */
297-
links[id].name = "dmic01";
298-
links[id].cpus = &cpus[id];
299-
links[id].cpus->dai_name = "DMIC01 Pin";
300-
links[id].init = dmic_init;
301-
if (dmic_be_num > 1) {
302-
/* set up 2 BE links at most */
303-
links[id + 1].name = "dmic16k";
304-
links[id + 1].cpus = &cpus[id + 1];
305-
links[id + 1].cpus->dai_name = "DMIC16k Pin";
306-
dmic_be_num = 2;
307-
}
259+
ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
260+
SOF_DMIC_01);
261+
if (ret)
262+
return NULL;
263+
264+
id++;
308265
}
309266

310-
for (i = 0; i < dmic_be_num; i++) {
311-
links[id].id = id;
312-
links[id].num_cpus = 1;
313-
links[id].codecs = dmic_component;
314-
links[id].num_codecs = ARRAY_SIZE(dmic_component);
315-
links[id].platforms = platform_component;
316-
links[id].num_platforms = ARRAY_SIZE(platform_component);
317-
links[id].ignore_suspend = 1;
318-
links[id].dpcm_capture = 1;
319-
links[id].no_pcm = 1;
267+
if (dmic_be_num > 1) {
268+
/* set up 2 BE links at most */
269+
ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
270+
SOF_DMIC_16K);
271+
if (ret)
272+
return NULL;
273+
320274
id++;
321275
}
322276

@@ -414,7 +368,6 @@ static int sof_audio_probe(struct platform_device *pdev)
414368
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
415369
struct snd_soc_dai_link *dai_links;
416370
struct sof_card_private *ctx;
417-
int dmic_be_num;
418371
int ret, ssp_amp, ssp_codec;
419372

420373
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -430,7 +383,7 @@ static int sof_audio_probe(struct platform_device *pdev)
430383
dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk);
431384

432385
/* default number of DMIC DAI's */
433-
dmic_be_num = 2;
386+
ctx->dmic_be_num = 2;
434387
ctx->hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >>
435388
SOF_NAU8825_NUM_HDMIDEV_SHIFT;
436389
/* default number of HDMI DAI's */
@@ -446,7 +399,7 @@ static int sof_audio_probe(struct platform_device *pdev)
446399
ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK;
447400

448401
/* compute number of dai links */
449-
sof_audio_card_nau8825.num_links = 1 + dmic_be_num + ctx->hdmi_num;
402+
sof_audio_card_nau8825.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num;
450403

451404
if (ctx->amp_type != CODEC_NONE)
452405
sof_audio_card_nau8825.num_links++;
@@ -455,8 +408,8 @@ static int sof_audio_probe(struct platform_device *pdev)
455408
sof_audio_card_nau8825.num_links++;
456409

457410
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
458-
ssp_codec, ssp_amp, dmic_be_num,
459-
ctx->hdmi_num,
411+
ssp_codec, ssp_amp,
412+
ctx->dmic_be_num, ctx->hdmi_num,
460413
ctx->hdmi.idisp_codec);
461414
if (!dai_links)
462415
return -ENOMEM;

0 commit comments

Comments
 (0)