@@ -70,15 +70,6 @@ static const struct dmi_system_id chromebook_platforms[] = {
7070 {},
7171};
7272
73- static const struct snd_soc_dapm_widget sof_ssp_amp_dapm_widgets [] = {
74- SND_SOC_DAPM_MIC ("SoC DMIC" , NULL ),
75- };
76-
77- static const struct snd_soc_dapm_route sof_ssp_amp_dapm_routes [] = {
78- /* digital mics */
79- {"DMic" , NULL , "SoC DMIC" },
80- };
81-
8273static int sof_card_late_probe (struct snd_soc_card * card )
8374{
8475 return sof_intel_board_card_late_probe (card );
@@ -87,10 +78,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
8778static struct snd_soc_card sof_ssp_amp_card = {
8879 .name = "ssp_amp" ,
8980 .owner = THIS_MODULE ,
90- .dapm_widgets = sof_ssp_amp_dapm_widgets ,
91- .num_dapm_widgets = ARRAY_SIZE (sof_ssp_amp_dapm_widgets ),
92- .dapm_routes = sof_ssp_amp_dapm_routes ,
93- .num_dapm_routes = ARRAY_SIZE (sof_ssp_amp_dapm_routes ),
9481 .fully_routed = true,
9582 .late_probe = sof_card_late_probe ,
9683};
@@ -102,17 +89,11 @@ static struct snd_soc_dai_link_component platform_component[] = {
10289 }
10390};
10491
105- static struct snd_soc_dai_link_component dmic_component [] = {
106- {
107- .name = "dmic-codec" ,
108- .dai_name = "dmic-hifi" ,
109- }
110- };
111-
11292/* BE ID defined in sof-tgl-rt1308-hdmi-ssp.m4 */
11393#define HDMI_IN_BE_ID 0
11494#define SPK_BE_ID 2
11595#define DMIC01_BE_ID 3
96+ #define DMIC16K_BE_ID 4
11697#define INTEL_HDMI_BE_ID 5
11798
11899static struct snd_soc_dai_link *
@@ -207,28 +188,23 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
207188 /* dmic */
208189 if (dmic_be_num > 0 ) {
209190 /* at least we have dmic01 */
210- links [id ].name = "dmic01" ;
211- links [id ].cpus = & cpus [id ];
212- links [id ].cpus -> dai_name = "DMIC01 Pin" ;
213- if (dmic_be_num > 1 ) {
214- /* set up 2 BE links at most */
215- links [id + 1 ].name = "dmic16k" ;
216- links [id + 1 ].cpus = & cpus [id + 1 ];
217- links [id + 1 ].cpus -> dai_name = "DMIC16k Pin" ;
218- dmic_be_num = 2 ;
219- }
191+ be_id = fixed_be ? DMIC01_BE_ID : id ;
192+ ret = sof_intel_board_set_dmic_link (dev , & links [id ], be_id ,
193+ SOF_DMIC_01 );
194+ if (ret )
195+ return NULL ;
196+
197+ id ++ ;
220198 }
221199
222- for (i = 0 ; i < dmic_be_num ; i ++ ) {
223- links [id ].id = fixed_be ? (DMIC01_BE_ID + i ) : id ;
224- links [id ].num_cpus = 1 ;
225- links [id ].codecs = dmic_component ;
226- links [id ].num_codecs = ARRAY_SIZE (dmic_component );
227- links [id ].platforms = platform_component ;
228- links [id ].num_platforms = ARRAY_SIZE (platform_component );
229- links [id ].ignore_suspend = 1 ;
230- links [id ].dpcm_capture = 1 ;
231- links [id ].no_pcm = 1 ;
200+ if (dmic_be_num > 1 ) {
201+ /* set up 2 BE links at most */
202+ be_id = fixed_be ? DMIC16K_BE_ID : id ;
203+ ret = sof_intel_board_set_dmic_link (dev , & links [id ], be_id ,
204+ SOF_DMIC_16K );
205+ if (ret )
206+ return NULL ;
207+
232208 id ++ ;
233209 }
234210
@@ -278,7 +254,6 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
278254 struct snd_soc_acpi_mach * mach = pdev -> dev .platform_data ;
279255 struct snd_soc_dai_link * dai_links ;
280256 struct sof_card_private * ctx ;
281- int dmic_be_num = 0 ;
282257 int ret , ssp_codec ;
283258
284259 ctx = devm_kzalloc (& pdev -> dev , sizeof (* ctx ), GFP_KERNEL );
@@ -291,12 +266,14 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
291266 ctx -> amp_type = sof_ssp_detect_amp_type (& pdev -> dev );
292267
293268 if (dmi_check_system (chromebook_platforms ) || mach -> mach_params .dmic_num > 0 )
294- dmic_be_num = 2 ;
269+ ctx -> dmic_be_num = 2 ;
270+ else
271+ ctx -> dmic_be_num = 0 ;
295272
296273 ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK ;
297274
298275 /* set number of dai links */
299- sof_ssp_amp_card .num_links = dmic_be_num ;
276+ sof_ssp_amp_card .num_links = ctx -> dmic_be_num ;
300277
301278 if (ctx -> amp_type != CODEC_NONE )
302279 sof_ssp_amp_card .num_links ++ ;
@@ -324,7 +301,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
324301 sof_ssp_amp_card .num_links ++ ;
325302
326303 dai_links = sof_card_dai_links_create (& pdev -> dev , ctx -> amp_type ,
327- ssp_codec , dmic_be_num ,
304+ ssp_codec , ctx -> dmic_be_num ,
328305 ctx -> hdmi_num ,
329306 ctx -> hdmi .idisp_codec );
330307 if (!dai_links )
0 commit comments