@@ -36,16 +36,108 @@ int sof_intel_board_card_late_probe(struct snd_soc_card *card)
3636}
3737EXPORT_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+
4282static 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+
49141int 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 )
0 commit comments