Lines Matching +full:mux +full:- +full:locked

1 // SPDX-License-Identifier: GPL-2.0-or-later
34 /* -54dB */
35 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0),
36 /* -52.5dB to 15dB */
37 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0)
42 /* -78dB to 12dB */
43 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
52 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
53 static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
54 static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
55 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -5700, 100, 0);
56 static const DECLARE_TLV_DB_SCALE(lineout_vol_tlv, -4800, 100, 0);
57 static const DECLARE_TLV_DB_SCALE(alc_threshold_tlv, -9450, 150, 0);
59 static const DECLARE_TLV_DB_SCALE(da7213_tonegen_gain_tlv, -4500, 300, 0);
213 /* Locked Kcontrol calls */
221 mutex_lock(&da7213->ctrl_lock); in da7213_volsw_locked_get()
223 mutex_unlock(&da7213->ctrl_lock); in da7213_volsw_locked_get()
235 mutex_lock(&da7213->ctrl_lock); in da7213_volsw_locked_put()
237 mutex_unlock(&da7213->ctrl_lock); in da7213_volsw_locked_put()
249 mutex_lock(&da7213->ctrl_lock); in da7213_enum_locked_get()
251 mutex_unlock(&da7213->ctrl_lock); in da7213_enum_locked_get()
263 mutex_lock(&da7213->ctrl_lock); in da7213_enum_locked_put()
265 mutex_unlock(&da7213->ctrl_lock); in da7213_enum_locked_put()
312 offset_l = -avg_left_data; in da7213_alc_calib_man()
313 offset_r = -avg_right_data; in da7213_alc_calib_man()
344 dev_warn(component->dev, in da7213_alc_calib_auto()
402 if (da7213->alc_calib_auto) in da7213_alc_calib()
430 if ((!ret) && (da7213->alc_en)) in da7213_put_mixin_gain()
443 if (ucontrol->value.integer.value[0] || in da7213_put_alc_sw()
444 ucontrol->value.integer.value[1]) { in da7213_put_alc_sw()
445 if (!da7213->alc_en) { in da7213_put_alc_sw()
447 da7213->alc_en = true; in da7213_put_alc_sw()
450 da7213->alc_en = false; in da7213_put_alc_sw()
463 (struct soc_mixer_control *) kcontrol->private_value; in da7213_tonegen_freq_get()
464 unsigned int reg = mixer_ctrl->reg; in da7213_tonegen_freq_get()
468 mutex_lock(&da7213->ctrl_lock); in da7213_tonegen_freq_get()
469 ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val)); in da7213_tonegen_freq_get()
470 mutex_unlock(&da7213->ctrl_lock); in da7213_tonegen_freq_get()
476 * Frequency value spans two 8-bit registers, lower then upper byte. in da7213_tonegen_freq_get()
479 ucontrol->value.integer.value[0] = le16_to_cpu(val); in da7213_tonegen_freq_get()
490 (struct soc_mixer_control *) kcontrol->private_value; in da7213_tonegen_freq_put()
491 unsigned int reg = mixer_ctrl->reg; in da7213_tonegen_freq_put()
496 * Frequency value spans two 8-bit registers, lower then upper byte. in da7213_tonegen_freq_put()
500 val_new = cpu_to_le16(ucontrol->value.integer.value[0]); in da7213_tonegen_freq_put()
502 mutex_lock(&da7213->ctrl_lock); in da7213_tonegen_freq_put()
503 ret = regmap_raw_read(da7213->regmap, reg, &val_old, sizeof(val_old)); in da7213_tonegen_freq_put()
505 ret = regmap_raw_write(da7213->regmap, reg, in da7213_tonegen_freq_put()
507 mutex_unlock(&da7213->ctrl_lock); in da7213_tonegen_freq_put()
759 SOC_DAPM_ENUM("Mic 1 Amp Source MUX", da7213_mic_1_amp_in_sel);
766 SOC_DAPM_ENUM("Mic 2 Amp Source MUX", da7213_mic_2_amp_in_sel);
778 SOC_DAPM_ENUM("DAI Left Source MUX", da7213_dai_l_src);
785 SOC_DAPM_ENUM("DAI Right Source MUX", da7213_dai_r_src);
798 SOC_DAPM_ENUM("DAC Left Source MUX", da7213_dac_l_src);
805 SOC_DAPM_ENUM("DAC Right Source MUX", da7213_dac_r_src);
901 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7213_dai_event()
910 if (da7213->master) in da7213_dai_event()
931 /* Check SRM has locked */ in da7213_dai_event()
943 dev_warn(component->dev, "SRM failed to lock\n"); in da7213_dai_event()
955 /* PC free-running */ in da7213_dai_event()
961 if (da7213->master) in da7213_dai_event()
966 return -EINVAL; in da7213_dai_event()
1001 SND_SOC_DAPM_MUX("Mic 1 Amp Source MUX", SND_SOC_NOPM, 0, 0,
1003 SND_SOC_DAPM_MUX("Mic 2 Amp Source MUX", SND_SOC_NOPM, 0, 0,
1043 SND_SOC_DAPM_MUX("DAI Left Source MUX", SND_SOC_NOPM, 0, 0,
1045 SND_SOC_DAPM_MUX("DAI Right Source MUX", SND_SOC_NOPM, 0, 0,
1057 SND_SOC_DAPM_MUX("DAC Left Source MUX", SND_SOC_NOPM, 0, 0,
1059 SND_SOC_DAPM_MUX("DAC Right Source MUX", SND_SOC_NOPM, 0, 0,
1113 {"Mic 1 Amp Source MUX", "Differential", "MIC1"},
1114 {"Mic 1 Amp Source MUX", "MIC_P", "MIC1"},
1115 {"Mic 1 Amp Source MUX", "MIC_N", "MIC1"},
1117 {"Mic 2 Amp Source MUX", "Differential", "MIC2"},
1118 {"Mic 2 Amp Source MUX", "MIC_P", "MIC2"},
1119 {"Mic 2 Amp Source MUX", "MIC_N", "MIC2"},
1121 {"Mic 1 PGA", NULL, "Mic 1 Amp Source MUX"},
1122 {"Mic 2 PGA", NULL, "Mic 2 Amp Source MUX"},
1143 {"DAI Left Source MUX", "ADC Left", "ADC Left"},
1144 {"DAI Left Source MUX", "ADC Right", "ADC Right"},
1145 {"DAI Left Source MUX", "DAI Input Left", "DAIINL"},
1146 {"DAI Left Source MUX", "DAI Input Right", "DAIINR"},
1148 {"DAI Right Source MUX", "ADC Left", "ADC Left"},
1149 {"DAI Right Source MUX", "ADC Right", "ADC Right"},
1150 {"DAI Right Source MUX", "DAI Input Left", "DAIINL"},
1151 {"DAI Right Source MUX", "DAI Input Right", "DAIINR"},
1153 {"DAIOUTL", NULL, "DAI Left Source MUX"},
1154 {"DAIOUTR", NULL, "DAI Right Source MUX"},
1163 {"DAC Left Source MUX", "ADC Output Left", "ADC Left"},
1164 {"DAC Left Source MUX", "ADC Output Right", "ADC Right"},
1165 {"DAC Left Source MUX", "DAI Input Left", "DAIINL"},
1166 {"DAC Left Source MUX", "DAI Input Right", "DAIINR"},
1168 {"DAC Right Source MUX", "ADC Output Left", "ADC Left"},
1169 {"DAC Right Source MUX", "ADC Output Right", "ADC Right"},
1170 {"DAC Right Source MUX", "DAI Input Left", "DAIINL"},
1171 {"DAC Right Source MUX", "DAI Input Right", "DAIINR"},
1173 {"DAC Left", NULL, "DAC Left Source MUX"},
1174 {"DAC Right", NULL, "DAC Right Source MUX"},
1324 struct snd_soc_component *component = dai->component; in da7213_hw_params()
1333 if (da7213->fmt != DA7213_DAI_FORMAT_DSP) { in da7213_hw_params()
1334 dev_err(component->dev, "Mono supported only in DSP mode\n"); in da7213_hw_params()
1335 return -EINVAL; in da7213_hw_params()
1343 return -EINVAL; in da7213_hw_params()
1362 return -EINVAL; in da7213_hw_params()
1369 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1373 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1377 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1381 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1385 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1389 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1393 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1397 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1401 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1405 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1408 return -EINVAL; in da7213_hw_params()
1423 struct snd_soc_component *component = codec_dai->component; in da7213_set_dai_fmt()
1431 da7213->master = true; in da7213_set_dai_fmt()
1434 da7213->master = false; in da7213_set_dai_fmt()
1437 return -EINVAL; in da7213_set_dai_fmt()
1459 return -EINVAL; in da7213_set_dai_fmt()
1479 return -EINVAL; in da7213_set_dai_fmt()
1483 return -EINVAL; in da7213_set_dai_fmt()
1490 da7213->fmt = DA7213_DAI_FORMAT_I2S_MODE; in da7213_set_dai_fmt()
1494 da7213->fmt = DA7213_DAI_FORMAT_LEFT_J; in da7213_set_dai_fmt()
1498 da7213->fmt = DA7213_DAI_FORMAT_RIGHT_J; in da7213_set_dai_fmt()
1503 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1507 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1510 return -EINVAL; in da7213_set_dai_fmt()
1529 struct snd_soc_component *component = dai->component; in da7213_mute()
1556 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) in da7213_set_component_sysclk()
1563 if (((freq < da7213->fin_min_rate) && (freq != 32768)) || (freq > 54000000)) { in da7213_set_component_sysclk()
1564 dev_err(component->dev, "Unsupported MCLK value %d\n", in da7213_set_component_sysclk()
1566 return -EINVAL; in da7213_set_component_sysclk()
1580 dev_err(component->dev, "Unknown clock source %d\n", clk_id); in da7213_set_component_sysclk()
1581 return -EINVAL; in da7213_set_component_sysclk()
1584 da7213->clk_src = clk_id; in da7213_set_component_sysclk()
1586 if (da7213->mclk) { in da7213_set_component_sysclk()
1587 freq = clk_round_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1588 ret = clk_set_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1590 dev_err(component->dev, "Failed to set clock rate %d\n", in da7213_set_component_sysclk()
1596 da7213->mclk_rate = freq; in da7213_set_component_sysclk()
1601 /* Supported PLL input frequencies are 32KHz, 5MHz - 54MHz. */
1614 if (da7213->mclk_rate == 32768) { in _da7213_set_component_pll()
1615 if (!da7213->master) { in _da7213_set_component_pll()
1616 dev_err(component->dev, in _da7213_set_component_pll()
1618 return -EINVAL; in _da7213_set_component_pll()
1628 if (da7213->mclk_rate < 5000000) { in _da7213_set_component_pll()
1629 dev_err(component->dev, in _da7213_set_component_pll()
1631 da7213->mclk_rate); in _da7213_set_component_pll()
1632 return -EINVAL; in _da7213_set_component_pll()
1633 } else if (da7213->mclk_rate <= 9000000) { in _da7213_set_component_pll()
1636 } else if (da7213->mclk_rate <= 18000000) { in _da7213_set_component_pll()
1639 } else if (da7213->mclk_rate <= 36000000) { in _da7213_set_component_pll()
1642 } else if (da7213->mclk_rate <= 54000000) { in _da7213_set_component_pll()
1646 dev_err(component->dev, in _da7213_set_component_pll()
1648 da7213->mclk_rate); in _da7213_set_component_pll()
1649 return -EINVAL; in _da7213_set_component_pll()
1651 freq_ref = (da7213->mclk_rate / indiv); in _da7213_set_component_pll()
1670 if (da7213->mclk_rate != 32768) { in _da7213_set_component_pll()
1671 dev_err(component->dev, in _da7213_set_component_pll()
1673 return -EINVAL; in _da7213_set_component_pll()
1680 dev_err(component->dev, "Invalid PLL config\n"); in _da7213_set_component_pll()
1681 return -EINVAL; in _da7213_set_component_pll()
1718 da7213->fixed_clk_auto_pll = false; in da7213_set_component_pll()
1750 .name = "da7213-hifi",
1776 if (!da7213->fixed_clk_auto_pll) in da7213_set_auto_pll()
1779 da7213->mclk_rate = clk_get_rate(da7213->mclk); in da7213_set_auto_pll()
1782 /* Slave mode needs SRM for non-harmonic frequencies */ in da7213_set_auto_pll()
1783 if (da7213->master) in da7213_set_auto_pll()
1789 switch (da7213->out_rate) { in da7213_set_auto_pll()
1791 if (da7213->mclk_rate == 11289600 || in da7213_set_auto_pll()
1792 da7213->mclk_rate == 22579200 || in da7213_set_auto_pll()
1793 da7213->mclk_rate == 45158400) in da7213_set_auto_pll()
1797 if (da7213->mclk_rate == 12288000 || in da7213_set_auto_pll()
1798 da7213->mclk_rate == 24576000 || in da7213_set_auto_pll()
1799 da7213->mclk_rate == 49152000) in da7213_set_auto_pll()
1804 return -1; in da7213_set_auto_pll()
1812 da7213->mclk_rate, da7213->out_rate); in da7213_set_auto_pll()
1827 if (da7213->mclk) { in da7213_set_bias_level()
1828 ret = clk_prepare_enable(da7213->mclk); in da7213_set_bias_level()
1830 dev_err(component->dev, in da7213_set_bias_level()
1847 if (da7213->mclk) { in da7213_set_bias_level()
1849 clk_disable_unprepare(da7213->mclk); in da7213_set_bias_level()
1897 dev_warn(component->dev, "Invalid micbias level\n"); in da7213_of_micbias_lvl()
1910 dev_warn(component->dev, "Invalid DMIC data select type\n"); in da7213_of_dmic_data_sel()
1923 dev_warn(component->dev, "Invalid DMIC sample phase\n"); in da7213_of_dmic_samplephase()
1937 dev_warn(component->dev, "Invalid DMIC clock rate\n"); in da7213_of_dmic_clkrate()
1945 struct device *dev = component->dev; in da7213_fw_to_pdata()
1950 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); in da7213_fw_to_pdata()
1954 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1955 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1957 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1959 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1960 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1962 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1964 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) in da7213_fw_to_pdata()
1965 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); in da7213_fw_to_pdata()
1967 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; in da7213_fw_to_pdata()
1969 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) in da7213_fw_to_pdata()
1970 pdata->dmic_samplephase = in da7213_fw_to_pdata()
1973 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; in da7213_fw_to_pdata()
1975 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) in da7213_fw_to_pdata()
1976 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); in da7213_fw_to_pdata()
1978 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; in da7213_fw_to_pdata()
1987 pm_runtime_get_sync(component->dev); in da7213_probe()
1992 da7213->alc_calib_auto = true; in da7213_probe()
1994 /* Default PC counter to free-running */ in da7213_probe()
2049 da7213->pdata = dev_get_platdata(component->dev); in da7213_probe()
2050 if (!da7213->pdata) in da7213_probe()
2051 da7213->pdata = da7213_fw_to_pdata(component); in da7213_probe()
2054 if (da7213->pdata) { in da7213_probe()
2055 struct da7213_platform_data *pdata = da7213->pdata; in da7213_probe()
2059 switch (pdata->micbias1_lvl) { in da7213_probe()
2064 micbias_lvl |= (pdata->micbias1_lvl << in da7213_probe()
2068 switch (pdata->micbias2_lvl) { in da7213_probe()
2073 micbias_lvl |= (pdata->micbias2_lvl << in da7213_probe()
2082 switch (pdata->dmic_data_sel) { in da7213_probe()
2085 dmic_cfg |= (pdata->dmic_data_sel << in da7213_probe()
2089 switch (pdata->dmic_samplephase) { in da7213_probe()
2092 dmic_cfg |= (pdata->dmic_samplephase << in da7213_probe()
2096 switch (pdata->dmic_clk_rate) { in da7213_probe()
2099 dmic_cfg |= (pdata->dmic_clk_rate << in da7213_probe()
2109 pm_runtime_put_sync(component->dev); in da7213_probe()
2112 da7213->mclk = devm_clk_get_optional(component->dev, "mclk"); in da7213_probe()
2113 if (IS_ERR(da7213->mclk)) in da7213_probe()
2114 return PTR_ERR(da7213->mclk); in da7213_probe()
2115 if (da7213->mclk) in da7213_probe()
2118 * with the simple-audio-card driver. */ in da7213_probe()
2119 da7213->fixed_clk_auto_pll = true; in da7213_probe()
2157 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_power_off()
2170 da7213 = devm_kzalloc(&i2c->dev, sizeof(*da7213), GFP_KERNEL); in da7213_i2c_probe()
2172 return -ENOMEM; in da7213_i2c_probe()
2174 da7213->fin_min_rate = (uintptr_t)i2c_get_match_data(i2c); in da7213_i2c_probe()
2175 if (!da7213->fin_min_rate) in da7213_i2c_probe()
2176 return -EINVAL; in da7213_i2c_probe()
2182 da7213->supplies[i].supply = da7213_supply_names[i]; in da7213_i2c_probe()
2184 ret = devm_regulator_bulk_get(&i2c->dev, DA7213_NUM_SUPPLIES, in da7213_i2c_probe()
2185 da7213->supplies); in da7213_i2c_probe()
2187 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); in da7213_i2c_probe()
2191 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_i2c_probe()
2195 ret = devm_add_action_or_reset(&i2c->dev, da7213_power_off, da7213); in da7213_i2c_probe()
2199 da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); in da7213_i2c_probe()
2200 if (IS_ERR(da7213->regmap)) { in da7213_i2c_probe()
2201 ret = PTR_ERR(da7213->regmap); in da7213_i2c_probe()
2202 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in da7213_i2c_probe()
2206 mutex_init(&da7213->ctrl_lock); in da7213_i2c_probe()
2208 pm_runtime_set_autosuspend_delay(&i2c->dev, 100); in da7213_i2c_probe()
2209 pm_runtime_use_autosuspend(&i2c->dev); in da7213_i2c_probe()
2210 pm_runtime_set_active(&i2c->dev); in da7213_i2c_probe()
2211 pm_runtime_enable(&i2c->dev); in da7213_i2c_probe()
2213 ret = devm_snd_soc_register_component(&i2c->dev, in da7213_i2c_probe()
2216 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", in da7213_i2c_probe()
2224 pm_runtime_disable(&i2c->dev); in da7213_i2c_remove()
2231 regcache_cache_only(da7213->regmap, true); in da7213_runtime_suspend()
2232 regcache_mark_dirty(da7213->regmap); in da7213_runtime_suspend()
2233 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_suspend()
2243 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_resume()
2246 regcache_cache_only(da7213->regmap, false); in da7213_runtime_resume()
2247 return regcache_sync(da7213->regmap); in da7213_runtime_resume()