Lines Matching +full:dc +full:- +full:dc +full:- +full:freq +full:- +full:hz
1 // SPDX-License-Identifier: GPL-2.0-or-later
33 /* -54dB */
34 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0),
35 /* -52.5dB to 15dB */
36 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0)
41 /* -78dB to 12dB */
42 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
51 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
52 static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
53 static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
54 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -5700, 100, 0);
55 static const DECLARE_TLV_DB_SCALE(lineout_vol_tlv, -4800, 100, 0);
56 static const DECLARE_TLV_DB_SCALE(alc_threshold_tlv, -9450, 150, 0);
61 "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz"
234 /* Calculate DC offset */ in da7213_alc_calib_man()
235 offset_l = -avg_left_data; in da7213_alc_calib_man()
236 offset_r = -avg_right_data; in da7213_alc_calib_man()
267 dev_warn(component->dev, in da7213_alc_calib_auto()
325 if (da7213->alc_calib_auto) in da7213_alc_calib()
353 if ((!ret) && (da7213->alc_en)) in da7213_put_mixin_gain()
366 if (ucontrol->value.integer.value[0] || in da7213_put_alc_sw()
367 ucontrol->value.integer.value[1]) { in da7213_put_alc_sw()
368 if (!da7213->alc_en) { in da7213_put_alc_sw()
370 da7213->alc_en = true; in da7213_put_alc_sw()
373 da7213->alc_en = false; in da7213_put_alc_sw()
735 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7213_dai_event()
744 if (da7213->master) in da7213_dai_event()
777 dev_warn(component->dev, "SRM failed to lock\n"); in da7213_dai_event()
789 /* PC free-running */ in da7213_dai_event()
795 if (da7213->master) in da7213_dai_event()
800 return -EINVAL; in da7213_dai_event()
1158 struct snd_soc_component *component = dai->component; in da7213_hw_params()
1167 if (da7213->fmt != DA7213_DAI_FORMAT_DSP) { in da7213_hw_params()
1168 dev_err(component->dev, "Mono supported only in DSP mode\n"); in da7213_hw_params()
1169 return -EINVAL; in da7213_hw_params()
1177 return -EINVAL; in da7213_hw_params()
1196 return -EINVAL; in da7213_hw_params()
1203 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1207 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1211 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1215 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1219 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1223 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1227 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1231 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1235 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1239 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1242 return -EINVAL; in da7213_hw_params()
1257 struct snd_soc_component *component = codec_dai->component; in da7213_set_dai_fmt()
1265 da7213->master = true; in da7213_set_dai_fmt()
1268 da7213->master = false; in da7213_set_dai_fmt()
1271 return -EINVAL; in da7213_set_dai_fmt()
1293 return -EINVAL; in da7213_set_dai_fmt()
1313 return -EINVAL; in da7213_set_dai_fmt()
1317 return -EINVAL; in da7213_set_dai_fmt()
1324 da7213->fmt = DA7213_DAI_FORMAT_I2S_MODE; in da7213_set_dai_fmt()
1328 da7213->fmt = DA7213_DAI_FORMAT_LEFT_J; in da7213_set_dai_fmt()
1332 da7213->fmt = DA7213_DAI_FORMAT_RIGHT_J; in da7213_set_dai_fmt()
1337 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1341 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1344 return -EINVAL; in da7213_set_dai_fmt()
1363 struct snd_soc_component *component = dai->component; in da7213_mute()
1385 unsigned int freq, int dir) in da7213_set_component_sysclk() argument
1390 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) in da7213_set_component_sysclk()
1393 if (((freq < 5000000) && (freq != 32768)) || (freq > 54000000)) { in da7213_set_component_sysclk()
1394 dev_err(component->dev, "Unsupported MCLK value %d\n", in da7213_set_component_sysclk()
1395 freq); in da7213_set_component_sysclk()
1396 return -EINVAL; in da7213_set_component_sysclk()
1410 dev_err(component->dev, "Unknown clock source %d\n", clk_id); in da7213_set_component_sysclk()
1411 return -EINVAL; in da7213_set_component_sysclk()
1414 da7213->clk_src = clk_id; in da7213_set_component_sysclk()
1416 if (da7213->mclk) { in da7213_set_component_sysclk()
1417 freq = clk_round_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1418 ret = clk_set_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1420 dev_err(component->dev, "Failed to set clock rate %d\n", in da7213_set_component_sysclk()
1421 freq); in da7213_set_component_sysclk()
1426 da7213->mclk_rate = freq; in da7213_set_component_sysclk()
1431 /* Supported PLL input frequencies are 32KHz, 5MHz - 54MHz. */
1444 if (da7213->mclk_rate == 32768) { in _da7213_set_component_pll()
1445 if (!da7213->master) { in _da7213_set_component_pll()
1446 dev_err(component->dev, in _da7213_set_component_pll()
1448 return -EINVAL; in _da7213_set_component_pll()
1458 if (da7213->mclk_rate < 5000000) { in _da7213_set_component_pll()
1459 dev_err(component->dev, in _da7213_set_component_pll()
1461 da7213->mclk_rate); in _da7213_set_component_pll()
1462 return -EINVAL; in _da7213_set_component_pll()
1463 } else if (da7213->mclk_rate <= 9000000) { in _da7213_set_component_pll()
1466 } else if (da7213->mclk_rate <= 18000000) { in _da7213_set_component_pll()
1469 } else if (da7213->mclk_rate <= 36000000) { in _da7213_set_component_pll()
1472 } else if (da7213->mclk_rate <= 54000000) { in _da7213_set_component_pll()
1476 dev_err(component->dev, in _da7213_set_component_pll()
1478 da7213->mclk_rate); in _da7213_set_component_pll()
1479 return -EINVAL; in _da7213_set_component_pll()
1481 freq_ref = (da7213->mclk_rate / indiv); in _da7213_set_component_pll()
1500 if (da7213->mclk_rate != 32768) { in _da7213_set_component_pll()
1501 dev_err(component->dev, in _da7213_set_component_pll()
1503 return -EINVAL; in _da7213_set_component_pll()
1510 dev_err(component->dev, "Invalid PLL config\n"); in _da7213_set_component_pll()
1511 return -EINVAL; in _da7213_set_component_pll()
1548 da7213->fixed_clk_auto_pll = false; in da7213_set_component_pll()
1562 .name = "da7213-hifi",
1588 if (!da7213->fixed_clk_auto_pll) in da7213_set_auto_pll()
1591 da7213->mclk_rate = clk_get_rate(da7213->mclk); in da7213_set_auto_pll()
1594 /* Slave mode needs SRM for non-harmonic frequencies */ in da7213_set_auto_pll()
1595 if (da7213->master) in da7213_set_auto_pll()
1601 switch (da7213->out_rate) { in da7213_set_auto_pll()
1603 if (da7213->mclk_rate == 11289600 || in da7213_set_auto_pll()
1604 da7213->mclk_rate == 22579200 || in da7213_set_auto_pll()
1605 da7213->mclk_rate == 45158400) in da7213_set_auto_pll()
1609 if (da7213->mclk_rate == 12288000 || in da7213_set_auto_pll()
1610 da7213->mclk_rate == 24576000 || in da7213_set_auto_pll()
1611 da7213->mclk_rate == 49152000) in da7213_set_auto_pll()
1616 return -1; in da7213_set_auto_pll()
1624 da7213->mclk_rate, da7213->out_rate); in da7213_set_auto_pll()
1639 if (da7213->mclk) { in da7213_set_bias_level()
1640 ret = clk_prepare_enable(da7213->mclk); in da7213_set_bias_level()
1642 dev_err(component->dev, in da7213_set_bias_level()
1659 if (da7213->mclk) { in da7213_set_bias_level()
1661 clk_disable_unprepare(da7213->mclk); in da7213_set_bias_level()
1706 dev_warn(component->dev, "Invalid micbias level\n"); in da7213_of_micbias_lvl()
1719 dev_warn(component->dev, "Invalid DMIC data select type\n"); in da7213_of_dmic_data_sel()
1732 dev_warn(component->dev, "Invalid DMIC sample phase\n"); in da7213_of_dmic_samplephase()
1746 dev_warn(component->dev, "Invalid DMIC clock rate\n"); in da7213_of_dmic_clkrate()
1754 struct device *dev = component->dev; in da7213_fw_to_pdata()
1759 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); in da7213_fw_to_pdata()
1763 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1764 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1766 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1768 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1769 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1771 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1773 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) in da7213_fw_to_pdata()
1774 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); in da7213_fw_to_pdata()
1776 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; in da7213_fw_to_pdata()
1778 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) in da7213_fw_to_pdata()
1779 pdata->dmic_samplephase = in da7213_fw_to_pdata()
1782 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; in da7213_fw_to_pdata()
1784 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) in da7213_fw_to_pdata()
1785 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); in da7213_fw_to_pdata()
1787 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; in da7213_fw_to_pdata()
1796 pm_runtime_get_sync(component->dev); in da7213_probe()
1801 da7213->alc_calib_auto = true; in da7213_probe()
1803 /* Default PC counter to free-running */ in da7213_probe()
1858 da7213->pdata = dev_get_platdata(component->dev); in da7213_probe()
1859 if (!da7213->pdata) in da7213_probe()
1860 da7213->pdata = da7213_fw_to_pdata(component); in da7213_probe()
1863 if (da7213->pdata) { in da7213_probe()
1864 struct da7213_platform_data *pdata = da7213->pdata; in da7213_probe()
1868 switch (pdata->micbias1_lvl) { in da7213_probe()
1873 micbias_lvl |= (pdata->micbias1_lvl << in da7213_probe()
1877 switch (pdata->micbias2_lvl) { in da7213_probe()
1882 micbias_lvl |= (pdata->micbias2_lvl << in da7213_probe()
1891 switch (pdata->dmic_data_sel) { in da7213_probe()
1894 dmic_cfg |= (pdata->dmic_data_sel << in da7213_probe()
1898 switch (pdata->dmic_samplephase) { in da7213_probe()
1901 dmic_cfg |= (pdata->dmic_samplephase << in da7213_probe()
1905 switch (pdata->dmic_clk_rate) { in da7213_probe()
1908 dmic_cfg |= (pdata->dmic_clk_rate << in da7213_probe()
1918 pm_runtime_put_sync(component->dev); in da7213_probe()
1921 da7213->mclk = devm_clk_get(component->dev, "mclk"); in da7213_probe()
1922 if (IS_ERR(da7213->mclk)) { in da7213_probe()
1923 if (PTR_ERR(da7213->mclk) != -ENOENT) in da7213_probe()
1924 return PTR_ERR(da7213->mclk); in da7213_probe()
1926 da7213->mclk = NULL; in da7213_probe()
1930 * with the simple-audio-card driver. */ in da7213_probe()
1931 da7213->fixed_clk_auto_pll = true; in da7213_probe()
1966 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_power_off()
1979 da7213 = devm_kzalloc(&i2c->dev, sizeof(*da7213), GFP_KERNEL); in da7213_i2c_probe()
1981 return -ENOMEM; in da7213_i2c_probe()
1987 da7213->supplies[i].supply = da7213_supply_names[i]; in da7213_i2c_probe()
1989 ret = devm_regulator_bulk_get(&i2c->dev, DA7213_NUM_SUPPLIES, in da7213_i2c_probe()
1990 da7213->supplies); in da7213_i2c_probe()
1992 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); in da7213_i2c_probe()
1996 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_i2c_probe()
2000 ret = devm_add_action_or_reset(&i2c->dev, da7213_power_off, da7213); in da7213_i2c_probe()
2004 da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); in da7213_i2c_probe()
2005 if (IS_ERR(da7213->regmap)) { in da7213_i2c_probe()
2006 ret = PTR_ERR(da7213->regmap); in da7213_i2c_probe()
2007 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in da7213_i2c_probe()
2011 pm_runtime_set_autosuspend_delay(&i2c->dev, 100); in da7213_i2c_probe()
2012 pm_runtime_use_autosuspend(&i2c->dev); in da7213_i2c_probe()
2013 pm_runtime_set_active(&i2c->dev); in da7213_i2c_probe()
2014 pm_runtime_enable(&i2c->dev); in da7213_i2c_probe()
2016 ret = devm_snd_soc_register_component(&i2c->dev, in da7213_i2c_probe()
2019 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", in da7213_i2c_probe()
2027 pm_runtime_disable(&i2c->dev); in da7213_i2c_remove()
2034 regcache_cache_only(da7213->regmap, true); in da7213_runtime_suspend()
2035 regcache_mark_dirty(da7213->regmap); in da7213_runtime_suspend()
2036 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_suspend()
2046 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_resume()
2049 regcache_cache_only(da7213->regmap, false); in da7213_runtime_resume()
2050 regcache_sync(da7213->regmap); in da7213_runtime_resume()