@@ -310,6 +310,11 @@ enum {
310310 VA_MACRO_CLK_DIV_16 ,
311311};
312312
313+ enum {
314+ MSM_DMIC ,
315+ SWR_MIC ,
316+ };
317+
313318#define VA_NUM_CLKS_MAX 3
314319
315320struct va_macro {
@@ -820,14 +825,32 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
820825 return - EINVAL ;
821826 }
822827
823- if (val != 0 )
824- snd_soc_component_update_bits (component , mic_sel_reg ,
825- CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK ,
826- CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC );
828+ if (val != 0 ) {
829+ if (strnstr (widget -> name , "SMIC" , strlen (widget -> name )))
830+ snd_soc_component_update_bits (component , mic_sel_reg ,
831+ CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK , 0 );
832+ else
833+ snd_soc_component_update_bits (component , mic_sel_reg ,
834+ CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK ,
835+ CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC );
836+ }
827837
828838 return snd_soc_dapm_put_enum_double (kcontrol , ucontrol );
829839}
830840
841+ static bool is_amic_enabled (struct snd_soc_component * comp , int decimator )
842+ {
843+ u16 adc_mux_reg = 0 ;
844+ bool ret = false;
845+
846+ adc_mux_reg = CDC_VA_INP_MUX_ADC_MUX0_CFG1 +
847+ VA_MACRO_ADC_MUX_CFG_OFFSET * decimator ;
848+ if (snd_soc_component_read (comp , adc_mux_reg ) & SWR_MIC )
849+ return true;
850+
851+ return ret ;
852+ }
853+
831854static int va_macro_tx_mixer_get (struct snd_kcontrol * kcontrol ,
832855 struct snd_ctl_elem_value * ucontrol )
833856{
@@ -1012,6 +1035,8 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
10121035 u16 tx_vol_ctl_reg , dec_cfg_reg , hpf_gate_reg ;
10131036 u16 tx_gain_ctl_reg ;
10141037 u8 hpf_cut_off_freq ;
1038+ u16 adc_mux0_reg = 0 ;
1039+ u16 adapt_ctrl = 0 ;
10151040
10161041 struct va_macro * va = snd_soc_component_get_drvdata (comp );
10171042
@@ -1025,6 +1050,10 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
10251050 VA_MACRO_TX_PATH_OFFSET * decimator ;
10261051 tx_gain_ctl_reg = CDC_VA_TX0_TX_VOL_CTL +
10271052 VA_MACRO_TX_PATH_OFFSET * decimator ;
1053+ adc_mux0_reg = CDC_VA_INP_MUX_ADC_MUX0_CFG0 +
1054+ VA_MACRO_ADC_MUX_CFG_OFFSET * decimator ;
1055+ adapt_ctrl = CDC_VA_CDC_ADPT0_ADPT_CTRL +
1056+ VA_MACRO_TX_PATH_OFFSET * decimator ;
10281057
10291058 switch (event ) {
10301059 case SND_SOC_DAPM_PRE_PMU :
@@ -1034,6 +1063,9 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
10341063 /* Enable TX PGA Mute */
10351064 break ;
10361065 case SND_SOC_DAPM_POST_PMU :
1066+ if (va -> codec_version == LPASS_CODEC_VERSION_4_0 )
1067+ snd_soc_component_update_bits (comp , adapt_ctrl , 0xFF , 0x00 );
1068+
10371069 /* Enable TX CLK */
10381070 snd_soc_component_update_bits (comp , tx_vol_ctl_reg ,
10391071 CDC_VA_TX_PATH_CLK_EN_MASK ,
@@ -1042,31 +1074,39 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
10421074 CDC_VA_TX_HPF_ZERO_GATE_MASK ,
10431075 CDC_VA_TX_HPF_ZERO_GATE );
10441076
1045- usleep_range (1000 , 1010 );
1077+ if (!is_amic_enabled (comp , decimator )) {
1078+ snd_soc_component_update_bits (comp , hpf_gate_reg ,
1079+ CDC_VA_TX_HPF_ZERO_GATE_MASK ,
1080+ CDC_VA_TX_HPF_ZERO_GATE );
1081+ usleep_range (1000 , 1010 );
1082+ }
1083+
10461084 hpf_cut_off_freq = (snd_soc_component_read (comp , dec_cfg_reg ) &
10471085 TX_HPF_CUT_OFF_FREQ_MASK ) >> 5 ;
10481086
10491087 if (hpf_cut_off_freq != CF_MIN_3DB_150HZ ) {
10501088 snd_soc_component_update_bits (comp , dec_cfg_reg ,
10511089 TX_HPF_CUT_OFF_FREQ_MASK ,
10521090 CF_MIN_3DB_150HZ << 5 );
1091+ }
10531092
1054- snd_soc_component_update_bits (comp , hpf_gate_reg ,
1055- CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_MASK ,
1056- CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_REQ );
1093+ snd_soc_component_update_bits (comp , hpf_gate_reg ,
1094+ CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_MASK ,
1095+ CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_REQ );
10571096
1058- /*
1059- * Minimum 1 clk cycle delay is required as per HW spec
1060- */
1061- usleep_range (1000 , 1010 );
1097+ /*
1098+ * Minimum 1 clk cycle delay is required as per HW spec
1099+ */
10621100
1101+ usleep_range (1000 , 1010 );
1102+
1103+ if (!is_amic_enabled (comp , decimator )) {
10631104 snd_soc_component_update_bits (comp ,
1064- hpf_gate_reg ,
1065- CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_MASK ,
1066- 0x0 );
1105+ hpf_gate_reg ,
1106+ CDC_VA_TX_HPF_CUTOFF_FREQ_CHANGE_MASK ,
1107+ 0x0 );
10671108 }
10681109
1069-
10701110 usleep_range (1000 , 1010 );
10711111 snd_soc_component_update_bits (comp , hpf_gate_reg ,
10721112 CDC_VA_TX_HPF_ZERO_GATE_MASK ,
@@ -1545,6 +1585,12 @@ static const struct snd_soc_dapm_route va_audio_map[] = {
15451585 {"VA DMIC MUX3" , "DMIC6" , "VA DMIC6" },
15461586 {"VA DMIC MUX3" , "DMIC7" , "VA DMIC7" },
15471587
1588+ /* SWR_MIC routes: connect each VA DECx MUX to its SWR_MIC input */
1589+ {"VA DEC0 MUX" , "SWR_MIC" , "VA SWR_MIC0" },
1590+ {"VA DEC1 MUX" , "SWR_MIC" , "VA SWR_MIC1" },
1591+ {"VA DEC2 MUX" , "SWR_MIC" , "VA SWR_MIC2" },
1592+ {"VA DEC3 MUX" , "SWR_MIC" , "VA SWR_MIC3" },
1593+
15481594 { "VA DMIC0" , NULL , "DMIC0 Pin" },
15491595 { "VA DMIC1" , NULL , "DMIC1 Pin" },
15501596 { "VA DMIC2" , NULL , "DMIC2 Pin" },
0 commit comments