Skip to content

Commit ec7cc1e

Browse files
brentluplbossart
authored andcommitted
ASoC: Intel: sof_rt5682: 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 d8c01d5 commit ec7cc1e

1 file changed

Lines changed: 17 additions & 64 deletions

File tree

sound/soc/intel/boards/sof_rt5682.c

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

506-
static const struct snd_soc_dapm_widget dmic_widgets[] = {
507-
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
508-
};
509-
510506
static const struct snd_soc_dapm_route sof_map[] = {
511507
/* HP jack connectors - unknown if we have jack detection */
512508
{ "Headphone Jack", NULL, "HPOL" },
@@ -522,11 +518,6 @@ static const struct snd_soc_dapm_route rt5650_spk_dapm_routes[] = {
522518
{ "Right Spk", NULL, "SPOR" },
523519
};
524520

525-
static const struct snd_soc_dapm_route dmic_map[] = {
526-
/* digital mics */
527-
{"DMic", NULL, "SoC DMIC"},
528-
};
529-
530521
static int rt5650_spk_init(struct snd_soc_pcm_runtime *rtd)
531522
{
532523
struct snd_soc_card *card = rtd->card;
@@ -540,28 +531,6 @@ static int rt5650_spk_init(struct snd_soc_pcm_runtime *rtd)
540531
return ret;
541532
}
542533

543-
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
544-
{
545-
struct snd_soc_card *card = rtd->card;
546-
int ret;
547-
548-
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
549-
ARRAY_SIZE(dmic_widgets));
550-
if (ret) {
551-
dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
552-
/* Don't need to add routes if widget addition failed */
553-
return ret;
554-
}
555-
556-
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
557-
ARRAY_SIZE(dmic_map));
558-
559-
if (ret)
560-
dev_err(card->dev, "DMic map addition failed: %d\n", ret);
561-
562-
return ret;
563-
}
564-
565534
/* sof audio machine driver for rt5682 codec */
566535
static struct snd_soc_card sof_audio_card_rt5682 = {
567536
.name = "rt5682", /* the sof- prefix is added by the core */
@@ -601,13 +570,6 @@ static struct snd_soc_dai_link_component rt5650_components[] = {
601570
}
602571
};
603572

604-
static struct snd_soc_dai_link_component dmic_component[] = {
605-
{
606-
.name = "dmic-codec",
607-
.dai_name = "dmic-hifi",
608-
}
609-
};
610-
611573
static struct snd_soc_dai_link *
612574
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,
613575
enum sof_ssp_codec amp_type, int ssp_codec,
@@ -692,29 +654,21 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,
692654
/* dmic */
693655
if (dmic_be_num > 0) {
694656
/* at least we have dmic01 */
695-
links[id].name = "dmic01";
696-
links[id].cpus = &cpus[id];
697-
links[id].cpus->dai_name = "DMIC01 Pin";
698-
links[id].init = dmic_init;
699-
if (dmic_be_num > 1) {
700-
/* set up 2 BE links at most */
701-
links[id + 1].name = "dmic16k";
702-
links[id + 1].cpus = &cpus[id + 1];
703-
links[id + 1].cpus->dai_name = "DMIC16k Pin";
704-
dmic_be_num = 2;
705-
}
657+
ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
658+
SOF_DMIC_01);
659+
if (ret)
660+
return NULL;
661+
662+
id++;
706663
}
707664

708-
for (i = 0; i < dmic_be_num; i++) {
709-
links[id].id = id;
710-
links[id].num_cpus = 1;
711-
links[id].codecs = dmic_component;
712-
links[id].num_codecs = ARRAY_SIZE(dmic_component);
713-
links[id].platforms = platform_component;
714-
links[id].num_platforms = ARRAY_SIZE(platform_component);
715-
links[id].ignore_suspend = 1;
716-
links[id].dpcm_capture = 1;
717-
links[id].no_pcm = 1;
665+
if (dmic_be_num > 1) {
666+
/* set up 2 BE links at most */
667+
ret = sof_intel_board_set_dmic_link(dev, &links[id], id,
668+
SOF_DMIC_16K);
669+
if (ret)
670+
return NULL;
671+
718672
id++;
719673
}
720674

@@ -865,7 +819,6 @@ static int sof_audio_probe(struct platform_device *pdev)
865819
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
866820
struct snd_soc_dai_link *dai_links;
867821
struct sof_card_private *ctx;
868-
int dmic_be_num;
869822
int ret, ssp_amp, ssp_codec;
870823

871824
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -891,15 +844,15 @@ static int sof_audio_probe(struct platform_device *pdev)
891844

892845
if (soc_intel_is_byt() || soc_intel_is_cht()) {
893846
ctx->rt5682.is_legacy_cpu = true;
894-
dmic_be_num = 0;
847+
ctx->dmic_be_num = 0;
895848
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
896849
ctx->hdmi_num = 0;
897850
/* default quirk for legacy cpu */
898851
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
899852
SOF_RT5682_MCLK_BYTCHT_EN |
900853
SOF_RT5682_SSP_CODEC(2);
901854
} else {
902-
dmic_be_num = 2;
855+
ctx->dmic_be_num = 2;
903856
ctx->hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
904857
SOF_RT5682_NUM_HDMIDEV_SHIFT;
905858
/* default number of HDMI DAI's */
@@ -938,7 +891,7 @@ static int sof_audio_probe(struct platform_device *pdev)
938891
ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK;
939892

940893
/* compute number of dai links */
941-
sof_audio_card_rt5682.num_links = 1 + dmic_be_num + ctx->hdmi_num;
894+
sof_audio_card_rt5682.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num;
942895

943896
if (ctx->amp_type != CODEC_NONE)
944897
sof_audio_card_rt5682.num_links++;
@@ -953,7 +906,7 @@ static int sof_audio_probe(struct platform_device *pdev)
953906

954907
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->codec_type,
955908
ctx->amp_type, ssp_codec, ssp_amp,
956-
dmic_be_num, ctx->hdmi_num,
909+
ctx->dmic_be_num, ctx->hdmi_num,
957910
ctx->hdmi.idisp_codec,
958911
ctx->rt5682.is_legacy_cpu);
959912
if (!dai_links)

0 commit comments

Comments
 (0)