Lines Matching +full:spk +full:- +full:mono
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5660.c -- RT5660 ALSA SoC audio codec driver
24 #include <sound/soc-dapm.h>
296 static const DECLARE_TLV_DB_SCALE(rt5660_out_vol_tlv, -4650, 150, 0);
297 static const DECLARE_TLV_DB_SCALE(rt5660_dac_vol_tlv, -6525, 75, 0);
298 static const DECLARE_TLV_DB_SCALE(rt5660_adc_vol_tlv, -1725, 75, 0);
300 static const DECLARE_TLV_DB_SCALE(rt5660_bst_tlv, -1200, 75, 0);
342 * rt5660_set_dmic_clk - Set parameter of dmic.
352 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5660_set_dmic_clk()
356 rate = rt5660->sysclk / rl6231_get_pre_div(rt5660->regmap, in rt5660_set_dmic_clk()
360 dev_err(component->dev, "Failed to set DMIC clock\n"); in rt5660_set_dmic_clk()
371 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in rt5660_is_sys_clk_from_pll()
539 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5660_lout_event()
666 SND_SOC_DAPM_MIXER("SPK MIX", RT5660_PWR_MIXER, RT5660_PWR_SM_BIT,
685 /* HPO/LOUT/Mono Mixer */
695 SND_SOC_DAPM_PGA_S("SPK amp", 1, RT5660_PWR_DIG1,
787 { "SPK MIX", "BST3 Switch", "BST3" },
788 { "SPK MIX", "BST1 Switch", "BST1" },
789 { "SPK MIX", "DACL Switch", "DAC L1" },
790 { "SPK MIX", "DACR Switch", "DAC R1" },
791 { "SPK MIX", "OUTMIXL Switch", "OUT MIXL" },
811 { "SPKVOL", "Switch", "SPK MIX" },
829 { "SPK amp", NULL, "SPO MIX" },
830 { "SPO", NULL, "SPK amp" },
836 struct snd_soc_component *component = dai->component; in rt5660_hw_params()
841 rt5660->lrck[dai->id] = params_rate(params); in rt5660_hw_params()
842 pre_div = rl6231_get_clk_info(rt5660->sysclk, rt5660->lrck[dai->id]); in rt5660_hw_params()
844 dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", in rt5660_hw_params()
845 rt5660->lrck[dai->id], dai->id); in rt5660_hw_params()
846 return -EINVAL; in rt5660_hw_params()
851 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5660_hw_params()
860 rt5660->bclk[dai->id] = rt5660->lrck[dai->id] * (32 << bclk_ms); in rt5660_hw_params()
862 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5660_hw_params()
863 rt5660->bclk[dai->id], rt5660->lrck[dai->id]); in rt5660_hw_params()
864 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5660_hw_params()
865 bclk_ms, pre_div, dai->id); in rt5660_hw_params()
880 return -EINVAL; in rt5660_hw_params()
883 switch (dai->id) { in rt5660_hw_params()
894 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5660_hw_params()
895 return -EINVAL; in rt5660_hw_params()
903 struct snd_soc_component *component = dai->component; in rt5660_set_dai_fmt()
909 rt5660->master[dai->id] = 1; in rt5660_set_dai_fmt()
914 rt5660->master[dai->id] = 0; in rt5660_set_dai_fmt()
918 return -EINVAL; in rt5660_set_dai_fmt()
930 return -EINVAL; in rt5660_set_dai_fmt()
950 return -EINVAL; in rt5660_set_dai_fmt()
953 switch (dai->id) { in rt5660_set_dai_fmt()
961 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5660_set_dai_fmt()
962 return -EINVAL; in rt5660_set_dai_fmt()
971 struct snd_soc_component *component = dai->component; in rt5660_set_dai_sysclk()
975 if (freq == rt5660->sysclk && clk_id == rt5660->sysclk_src) in rt5660_set_dai_sysclk()
992 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5660_set_dai_sysclk()
993 return -EINVAL; in rt5660_set_dai_sysclk()
999 rt5660->sysclk = freq; in rt5660_set_dai_sysclk()
1000 rt5660->sysclk_src = clk_id; in rt5660_set_dai_sysclk()
1002 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5660_set_dai_sysclk()
1010 struct snd_soc_component *component = dai->component; in rt5660_set_dai_pll()
1015 if (source == rt5660->pll_src && freq_in == rt5660->pll_in && in rt5660_set_dai_pll()
1016 freq_out == rt5660->pll_out) in rt5660_set_dai_pll()
1020 dev_dbg(component->dev, "PLL disabled\n"); in rt5660_set_dai_pll()
1022 rt5660->pll_in = 0; in rt5660_set_dai_pll()
1023 rt5660->pll_out = 0; in rt5660_set_dai_pll()
1041 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5660_set_dai_pll()
1042 return -EINVAL; in rt5660_set_dai_pll()
1047 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt5660_set_dai_pll()
1051 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5660_set_dai_pll()
1061 rt5660->pll_in = freq_in; in rt5660_set_dai_pll()
1062 rt5660->pll_out = freq_out; in rt5660_set_dai_pll()
1063 rt5660->pll_src = source; in rt5660_set_dai_pll()
1083 clk_disable_unprepare(rt5660->mclk); in rt5660_set_bias_level()
1085 ret = clk_prepare_enable(rt5660->mclk); in rt5660_set_bias_level()
1121 rt5660->component = component; in rt5660_probe()
1136 regcache_cache_only(rt5660->regmap, true); in rt5660_suspend()
1137 regcache_mark_dirty(rt5660->regmap); in rt5660_suspend()
1146 if (rt5660->pdata.poweroff_codec_in_suspend) in rt5660_resume()
1149 regcache_cache_only(rt5660->regmap, false); in rt5660_resume()
1150 regcache_sync(rt5660->regmap); in rt5660_resume()
1172 .name = "rt5660-aif1",
1251 rt5660->pdata.in1_diff = device_property_read_bool(dev, in rt5660_parse_dt()
1252 "realtek,in1-differential"); in rt5660_parse_dt()
1253 rt5660->pdata.in3_diff = device_property_read_bool(dev, in rt5660_parse_dt()
1254 "realtek,in3-differential"); in rt5660_parse_dt()
1255 rt5660->pdata.poweroff_codec_in_suspend = device_property_read_bool(dev, in rt5660_parse_dt()
1256 "realtek,poweroff-in-suspend"); in rt5660_parse_dt()
1257 device_property_read_u32(dev, "realtek,dmic1-data-pin", in rt5660_parse_dt()
1258 &rt5660->pdata.dmic1_data_pin); in rt5660_parse_dt()
1265 struct rt5660_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt5660_i2c_probe()
1270 rt5660 = devm_kzalloc(&i2c->dev, sizeof(struct rt5660_priv), in rt5660_i2c_probe()
1274 return -ENOMEM; in rt5660_i2c_probe()
1277 rt5660->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); in rt5660_i2c_probe()
1278 if (IS_ERR(rt5660->mclk)) in rt5660_i2c_probe()
1279 return PTR_ERR(rt5660->mclk); in rt5660_i2c_probe()
1284 rt5660->pdata = *pdata; in rt5660_i2c_probe()
1285 else if (i2c->dev.of_node) in rt5660_i2c_probe()
1286 rt5660_parse_dt(rt5660, &i2c->dev); in rt5660_i2c_probe()
1288 rt5660->regmap = devm_regmap_init_i2c(i2c, &rt5660_regmap); in rt5660_i2c_probe()
1289 if (IS_ERR(rt5660->regmap)) { in rt5660_i2c_probe()
1290 ret = PTR_ERR(rt5660->regmap); in rt5660_i2c_probe()
1291 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5660_i2c_probe()
1296 regmap_read(rt5660->regmap, RT5660_VENDOR_ID2, &val); in rt5660_i2c_probe()
1298 dev_err(&i2c->dev, in rt5660_i2c_probe()
1300 return -ENODEV; in rt5660_i2c_probe()
1303 regmap_write(rt5660->regmap, RT5660_RESET, 0); in rt5660_i2c_probe()
1305 ret = regmap_register_patch(rt5660->regmap, rt5660_patch, in rt5660_i2c_probe()
1308 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5660_i2c_probe()
1310 regmap_update_bits(rt5660->regmap, RT5660_GEN_CTRL1, in rt5660_i2c_probe()
1314 if (rt5660->pdata.dmic1_data_pin) { in rt5660_i2c_probe()
1315 regmap_update_bits(rt5660->regmap, RT5660_GPIO_CTRL1, in rt5660_i2c_probe()
1318 if (rt5660->pdata.dmic1_data_pin == RT5660_DMIC1_DATA_GPIO2) in rt5660_i2c_probe()
1319 regmap_update_bits(rt5660->regmap, RT5660_DMIC_CTRL1, in rt5660_i2c_probe()
1322 else if (rt5660->pdata.dmic1_data_pin == RT5660_DMIC1_DATA_IN1P) in rt5660_i2c_probe()
1323 regmap_update_bits(rt5660->regmap, RT5660_DMIC_CTRL1, in rt5660_i2c_probe()
1328 return devm_snd_soc_register_component(&i2c->dev, in rt5660_i2c_probe()