Lines Matching +full:out +full:- +full:mono
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5670.c -- RT5670 ALSA SoC audio codec driver
25 #include <sound/soc-dapm.h>
31 #include "rt5670-dsp.h"
50 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
422 * rt5670_headset_detect - Detect headset.
457 rt5670->jack_type = SND_JACK_HEADSET; in rt5670_headset_detect()
464 rt5670->jack_type = SND_JACK_HEADPHONE; in rt5670_headset_detect()
471 rt5670->jack_type = 0; in rt5670_headset_detect()
476 return rt5670->jack_type; in rt5670_headset_detect()
483 rt5670->jack_type_saved = rt5670->jack_type; in rt5670_jack_suspend()
492 if (rt5670->jack_type_saved) in rt5670_jack_resume()
516 struct snd_soc_jack_gpio *gpio = &rt5670->hp_gpio; in rt5670_irq_detection()
517 struct snd_soc_jack *jack = rt5670->jack; in rt5670_irq_detection()
518 int val, btn_type, report = jack->status; in rt5670_irq_detection()
520 if (rt5670->jd_mode == 1) /* 2 port */ in rt5670_irq_detection()
521 val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; in rt5670_irq_detection()
523 val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; in rt5670_irq_detection()
529 if (rt5670->jack_type == 0) { in rt5670_irq_detection()
530 report = rt5670_headset_detect(rt5670->component, 1); in rt5670_irq_detection()
531 /* for push button and jack out */ in rt5670_irq_detection()
532 gpio->debounce_time = 25; in rt5670_irq_detection()
536 if (snd_soc_component_read(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { in rt5670_irq_detection()
539 btn_type = rt5670_button_detect(rt5670->component); in rt5670_irq_detection()
551 dev_err(rt5670->component->dev, in rt5670_irq_detection()
558 report = rt5670->jack_type; in rt5670_irq_detection()
561 /* jack out */ in rt5670_irq_detection()
566 snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); in rt5670_irq_detection()
567 rt5670_headset_detect(rt5670->component, 0); in rt5670_irq_detection()
568 gpio->debounce_time = 150; /* for jack in */ in rt5670_irq_detection()
583 rt5670->jack = jack; in rt5670_set_jack_detect()
584 rt5670->hp_gpio.gpiod_dev = component->dev; in rt5670_set_jack_detect()
585 rt5670->hp_gpio.name = "headset"; in rt5670_set_jack_detect()
586 rt5670->hp_gpio.report = SND_JACK_HEADSET | in rt5670_set_jack_detect()
588 rt5670->hp_gpio.debounce_time = 150; in rt5670_set_jack_detect()
589 rt5670->hp_gpio.wake = true; in rt5670_set_jack_detect()
590 rt5670->hp_gpio.data = (struct rt5670_priv *)rt5670; in rt5670_set_jack_detect()
591 rt5670->hp_gpio.jack_status_check = rt5670_irq_detection; in rt5670_set_jack_detect()
593 ret = snd_soc_jack_add_gpios(rt5670->jack, 1, in rt5670_set_jack_detect()
594 &rt5670->hp_gpio); in rt5670_set_jack_detect()
596 dev_err(component->dev, "Adding jack GPIO failed\n"); in rt5670_set_jack_detect()
604 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
605 static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
606 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
607 static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
640 SOC_DOUBLE("OUT Channel Switch", RT5670_LOUT1,
642 SOC_DOUBLE_TLV("OUT Playback Volume", RT5670_LOUT1,
650 SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5670_DAC2_DIG_VOL,
669 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL,
687 * set_dmic_clk - Set parameter of dmic.
699 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
703 rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, in set_dmic_clk()
707 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
717 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_sys_clk_from_pll()
720 if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) in is_sys_clk_from_pll()
729 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_using_asrc()
732 switch (source->shift) { in is_using_asrc()
781 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in can_use_asrc()
784 if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) in can_use_asrc()
792 * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters
812 return -EINVAL; in rt5670_sel_asrc_clk_src()
1065 /* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */
1082 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1105 /*RxDP source*/ /* MX-2D [15:13] */
1108 "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1"
1117 /* MX-2D [1] [0] */
1135 /* MX-26 [15] */
1147 /* MX-27 MX-26 [12] */
1165 /* MX-27 MX-26 [11] */
1182 /* MX-27 MX-26 [9:8] */
1199 /* Mono ADC source */
1200 /* MX-28 [12] */
1202 "Mono DAC MIXL", "ADC1"
1209 SOC_DAPM_ENUM("Mono ADC1 left source", rt5670_mono_adc_l1_enum);
1210 /* MX-28 [11] */
1212 "Mono DAC MIXL", "DMIC"
1219 SOC_DAPM_ENUM("Mono ADC2 left source", rt5670_mono_adc_l2_enum);
1221 /* MX-28 [9:8] */
1230 SOC_DAPM_ENUM("Mono DMIC left source", rt5670_mono_dmic_l_enum);
1231 /* MX-28 [1:0] */
1236 SOC_DAPM_ENUM("Mono DMIC Right source", rt5670_mono_dmic_r_enum);
1237 /* MX-28 [4] */
1239 "Mono DAC MIXR", "ADC2"
1246 SOC_DAPM_ENUM("Mono ADC1 right source", rt5670_mono_adc_r1_enum);
1247 /* MX-28 [3] */
1249 "Mono DAC MIXR", "DMIC"
1256 SOC_DAPM_ENUM("Mono ADC2 right source", rt5670_mono_adc_r2_enum);
1258 /* MX-2D [3:2] */
1260 "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7"
1269 /* MX-2F [15] */
1280 /* MX-2F [14:12] */
1291 /* MX-31 [15] [13] [11] [9] */
1293 "Mono DAC", "Stereo DAC"
1320 /* MX-FA [12] */
1331 /* MX-FA [11] */
1342 /* MX-FA [10] */
1353 /* MX-9D [9:8] */
1355 "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L"
1367 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_power_event()
1372 regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, in rt5670_hp_power_event()
1374 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_power_event()
1377 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_hp_power_event()
1382 regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); in rt5670_hp_power_event()
1383 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); in rt5670_hp_power_event()
1384 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_power_event()
1387 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_power_event()
1390 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); in rt5670_hp_power_event()
1403 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_event()
1409 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1411 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1412 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); in rt5670_hp_event()
1413 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1414 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_event()
1416 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1419 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1424 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1426 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1427 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); in rt5670_hp_event()
1429 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1431 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1435 regmap_update_bits(rt5670->regmap, in rt5670_hp_event()
1437 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1438 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); in rt5670_hp_event()
1439 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1453 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_spk_event()
1456 if (!rt5670->gpio1_is_ext_spk_en) in rt5670_spk_event()
1461 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1466 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1480 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst1_event()
1503 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst2_event()
1538 SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5670_ASRC_1,
1540 SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1,
1546 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5670_ASRC_1,
1548 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5670_ASRC_1,
1554 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1,
1556 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1,
1642 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
1644 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
1646 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
1648 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
1650 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
1652 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
1671 SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2,
1673 SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL,
1676 SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2,
1678 SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL,
1690 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1787 SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5670_PWR_DIG2,
1789 SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5670_PWR_DIG2,
1797 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
1800 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
1822 /* OUT Mixer */
1824 SND_SOC_DAPM_MIXER("OUT MIXL", RT5670_PWR_MIXER, RT5670_PWR_OM_L_BIT,
1826 SND_SOC_DAPM_MIXER("OUT MIXR", RT5670_PWR_MIXER, RT5670_PWR_OM_R_BIT,
1839 /* HPO/LOUT/Mono Mixer */
1902 { "ADC Mono Left Filter", NULL, "ADC MONO L ASRC", is_using_asrc },
1903 { "ADC Mono Right Filter", NULL, "ADC MONO R ASRC", is_using_asrc },
1904 { "DAC Mono Left Filter", NULL, "DAC MONO L ASRC", is_using_asrc },
1905 { "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc },
1909 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
1910 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
1967 { "Mono DMIC L Mux", "DMIC1", "DMIC L1" },
1968 { "Mono DMIC L Mux", "DMIC2", "DMIC L2" },
1969 { "Mono DMIC L Mux", "DMIC3", "DMIC L3" },
1971 { "Mono DMIC R Mux", "DMIC1", "DMIC R1" },
1972 { "Mono DMIC R Mux", "DMIC2", "DMIC R2" },
1973 { "Mono DMIC R Mux", "DMIC3", "DMIC R3" },
1988 { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
1989 { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
1990 { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
1991 { "Mono ADC L1 Mux", "ADC1", "ADC 1" },
1993 { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
1994 { "Mono ADC R1 Mux", "ADC2", "ADC 2" },
1995 { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
1996 { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2010 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2011 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2012 { "Mono ADC MIXL", NULL, "ADC Mono Left Filter" },
2013 { "ADC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
2015 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2016 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2017 { "Mono ADC MIXR", NULL, "ADC Mono Right Filter" },
2018 { "ADC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
2049 { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" },
2050 { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" },
2057 { "IF_ADC2", NULL, "Mono ADC MIXL" },
2058 { "IF_ADC2", NULL, "Mono ADC MIXR" },
2081 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
2082 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
2088 { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" },
2089 { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" },
2092 { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" },
2093 { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" },
2094 { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" },
2095 { "TDM Data Mux", "Slot 6-7", "IF2 DAC" },
2161 { "DAC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
2162 { "DAC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
2175 { "DAC L2 Volume", NULL, "DAC Mono Left Filter" },
2182 { "DAC R2 Volume", NULL, "DAC Mono Right Filter" },
2195 { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
2196 { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2197 { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" },
2198 { "Mono DAC MIXL", NULL, "DAC Mono Left Filter" },
2199 { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
2200 { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2201 { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" },
2202 { "Mono DAC MIXR", NULL, "DAC Mono Right Filter" },
2215 { "DAC L2", NULL, "Mono DAC MIXL" },
2216 { "DAC R2", NULL, "Mono DAC MIXR" },
2218 { "OUT MIXL", "BST1 Switch", "BST1" },
2219 { "OUT MIXL", "INL Switch", "INL VOL" },
2220 { "OUT MIXL", "DAC L2 Switch", "DAC L2" },
2221 { "OUT MIXL", "DAC L1 Switch", "DAC L1" },
2223 { "OUT MIXR", "BST2 Switch", "BST2" },
2224 { "OUT MIXR", "INR Switch", "INR VOL" },
2225 { "OUT MIXR", "DAC R2 Switch", "DAC R2" },
2226 { "OUT MIXR", "DAC R1 Switch", "DAC R1" },
2244 { "LOUT MIX", "OUTMIX L Switch", "OUT MIXL" },
2245 { "LOUT MIX", "OUTMIX R Switch", "OUT MIXR" },
2248 { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" },
2251 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
2274 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
2277 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
2297 struct snd_soc_component *component = dai->component; in rt5670_hw_params()
2302 rt5670->lrck[dai->id] = params_rate(params); in rt5670_hw_params()
2303 pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); in rt5670_hw_params()
2305 dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", in rt5670_hw_params()
2306 rt5670->lrck[dai->id], dai->id); in rt5670_hw_params()
2307 return -EINVAL; in rt5670_hw_params()
2311 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5670_hw_params()
2312 return -EINVAL; in rt5670_hw_params()
2315 rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); in rt5670_hw_params()
2317 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5670_hw_params()
2318 rt5670->bclk[dai->id], rt5670->lrck[dai->id]); in rt5670_hw_params()
2319 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5670_hw_params()
2320 bclk_ms, pre_div, dai->id); in rt5670_hw_params()
2335 return -EINVAL; in rt5670_hw_params()
2338 switch (dai->id) { in rt5670_hw_params()
2356 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_hw_params()
2357 return -EINVAL; in rt5670_hw_params()
2365 struct snd_soc_component *component = dai->component; in rt5670_set_dai_fmt()
2371 rt5670->master[dai->id] = 1; in rt5670_set_dai_fmt()
2375 rt5670->master[dai->id] = 0; in rt5670_set_dai_fmt()
2378 return -EINVAL; in rt5670_set_dai_fmt()
2388 return -EINVAL; in rt5670_set_dai_fmt()
2404 return -EINVAL; in rt5670_set_dai_fmt()
2407 switch (dai->id) { in rt5670_set_dai_fmt()
2419 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_fmt()
2420 return -EINVAL; in rt5670_set_dai_fmt()
2442 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5670_set_codec_sysclk()
2443 return -EINVAL; in rt5670_set_codec_sysclk()
2447 rt5670->sysclk = freq; in rt5670_set_codec_sysclk()
2449 rt5670->sysclk_src = clk_id; in rt5670_set_codec_sysclk()
2451 dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); in rt5670_set_codec_sysclk()
2459 struct snd_soc_component *component = dai->component; in rt5670_set_dai_pll()
2464 if (source == rt5670->pll_src && freq_in == rt5670->pll_in && in rt5670_set_dai_pll()
2465 freq_out == rt5670->pll_out) in rt5670_set_dai_pll()
2469 dev_dbg(component->dev, "PLL disabled\n"); in rt5670_set_dai_pll()
2471 rt5670->pll_in = 0; in rt5670_set_dai_pll()
2472 rt5670->pll_out = 0; in rt5670_set_dai_pll()
2487 switch (dai->id) { in rt5670_set_dai_pll()
2497 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_pll()
2498 return -EINVAL; in rt5670_set_dai_pll()
2502 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5670_set_dai_pll()
2503 return -EINVAL; in rt5670_set_dai_pll()
2508 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5670_set_dai_pll()
2512 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5670_set_dai_pll()
2522 rt5670->pll_in = freq_in; in rt5670_set_dai_pll()
2523 rt5670->pll_out = freq_out; in rt5670_set_dai_pll()
2524 rt5670->pll_src = source; in rt5670_set_dai_pll()
2532 struct snd_soc_component *component = dai->component; in rt5670_set_tdm_slot()
2551 return -EINVAL; in rt5670_set_tdm_slot()
2567 return -EINVAL; in rt5670_set_tdm_slot()
2577 struct snd_soc_component *component = dai->component; in rt5670_set_bclk_ratio()
2579 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt5670_set_bclk_ratio()
2580 if (dai->id != RT5670_AIF1) in rt5670_set_bclk_ratio()
2626 if (rt5670->jd_mode) in rt5670_set_bias_level()
2672 dev_err(component->dev, in rt5670_probe()
2674 return -ENODEV; in rt5670_probe()
2676 rt5670->component = component; in rt5670_probe()
2685 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_remove()
2686 snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); in rt5670_remove()
2694 regcache_cache_only(rt5670->regmap, true); in rt5670_suspend()
2695 regcache_mark_dirty(rt5670->regmap); in rt5670_suspend()
2703 regcache_cache_only(rt5670->regmap, false); in rt5670_resume()
2704 regcache_sync(rt5670->regmap); in rt5670_resume()
2727 .name = "rt5670-aif1",
2747 .name = "rt5670-aif2",
2822 rt5670_quirk = (unsigned long)id->driver_data; in rt5670_quirk_cb()
2945 rt5670 = devm_kzalloc(&i2c->dev, in rt5670_i2c_probe()
2949 return -ENOMEM; in rt5670_i2c_probe()
2955 dev_info(&i2c->dev, "Overriding quirk 0x%x => 0x%x\n", in rt5670_i2c_probe()
2961 rt5670->gpio1_is_irq = true; in rt5670_i2c_probe()
2962 dev_info(&i2c->dev, "quirk GPIO1 is IRQ\n"); in rt5670_i2c_probe()
2965 rt5670->gpio1_is_ext_spk_en = true; in rt5670_i2c_probe()
2966 dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n"); in rt5670_i2c_probe()
2969 rt5670->in2_diff = true; in rt5670_i2c_probe()
2970 dev_info(&i2c->dev, "quirk IN2_DIFF\n"); in rt5670_i2c_probe()
2973 rt5670->dmic_en = true; in rt5670_i2c_probe()
2974 dev_info(&i2c->dev, "quirk DMIC enabled\n"); in rt5670_i2c_probe()
2977 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_IN2P; in rt5670_i2c_probe()
2978 dev_info(&i2c->dev, "quirk DMIC1 on IN2P pin\n"); in rt5670_i2c_probe()
2981 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; in rt5670_i2c_probe()
2982 dev_info(&i2c->dev, "quirk DMIC1 on GPIO6 pin\n"); in rt5670_i2c_probe()
2985 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; in rt5670_i2c_probe()
2986 dev_info(&i2c->dev, "quirk DMIC1 on GPIO7 pin\n"); in rt5670_i2c_probe()
2989 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_IN3N; in rt5670_i2c_probe()
2990 dev_info(&i2c->dev, "quirk DMIC2 on INR pin\n"); in rt5670_i2c_probe()
2993 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; in rt5670_i2c_probe()
2994 dev_info(&i2c->dev, "quirk DMIC2 on GPIO8 pin\n"); in rt5670_i2c_probe()
2997 rt5670->dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; in rt5670_i2c_probe()
2998 dev_info(&i2c->dev, "quirk DMIC3 on GPIO5 pin\n"); in rt5670_i2c_probe()
3002 rt5670->jd_mode = 1; in rt5670_i2c_probe()
3003 dev_info(&i2c->dev, "quirk JD mode 1\n"); in rt5670_i2c_probe()
3006 rt5670->jd_mode = 2; in rt5670_i2c_probe()
3007 dev_info(&i2c->dev, "quirk JD mode 2\n"); in rt5670_i2c_probe()
3010 rt5670->jd_mode = 3; in rt5670_i2c_probe()
3011 dev_info(&i2c->dev, "quirk JD mode 3\n"); in rt5670_i2c_probe()
3014 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); in rt5670_i2c_probe()
3015 if (IS_ERR(rt5670->regmap)) { in rt5670_i2c_probe()
3016 ret = PTR_ERR(rt5670->regmap); in rt5670_i2c_probe()
3017 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5670_i2c_probe()
3022 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); in rt5670_i2c_probe()
3024 dev_err(&i2c->dev, in rt5670_i2c_probe()
3026 return -ENODEV; in rt5670_i2c_probe()
3029 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3030 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3035 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3037 regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val); in rt5670_i2c_probe()
3039 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980); in rt5670_i2c_probe()
3041 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00); in rt5670_i2c_probe()
3043 ret = regmap_register_patch(rt5670->regmap, init_list, in rt5670_i2c_probe()
3046 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5670_i2c_probe()
3048 regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, in rt5670_i2c_probe()
3051 if (rt5670->in2_diff) in rt5670_i2c_probe()
3052 regmap_update_bits(rt5670->regmap, RT5670_IN2, in rt5670_i2c_probe()
3055 if (rt5670->gpio1_is_irq) { in rt5670_i2c_probe()
3057 regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); in rt5670_i2c_probe()
3058 regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); in rt5670_i2c_probe()
3059 regmap_write(rt5670->regmap, RT5670_IL_CMD3, 0x0014); in rt5670_i2c_probe()
3061 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3063 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3067 if (rt5670->gpio1_is_ext_spk_en) { in rt5670_i2c_probe()
3068 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3070 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3074 if (rt5670->jd_mode) { in rt5670_i2c_probe()
3075 regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, in rt5670_i2c_probe()
3077 rt5670->sysclk = 0; in rt5670_i2c_probe()
3078 rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; in rt5670_i2c_probe()
3079 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3081 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, in rt5670_i2c_probe()
3083 regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, in rt5670_i2c_probe()
3085 regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, in rt5670_i2c_probe()
3089 switch (rt5670->jd_mode) { in rt5670_i2c_probe()
3091 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3096 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3101 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3110 if (rt5670->dmic_en) { in rt5670_i2c_probe()
3111 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3115 switch (rt5670->dmic1_data_pin) { in rt5670_i2c_probe()
3117 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3123 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3126 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3132 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3135 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3144 switch (rt5670->dmic2_data_pin) { in rt5670_i2c_probe()
3146 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3152 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3155 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3164 switch (rt5670->dmic3_data_pin) { in rt5670_i2c_probe()
3166 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, in rt5670_i2c_probe()
3169 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3176 dev_err(&i2c->dev, in rt5670_i2c_probe()
3186 pm_runtime_enable(&i2c->dev); in rt5670_i2c_probe()
3187 pm_request_idle(&i2c->dev); in rt5670_i2c_probe()
3189 ret = devm_snd_soc_register_component(&i2c->dev, in rt5670_i2c_probe()
3195 pm_runtime_put(&i2c->dev); in rt5670_i2c_probe()
3199 pm_runtime_disable(&i2c->dev); in rt5670_i2c_probe()
3206 pm_runtime_disable(&i2c->dev); in rt5670_i2c_remove()