Lines Matching +full:spk +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()
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()
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);
633 * For reliable output-mute LED control we need a "DAC1 Playback Switch" control.
636 * DAPM-mixer DAC1 input are enabled.
642 if (rt5670->dac1_mixl_dac1_switch && rt5670->dac1_playback_switch_l) in rt5670_update_ad_da_mixer_dac1_m_bits()
645 if (rt5670->dac1_mixr_dac1_switch && rt5670->dac1_playback_switch_r) in rt5670_update_ad_da_mixer_dac1_m_bits()
648 regmap_update_bits(rt5670->regmap, RT5670_AD_DA_MIXER, in rt5670_update_ad_da_mixer_dac1_m_bits()
658 ucontrol->value.integer.value[0] = rt5670->dac1_playback_switch_l; in rt5670_dac1_playback_switch_get()
659 ucontrol->value.integer.value[1] = rt5670->dac1_playback_switch_r; in rt5670_dac1_playback_switch_get()
670 if (rt5670->dac1_playback_switch_l == ucontrol->value.integer.value[0] && in rt5670_dac1_playback_switch_put()
671 rt5670->dac1_playback_switch_r == ucontrol->value.integer.value[1]) in rt5670_dac1_playback_switch_put()
674 rt5670->dac1_playback_switch_l = ucontrol->value.integer.value[0]; in rt5670_dac1_playback_switch_put()
675 rt5670->dac1_playback_switch_r = ucontrol->value.integer.value[1]; in rt5670_dac1_playback_switch_put()
698 SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5670_DAC2_DIG_VOL,
717 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL,
735 * set_dmic_clk - Set parameter of dmic.
747 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
751 rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, in set_dmic_clk()
755 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
765 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_sys_clk_from_pll()
768 if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) in is_sys_clk_from_pll()
777 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_using_asrc()
780 switch (source->shift) { in is_using_asrc()
829 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in can_use_asrc()
832 if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) in can_use_asrc()
840 * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters
860 return -EINVAL; in rt5670_sel_asrc_clk_src()
968 struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; in rt5670_put_dac1_mix_dac1_switch()
973 if (mc->shift == 0) in rt5670_put_dac1_mix_dac1_switch()
974 rt5670->dac1_mixl_dac1_switch = ucontrol->value.integer.value[0]; in rt5670_put_dac1_mix_dac1_switch()
976 rt5670->dac1_mixr_dac1_switch = ucontrol->value.integer.value[0]; in rt5670_put_dac1_mix_dac1_switch()
1139 /* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */
1156 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1179 /*RxDP source*/ /* MX-2D [15:13] */
1182 "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1"
1191 /* MX-2D [1] [0] */
1209 /* MX-26 [15] */
1221 /* MX-27 MX-26 [12] */
1239 /* MX-27 MX-26 [11] */
1256 /* MX-27 MX-26 [9:8] */
1273 /* Mono ADC source */
1274 /* MX-28 [12] */
1276 "Mono DAC MIXL", "ADC1"
1283 SOC_DAPM_ENUM("Mono ADC1 left source", rt5670_mono_adc_l1_enum);
1284 /* MX-28 [11] */
1286 "Mono DAC MIXL", "DMIC"
1293 SOC_DAPM_ENUM("Mono ADC2 left source", rt5670_mono_adc_l2_enum);
1295 /* MX-28 [9:8] */
1304 SOC_DAPM_ENUM("Mono DMIC left source", rt5670_mono_dmic_l_enum);
1305 /* MX-28 [1:0] */
1310 SOC_DAPM_ENUM("Mono DMIC Right source", rt5670_mono_dmic_r_enum);
1311 /* MX-28 [4] */
1313 "Mono DAC MIXR", "ADC2"
1320 SOC_DAPM_ENUM("Mono ADC1 right source", rt5670_mono_adc_r1_enum);
1321 /* MX-28 [3] */
1323 "Mono DAC MIXR", "DMIC"
1330 SOC_DAPM_ENUM("Mono ADC2 right source", rt5670_mono_adc_r2_enum);
1332 /* MX-2D [3:2] */
1334 "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7"
1343 /* MX-2F [15] */
1354 /* MX-2F [14:12] */
1365 /* MX-31 [15] [13] [11] [9] */
1367 "Mono DAC", "Stereo DAC"
1394 /* MX-FA [12] */
1405 /* MX-FA [11] */
1416 /* MX-FA [10] */
1427 /* MX-9D [9:8] */
1429 "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L"
1441 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_power_event()
1446 regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, in rt5670_hp_power_event()
1448 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_power_event()
1451 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_hp_power_event()
1456 regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); in rt5670_hp_power_event()
1457 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); in rt5670_hp_power_event()
1458 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_power_event()
1461 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_power_event()
1464 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); in rt5670_hp_power_event()
1477 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_event()
1483 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1485 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1486 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); in rt5670_hp_event()
1487 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1488 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_event()
1490 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1493 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1498 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1500 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1501 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); in rt5670_hp_event()
1503 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1505 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1509 regmap_update_bits(rt5670->regmap, in rt5670_hp_event()
1511 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1512 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); in rt5670_hp_event()
1513 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1527 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_spk_event()
1530 if (!rt5670->gpio1_is_ext_spk_en) in rt5670_spk_event()
1535 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1540 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1554 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst1_event()
1577 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst2_event()
1612 SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5670_ASRC_1,
1614 SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1,
1620 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5670_ASRC_1,
1622 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5670_ASRC_1,
1628 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1,
1630 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1,
1716 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
1718 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
1720 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
1722 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
1724 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
1726 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
1743 SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2,
1745 SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL,
1748 SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2,
1750 SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL,
1762 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1859 SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5670_PWR_DIG2,
1861 SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5670_PWR_DIG2,
1869 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
1872 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
1911 /* HPO/LOUT/Mono Mixer */
1974 { "ADC Mono Left Filter", NULL, "ADC MONO L ASRC", is_using_asrc },
1975 { "ADC Mono Right Filter", NULL, "ADC MONO R ASRC", is_using_asrc },
1976 { "DAC Mono Left Filter", NULL, "DAC MONO L ASRC", is_using_asrc },
1977 { "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc },
1981 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
1982 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2039 { "Mono DMIC L Mux", "DMIC1", "DMIC L1" },
2040 { "Mono DMIC L Mux", "DMIC2", "DMIC L2" },
2041 { "Mono DMIC L Mux", "DMIC3", "DMIC L3" },
2043 { "Mono DMIC R Mux", "DMIC1", "DMIC R1" },
2044 { "Mono DMIC R Mux", "DMIC2", "DMIC R2" },
2045 { "Mono DMIC R Mux", "DMIC3", "DMIC R3" },
2060 { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
2061 { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2062 { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2063 { "Mono ADC L1 Mux", "ADC1", "ADC 1" },
2065 { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2066 { "Mono ADC R1 Mux", "ADC2", "ADC 2" },
2067 { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
2068 { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2082 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2083 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2084 { "Mono ADC MIXL", NULL, "ADC Mono Left Filter" },
2085 { "ADC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
2087 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2088 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2089 { "Mono ADC MIXR", NULL, "ADC Mono Right Filter" },
2090 { "ADC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
2121 { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" },
2122 { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" },
2129 { "IF_ADC2", NULL, "Mono ADC MIXL" },
2130 { "IF_ADC2", NULL, "Mono ADC MIXR" },
2153 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
2154 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
2160 { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" },
2161 { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" },
2164 { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" },
2165 { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" },
2166 { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" },
2167 { "TDM Data Mux", "Slot 6-7", "IF2 DAC" },
2233 { "DAC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
2234 { "DAC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
2247 { "DAC L2 Volume", NULL, "DAC Mono Left Filter" },
2254 { "DAC R2 Volume", NULL, "DAC Mono Right Filter" },
2267 { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
2268 { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2269 { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" },
2270 { "Mono DAC MIXL", NULL, "DAC Mono Left Filter" },
2271 { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
2272 { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2273 { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" },
2274 { "Mono DAC MIXR", NULL, "DAC Mono Right Filter" },
2287 { "DAC L2", NULL, "Mono DAC MIXL" },
2288 { "DAC R2", NULL, "Mono DAC MIXR" },
2320 { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" },
2323 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
2346 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
2349 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
2369 struct snd_soc_component *component = dai->component; in rt5670_hw_params()
2374 rt5670->lrck[dai->id] = params_rate(params); in rt5670_hw_params()
2375 pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); in rt5670_hw_params()
2377 dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", in rt5670_hw_params()
2378 rt5670->lrck[dai->id], dai->id); in rt5670_hw_params()
2379 return -EINVAL; in rt5670_hw_params()
2383 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5670_hw_params()
2384 return -EINVAL; in rt5670_hw_params()
2387 rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); in rt5670_hw_params()
2389 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5670_hw_params()
2390 rt5670->bclk[dai->id], rt5670->lrck[dai->id]); in rt5670_hw_params()
2391 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5670_hw_params()
2392 bclk_ms, pre_div, dai->id); in rt5670_hw_params()
2407 return -EINVAL; in rt5670_hw_params()
2410 switch (dai->id) { in rt5670_hw_params()
2428 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_hw_params()
2429 return -EINVAL; in rt5670_hw_params()
2437 struct snd_soc_component *component = dai->component; in rt5670_set_dai_fmt()
2443 rt5670->master[dai->id] = 1; in rt5670_set_dai_fmt()
2447 rt5670->master[dai->id] = 0; in rt5670_set_dai_fmt()
2450 return -EINVAL; in rt5670_set_dai_fmt()
2460 return -EINVAL; in rt5670_set_dai_fmt()
2476 return -EINVAL; in rt5670_set_dai_fmt()
2479 switch (dai->id) { in rt5670_set_dai_fmt()
2491 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_fmt()
2492 return -EINVAL; in rt5670_set_dai_fmt()
2514 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5670_set_codec_sysclk()
2515 return -EINVAL; in rt5670_set_codec_sysclk()
2519 rt5670->sysclk = freq; in rt5670_set_codec_sysclk()
2521 rt5670->sysclk_src = clk_id; in rt5670_set_codec_sysclk()
2523 dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); in rt5670_set_codec_sysclk()
2531 struct snd_soc_component *component = dai->component; in rt5670_set_dai_pll()
2536 if (source == rt5670->pll_src && freq_in == rt5670->pll_in && in rt5670_set_dai_pll()
2537 freq_out == rt5670->pll_out) in rt5670_set_dai_pll()
2541 dev_dbg(component->dev, "PLL disabled\n"); in rt5670_set_dai_pll()
2543 rt5670->pll_in = 0; in rt5670_set_dai_pll()
2544 rt5670->pll_out = 0; in rt5670_set_dai_pll()
2559 switch (dai->id) { in rt5670_set_dai_pll()
2569 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_pll()
2570 return -EINVAL; in rt5670_set_dai_pll()
2574 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5670_set_dai_pll()
2575 return -EINVAL; in rt5670_set_dai_pll()
2580 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt5670_set_dai_pll()
2584 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5670_set_dai_pll()
2594 rt5670->pll_in = freq_in; in rt5670_set_dai_pll()
2595 rt5670->pll_out = freq_out; in rt5670_set_dai_pll()
2596 rt5670->pll_src = source; in rt5670_set_dai_pll()
2604 struct snd_soc_component *component = dai->component; in rt5670_set_tdm_slot()
2623 return -EINVAL; in rt5670_set_tdm_slot()
2639 return -EINVAL; in rt5670_set_tdm_slot()
2649 struct snd_soc_component *component = dai->component; in rt5670_set_bclk_ratio()
2651 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt5670_set_bclk_ratio()
2652 if (dai->id != RT5670_AIF1) in rt5670_set_bclk_ratio()
2698 if (rt5670->jd_mode) in rt5670_set_bias_level()
2744 dev_err(component->dev, in rt5670_probe()
2746 return -ENODEV; in rt5670_probe()
2748 rt5670->component = component; in rt5670_probe()
2757 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_remove()
2758 snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); in rt5670_remove()
2766 regcache_cache_only(rt5670->regmap, true); in rt5670_suspend()
2767 regcache_mark_dirty(rt5670->regmap); in rt5670_suspend()
2775 regcache_cache_only(rt5670->regmap, false); in rt5670_resume()
2776 regcache_sync(rt5670->regmap); in rt5670_resume()
2799 .name = "rt5670-aif1",
2819 .name = "rt5670-aif2",
2893 rt5670_quirk = (unsigned long)id->driver_data; in rt5670_quirk_cb()
3036 return "cfg-spk:2 cfg-mic:dmics12"; in rt5670_components()
3038 return "cfg-spk:2 cfg-mic:dmic1"; in rt5670_components()
3040 return "cfg-spk:2 cfg-mic:dmic2"; in rt5670_components()
3042 return "cfg-spk:2 cfg-mic:dmic3"; in rt5670_components()
3054 rt5670 = devm_kzalloc(&i2c->dev, in rt5670_i2c_probe()
3058 return -ENOMEM; in rt5670_i2c_probe()
3064 dev_info(&i2c->dev, "Overriding quirk 0x%x => 0x%x\n", in rt5670_i2c_probe()
3070 rt5670->gpio1_is_irq = true; in rt5670_i2c_probe()
3071 dev_info(&i2c->dev, "quirk GPIO1 is IRQ\n"); in rt5670_i2c_probe()
3074 rt5670->gpio1_is_ext_spk_en = true; in rt5670_i2c_probe()
3075 dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n"); in rt5670_i2c_probe()
3078 rt5670->in2_diff = true; in rt5670_i2c_probe()
3079 dev_info(&i2c->dev, "quirk IN2_DIFF\n"); in rt5670_i2c_probe()
3082 rt5670->dmic_en = true; in rt5670_i2c_probe()
3083 dev_info(&i2c->dev, "quirk DMIC enabled\n"); in rt5670_i2c_probe()
3086 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_IN2P; in rt5670_i2c_probe()
3087 dev_info(&i2c->dev, "quirk DMIC1 on IN2P pin\n"); in rt5670_i2c_probe()
3090 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; in rt5670_i2c_probe()
3091 dev_info(&i2c->dev, "quirk DMIC1 on GPIO6 pin\n"); in rt5670_i2c_probe()
3094 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; in rt5670_i2c_probe()
3095 dev_info(&i2c->dev, "quirk DMIC1 on GPIO7 pin\n"); in rt5670_i2c_probe()
3098 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_IN3N; in rt5670_i2c_probe()
3099 dev_info(&i2c->dev, "quirk DMIC2 on INR pin\n"); in rt5670_i2c_probe()
3102 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; in rt5670_i2c_probe()
3103 dev_info(&i2c->dev, "quirk DMIC2 on GPIO8 pin\n"); in rt5670_i2c_probe()
3106 rt5670->dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; in rt5670_i2c_probe()
3107 dev_info(&i2c->dev, "quirk DMIC3 on GPIO5 pin\n"); in rt5670_i2c_probe()
3111 rt5670->jd_mode = 1; in rt5670_i2c_probe()
3112 dev_info(&i2c->dev, "quirk JD mode 1\n"); in rt5670_i2c_probe()
3115 rt5670->jd_mode = 2; in rt5670_i2c_probe()
3116 dev_info(&i2c->dev, "quirk JD mode 2\n"); in rt5670_i2c_probe()
3119 rt5670->jd_mode = 3; in rt5670_i2c_probe()
3120 dev_info(&i2c->dev, "quirk JD mode 3\n"); in rt5670_i2c_probe()
3127 rt5670->dac1_playback_switch_l = true; in rt5670_i2c_probe()
3128 rt5670->dac1_playback_switch_r = true; in rt5670_i2c_probe()
3129 /* The Power-On-Reset values for the DAC1 mixer have the DAC1 input enabled. */ in rt5670_i2c_probe()
3130 rt5670->dac1_mixl_dac1_switch = true; in rt5670_i2c_probe()
3131 rt5670->dac1_mixr_dac1_switch = true; in rt5670_i2c_probe()
3133 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); in rt5670_i2c_probe()
3134 if (IS_ERR(rt5670->regmap)) { in rt5670_i2c_probe()
3135 ret = PTR_ERR(rt5670->regmap); in rt5670_i2c_probe()
3136 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5670_i2c_probe()
3141 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); in rt5670_i2c_probe()
3143 dev_err(&i2c->dev, in rt5670_i2c_probe()
3145 return -ENODEV; in rt5670_i2c_probe()
3148 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3149 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3154 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3156 regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val); in rt5670_i2c_probe()
3158 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980); in rt5670_i2c_probe()
3160 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00); in rt5670_i2c_probe()
3162 ret = regmap_register_patch(rt5670->regmap, init_list, in rt5670_i2c_probe()
3165 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5670_i2c_probe()
3167 regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, in rt5670_i2c_probe()
3170 if (rt5670->in2_diff) in rt5670_i2c_probe()
3171 regmap_update_bits(rt5670->regmap, RT5670_IN2, in rt5670_i2c_probe()
3174 if (rt5670->gpio1_is_irq) { in rt5670_i2c_probe()
3176 regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); in rt5670_i2c_probe()
3177 regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); in rt5670_i2c_probe()
3178 regmap_write(rt5670->regmap, RT5670_IL_CMD3, 0x0014); in rt5670_i2c_probe()
3180 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3182 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3186 if (rt5670->gpio1_is_ext_spk_en) { in rt5670_i2c_probe()
3187 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3189 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3193 if (rt5670->jd_mode) { in rt5670_i2c_probe()
3194 regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, in rt5670_i2c_probe()
3196 rt5670->sysclk = 0; in rt5670_i2c_probe()
3197 rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; in rt5670_i2c_probe()
3198 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3200 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, in rt5670_i2c_probe()
3202 regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, in rt5670_i2c_probe()
3204 regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, in rt5670_i2c_probe()
3208 switch (rt5670->jd_mode) { in rt5670_i2c_probe()
3210 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3215 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3220 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3229 if (rt5670->dmic_en) { in rt5670_i2c_probe()
3230 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3234 switch (rt5670->dmic1_data_pin) { in rt5670_i2c_probe()
3236 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3242 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3245 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3251 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3254 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3263 switch (rt5670->dmic2_data_pin) { in rt5670_i2c_probe()
3265 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3271 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3274 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3283 switch (rt5670->dmic3_data_pin) { in rt5670_i2c_probe()
3285 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, in rt5670_i2c_probe()
3288 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3295 dev_err(&i2c->dev, in rt5670_i2c_probe()
3305 pm_runtime_enable(&i2c->dev); in rt5670_i2c_probe()
3306 pm_request_idle(&i2c->dev); in rt5670_i2c_probe()
3308 ret = devm_snd_soc_register_component(&i2c->dev, in rt5670_i2c_probe()
3316 pm_runtime_disable(&i2c->dev); in rt5670_i2c_probe()
3323 pm_runtime_disable(&i2c->dev); in rt5670_i2c_remove()