Lines Matching +full:mic +full:- +full:offset
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:-
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"};
172 static const char *wm8753_sidetone_mux[] = {"Left PGA", "Mic 1", "Mic 2",
178 static const char *wm8753_radcsel[] = {"PGA", "Line or RXP-RXN", "Sidetone"};
179 static const char *wm8753_ladcsel[] = {"PGA", "Line or RXP-RXN", "Line"};
185 static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
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),
315 SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
328 SOC_ENUM("Capture Filter Cut-off", wm8753_enum[24]),
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]),
424 /* MIC mux */
456 /* Mic Selector Mux */
461 SND_SOC_DAPM_MICBIAS("Mic Bias", WM8753_PWR1, 5, 0),
504 SND_SOC_DAPM_MUX("Mic Sidetone Mux", SND_SOC_NOPM, 0, 0,
520 SND_SOC_DAPM_PGA("Mic 1 Volume", WM8753_PWR2, 8, 0, NULL, 0),
521 SND_SOC_DAPM_PGA("Mic 2 Volume", WM8753_PWR2, 7, 0, NULL, 0),
522 SND_SOC_DAPM_MUX("Mic Selection Mux", SND_SOC_NOPM, 0, 0,
541 {"Left Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
547 {"Right Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
554 {"Mono Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
602 /* Mic/SideTone Mux */
603 {"Mic Sidetone Mux", "Left PGA", "Left Capture Volume"},
604 {"Mic Sidetone Mux", "Right PGA", "Right Capture Volume"},
605 {"Mic Sidetone Mux", "Mic 1", "Mic 1 Volume"},
606 {"Mic Sidetone Mux", "Mic 2", "Mic 2 Volume"},
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 */
638 {"Right Capture Volume", NULL, "Mic 2 Volume"},
642 {"ALC Mixer", "Mic2 Capture Switch", "Mic 2 Volume"},
643 {"ALC Mixer", "Mic1 Capture Switch", "Mic 1 Volume"},
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"},
674 /* Mic 1 Volume */
675 {"Mic 1 Volume", NULL, "MIC1N"},
676 {"Mic 1 Volume", NULL, "Mic Selection Mux"},
678 /* Mic 2 Volume */
679 {"Mic 2 Volume", NULL, "MIC2N"},
680 {"Mic 2 Volume", NULL, "MIC2"},
682 /* Mic Selector Mux */
683 {"Mic Selection Mux", "Mic 1", "MIC1"},
684 {"Mic Selection Mux", "Mic 2", "MIC2N"},
685 {"Mic Selection Mux", "Mic 3", "MIC2"},
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()
742 int offset; in wm8753_set_dai_pll() local
743 struct snd_soc_component *component = codec_dai->component; in wm8753_set_dai_pll()
746 return -ENODEV; in wm8753_set_dai_pll()
749 offset = 0; in wm8753_set_dai_pll()
753 offset = 4; in wm8753_set_dai_pll()
760 snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0026); in wm8753_set_dai_pll()
772 snd_soc_component_write(component, WM8753_PLL1CTL2 + offset, value); in wm8753_set_dai_pll()
776 snd_soc_component_write(component, WM8753_PLL1CTL3 + offset, value); in wm8753_set_dai_pll()
780 snd_soc_component_write(component, WM8753_PLL1CTL4 + offset, value); in wm8753_set_dai_pll()
783 snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0027 | 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()
910 return -EINVAL; in wm8753_vdac_adc_set_dai_fmt()
924 struct snd_soc_component *component = dai->component; 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()
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()