• Home
  • Raw
  • Download

Lines Matching +full:dsp +full:- +full:aif2 +full:- +full:bclk

2  * rt5651.c  --  RT5651 ALSA SoC audio codec driver
26 #include <sound/soc-dapm.h>
290 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
291 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
292 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
293 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
372 * set_dmic_clk - Set parameter of dmic.
382 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
386 rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap, in set_dmic_clk()
390 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
687 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_amp_power_event()
693 regmap_update_bits(rt5651->regmap, RT5651_PR_BASE + in rt5651_amp_power_event()
695 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M2, in rt5651_amp_power_event()
697 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M1, in rt5651_amp_power_event()
701 regmap_write(rt5651->regmap, RT5651_PR_BASE + in rt5651_amp_power_event()
704 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
706 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
710 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
725 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_hp_event()
731 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M2, in rt5651_hp_event()
734 regmap_update_bits(rt5651->regmap, RT5651_CHARGE_PUMP, in rt5651_hp_event()
737 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M3, in rt5651_hp_event()
744 regmap_write(rt5651->regmap, RT5651_PR_BASE + in rt5651_hp_event()
746 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M1, in rt5651_hp_event()
749 regmap_update_bits(rt5651->regmap, RT5651_PR_BASE + in rt5651_hp_event()
751 rt5651->hp_mute = 0; in rt5651_hp_event()
755 rt5651->hp_mute = 1; in rt5651_hp_event()
770 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_hp_post_event()
775 if (!rt5651->hp_mute) in rt5651_hp_post_event()
790 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst1_event()
813 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst2_event()
836 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst3_event()
981 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
982 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
984 /* Audio DSP */
985 SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
1194 {"Audio DSP", NULL, "DAC MIXL"},
1195 {"Audio DSP", NULL, "DAC MIXR"},
1205 {"Stereo DAC MIXL", "DAC L1 Switch", "Audio DSP"},
1210 {"Stereo DAC MIXR", "DAC R1 Switch", "Audio DSP"},
1287 struct snd_soc_component *component = dai->component; in rt5651_hw_params()
1292 rt5651->lrck[dai->id] = params_rate(params); in rt5651_hw_params()
1293 pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); in rt5651_hw_params()
1296 dev_err(component->dev, "Unsupported clock setting\n"); in rt5651_hw_params()
1297 return -EINVAL; in rt5651_hw_params()
1301 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5651_hw_params()
1302 return -EINVAL; in rt5651_hw_params()
1305 rt5651->bclk[dai->id] = rt5651->lrck[dai->id] * (32 << bclk_ms); in rt5651_hw_params()
1307 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5651_hw_params()
1308 rt5651->bclk[dai->id], rt5651->lrck[dai->id]); in rt5651_hw_params()
1309 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5651_hw_params()
1310 bclk_ms, pre_div, dai->id); in rt5651_hw_params()
1325 return -EINVAL; in rt5651_hw_params()
1328 switch (dai->id) { in rt5651_hw_params()
1344 dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); in rt5651_hw_params()
1345 return -EINVAL; in rt5651_hw_params()
1353 struct snd_soc_component *component = dai->component; in rt5651_set_dai_fmt()
1359 rt5651->master[dai->id] = 1; in rt5651_set_dai_fmt()
1363 rt5651->master[dai->id] = 0; in rt5651_set_dai_fmt()
1366 return -EINVAL; in rt5651_set_dai_fmt()
1376 return -EINVAL; in rt5651_set_dai_fmt()
1392 return -EINVAL; in rt5651_set_dai_fmt()
1395 switch (dai->id) { in rt5651_set_dai_fmt()
1407 dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); in rt5651_set_dai_fmt()
1408 return -EINVAL; in rt5651_set_dai_fmt()
1416 struct snd_soc_component *component = dai->component; in rt5651_set_dai_sysclk()
1421 if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) in rt5651_set_dai_sysclk()
1436 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5651_set_dai_sysclk()
1437 return -EINVAL; in rt5651_set_dai_sysclk()
1443 rt5651->sysclk = freq; in rt5651_set_dai_sysclk()
1444 rt5651->sysclk_src = clk_id; in rt5651_set_dai_sysclk()
1446 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5651_set_dai_sysclk()
1454 struct snd_soc_component *component = dai->component; in rt5651_set_dai_pll()
1459 if (source == rt5651->pll_src && freq_in == rt5651->pll_in && in rt5651_set_dai_pll()
1460 freq_out == rt5651->pll_out) in rt5651_set_dai_pll()
1464 dev_dbg(component->dev, "PLL disabled\n"); in rt5651_set_dai_pll()
1466 rt5651->pll_in = 0; in rt5651_set_dai_pll()
1467 rt5651->pll_out = 0; in rt5651_set_dai_pll()
1487 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5651_set_dai_pll()
1488 return -EINVAL; in rt5651_set_dai_pll()
1493 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5651_set_dai_pll()
1497 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5651_set_dai_pll()
1507 rt5651->pll_in = freq_in; in rt5651_set_dai_pll()
1508 rt5651->pll_out = freq_out; in rt5651_set_dai_pll()
1509 rt5651->pll_src = source; in rt5651_set_dai_pll()
1546 /* Do not touch the LDO voltage select bits on bias-off */ in rt5651_set_bias_level()
1549 /* Leave PLL1 and jack-detect power as is, all others off */ in rt5651_set_bias_level()
1568 /* OVCD is unreliable when used with RCCLK as sysclk-source */ in rt5651_enable_micbias1_for_ovcd()
1592 rt5651->ovcd_irq_enabled = true; in rt5651_enable_micbias1_ovcd_irq()
1601 rt5651->ovcd_irq_enabled = false; in rt5651_disable_micbias1_ovcd_irq()
1615 dev_dbg(component->dev, "irq ctrl2 %#04x\n", val); in rt5651_micbias1_ovcd()
1626 dev_dbg(component->dev, "irq status %#04x\n", val); in rt5651_jack_inserted()
1628 switch (rt5651->jd_src) { in rt5651_jack_inserted()
1645 /* Jack detect and button-press timings */
1658 rt5651->poll_count = 0; in rt5651_start_button_press_work()
1659 rt5651->press_count = 0; in rt5651_start_button_press_work()
1660 rt5651->release_count = 0; in rt5651_start_button_press_work()
1661 rt5651->pressed = false; in rt5651_start_button_press_work()
1662 rt5651->press_reported = false; in rt5651_start_button_press_work()
1664 schedule_delayed_work(&rt5651->bp_work, msecs_to_jiffies(BP_POLL_TIME)); in rt5651_start_button_press_work()
1671 struct snd_soc_component *component = rt5651->component; in rt5651_button_press_work()
1678 rt5651->release_count = 0; in rt5651_button_press_work()
1679 rt5651->press_count++; in rt5651_button_press_work()
1681 if (rt5651->press_count >= BP_THRESHOLD) in rt5651_button_press_work()
1682 rt5651->pressed = true; in rt5651_button_press_work()
1685 rt5651->press_count = 0; in rt5651_button_press_work()
1686 rt5651->release_count++; in rt5651_button_press_work()
1691 * at least JACK_UNPLUG_TIME milli-seconds before reporting a press. in rt5651_button_press_work()
1693 rt5651->poll_count++; in rt5651_button_press_work()
1694 if (rt5651->poll_count < (JACK_UNPLUG_TIME / BP_POLL_TIME)) { in rt5651_button_press_work()
1695 schedule_delayed_work(&rt5651->bp_work, in rt5651_button_press_work()
1700 if (rt5651->pressed && !rt5651->press_reported) { in rt5651_button_press_work()
1701 dev_dbg(component->dev, "headset button press\n"); in rt5651_button_press_work()
1702 snd_soc_jack_report(rt5651->hp_jack, SND_JACK_BTN_0, in rt5651_button_press_work()
1704 rt5651->press_reported = true; in rt5651_button_press_work()
1707 if (rt5651->release_count >= BP_THRESHOLD) { in rt5651_button_press_work()
1708 if (rt5651->press_reported) { in rt5651_button_press_work()
1709 dev_dbg(component->dev, "headset button release\n"); in rt5651_button_press_work()
1710 snd_soc_jack_report(rt5651->hp_jack, 0, SND_JACK_BTN_0); in rt5651_button_press_work()
1712 /* Re-enable OVCD IRQ to detect next press */ in rt5651_button_press_work()
1717 schedule_delayed_work(&rt5651->bp_work, msecs_to_jiffies(BP_POLL_TIME)); in rt5651_button_press_work()
1732 /* Clear any previous over-current status flag */ in rt5651_detect_headset()
1747 dev_dbg(component->dev, "mic-gnd shorted\n"); in rt5651_detect_headset()
1753 dev_dbg(component->dev, "mic-gnd open\n"); in rt5651_detect_headset()
1761 …dev_err(component->dev, "Error detecting headset vs headphones, bad contact?, assuming headphones\… in rt5651_detect_headset()
1769 struct snd_soc_component *component = rt5651->component; in rt5651_jack_detect_work()
1774 if (rt5651->hp_jack->status & SND_JACK_HEADPHONE) { in rt5651_jack_detect_work()
1775 if (rt5651->hp_jack->status & SND_JACK_MICROPHONE) { in rt5651_jack_detect_work()
1776 cancel_delayed_work_sync(&rt5651->bp_work); in rt5651_jack_detect_work()
1780 snd_soc_jack_report(rt5651->hp_jack, 0, in rt5651_jack_detect_work()
1782 dev_dbg(component->dev, "jack unplugged\n"); in rt5651_jack_detect_work()
1784 } else if (!(rt5651->hp_jack->status & SND_JACK_HEADPHONE)) { in rt5651_jack_detect_work()
1786 WARN_ON(rt5651->ovcd_irq_enabled); in rt5651_jack_detect_work()
1796 dev_dbg(component->dev, "detect report %#02x\n", report); in rt5651_jack_detect_work()
1797 snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); in rt5651_jack_detect_work()
1798 } else if (rt5651->ovcd_irq_enabled && rt5651_micbias1_ovcd(component)) { in rt5651_jack_detect_work()
1799 dev_dbg(component->dev, "OVCD IRQ\n"); in rt5651_jack_detect_work()
1814 * If the jack-detect IRQ flag goes high (unplug) after our in rt5651_jack_detect_work()
1817 * we react to edges, we miss the unplug event -> recheck. in rt5651_jack_detect_work()
1819 queue_work(system_long_wq, &rt5651->jack_detect_work); in rt5651_jack_detect_work()
1827 queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); in rt5651_irq()
1836 cancel_work_sync(&rt5651->jack_detect_work); in rt5651_cancel_work()
1837 cancel_delayed_work_sync(&rt5651->bp_work); in rt5651_cancel_work()
1850 switch (rt5651->jd_src) { in rt5651_enable_jack_detect()
1872 dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); in rt5651_enable_jack_detect()
1880 /* Set OVCD threshold current and scale-factor */ in rt5651_enable_jack_detect()
1882 0xa800 | rt5651->ovcd_sf); in rt5651_enable_jack_detect()
1890 rt5651->ovcd_th | in rt5651_enable_jack_detect()
1895 * The over-current-detect is only reliable in detecting the absence in rt5651_enable_jack_detect()
1896 * of over-current, when the mic-contact in the jack is short-circuited, in rt5651_enable_jack_detect()
1897 * the hardware periodically retries if it can apply the bias-current in rt5651_enable_jack_detect()
1898 * leading to the ovcd status flip-flopping 1-0-1 with it being 0 about in rt5651_enable_jack_detect()
1906 rt5651->hp_jack = hp_jack; in rt5651_enable_jack_detect()
1907 if (rt5651->hp_jack->status & SND_JACK_MICROPHONE) { in rt5651_enable_jack_detect()
1912 enable_irq(rt5651->irq); in rt5651_enable_jack_detect()
1914 queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); in rt5651_enable_jack_detect()
1921 disable_irq(rt5651->irq); in rt5651_disable_jack_detect()
1924 if (rt5651->hp_jack->status & SND_JACK_MICROPHONE) { in rt5651_disable_jack_detect()
1927 snd_soc_jack_report(rt5651->hp_jack, 0, SND_JACK_BTN_0); in rt5651_disable_jack_detect()
1930 rt5651->hp_jack = NULL; in rt5651_disable_jack_detect()
1945 * Note on some platforms the platform code may need to add device-properties,
1948 * rather then from the i2c driver's probe function, so that the platform-code
1956 if (device_property_read_bool(component->dev, "realtek,in2-differential")) in rt5651_apply_properties()
1960 if (device_property_read_bool(component->dev, "realtek,dmic-en")) in rt5651_apply_properties()
1964 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
1965 "realtek,jack-detect-source", &val) == 0) in rt5651_apply_properties()
1966 rt5651->jd_src = val; in rt5651_apply_properties()
1970 * threshold and scale-factor are 2000µA and 0.75. For an effective in rt5651_apply_properties()
1973 rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; in rt5651_apply_properties()
1974 rt5651->ovcd_sf = RT5651_MIC_OVCD_SF_0P75; in rt5651_apply_properties()
1976 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
1977 "realtek,over-current-threshold-microamp", &val) == 0) { in rt5651_apply_properties()
1980 rt5651->ovcd_th = RT5651_MIC1_OVTH_600UA; in rt5651_apply_properties()
1983 rt5651->ovcd_th = RT5651_MIC1_OVTH_1500UA; in rt5651_apply_properties()
1986 rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; in rt5651_apply_properties()
1989 …dev_warn(component->dev, "Warning: Invalid over-current-threshold-microamp value: %d, defaulting t… in rt5651_apply_properties()
1994 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
1995 "realtek,over-current-scale-factor", &val) == 0) { in rt5651_apply_properties()
1997 rt5651->ovcd_sf = val << RT5651_MIC_OVCD_SF_SFT; in rt5651_apply_properties()
1999 …dev_warn(component->dev, "Warning: Invalid over-current-scale-factor value: %d, defaulting to 0.75… in rt5651_apply_properties()
2008 rt5651->component = component; in rt5651_probe()
2025 regcache_cache_only(rt5651->regmap, true); in rt5651_suspend()
2026 regcache_mark_dirty(rt5651->regmap); in rt5651_suspend()
2034 regcache_cache_only(rt5651->regmap, false); in rt5651_resume()
2057 .name = "rt5651-aif1",
2076 .name = "rt5651-aif2",
2079 .stream_name = "AIF2 Playback",
2086 .stream_name = "AIF2 Capture",
2153 * Note this function MUST not look at device-properties, see the comment
2162 rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651), in rt5651_i2c_probe()
2165 return -ENOMEM; in rt5651_i2c_probe()
2169 rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); in rt5651_i2c_probe()
2170 if (IS_ERR(rt5651->regmap)) { in rt5651_i2c_probe()
2171 ret = PTR_ERR(rt5651->regmap); in rt5651_i2c_probe()
2172 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5651_i2c_probe()
2177 regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret); in rt5651_i2c_probe()
2179 dev_err(&i2c->dev, in rt5651_i2c_probe()
2181 return -ENODEV; in rt5651_i2c_probe()
2184 regmap_write(rt5651->regmap, RT5651_RESET, 0); in rt5651_i2c_probe()
2186 ret = regmap_register_patch(rt5651->regmap, init_list, in rt5651_i2c_probe()
2189 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5651_i2c_probe()
2191 rt5651->irq = i2c->irq; in rt5651_i2c_probe()
2192 rt5651->hp_mute = 1; in rt5651_i2c_probe()
2194 INIT_DELAYED_WORK(&rt5651->bp_work, rt5651_button_press_work); in rt5651_i2c_probe()
2195 INIT_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); in rt5651_i2c_probe()
2197 /* Make sure work is stopped on probe-error / remove */ in rt5651_i2c_probe()
2198 ret = devm_add_action_or_reset(&i2c->dev, rt5651_cancel_work, rt5651); in rt5651_i2c_probe()
2202 ret = devm_request_irq(&i2c->dev, rt5651->irq, rt5651_irq, in rt5651_i2c_probe()
2206 /* Gets re-enabled by rt5651_set_jack() */ in rt5651_i2c_probe()
2207 disable_irq(rt5651->irq); in rt5651_i2c_probe()
2209 dev_warn(&i2c->dev, "Failed to reguest IRQ %d: %d\n", in rt5651_i2c_probe()
2210 rt5651->irq, ret); in rt5651_i2c_probe()
2211 rt5651->irq = -ENXIO; in rt5651_i2c_probe()
2214 ret = devm_snd_soc_register_component(&i2c->dev, in rt5651_i2c_probe()