• Home
  • Raw
  • Download

Lines Matching +full:out +full:- +full:mono

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5645.c -- RT5645 ALSA SoC audio codec driver
27 #include <sound/soc-dapm.h>
41 static unsigned int quirk = -1;
638 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
639 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
640 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
641 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
655 /* {-6, -4.5, -3, -1.5, 0, 0.82, 1.58, 2.28} dB */
657 0, 4, TLV_DB_SCALE_ITEM(-600, 150, 0),
666 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in rt5645_hweq_info()
667 uinfo->count = RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s); in rt5645_hweq_info()
678 (struct rt5645_eq_param_s_be16 *)ucontrol->value.bytes.data; in rt5645_hweq_get()
682 eq_param[i].reg = cpu_to_be16(rt5645->eq_param[i].reg); in rt5645_hweq_get()
683 eq_param[i].val = cpu_to_be16(rt5645->eq_param[i].val); in rt5645_hweq_get()
704 (struct rt5645_eq_param_s_be16 *)ucontrol->value.bytes.data; in rt5645_hweq_put()
708 rt5645->eq_param[i].reg = be16_to_cpu(eq_param[i].reg); in rt5645_hweq_put()
709 rt5645->eq_param[i].val = be16_to_cpu(eq_param[i].val); in rt5645_hweq_put()
713 for (i = RT5645_HWEQ_NUM - 1; i >= 0; i--) { in rt5645_hweq_put()
714 if (rt5645->eq_param[i].reg == 0) in rt5645_hweq_put()
716 else if (rt5645->eq_param[i].reg != RT5645_EQ_CTRL2) in rt5645_hweq_put()
723 if (!rt5645_validate_hweq(rt5645->eq_param[i].reg) && in rt5645_hweq_put()
724 rt5645->eq_param[i].reg != 0) in rt5645_hweq_put()
726 else if (rt5645->eq_param[i].reg == 0) in rt5645_hweq_put()
747 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS, in rt5645_spk_put_volsw()
752 mod_delayed_work(system_power_efficient_wq, &rt5645->rcclock_work, in rt5645_spk_put_volsw()
785 SOC_DOUBLE("OUT Playback Switch", RT5645_LOUT1,
787 SOC_DOUBLE("OUT Channel Switch", RT5645_LOUT1,
789 SOC_DOUBLE_TLV("OUT Playback Volume", RT5645_LOUT1,
797 SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5645_DAC2_DIG_VOL,
815 SOC_DOUBLE("Mono ADC Capture Switch", RT5645_MONO_ADC_DIG_VOL,
817 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5645_MONO_ADC_DIG_VOL,
824 SOC_DOUBLE_TLV("Mono ADC Boost Capture Volume", RT5645_ADC_BST_VOL2,
838 * set_dmic_clk - Set parameter of dmic.
848 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
852 rate = rt5645->sysclk / rl6231_get_pre_div(rt5645->regmap, in set_dmic_clk()
856 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
866 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_sys_clk_from_pll()
880 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_using_asrc()
883 switch (source->shift) { in is_using_asrc()
931 if (rt5645_validate_hweq(rt5645->eq_param[i].reg)) in rt5645_enable_hweq()
932 regmap_write(rt5645->regmap, rt5645->eq_param[i].reg, in rt5645_enable_hweq()
933 rt5645->eq_param[i].val); in rt5645_enable_hweq()
942 * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters
971 return -EINVAL; in rt5645_sel_asrc_clk_src()
1129 SOC_DAPM_SINGLE("OUT MIXL Switch", RT5645_REC_L2_MIXER,
1142 SOC_DAPM_SINGLE("OUT MIXR Switch", RT5645_REC_R2_MIXER,
1248 /*DAC1 L/R source*/ /* MX-29 [9:8] [11:10] */
1267 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1269 "IF1 DAC", "IF2 DAC", "IF3 DAC", "Mono ADC", "VAD_ADC"
1280 "IF1 DAC", "IF2 DAC", "IF3 DAC", "Mono ADC", "Haptic"
1291 /* MX-27 [12] */
1303 /* MX-27 [11] */
1315 /* MX-27 [8] */
1327 /* Mono ADC source */
1328 /* MX-28 [12] */
1330 "Mono DAC MIXL", "ADC"
1338 SOC_DAPM_ENUM("Mono ADC1 left source", rt5645_mono_adc_l1_enum);
1339 /* MX-28 [11] */
1341 "Mono DAC MIXL", "DMIC"
1349 SOC_DAPM_ENUM("Mono ADC2 left source", rt5645_mono_adc_l2_enum);
1351 /* MX-28 [8] */
1361 SOC_DAPM_ENUM("Mono DMIC left source", rt5645_mono_dmic_l_enum);
1362 /* MX-28 [1:0] */
1368 SOC_DAPM_ENUM("Mono DMIC Right source", rt5645_mono_dmic_r_enum);
1369 /* MX-28 [4] */
1371 "Mono DAC MIXR", "ADC"
1379 SOC_DAPM_ENUM("Mono ADC1 right source", rt5645_mono_adc_r1_enum);
1380 /* MX-28 [3] */
1382 "Mono DAC MIXR", "DMIC"
1390 SOC_DAPM_ENUM("Mono ADC2 right source", rt5645_mono_adc_r2_enum);
1392 /* MX-77 [9:8] */
1405 /* MX-78 [4:0] */
1443 /* MX-78 [15:14][13:12][11:10] */
1466 /* MX-77 [7:6][5:4][3:2] */
1485 /* MX-79 [14:12][10:8][6:4][2:0] */
1514 /* MX-7a [14:12][10:8][6:4][2:0] */
1539 /* MX-2d [3] [2] */
1558 /* MX-2d [1] [0] */
1560 "Stereo DAC Mixer", "Mono DAC Mixer"
1577 /* MX-2F [13:12] */
1589 /* MX-31 [15] [13] [11] [9] */
1591 "Mono DAC", "Stereo DAC"
1608 /* MX-9D [9:8] */
1610 "Sto1 ADC L", "Mono ADC L", "Mono ADC R"
1651 if (rt5645->codec_type == CODEC_TYPE_RT5650) { in hp_amp_power()
1656 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1661 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1664 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1668 rt5645->hp_on = true; in hp_amp_power()
1674 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1696 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1698 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1704 hp_amp_power_count--; in hp_amp_power()
1706 if (rt5645->codec_type == CODEC_TYPE_RT5650) { in hp_amp_power()
1707 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1710 regmap_write(rt5645->regmap, RT5645_PR_BASE + in hp_amp_power()
1739 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_hp_event()
1746 if (rt5645->codec_type == CODEC_TYPE_RT5645) { in rt5645_hp_event()
1753 regmap_write(rt5645->regmap, RT5645_PR_BASE + in rt5645_hp_event()
1773 if (rt5645->codec_type == CODEC_TYPE_RT5645) { in rt5645_hp_event()
1780 regmap_write(rt5645->regmap, RT5645_PR_BASE + in rt5645_hp_event()
1805 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_spk_event()
1838 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_lout_event()
1868 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_bst2_event()
1891 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5650_hp_event()
1896 if (rt5645->hp_on) { in rt5650_hp_event()
1898 rt5645->hp_on = false; in rt5650_hp_event()
1912 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_set_micbias1_event()
1937 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5645_set_micbias2_event()
1977 SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5645_ASRC_1,
1979 SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5645_ASRC_1,
1983 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5645_ASRC_1,
1985 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5645_ASRC_1,
1989 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5645_ASRC_1,
1991 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5645_ASRC_1,
2059 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
2061 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
2063 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2065 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2067 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2069 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2081 SND_SOC_DAPM_SUPPLY_S("adc mono left filter", 1, RT5645_PWR_DIG2,
2083 SND_SOC_DAPM_MIXER_E("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
2086 SND_SOC_DAPM_SUPPLY_S("adc mono right filter", 1, RT5645_PWR_DIG2,
2088 SND_SOC_DAPM_MIXER_E("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
2156 SND_SOC_DAPM_SUPPLY_S("dac mono left filter", 1, RT5645_PWR_DIG2,
2158 SND_SOC_DAPM_SUPPLY_S("dac mono right filter", 1, RT5645_PWR_DIG2,
2164 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
2166 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
2182 /* OUT Mixer */
2187 SND_SOC_DAPM_MIXER("OUT MIXL", RT5645_PWR_MIXER, RT5645_PWR_OM_L_BIT,
2189 SND_SOC_DAPM_MIXER("OUT MIXR", RT5645_PWR_MIXER, RT5645_PWR_OM_R_BIT,
2210 /* HPO/LOUT/Mono Mixer */
2298 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
2299 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
2300 { "dac mono left filter", NULL, "DAC MONO L ASRC", is_using_asrc },
2301 { "dac mono right filter", NULL, "DAC MONO R ASRC", is_using_asrc },
2329 { "RECMIXL", "OUT MIXL Switch", "OUT MIXL" },
2335 { "RECMIXR", "OUT MIXR Switch", "OUT MIXR" },
2355 { "Mono DMIC L Mux", "DMIC1", "DMIC L1" },
2356 { "Mono DMIC L Mux", "DMIC2", "DMIC L2" },
2357 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC" },
2359 { "Mono DMIC R Mux", "DMIC1", "DMIC R1" },
2360 { "Mono DMIC R Mux", "DMIC2", "DMIC R2" },
2361 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC" },
2373 { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
2374 { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2375 { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2376 { "Mono ADC L1 Mux", "ADC", "ADC L" },
2378 { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2379 { "Mono ADC R1 Mux", "ADC", "ADC R" },
2380 { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
2381 { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2396 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2397 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2398 { "Mono ADC MIXL", NULL, "adc mono left filter" },
2399 { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
2401 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2402 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2403 { "Mono ADC MIXR", NULL, "adc mono right filter" },
2404 { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
2407 { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" },
2408 { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" },
2412 { "IF_ADC2", NULL, "Mono ADC MIXL" },
2413 { "IF_ADC2", NULL, "Mono ADC MIXR" },
2452 { "DAC L2 Mux", "Mono ADC", "Mono ADC MIXL" },
2455 { "DAC L2 Volume", NULL, "dac mono left filter" },
2458 { "DAC R2 Mux", "Mono ADC", "Mono ADC MIXR" },
2461 { "DAC R2 Volume", NULL, "dac mono right filter" },
2472 { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
2473 { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2474 { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" },
2475 { "Mono DAC MIXL", NULL, "dac mono left filter" },
2476 { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
2477 { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2478 { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" },
2479 { "Mono DAC MIXR", NULL, "dac mono right filter" },
2502 { "OUT MIXL", "BST1 Switch", "BST1" },
2503 { "OUT MIXL", "INL Switch", "INL VOL" },
2504 { "OUT MIXL", "DAC L2 Switch", "DAC L2" },
2505 { "OUT MIXL", "DAC L1 Switch", "DAC L1" },
2507 { "OUT MIXR", "BST2 Switch", "BST2" },
2508 { "OUT MIXR", "INR Switch", "INR VOL" },
2509 { "OUT MIXR", "DAC R2 Switch", "DAC R2" },
2510 { "OUT MIXR", "DAC R1 Switch", "DAC R1" },
2544 { "LOUT MIX", "OUTMIX L Switch", "OUT MIXL" },
2545 { "LOUT MIX", "OUTMIX R Switch", "OUT MIXR" },
2548 { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" },
2551 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
2584 { "A DAC2 L Mux", "Mono DAC Mixer", "Mono DAC MIXL"},
2586 { "A DAC2 R Mux", "Mono DAC Mixer", "Mono DAC MIXR"},
2671 { "DAC L2", NULL, "Mono DAC MIXL" },
2672 { "DAC R2", NULL, "Mono DAC MIXR" },
2734 struct snd_soc_component *component = dai->component; in rt5645_hw_params()
2739 rt5645->lrck[dai->id] = params_rate(params); in rt5645_hw_params()
2740 pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); in rt5645_hw_params()
2742 dev_err(component->dev, "Unsupported clock setting\n"); in rt5645_hw_params()
2743 return -EINVAL; in rt5645_hw_params()
2747 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5645_hw_params()
2748 return -EINVAL; in rt5645_hw_params()
2751 switch (rt5645->codec_type) { in rt5645_hw_params()
2761 rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms); in rt5645_hw_params()
2763 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5645_hw_params()
2764 rt5645->bclk[dai->id], rt5645->lrck[dai->id]); in rt5645_hw_params()
2765 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5645_hw_params()
2766 bclk_ms, pre_div, dai->id); in rt5645_hw_params()
2781 return -EINVAL; in rt5645_hw_params()
2784 switch (dai->id) { in rt5645_hw_params()
2801 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5645_hw_params()
2802 return -EINVAL; in rt5645_hw_params()
2810 struct snd_soc_component *component = dai->component; in rt5645_set_dai_fmt()
2814 switch (rt5645->codec_type) { in rt5645_set_dai_fmt()
2825 rt5645->master[dai->id] = 1; in rt5645_set_dai_fmt()
2829 rt5645->master[dai->id] = 0; in rt5645_set_dai_fmt()
2832 return -EINVAL; in rt5645_set_dai_fmt()
2842 return -EINVAL; in rt5645_set_dai_fmt()
2858 return -EINVAL; in rt5645_set_dai_fmt()
2860 switch (dai->id) { in rt5645_set_dai_fmt()
2872 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5645_set_dai_fmt()
2873 return -EINVAL; in rt5645_set_dai_fmt()
2881 struct snd_soc_component *component = dai->component; in rt5645_set_dai_sysclk()
2885 if (freq == rt5645->sysclk && clk_id == rt5645->sysclk_src) in rt5645_set_dai_sysclk()
2899 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5645_set_dai_sysclk()
2900 return -EINVAL; in rt5645_set_dai_sysclk()
2904 rt5645->sysclk = freq; in rt5645_set_dai_sysclk()
2905 rt5645->sysclk_src = clk_id; in rt5645_set_dai_sysclk()
2907 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5645_set_dai_sysclk()
2915 struct snd_soc_component *component = dai->component; in rt5645_set_dai_pll()
2920 if (source == rt5645->pll_src && freq_in == rt5645->pll_in && in rt5645_set_dai_pll()
2921 freq_out == rt5645->pll_out) in rt5645_set_dai_pll()
2925 dev_dbg(component->dev, "PLL disabled\n"); in rt5645_set_dai_pll()
2927 rt5645->pll_in = 0; in rt5645_set_dai_pll()
2928 rt5645->pll_out = 0; in rt5645_set_dai_pll()
2941 switch (dai->id) { in rt5645_set_dai_pll()
2951 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5645_set_dai_pll()
2952 return -EINVAL; in rt5645_set_dai_pll()
2956 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5645_set_dai_pll()
2957 return -EINVAL; in rt5645_set_dai_pll()
2962 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5645_set_dai_pll()
2966 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5645_set_dai_pll()
2976 rt5645->pll_in = freq_in; in rt5645_set_dai_pll()
2977 rt5645->pll_out = freq_out; in rt5645_set_dai_pll()
2978 rt5645->pll_src = source; in rt5645_set_dai_pll()
2986 struct snd_soc_component *component = dai->component; in rt5645_set_tdm_slot()
2991 switch (rt5645->codec_type) { in rt5645_set_tdm_slot()
3009 if (rt5645->codec_type == CODEC_TYPE_RT5645) in rt5645_set_tdm_slot()
3084 if (rt5645->en_button_func) in rt5645_set_bias_level()
3086 &rt5645->jack_detect_work, in rt5645_set_bias_level()
3093 if (!rt5645->en_button_func) in rt5645_set_bias_level()
3144 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06); in rt5645_jack_detect()
3150 if (!dapm->card->instantiated) { in rt5645_jack_detect()
3153 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1, in rt5645_jack_detect()
3156 regmap_update_bits(rt5645->regmap, RT5645_PWR_MIXER, in rt5645_jack_detect()
3158 regmap_update_bits(rt5645->regmap, RT5645_PWR_VOL, in rt5645_jack_detect()
3162 regmap_write(rt5645->regmap, RT5645_JD_CTRL3, 0x00f0); in rt5645_jack_detect()
3163 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, in rt5645_jack_detect()
3165 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, in rt5645_jack_detect()
3168 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, in rt5645_jack_detect()
3172 regmap_read(rt5645->regmap, RT5645_IN1_CTRL3, &val); in rt5645_jack_detect()
3174 dev_dbg(component->dev, "val = %d\n", val); in rt5645_jack_detect()
3177 rt5645->jack_type = SND_JACK_HEADSET; in rt5645_jack_detect()
3178 if (rt5645->en_button_func) { in rt5645_jack_detect()
3184 rt5645->jack_type = SND_JACK_HEADPHONE; in rt5645_jack_detect()
3186 if (rt5645->pdata.level_trigger_irq) in rt5645_jack_detect()
3187 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, in rt5645_jack_detect()
3189 } else { /* jack out */ in rt5645_jack_detect()
3190 rt5645->jack_type = 0; in rt5645_jack_detect()
3192 regmap_update_bits(rt5645->regmap, RT5645_HP_VOL, in rt5645_jack_detect()
3195 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, in rt5645_jack_detect()
3197 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, in rt5645_jack_detect()
3200 if (rt5645->en_button_func) in rt5645_jack_detect()
3203 if (rt5645->pdata.jd_mode == 0) in rt5645_jack_detect()
3207 if (rt5645->pdata.level_trigger_irq) in rt5645_jack_detect()
3208 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, in rt5645_jack_detect()
3212 return rt5645->jack_type; in rt5645_jack_detect()
3235 rt5645->hp_jack = hp_jack; in rt5645_set_jack_detect()
3236 rt5645->mic_jack = mic_jack; in rt5645_set_jack_detect()
3237 rt5645->btn_jack = btn_jack; in rt5645_set_jack_detect()
3238 if (rt5645->btn_jack && rt5645->codec_type == CODEC_TYPE_RT5650) { in rt5645_set_jack_detect()
3239 rt5645->en_button_func = true; in rt5645_set_jack_detect()
3240 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_set_jack_detect()
3242 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL1, in rt5645_set_jack_detect()
3257 if (!rt5645->component) in rt5645_jack_detect_work()
3260 switch (rt5645->pdata.jd_mode) { in rt5645_jack_detect_work()
3262 if (rt5645->gpiod_hp_det) { in rt5645_jack_detect_work()
3263 gpio_state = gpiod_get_value(rt5645->gpiod_hp_det); in rt5645_jack_detect_work()
3264 dev_dbg(rt5645->component->dev, "gpio_state = %d\n", in rt5645_jack_detect_work()
3266 report = rt5645_jack_detect(rt5645->component, gpio_state); in rt5645_jack_detect_work()
3268 snd_soc_jack_report(rt5645->hp_jack, in rt5645_jack_detect_work()
3270 snd_soc_jack_report(rt5645->mic_jack, in rt5645_jack_detect_work()
3274 val = snd_soc_component_read(rt5645->component, RT5645_A_JD_CTRL1) & 0x0020; in rt5645_jack_detect_work()
3277 val = snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000; in rt5645_jack_detect_work()
3282 if (!val && (rt5645->jack_type == 0)) { /* jack in */ in rt5645_jack_detect_work()
3283 report = rt5645_jack_detect(rt5645->component, 1); in rt5645_jack_detect_work()
3284 } else if (!val && rt5645->jack_type != 0) { in rt5645_jack_detect_work()
3285 /* for push button and jack out */ in rt5645_jack_detect_work()
3287 if (snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x4) { in rt5645_jack_detect_work()
3290 btn_type = rt5645_button_detect(rt5645->component); in rt5645_jack_detect_work()
3320 dev_err(rt5645->component->dev, in rt5645_jack_detect_work()
3327 report = rt5645->jack_type; in rt5645_jack_detect_work()
3329 mod_timer(&rt5645->btn_check_timer, in rt5645_jack_detect_work()
3333 /* jack out */ in rt5645_jack_detect_work()
3335 snd_soc_component_update_bits(rt5645->component, in rt5645_jack_detect_work()
3337 rt5645_jack_detect(rt5645->component, 0); in rt5645_jack_detect_work()
3340 snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE); in rt5645_jack_detect_work()
3341 snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE); in rt5645_jack_detect_work()
3342 if (rt5645->en_button_func) in rt5645_jack_detect_work()
3343 snd_soc_jack_report(rt5645->btn_jack, in rt5645_jack_detect_work()
3353 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS, in rt5645_rcclock_work()
3362 &rt5645->jack_detect_work, msecs_to_jiffies(250)); in rt5645_irq()
3372 &rt5645->jack_detect_work, msecs_to_jiffies(5)); in rt5645_btn_check_callback()
3380 rt5645->component = component; in rt5645_probe()
3382 switch (rt5645->codec_type) { in rt5645_probe()
3390 if (rt5645->v_id < 3) { in rt5645_probe()
3409 if (rt5645->pdata.jd_mode) { in rt5645_probe()
3415 if (rt5645->pdata.long_name) in rt5645_probe()
3416 component->card->long_name = rt5645->pdata.long_name; in rt5645_probe()
3418 rt5645->eq_param = devm_kcalloc(component->dev, in rt5645_probe()
3422 if (!rt5645->eq_param) in rt5645_probe()
3423 return -ENOMEM; in rt5645_probe()
3438 regcache_cache_only(rt5645->regmap, true); in rt5645_suspend()
3439 regcache_mark_dirty(rt5645->regmap); in rt5645_suspend()
3448 regcache_cache_only(rt5645->regmap, false); in rt5645_resume()
3449 regcache_sync(rt5645->regmap); in rt5645_resume()
3472 .name = "rt5645-aif1",
3491 .name = "rt5645-aif2",
3616 .long_name = "gpd-win-pocket-rt5645",
3726 .ident = "MINIX Z83-4",
3729 DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
3746 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"),
3755 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
3788 if (device_property_present(dev, "realtek,in2-differential") || in rt5645_check_dp()
3789 device_property_present(dev, "realtek,dmic1-data-pin") || in rt5645_check_dp()
3790 device_property_present(dev, "realtek,dmic2-data-pin") || in rt5645_check_dp()
3791 device_property_present(dev, "realtek,jd-mode")) in rt5645_check_dp()
3799 rt5645->pdata.in2_diff = device_property_read_bool(dev, in rt5645_parse_dt()
3800 "realtek,in2-differential"); in rt5645_parse_dt()
3802 "realtek,dmic1-data-pin", &rt5645->pdata.dmic1_data_pin); in rt5645_parse_dt()
3804 "realtek,dmic2-data-pin", &rt5645->pdata.dmic2_data_pin); in rt5645_parse_dt()
3806 "realtek,jd-mode", &rt5645->pdata.jd_mode); in rt5645_parse_dt()
3814 struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt5645_i2c_probe()
3821 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv), in rt5645_i2c_probe()
3824 return -ENOMEM; in rt5645_i2c_probe()
3826 rt5645->i2c = i2c; in rt5645_i2c_probe()
3831 dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident); in rt5645_i2c_probe()
3832 pdata = dmi_data->driver_data; in rt5645_i2c_probe()
3836 rt5645->pdata = *pdata; in rt5645_i2c_probe()
3837 else if (rt5645_check_dp(&i2c->dev)) in rt5645_i2c_probe()
3838 rt5645_parse_dt(rt5645, &i2c->dev); in rt5645_i2c_probe()
3840 rt5645->pdata = jd_mode3_platform_data; in rt5645_i2c_probe()
3842 if (quirk != -1) { in rt5645_i2c_probe()
3843 rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk); in rt5645_i2c_probe()
3844 rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk); in rt5645_i2c_probe()
3845 rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk); in rt5645_i2c_probe()
3846 rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk); in rt5645_i2c_probe()
3847 rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk); in rt5645_i2c_probe()
3848 rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk); in rt5645_i2c_probe()
3851 rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect", in rt5645_i2c_probe()
3854 if (IS_ERR(rt5645->gpiod_hp_det)) { in rt5645_i2c_probe()
3855 dev_info(&i2c->dev, "failed to initialize gpiod\n"); in rt5645_i2c_probe()
3856 ret = PTR_ERR(rt5645->gpiod_hp_det); in rt5645_i2c_probe()
3859 * errors, including -EPROBE_DEFER in rt5645_i2c_probe()
3861 if (ret != -ENOENT) in rt5645_i2c_probe()
3865 for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++) in rt5645_i2c_probe()
3866 rt5645->supplies[i].supply = rt5645_supply_names[i]; in rt5645_i2c_probe()
3868 ret = devm_regulator_bulk_get(&i2c->dev, in rt5645_i2c_probe()
3869 ARRAY_SIZE(rt5645->supplies), in rt5645_i2c_probe()
3870 rt5645->supplies); in rt5645_i2c_probe()
3872 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in rt5645_i2c_probe()
3876 ret = regulator_bulk_enable(ARRAY_SIZE(rt5645->supplies), in rt5645_i2c_probe()
3877 rt5645->supplies); in rt5645_i2c_probe()
3879 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in rt5645_i2c_probe()
3886 dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n", in rt5645_i2c_probe()
3900 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap); in rt5645_i2c_probe()
3901 rt5645->codec_type = CODEC_TYPE_RT5645; in rt5645_i2c_probe()
3904 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5650_regmap); in rt5645_i2c_probe()
3905 rt5645->codec_type = CODEC_TYPE_RT5650; in rt5645_i2c_probe()
3908 dev_err(&i2c->dev, in rt5645_i2c_probe()
3911 ret = -ENODEV; in rt5645_i2c_probe()
3915 if (IS_ERR(rt5645->regmap)) { in rt5645_i2c_probe()
3916 ret = PTR_ERR(rt5645->regmap); in rt5645_i2c_probe()
3917 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5645_i2c_probe()
3922 regmap_write(rt5645->regmap, RT5645_RESET, 0); in rt5645_i2c_probe()
3925 rt5645->v_id = val & 0xff; in rt5645_i2c_probe()
3927 regmap_write(rt5645->regmap, RT5645_AD_DA_MIXER, 0x8080); in rt5645_i2c_probe()
3929 ret = regmap_register_patch(rt5645->regmap, init_list, in rt5645_i2c_probe()
3932 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5645_i2c_probe()
3934 if (rt5645->codec_type == CODEC_TYPE_RT5650) { in rt5645_i2c_probe()
3935 ret = regmap_register_patch(rt5645->regmap, rt5650_init_list, in rt5645_i2c_probe()
3938 dev_warn(&i2c->dev, "Apply rt5650 patch failed: %d\n", in rt5645_i2c_probe()
3942 regmap_update_bits(rt5645->regmap, RT5645_CLSD_OUT_CTRL, 0xc0, 0xc0); in rt5645_i2c_probe()
3944 if (rt5645->pdata.in2_diff) in rt5645_i2c_probe()
3945 regmap_update_bits(rt5645->regmap, RT5645_IN2_CTRL, in rt5645_i2c_probe()
3948 if (rt5645->pdata.dmic1_data_pin || rt5645->pdata.dmic2_data_pin) { in rt5645_i2c_probe()
3949 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
3952 switch (rt5645->pdata.dmic1_data_pin) { in rt5645_i2c_probe()
3954 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3959 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
3961 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3963 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
3968 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3970 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
3979 switch (rt5645->pdata.dmic2_data_pin) { in rt5645_i2c_probe()
3981 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3986 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3988 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
3993 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
3995 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
4001 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, in rt5645_i2c_probe()
4003 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
4012 if (rt5645->pdata.jd_mode) { in rt5645_i2c_probe()
4013 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, in rt5645_i2c_probe()
4016 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS, in rt5645_i2c_probe()
4018 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, in rt5645_i2c_probe()
4020 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, in rt5645_i2c_probe()
4022 regmap_update_bits(rt5645->regmap, RT5645_HPO_MIXER, in rt5645_i2c_probe()
4024 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS, in rt5645_i2c_probe()
4026 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, in rt5645_i2c_probe()
4028 switch (rt5645->pdata.jd_mode) { in rt5645_i2c_probe()
4030 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1, in rt5645_i2c_probe()
4035 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1, in rt5645_i2c_probe()
4041 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1, in rt5645_i2c_probe()
4048 if (rt5645->pdata.inv_jd1_1) { in rt5645_i2c_probe()
4049 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, in rt5645_i2c_probe()
4054 regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1, in rt5645_i2c_probe()
4057 if (rt5645->pdata.level_trigger_irq) { in rt5645_i2c_probe()
4058 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, in rt5645_i2c_probe()
4061 timer_setup(&rt5645->btn_check_timer, rt5645_btn_check_callback, 0); in rt5645_i2c_probe()
4063 INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work); in rt5645_i2c_probe()
4064 INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work); in rt5645_i2c_probe()
4066 if (rt5645->i2c->irq) { in rt5645_i2c_probe()
4067 ret = request_threaded_irq(rt5645->i2c->irq, NULL, rt5645_irq, in rt5645_i2c_probe()
4071 dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); in rt5645_i2c_probe()
4076 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5645, in rt5645_i2c_probe()
4084 if (rt5645->i2c->irq) in rt5645_i2c_probe()
4085 free_irq(rt5645->i2c->irq, rt5645); in rt5645_i2c_probe()
4087 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies); in rt5645_i2c_probe()
4095 if (i2c->irq) in rt5645_i2c_remove()
4096 free_irq(i2c->irq, rt5645); in rt5645_i2c_remove()
4098 cancel_delayed_work_sync(&rt5645->jack_detect_work); in rt5645_i2c_remove()
4099 cancel_delayed_work_sync(&rt5645->rcclock_work); in rt5645_i2c_remove()
4100 del_timer_sync(&rt5645->btn_check_timer); in rt5645_i2c_remove()
4102 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies); in rt5645_i2c_remove()
4111 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, in rt5645_i2c_shutdown()
4113 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, RT5645_CBJ_MN_JD, in rt5645_i2c_shutdown()
4115 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, RT5645_CBJ_BST1_EN, in rt5645_i2c_shutdown()
4118 regmap_write(rt5645->regmap, RT5645_RESET, 0); in rt5645_i2c_shutdown()