Lines Matching +full:adc +full:- +full:sample +full:- +full:hold +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8753.c -- WM8753 ALSA Soc Audio driver
5 * Copyright 2003-11 Wolfson Microelectronics PLC.
12 * Dual DAI:-
23 * Fast DAI switching:-
51 MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
159 static const char *wm8753_ng_type[] = {"Constant PGA Gain", "Mute ADC Output"};
166 static const char *wm8753_line_mix[] = {"Line 1 + 2", "Line 1 - 2",
171 static const char *wm8753_rxmsel[] = {"RXP - RXN", "RXP + RXN", "RXP", "RXN"};
178 static const char *wm8753_radcsel[] = {"PGA", "Line or RXP-RXN", "Sidetone"};
179 static const char *wm8753_ladcsel[] = {"PGA", "Line or RXP-RXN", "Line"};
187 static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
230 ucontrol->value.enumerated.item[0] = wm8753->dai_func; in wm8753_get_dai()
241 if (wm8753->dai_func == ucontrol->value.enumerated.item[0]) in wm8753_set_dai()
245 return -EBUSY; in wm8753_set_dai()
249 wm8753->dai_func = ucontrol->value.enumerated.item[0]; in wm8753_set_dai()
251 if (((ioctl >> 2) & 0x3) == wm8753->dai_func) in wm8753_set_dai()
254 ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2); in wm8753_set_dai()
258 wm8753_hifi_write_dai_fmt(component, wm8753->hifi_fmt); in wm8753_set_dai()
259 wm8753_voice_write_dai_fmt(component, wm8753->voice_fmt); in wm8753_set_dai()
264 static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 300, 0);
266 static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
267 static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
269 /* 0000000 - 0101111 = "Analogue mute" */
270 0, 48, TLV_DB_SCALE_ITEM(-25500, 0, 0),
271 48, 127, TLV_DB_SCALE_ITEM(-7300, 100, 0)
273 static const DECLARE_TLV_DB_SCALE(mix_tlv, -1500, 300, 0);
274 static const DECLARE_TLV_DB_SCALE(voice_mix_tlv, -1200, 300, 0);
275 static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0);
278 SOC_SINGLE("Hi-Fi DAC Left/Right channel Swap", WM8753_HIFI, 5, 1, 0),
281 SOC_DOUBLE_R_TLV("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0,
315 SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
328 SOC_ENUM("Capture Filter Cut-off", wm8753_enum[24]),
335 SOC_SINGLE("ALC Capture Hold Time", WM8753_ALC2, 0, 15, 1),
336 SOC_SINGLE("ALC Capture Decay Time", WM8753_ALC3, 4, 15, 1),
337 SOC_SINGLE("ALC Capture Attack Time", WM8753_ALC3, 0, 15, 0),
343 SOC_ENUM("3D Upper Cut-off", wm8753_enum[6]),
344 SOC_ENUM("3D Lower Cut-off", wm8753_enum[7]),
351 SOC_ENUM("De-emphasis", wm8753_enum[8]),
360 SOC_ENUM("ADC Data Select", wm8753_enum[27]),
405 /* ADC Mono Mix */
416 /* Left ADC mux */
420 /* Right ADC mux */
494 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8753_PWR2, 3, 0),
495 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8753_PWR2, 2, 0),
610 {"Capture Left Mux", "Line or RXP-RXN", "Line Left Mux"},
615 {"Capture Right Mux", "Line or RXP-RXN", "Line Right Mux"},
618 /* Mono Capture mixer-mux */
630 /* ADC */
631 {"Left ADC", NULL, "Capture Left Mixer"},
632 {"Right ADC", NULL, "Capture Right Mixer"},
660 {"Line Mixer", "Line 1 - 2", "LINE1"},
662 {"Line Mixer", "Line 1 - 2", "LINE2"},
667 {"Rx Mixer", "RXP - RXN", "RXP"},
669 {"Rx Mixer", "RXP - RXN", "RXN"},
711 pll_div->div2 = 1; in pll_factors()
714 pll_div->div2 = 0; in pll_factors()
720 pll_div->n = Ndiv; in pll_factors()
735 pll_div->k = K; in pll_factors()
743 struct snd_soc_component *component = codec_dai->component; in wm8753_set_dai_pll()
746 return -ENODEV; in wm8753_set_dai_pll()
855 return -EINVAL; in get_coeff()
864 struct snd_soc_component *component = codec_dai->component; in wm8753_set_dai_sysclk()
874 wm8753->sysclk = freq; in wm8753_set_dai_sysclk()
877 wm8753->pcmclk = freq; in wm8753_set_dai_sysclk()
882 return -EINVAL; in wm8753_set_dai_sysclk()
886 * Set's ADC and Voice DAC format.
910 return -EINVAL; in wm8753_vdac_adc_set_dai_fmt()
918 * Set PCM DAI bit size and sample rate.
924 struct snd_soc_component *component = dai->component; in wm8753_pcm_hw_params()
944 /* sample rate */ in wm8753_pcm_hw_params()
945 if (params_rate(params) * 384 == wm8753->pcmclk) in wm8753_pcm_hw_params()
975 return -EINVAL; in wm8753_pcm_set_dai_fmt()
990 return -EINVAL; in wm8753_pcm_set_dai_fmt()
1010 return -EINVAL; in wm8753_pcm_set_dai_fmt()
1014 return -EINVAL; in wm8753_pcm_set_dai_fmt()
1025 struct snd_soc_component *component = codec_dai->component; in wm8753_set_dai_clkdiv()
1042 return -EINVAL; in wm8753_set_dai_clkdiv()
1072 return -EINVAL; in wm8753_hdac_set_dai_fmt()
1101 return -EINVAL; in wm8753_i2s_set_dai_fmt()
1116 return -EINVAL; in wm8753_i2s_set_dai_fmt()
1136 return -EINVAL; in wm8753_i2s_set_dai_fmt()
1140 return -EINVAL; in wm8753_i2s_set_dai_fmt()
1149 * Set PCM DAI bit size and sample rate.
1155 struct snd_soc_component *component = dai->component; in wm8753_i2s_hw_params()
1162 coeff = get_coeff(wm8753->sysclk, params_rate(params)); in wm8753_i2s_hw_params()
1229 return -EINVAL; in wm8753_mode3_4_set_dai_fmt()
1239 switch (wm8753->dai_func) { in wm8753_hifi_write_dai_fmt()
1262 struct snd_soc_component *component = codec_dai->component; in wm8753_hifi_set_dai_fmt()
1265 wm8753->hifi_fmt = fmt; in wm8753_hifi_set_dai_fmt()
1276 if (wm8753->dai_func != 0) in wm8753_voice_write_dai_fmt()
1292 struct snd_soc_component *component = codec_dai->component; in wm8753_voice_set_dai_fmt()
1295 wm8753->voice_fmt = fmt; in wm8753_voice_set_dai_fmt()
1302 struct snd_soc_component *component = dai->component; in wm8753_mute()
1308 if (mute && wm8753->dai_func == 1) { in wm8753_mute()
1327 regmap_update_bits(wm8753->regmap, WM8753_PWR1, 0x0180, 0x0100); in wm8753_charge_work()
1343 flush_delayed_work(&wm8753->charge_work); in wm8753_set_bias_level()
1349 schedule_delayed_work(&wm8753->charge_work, in wm8753_set_bias_level()
1357 cancel_delayed_work_sync(&wm8753->charge_work); in wm8753_set_bias_level()
1378 * 1. Voice over PCM DAI - HIFI DAC over HIFI DAI
1379 * 2. Voice over HIFI DAI - HIFI disabled
1380 * 3. Voice disabled - HIFI over HIFI
1381 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture
1405 { .name = "wm8753-hifi",
1423 { .name = "wm8753-voice",
1446 regcache_sync(wm8753->regmap); in wm8753_resume()
1456 INIT_DELAYED_WORK(&wm8753->charge_work, wm8753_charge_work); in wm8753_probe()
1460 dev_err(component->dev, "Failed to issue reset: %d\n", ret); in wm8753_probe()
1464 wm8753->dai_func = 0; in wm8753_probe()
1521 wm8753 = devm_kzalloc(&spi->dev, sizeof(struct wm8753_priv), in wm8753_spi_probe()
1524 return -ENOMEM; in wm8753_spi_probe()
1528 wm8753->regmap = devm_regmap_init_spi(spi, &wm8753_regmap); in wm8753_spi_probe()
1529 if (IS_ERR(wm8753->regmap)) { in wm8753_spi_probe()
1530 ret = PTR_ERR(wm8753->regmap); in wm8753_spi_probe()
1531 dev_err(&spi->dev, "Failed to allocate register map: %d\n", in wm8753_spi_probe()
1536 ret = devm_snd_soc_register_component(&spi->dev, &soc_component_dev_wm8753, in wm8753_spi_probe()
1539 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); in wm8753_spi_probe()
1559 wm8753 = devm_kzalloc(&i2c->dev, sizeof(struct wm8753_priv), in wm8753_i2c_probe()
1562 return -ENOMEM; in wm8753_i2c_probe()
1566 wm8753->regmap = devm_regmap_init_i2c(i2c, &wm8753_regmap); in wm8753_i2c_probe()
1567 if (IS_ERR(wm8753->regmap)) { in wm8753_i2c_probe()
1568 ret = PTR_ERR(wm8753->regmap); in wm8753_i2c_probe()
1569 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm8753_i2c_probe()
1574 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8753, in wm8753_i2c_probe()
1577 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); in wm8753_i2c_probe()