4848 (((quirk) << SOF_HDMI_CAPTURE_2_SSP_SHIFT) & SOF_HDMI_CAPTURE_2_SSP_MASK)
4949
5050#define SOF_ES8336_ENABLE_DMIC BIT(5)
51- #define SOC_ES8336_HEADSET_MIC1 BIT(8)
5251
5352static unsigned long quirk ;
5453
@@ -66,6 +65,7 @@ struct sof_es8336_private {
6665
6766 struct acpi_gpio_params enable_spk_gpio , enable_hp_gpio ;
6867 struct acpi_gpio_mapping gpio_mapping [3 ];
68+ struct snd_soc_dapm_route mic_map [2 ];
6969};
7070
7171struct sof_hdmi_pcm {
@@ -82,8 +82,6 @@ static void log_quirks(struct device *dev)
8282 dev_info (dev , "quirk DMIC enabled\n" );
8383 if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK )
8484 dev_info (dev , "Speakers GPIO1 quirk enabled\n" );
85- if (quirk & SOC_ES8336_HEADSET_MIC1 )
86- dev_info (dev , "quirk headset at mic1 port enabled\n" );
8785}
8886
8987static void pcm_pop_work_events (struct work_struct * work )
@@ -174,16 +172,6 @@ static const struct snd_soc_dapm_route sof_es8316_audio_map[] = {
174172 {"Speaker" , NULL , "Speaker Power" },
175173};
176174
177- static const struct snd_soc_dapm_route sof_es8316_headset_mic2_map [] = {
178- {"MIC1" , NULL , "Internal Mic" },
179- {"MIC2" , NULL , "Headset Mic" },
180- };
181-
182- static const struct snd_soc_dapm_route sof_es8316_headset_mic1_map [] = {
183- {"MIC2" , NULL , "Internal Mic" },
184- {"MIC1" , NULL , "Headset Mic" },
185- };
186-
187175static const struct snd_soc_dapm_route dmic_map [] = {
188176 /* digital mics */
189177 {"DMic" , NULL , "SoC DMIC" },
@@ -251,21 +239,44 @@ static int sof_es8316_init(struct snd_soc_pcm_runtime *runtime)
251239 struct snd_soc_component * codec = asoc_rtd_to_codec (runtime , 0 )-> component ;
252240 struct snd_soc_card * card = runtime -> card ;
253241 struct sof_es8336_private * priv = snd_soc_card_get_drvdata (card );
254- const struct snd_soc_dapm_route * custom_map ;
255- int num_routes ;
256- int ret ;
242+ int num_routes = 0 ;
243+ int i , ret ;
257244
258245 card -> dapm .idle_bias_off = true;
259246
260- if (quirk & SOC_ES8336_HEADSET_MIC1 ) {
261- custom_map = sof_es8316_headset_mic1_map ;
262- num_routes = ARRAY_SIZE (sof_es8316_headset_mic1_map );
263- } else {
264- custom_map = sof_es8316_headset_mic2_map ;
265- num_routes = ARRAY_SIZE (sof_es8316_headset_mic2_map );
247+ /*
248+ * Need to check if DMIC is not enabled, as the _DSM table may be
249+ * reporting a non-existent AMIC.
250+ */
251+ if (!(quirk & SOF_ES8336_ENABLE_DMIC )) {
252+ ret = es83xx_dsm_mic_type (priv -> codec_dev , true);
253+ if (ret == PLATFORM_MIC_AMIC_LIN1RIN1 ) {
254+ priv -> mic_map [num_routes ].sink = "MIC1" ;
255+ priv -> mic_map [num_routes ].source = "Internal Mic" ;
256+ num_routes ++ ;
257+ } else if (ret == PLATFORM_MIC_AMIC_LIN2RIN2 ) {
258+ priv -> mic_map [num_routes ].sink = "MIC2" ;
259+ priv -> mic_map [num_routes ].source = "Internal Mic" ;
260+ num_routes ++ ;
261+ }
262+ }
263+
264+ ret = es83xx_dsm_mic_type (priv -> codec_dev , false);
265+ if (ret == PLATFORM_MIC_AMIC_LIN1RIN1 ) {
266+ priv -> mic_map [num_routes ].sink = "MIC1" ;
267+ priv -> mic_map [num_routes ].source = "Headset Mic" ;
268+ num_routes ++ ;
269+ } else if (ret == PLATFORM_MIC_AMIC_LIN2RIN2 ) {
270+ priv -> mic_map [num_routes ].sink = "MIC2" ;
271+ priv -> mic_map [num_routes ].source = "Headset Mic" ;
272+ num_routes ++ ;
266273 }
267274
268- ret = snd_soc_dapm_add_routes (& card -> dapm , custom_map , num_routes );
275+ for (i = 0 ; i < num_routes ; i ++ )
276+ dev_info (card -> dev , "%s is %s\n" ,
277+ priv -> mic_map [i ].source , priv -> mic_map [i ].sink );
278+
279+ ret = snd_soc_dapm_add_routes (& card -> dapm , priv -> mic_map , num_routes );
269280 if (ret )
270281 return ret ;
271282
@@ -325,8 +336,7 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = {
325336 DMI_MATCH (DMI_SYS_VENDOR , "HUAWEI" ),
326337 DMI_MATCH (DMI_BOARD_NAME , "BOHB-WAX9-PCB-B2" ),
327338 },
328- .driver_data = (void * )(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK |
329- SOC_ES8336_HEADSET_MIC1 )
339+ .driver_data = (void * )(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK )
330340 },
331341 {}
332342};
0 commit comments