• Home
  • Raw
  • Download

Lines Matching +full:codec +full:- +full:aif1 +full:- +full:bclk

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5616.c -- RT5616 ALSA SoC audio codec driver
22 #include <sound/soc-dapm.h>
150 int bclk[RT5616_AIFS]; member
287 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
288 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
289 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
290 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
351 val = snd_soc_component_read(snd_soc_dapm_to_component(source->dapm), RT5616_GLB_CLK); in is_sys_clk_from_pll()
466 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_adc_event()
490 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_charge_pump_event()
556 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_hp_event()
626 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_lout_event()
654 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_bst1_event()
677 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5616_bst2_event()
766 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
767 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
960 struct snd_soc_component *component = dai->component; in rt5616_hw_params()
965 rt5616->lrck[dai->id] = params_rate(params); in rt5616_hw_params()
967 pre_div = rl6231_get_clk_info(rt5616->sysclk, rt5616->lrck[dai->id]); in rt5616_hw_params()
970 dev_err(component->dev, "Unsupported clock setting\n"); in rt5616_hw_params()
971 return -EINVAL; in rt5616_hw_params()
975 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5616_hw_params()
976 return -EINVAL; in rt5616_hw_params()
979 rt5616->bclk[dai->id] = rt5616->lrck[dai->id] * (32 << bclk_ms); in rt5616_hw_params()
981 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5616_hw_params()
982 rt5616->bclk[dai->id], rt5616->lrck[dai->id]); in rt5616_hw_params()
983 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5616_hw_params()
984 bclk_ms, pre_div, dai->id); in rt5616_hw_params()
999 return -EINVAL; in rt5616_hw_params()
1013 struct snd_soc_component *component = dai->component; in rt5616_set_dai_fmt()
1019 rt5616->master[dai->id] = 1; in rt5616_set_dai_fmt()
1023 rt5616->master[dai->id] = 0; in rt5616_set_dai_fmt()
1026 return -EINVAL; in rt5616_set_dai_fmt()
1036 return -EINVAL; in rt5616_set_dai_fmt()
1052 return -EINVAL; in rt5616_set_dai_fmt()
1065 struct snd_soc_component *component = dai->component; in rt5616_set_dai_sysclk()
1069 if (freq == rt5616->sysclk && clk_id == rt5616->sysclk_src) in rt5616_set_dai_sysclk()
1080 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5616_set_dai_sysclk()
1081 return -EINVAL; in rt5616_set_dai_sysclk()
1086 rt5616->sysclk = freq; in rt5616_set_dai_sysclk()
1087 rt5616->sysclk_src = clk_id; in rt5616_set_dai_sysclk()
1089 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5616_set_dai_sysclk()
1097 struct snd_soc_component *component = dai->component; in rt5616_set_dai_pll()
1102 if (source == rt5616->pll_src && freq_in == rt5616->pll_in && in rt5616_set_dai_pll()
1103 freq_out == rt5616->pll_out) in rt5616_set_dai_pll()
1107 dev_dbg(component->dev, "PLL disabled\n"); in rt5616_set_dai_pll()
1109 rt5616->pll_in = 0; in rt5616_set_dai_pll()
1110 rt5616->pll_out = 0; in rt5616_set_dai_pll()
1130 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5616_set_dai_pll()
1131 return -EINVAL; in rt5616_set_dai_pll()
1136 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5616_set_dai_pll()
1140 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5616_set_dai_pll()
1151 rt5616->pll_in = freq_in; in rt5616_set_dai_pll()
1152 rt5616->pll_out = freq_out; in rt5616_set_dai_pll()
1153 rt5616->pll_src = source; in rt5616_set_dai_pll()
1177 if (IS_ERR(rt5616->mclk)) in rt5616_set_bias_level()
1181 clk_disable_unprepare(rt5616->mclk); in rt5616_set_bias_level()
1183 ret = clk_prepare_enable(rt5616->mclk); in rt5616_set_bias_level()
1228 rt5616->mclk = devm_clk_get(component->dev, "mclk"); in rt5616_probe()
1229 if (PTR_ERR(rt5616->mclk) == -EPROBE_DEFER) in rt5616_probe()
1230 return -EPROBE_DEFER; in rt5616_probe()
1232 rt5616->component = component; in rt5616_probe()
1242 regcache_cache_only(rt5616->regmap, true); in rt5616_suspend()
1243 regcache_mark_dirty(rt5616->regmap); in rt5616_suspend()
1252 regcache_cache_only(rt5616->regmap, false); in rt5616_resume()
1253 regcache_sync(rt5616->regmap); in rt5616_resume()
1274 .name = "rt5616-aif1",
1277 .stream_name = "AIF1 Playback",
1284 .stream_name = "AIF1 Capture",
1347 rt5616 = devm_kzalloc(&i2c->dev, sizeof(struct rt5616_priv), in rt5616_i2c_probe()
1350 return -ENOMEM; in rt5616_i2c_probe()
1354 rt5616->regmap = devm_regmap_init_i2c(i2c, &rt5616_regmap); in rt5616_i2c_probe()
1355 if (IS_ERR(rt5616->regmap)) { in rt5616_i2c_probe()
1356 ret = PTR_ERR(rt5616->regmap); in rt5616_i2c_probe()
1357 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5616_i2c_probe()
1362 regmap_read(rt5616->regmap, RT5616_DEVICE_ID, &val); in rt5616_i2c_probe()
1364 dev_err(&i2c->dev, in rt5616_i2c_probe()
1367 return -ENODEV; in rt5616_i2c_probe()
1369 regmap_write(rt5616->regmap, RT5616_RESET, 0); in rt5616_i2c_probe()
1370 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, in rt5616_i2c_probe()
1376 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, in rt5616_i2c_probe()
1380 ret = regmap_register_patch(rt5616->regmap, init_list, in rt5616_i2c_probe()
1383 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5616_i2c_probe()
1385 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, in rt5616_i2c_probe()
1388 return devm_snd_soc_register_component(&i2c->dev, in rt5616_i2c_probe()
1402 regmap_write(rt5616->regmap, RT5616_HP_VOL, 0xc8c8); in rt5616_i2c_shutdown()
1403 regmap_write(rt5616->regmap, RT5616_LOUT_CTRL1, 0xc8c8); in rt5616_i2c_shutdown()