@@ -160,10 +160,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
160160 SND_SOC_DAPM_MIC ("Headset Mic" , NULL ),
161161};
162162
163- static const struct snd_soc_dapm_widget dmic_widgets [] = {
164- SND_SOC_DAPM_MIC ("SoC DMIC" , NULL ),
165- };
166-
167163static const struct snd_soc_dapm_route sof_map [] = {
168164 /* HP jack connectors - unknown if we have jack detection */
169165 {"Headphone Jack" , NULL , "HP" },
@@ -172,33 +168,6 @@ static const struct snd_soc_dapm_route sof_map[] = {
172168 {"HS" , NULL , "Headset Mic" },
173169};
174170
175- static const struct snd_soc_dapm_route dmic_map [] = {
176- /* digital mics */
177- {"DMic" , NULL , "SoC DMIC" },
178- };
179-
180- static int dmic_init (struct snd_soc_pcm_runtime * rtd )
181- {
182- struct snd_soc_card * card = rtd -> card ;
183- int ret ;
184-
185- ret = snd_soc_dapm_new_controls (& card -> dapm , dmic_widgets ,
186- ARRAY_SIZE (dmic_widgets ));
187- if (ret ) {
188- dev_err (card -> dev , "DMic widget addition failed: %d\n" , ret );
189- /* Don't need to add routes if widget addition failed */
190- return ret ;
191- }
192-
193- ret = snd_soc_dapm_add_routes (& card -> dapm , dmic_map ,
194- ARRAY_SIZE (dmic_map ));
195-
196- if (ret )
197- dev_err (card -> dev , "DMic map addition failed: %d\n" , ret );
198-
199- return ret ;
200- }
201-
202171/* sof audio machine driver for cs42l42 codec */
203172static struct snd_soc_card sof_audio_card_cs42l42 = {
204173 .name = "cs42l42" , /* the sof- prefix is added by the core */
@@ -220,13 +189,6 @@ static struct snd_soc_dai_link_component cs42l42_component[] = {
220189 }
221190};
222191
223- static struct snd_soc_dai_link_component dmic_component [] = {
224- {
225- .name = "dmic-codec" ,
226- .dai_name = "dmic-hifi" ,
227- }
228- };
229-
230192static int create_spk_amp_dai_links (struct device * dev ,
231193 struct snd_soc_dai_link * links ,
232194 struct snd_soc_dai_link_component * cpus ,
@@ -322,47 +284,6 @@ static int create_hp_codec_dai_links(struct device *dev,
322284 return - ENOMEM ;
323285}
324286
325- static int create_dmic_dai_links (struct device * dev ,
326- struct snd_soc_dai_link * links ,
327- struct snd_soc_dai_link_component * cpus ,
328- int * id , int dmic_be_num )
329- {
330- int i ;
331-
332- /* dmic */
333- if (dmic_be_num <= 0 )
334- return 0 ;
335-
336- /* at least we have dmic01 */
337- links [* id ].name = "dmic01" ;
338- links [* id ].cpus = & cpus [* id ];
339- links [* id ].cpus -> dai_name = "DMIC01 Pin" ;
340- links [* id ].init = dmic_init ;
341- if (dmic_be_num > 1 ) {
342- /* set up 2 BE links at most */
343- links [* id + 1 ].name = "dmic16k" ;
344- links [* id + 1 ].cpus = & cpus [* id + 1 ];
345- links [* id + 1 ].cpus -> dai_name = "DMIC16k Pin" ;
346- dmic_be_num = 2 ;
347- }
348-
349- for (i = 0 ; i < dmic_be_num ; i ++ ) {
350- links [* id ].id = * id ;
351- links [* id ].num_cpus = 1 ;
352- links [* id ].codecs = dmic_component ;
353- links [* id ].num_codecs = ARRAY_SIZE (dmic_component );
354- links [* id ].platforms = platform_component ;
355- links [* id ].num_platforms = ARRAY_SIZE (platform_component );
356- links [* id ].ignore_suspend = 1 ;
357- links [* id ].dpcm_capture = 1 ;
358- links [* id ].no_pcm = 1 ;
359-
360- (* id )++ ;
361- }
362-
363- return 0 ;
364- }
365-
366287static int create_bt_offload_dai_links (struct device * dev ,
367288 struct snd_soc_dai_link * links ,
368289 struct snd_soc_dai_link_component * cpus ,
@@ -446,11 +367,34 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
446367 }
447368 break ;
448369 case LINK_DMIC :
449- ret = create_dmic_dai_links (dev , links , cpus , & id , dmic_be_num );
450- if (ret < 0 ) {
451- dev_err (dev , "fail to create dmic dai links, ret %d\n" ,
452- ret );
453- goto devm_err ;
370+ if (dmic_be_num > 0 ) {
371+ /* at least we have dmic01 */
372+ ret = sof_intel_board_set_dmic_link (dev ,
373+ & links [id ],
374+ id ,
375+ SOF_DMIC_01 );
376+ if (ret ) {
377+ dev_err (dev , "fail to create dmic01 link, ret %d\n" ,
378+ ret );
379+ goto devm_err ;
380+ }
381+
382+ id ++ ;
383+ }
384+
385+ if (dmic_be_num > 1 ) {
386+ /* set up 2 BE links at most */
387+ ret = sof_intel_board_set_dmic_link (dev ,
388+ & links [id ],
389+ id ,
390+ SOF_DMIC_16K );
391+ if (ret ) {
392+ dev_err (dev , "fail to create dmic16k link, ret %d\n" ,
393+ ret );
394+ goto devm_err ;
395+ }
396+
397+ id ++ ;
454398 }
455399 break ;
456400 case LINK_HDMI :
@@ -496,7 +440,6 @@ static int sof_audio_probe(struct platform_device *pdev)
496440 struct snd_soc_acpi_mach * mach = pdev -> dev .platform_data ;
497441 struct snd_soc_dai_link * dai_links ;
498442 struct sof_card_private * ctx ;
499- int dmic_be_num ;
500443 int ret , ssp_bt , ssp_amp , ssp_codec ;
501444
502445 ctx = devm_kzalloc (& pdev -> dev , sizeof (* ctx ), GFP_KERNEL );
@@ -510,10 +453,10 @@ static int sof_audio_probe(struct platform_device *pdev)
510453 ctx -> amp_type = sof_ssp_detect_amp_type (& pdev -> dev );
511454
512455 if (soc_intel_is_glk ()) {
513- dmic_be_num = 1 ;
456+ ctx -> dmic_be_num = 1 ;
514457 ctx -> hdmi_num = 3 ;
515458 } else {
516- dmic_be_num = 2 ;
459+ ctx -> dmic_be_num = 2 ;
517460 ctx -> hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK ) >>
518461 SOF_CS42L42_NUM_HDMIDEV_SHIFT ;
519462 /* default number of HDMI DAI's */
@@ -535,7 +478,7 @@ static int sof_audio_probe(struct platform_device *pdev)
535478 ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK ;
536479
537480 /* compute number of dai links */
538- sof_audio_card_cs42l42 .num_links = 1 + dmic_be_num + ctx -> hdmi_num ;
481+ sof_audio_card_cs42l42 .num_links = 1 + ctx -> dmic_be_num + ctx -> hdmi_num ;
539482
540483 if (ctx -> amp_type != CODEC_NONE )
541484 sof_audio_card_cs42l42 .num_links ++ ;
@@ -544,7 +487,7 @@ static int sof_audio_probe(struct platform_device *pdev)
544487
545488 dai_links = sof_card_dai_links_create (& pdev -> dev , ctx -> amp_type ,
546489 ssp_codec , ssp_amp , ssp_bt ,
547- dmic_be_num , ctx -> hdmi_num ,
490+ ctx -> dmic_be_num , ctx -> hdmi_num ,
548491 ctx -> hdmi .idisp_codec );
549492 if (!dai_links )
550493 return - ENOMEM ;
0 commit comments