Skip to content

Commit 3477834

Browse files
brentluplbossart
authored andcommitted
ASoC: Intel: board_helpers: support dmic link initialization
Add functions for machine drivers to initialize dmic01 and dmic16k DAI links. Signed-off-by: Brent Lu <brent.lu@intel.com>
1 parent e517f4b commit 3477834

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

sound/soc/intel/boards/sof_board_helpers.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,108 @@ int sof_intel_board_card_late_probe(struct snd_soc_card *card)
3636
}
3737
EXPORT_SYMBOL_NS(sof_intel_board_card_late_probe, SND_SOC_INTEL_SOF_BOARD_HELPERS);
3838

39+
/*
40+
* DMIC DAI Link
41+
*/
42+
static const struct snd_soc_dapm_widget dmic_widgets[] = {
43+
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
44+
};
45+
46+
static const struct snd_soc_dapm_route dmic_routes[] = {
47+
{"DMic", NULL, "SoC DMIC"},
48+
};
49+
50+
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
51+
{
52+
struct snd_soc_card *card = rtd->card;
53+
int ret;
54+
55+
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
56+
ARRAY_SIZE(dmic_widgets));
57+
if (ret) {
58+
dev_err(rtd->dev, "fail to add dmic widgets, ret %d\n", ret);
59+
return ret;
60+
}
61+
62+
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_routes,
63+
ARRAY_SIZE(dmic_routes));
64+
if (ret) {
65+
dev_err(rtd->dev, "fail to add dmic routes, ret %d\n", ret);
66+
return ret;
67+
}
68+
69+
return 0;
70+
}
71+
3972
/*
4073
* DAI Link Helpers
4174
*/
75+
static struct snd_soc_dai_link_component dmic_component[] = {
76+
{
77+
.name = "dmic-codec",
78+
.dai_name = "dmic-hifi",
79+
}
80+
};
81+
4282
static struct snd_soc_dai_link_component platform_component[] = {
4383
{
4484
/* name might be overridden during probe */
4585
.name = "0000:00:1f.3"
4686
}
4787
};
4888

89+
int sof_intel_board_set_dmic_link(struct device *dev,
90+
struct snd_soc_dai_link *link, int be_id,
91+
enum sof_dmic_be_type be_type)
92+
{
93+
struct snd_soc_dai_link_component *cpus;
94+
95+
/* cpus */
96+
cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
97+
GFP_KERNEL);
98+
if (!cpus)
99+
return -ENOMEM;
100+
101+
switch (be_type) {
102+
case SOF_DMIC_01:
103+
dev_dbg(dev, "link %d: dmic01\n", be_id);
104+
105+
link->name = "dmic01";
106+
cpus->dai_name = "DMIC01 Pin";
107+
break;
108+
case SOF_DMIC_16K:
109+
dev_dbg(dev, "link %d: dmic16k\n", be_id);
110+
111+
link->name = "dmic16k";
112+
cpus->dai_name = "DMIC16k Pin";
113+
break;
114+
default:
115+
dev_err(dev, "invalid be type %d\n", be_type);
116+
return -EINVAL;
117+
}
118+
119+
link->cpus = cpus;
120+
link->num_cpus = 1;
121+
122+
/* codecs */
123+
link->codecs = dmic_component;
124+
link->num_codecs = ARRAY_SIZE(dmic_component);
125+
126+
/* platforms */
127+
link->platforms = platform_component;
128+
link->num_platforms = ARRAY_SIZE(platform_component);
129+
130+
link->id = be_id;
131+
if (be_type == SOF_DMIC_01)
132+
link->init = dmic_init;
133+
link->ignore_suspend = 1;
134+
link->no_pcm = 1;
135+
link->dpcm_capture = 1;
136+
137+
return 0;
138+
}
139+
EXPORT_SYMBOL_NS(sof_intel_board_set_dmic_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
140+
49141
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
50142
struct snd_soc_dai_link *link, int be_id,
51143
int hdmi_id, bool idisp_codec)

sound/soc/intel/boards/sof_board_helpers.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct sof_rt5682_private {
2828
* @hdmi: init data for hdmi dai link
2929
* @codec_type: type of headset codec
3030
* @amp_type: type of speaker amplifier
31+
* @dmic_be_num: number of Intel PCH DMIC BE link
3132
* @hdmi_num: number of Intel HDMI BE link
3233
* @rt5682: private data for rt5682 machine driver
3334
*/
@@ -38,15 +39,24 @@ struct sof_card_private {
3839
enum sof_ssp_codec codec_type;
3940
enum sof_ssp_codec amp_type;
4041

42+
int dmic_be_num;
4143
int hdmi_num;
4244

4345
union {
4446
struct sof_rt5682_private rt5682;
4547
};
4648
};
4749

50+
enum sof_dmic_be_type {
51+
SOF_DMIC_01,
52+
SOF_DMIC_16K,
53+
};
54+
4855
int sof_intel_board_card_late_probe(struct snd_soc_card *card);
4956

57+
int sof_intel_board_set_dmic_link(struct device *dev,
58+
struct snd_soc_dai_link *link, int be_id,
59+
enum sof_dmic_be_type be_type);
5060
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
5161
struct snd_soc_dai_link *link, int be_id,
5262
int hdmi_id, bool idisp_codec);

0 commit comments

Comments
 (0)