aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5677.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/rt5677.c')
-rw-r--r--sound/soc/codecs/rt5677.c267
1 files changed, 229 insertions, 38 deletions
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 81fe1464d268..26fc538f03b1 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -784,8 +784,8 @@ static unsigned int bst_tlv[] = {
784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol, 784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol) 785 struct snd_ctl_elem_value *ucontrol)
786{ 786{
787 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 787 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 788 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
789 789
790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en; 790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
791 791
@@ -795,8 +795,9 @@ static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol, 795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_value *ucontrol) 796 struct snd_ctl_elem_value *ucontrol)
797{ 797{
798 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 798 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
799 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 799 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
800 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
800 801
801 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0]; 802 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
802 803
@@ -895,7 +896,7 @@ static const struct snd_kcontrol_new rt5677_snd_controls[] = {
895static int set_dmic_clk(struct snd_soc_dapm_widget *w, 896static int set_dmic_clk(struct snd_soc_dapm_widget *w,
896 struct snd_kcontrol *kcontrol, int event) 897 struct snd_kcontrol *kcontrol, int event)
897{ 898{
898 struct snd_soc_codec *codec = w->codec; 899 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
899 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 900 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
900 int idx = rl6231_calc_dmic_clk(rt5677->sysclk); 901 int idx = rl6231_calc_dmic_clk(rt5677->sysclk);
901 902
@@ -910,7 +911,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
910static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 911static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
911 struct snd_soc_dapm_widget *sink) 912 struct snd_soc_dapm_widget *sink)
912{ 913{
913 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec); 914 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
915 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
914 unsigned int val; 916 unsigned int val;
915 917
916 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); 918 regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
@@ -921,6 +923,101 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
921 return 0; 923 return 0;
922} 924}
923 925
926static int is_using_asrc(struct snd_soc_dapm_widget *source,
927 struct snd_soc_dapm_widget *sink)
928{
929 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
930 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
931 unsigned int reg, shift, val;
932
933 if (source->reg == RT5677_ASRC_1) {
934 switch (source->shift) {
935 case 12:
936 reg = RT5677_ASRC_4;
937 shift = 0;
938 break;
939 case 13:
940 reg = RT5677_ASRC_4;
941 shift = 4;
942 break;
943 case 14:
944 reg = RT5677_ASRC_4;
945 shift = 8;
946 break;
947 case 15:
948 reg = RT5677_ASRC_4;
949 shift = 12;
950 break;
951 default:
952 return 0;
953 }
954 } else {
955 switch (source->shift) {
956 case 0:
957 reg = RT5677_ASRC_6;
958 shift = 8;
959 break;
960 case 1:
961 reg = RT5677_ASRC_6;
962 shift = 12;
963 break;
964 case 2:
965 reg = RT5677_ASRC_5;
966 shift = 0;
967 break;
968 case 3:
969 reg = RT5677_ASRC_5;
970 shift = 4;
971 break;
972 case 4:
973 reg = RT5677_ASRC_5;
974 shift = 8;
975 break;
976 case 5:
977 reg = RT5677_ASRC_5;
978 shift = 12;
979 break;
980 case 12:
981 reg = RT5677_ASRC_3;
982 shift = 0;
983 break;
984 case 13:
985 reg = RT5677_ASRC_3;
986 shift = 4;
987 break;
988 case 14:
989 reg = RT5677_ASRC_3;
990 shift = 12;
991 break;
992 default:
993 return 0;
994 }
995 }
996
997 regmap_read(rt5677->regmap, reg, &val);
998 val = (val >> shift) & 0xf;
999
1000 switch (val) {
1001 case 1 ... 6:
1002 return 1;
1003 default:
1004 return 0;
1005 }
1006
1007}
1008
1009static int can_use_asrc(struct snd_soc_dapm_widget *source,
1010 struct snd_soc_dapm_widget *sink)
1011{
1012 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
1013 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
1014
1015 if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
1016 return 1;
1017
1018 return 0;
1019}
1020
924/* Digital Mixer */ 1021/* Digital Mixer */
925static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = { 1022static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
926 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, 1023 SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
@@ -2030,7 +2127,7 @@ static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
2030static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, 2127static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2031 struct snd_kcontrol *kcontrol, int event) 2128 struct snd_kcontrol *kcontrol, int event)
2032{ 2129{
2033 struct snd_soc_codec *codec = w->codec; 2130 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2034 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2131 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2035 2132
2036 switch (event) { 2133 switch (event) {
@@ -2054,7 +2151,7 @@ static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
2054static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, 2151static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2055 struct snd_kcontrol *kcontrol, int event) 2152 struct snd_kcontrol *kcontrol, int event)
2056{ 2153{
2057 struct snd_soc_codec *codec = w->codec; 2154 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2058 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2155 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2059 2156
2060 switch (event) { 2157 switch (event) {
@@ -2078,14 +2175,18 @@ static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
2078static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, 2175static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2079 struct snd_kcontrol *kcontrol, int event) 2176 struct snd_kcontrol *kcontrol, int event)
2080{ 2177{
2081 struct snd_soc_codec *codec = w->codec; 2178 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2082 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2179 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2083 2180
2084 switch (event) { 2181 switch (event) {
2085 case SND_SOC_DAPM_POST_PMU: 2182 case SND_SOC_DAPM_PRE_PMU:
2086 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2); 2183 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
2184 break;
2185
2186 case SND_SOC_DAPM_POST_PMU:
2087 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0); 2187 regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
2088 break; 2188 break;
2189
2089 default: 2190 default:
2090 return 0; 2191 return 0;
2091 } 2192 }
@@ -2096,14 +2197,18 @@ static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
2096static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, 2197static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2097 struct snd_kcontrol *kcontrol, int event) 2198 struct snd_kcontrol *kcontrol, int event)
2098{ 2199{
2099 struct snd_soc_codec *codec = w->codec; 2200 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2100 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2201 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2101 2202
2102 switch (event) { 2203 switch (event) {
2103 case SND_SOC_DAPM_POST_PMU: 2204 case SND_SOC_DAPM_PRE_PMU:
2104 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2); 2205 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
2206 break;
2207
2208 case SND_SOC_DAPM_POST_PMU:
2105 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0); 2209 regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
2106 break; 2210 break;
2211
2107 default: 2212 default:
2108 return 0; 2213 return 0;
2109 } 2214 }
@@ -2114,7 +2219,7 @@ static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
2114static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, 2219static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2115 struct snd_kcontrol *kcontrol, int event) 2220 struct snd_kcontrol *kcontrol, int event)
2116{ 2221{
2117 struct snd_soc_codec *codec = w->codec; 2222 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2118 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2223 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2119 2224
2120 switch (event) { 2225 switch (event) {
@@ -2141,7 +2246,7 @@ static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
2141static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, 2246static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2142 struct snd_kcontrol *kcontrol, int event) 2247 struct snd_kcontrol *kcontrol, int event)
2143{ 2248{
2144 struct snd_soc_codec *codec = w->codec; 2249 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2145 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2250 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2146 unsigned int value; 2251 unsigned int value;
2147 2252
@@ -2164,7 +2269,7 @@ static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
2164static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, 2269static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2165 struct snd_kcontrol *kcontrol, int event) 2270 struct snd_kcontrol *kcontrol, int event)
2166{ 2271{
2167 struct snd_soc_codec *codec = w->codec; 2272 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2168 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2273 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2169 unsigned int value; 2274 unsigned int value;
2170 2275
@@ -2187,7 +2292,7 @@ static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
2187static int rt5677_vref_event(struct snd_soc_dapm_widget *w, 2292static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2188 struct snd_kcontrol *kcontrol, int event) 2293 struct snd_kcontrol *kcontrol, int event)
2189{ 2294{
2190 struct snd_soc_codec *codec = w->codec; 2295 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2191 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 2296 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2192 2297
2193 switch (event) { 2298 switch (event) {
@@ -2211,9 +2316,50 @@ static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
2211 2316
2212static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { 2317static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2213 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT, 2318 SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
2214 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU), 2319 0, rt5677_set_pll1_event, SND_SOC_DAPM_PRE_PMU |
2320 SND_SOC_DAPM_POST_PMU),
2215 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT, 2321 SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
2216 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU), 2322 0, rt5677_set_pll2_event, SND_SOC_DAPM_PRE_PMU |
2323 SND_SOC_DAPM_POST_PMU),
2324
2325 /* ASRC */
2326 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
2327 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
2328 SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
2329 SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
2330 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
2331 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
2332 0),
2333 SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
2334 0),
2335 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
2336 0),
2337 SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
2338 0),
2339 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
2340 0),
2341 SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
2342 0),
2343 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
2344 0),
2345 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
2346 0),
2347 SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
2348 0),
2349 SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
2350 0),
2351 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
2352 0),
2353 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
2354 0),
2355 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
2356 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
2357 SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
2358 SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
2359 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
2360 0),
2361 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
2362 0),
2217 2363
2218 /* Input Side */ 2364 /* Input Side */
2219 /* micbias */ 2365 /* micbias */
@@ -2645,10 +2791,18 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2645 /* DAC Mixer */ 2791 /* DAC Mixer */
2646 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2, 2792 SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
2647 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0), 2793 RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0),
2648 SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2, 2794 SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
2649 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0), 2795 RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0),
2650 SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2, 2796 SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
2651 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0), 2797 RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0),
2798 SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
2799 RT5677_PWR_DAC_M3F_L_BIT, 0, NULL, 0),
2800 SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
2801 RT5677_PWR_DAC_M3F_R_BIT, 0, NULL, 0),
2802 SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
2803 RT5677_PWR_DAC_M4F_L_BIT, 0, NULL, 0),
2804 SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
2805 RT5677_PWR_DAC_M4F_R_BIT, 0, NULL, 0),
2652 2806
2653 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, 2807 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
2654 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)), 2808 rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
@@ -2721,6 +2875,31 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
2721}; 2875};
2722 2876
2723static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { 2877static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2878 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
2879 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
2880 { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", can_use_asrc },
2881 { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", can_use_asrc },
2882 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
2883 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2884 { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
2885 { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
2886 { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
2887 { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
2888
2889 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
2890 { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
2891 { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
2892 { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
2893 { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
2894 { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
2895 { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
2896 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
2897 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
2898 { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
2899 { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
2900 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
2901 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
2902
2724 { "DMIC1", NULL, "DMIC L1" }, 2903 { "DMIC1", NULL, "DMIC L1" },
2725 { "DMIC1", NULL, "DMIC R1" }, 2904 { "DMIC1", NULL, "DMIC R1" },
2726 { "DMIC2", NULL, "DMIC L2" }, 2905 { "DMIC2", NULL, "DMIC L2" },
@@ -2851,8 +3030,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2851 3030
2852 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, 3031 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
2853 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" }, 3032 { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
2854 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
2855
2856 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, 3033 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
2857 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" }, 3034 { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
2858 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3035 { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2873,8 +3050,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2873 3050
2874 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, 3051 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
2875 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" }, 3052 { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
2876 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
2877
2878 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, 3053 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
2879 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" }, 3054 { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
2880 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3055 { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2889,8 +3064,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2889 3064
2890 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" }, 3065 { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
2891 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" }, 3066 { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
2892 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
2893
2894 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" }, 3067 { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
2895 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" }, 3068 { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
2896 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3069 { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -2905,8 +3078,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
2905 3078
2906 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" }, 3079 { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
2907 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" }, 3080 { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
2908 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
2909
2910 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" }, 3081 { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
2911 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" }, 3082 { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
2912 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, 3083 { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
@@ -3455,10 +3626,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3455 3626
3456 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" }, 3627 { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
3457 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" }, 3628 { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
3458 { "DAC1 MIXL", NULL, "dac stereo1 filter" },
3459 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" }, 3629 { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
3460 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" }, 3630 { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
3461 { "DAC1 MIXR", NULL, "dac stereo1 filter" },
3462 3631
3463 { "DAC1 FS", NULL, "DAC1 MIXL" }, 3632 { "DAC1 FS", NULL, "DAC1 MIXL" },
3464 { "DAC1 FS", NULL, "DAC1 MIXR" }, 3633 { "DAC1 FS", NULL, "DAC1 MIXR" },
@@ -3525,35 +3694,46 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3525 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3694 { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3526 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" }, 3695 { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
3527 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" }, 3696 { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
3697 { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
3528 3698
3529 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" }, 3699 { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
3530 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, 3700 { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
3531 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, 3701 { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
3532 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, 3702 { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
3533 { "Mono DAC MIXL", NULL, "dac mono left filter" }, 3703 { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
3704 { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3534 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, 3705 { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
3535 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, 3706 { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
3536 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, 3707 { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
3537 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, 3708 { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
3538 { "Mono DAC MIXR", NULL, "dac mono right filter" }, 3709 { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
3710 { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3539 3711
3540 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3712 { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3541 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3713 { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3542 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, 3714 { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
3543 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, 3715 { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
3716 { "DD1 MIXL", NULL, "dac mono3 left filter" },
3717 { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3544 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3718 { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3545 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3719 { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3546 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, 3720 { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
3547 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, 3721 { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
3722 { "DD1 MIXR", NULL, "dac mono3 right filter" },
3723 { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3548 3724
3549 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 3725 { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
3550 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, 3726 { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
3551 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, 3727 { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
3552 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, 3728 { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
3729 { "DD2 MIXL", NULL, "dac mono4 left filter" },
3730 { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
3553 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 3731 { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
3554 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, 3732 { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
3555 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, 3733 { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
3556 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, 3734 { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
3735 { "DD2 MIXR", NULL, "dac mono4 right filter" },
3736 { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
3557 3737
3558 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, 3738 { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
3559 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, 3739 { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
@@ -3575,11 +3755,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3575 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" }, 3755 { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
3576 3756
3577 { "DAC 1", NULL, "DAC12 SRC Mux" }, 3757 { "DAC 1", NULL, "DAC12 SRC Mux" },
3578 { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll },
3579 { "DAC 2", NULL, "DAC12 SRC Mux" }, 3758 { "DAC 2", NULL, "DAC12 SRC Mux" },
3580 { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll },
3581 { "DAC 3", NULL, "DAC3 SRC Mux" }, 3759 { "DAC 3", NULL, "DAC3 SRC Mux" },
3582 { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll },
3583 3760
3584 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, 3761 { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
3585 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, 3762 { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
@@ -3926,7 +4103,8 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3926 unsigned int rx_mask, int slots, int slot_width) 4103 unsigned int rx_mask, int slots, int slot_width)
3927{ 4104{
3928 struct snd_soc_codec *codec = dai->codec; 4105 struct snd_soc_codec *codec = dai->codec;
3929 unsigned int val = 0; 4106 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4107 unsigned int val = 0, slot_width_25 = 0;
3930 4108
3931 if (rx_mask || tx_mask) 4109 if (rx_mask || tx_mask)
3932 val |= (1 << 12); 4110 val |= (1 << 12);
@@ -3950,6 +4128,8 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3950 case 20: 4128 case 20:
3951 val |= (1 << 8); 4129 val |= (1 << 8);
3952 break; 4130 break;
4131 case 25:
4132 slot_width_25 = 0x8080;
3953 case 24: 4133 case 24:
3954 val |= (2 << 8); 4134 val |= (2 << 8);
3955 break; 4135 break;
@@ -3963,10 +4143,16 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3963 4143
3964 switch (dai->id) { 4144 switch (dai->id) {
3965 case RT5677_AIF1: 4145 case RT5677_AIF1:
3966 snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val); 4146 regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
4147 val);
4148 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000,
4149 slot_width_25);
3967 break; 4150 break;
3968 case RT5677_AIF2: 4151 case RT5677_AIF2:
3969 snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val); 4152 regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
4153 val);
4154 regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80,
4155 slot_width_25);
3970 break; 4156 break;
3971 default: 4157 default:
3972 break; 4158 break;
@@ -4751,6 +4937,11 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
4751 RT5677_GPIO5_DIR_OUT); 4937 RT5677_GPIO5_DIR_OUT);
4752 } 4938 }
4753 4939
4940 if (rt5677->pdata.micbias1_vdd_3v3)
4941 regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
4942 RT5677_MICBIAS1_CTRL_VDD_MASK,
4943 RT5677_MICBIAS1_CTRL_VDD_3_3V);
4944
4754 rt5677_init_gpio(i2c); 4945 rt5677_init_gpio(i2c);
4755 rt5677_init_irq(i2c); 4946 rt5677_init_irq(i2c);
4756 4947