Lines Matching +full:adc +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0-only
3 // es8323.c -- es8323 ALSA SoC audio driver
10 // Jianqun Xu <jay.xu@rock-chips.com>
11 // Nickey Yang <nickey.yang@rock-chips.com>
25 #include <sound/soc-dapm.h>
98 static const char *const es8323_ng_type_texts[] = { "Constant PGA Gain", "Mute ADC Output" };
110 static const DECLARE_TLV_DB_SCALE(es8323_adc_tlv, -9600, 50, 1);
111 static const DECLARE_TLV_DB_SCALE(es8323_dac_tlv, -9600, 50, 1);
112 static const DECLARE_TLV_DB_SCALE(es8323_out_tlv, -4500, 150, 0);
114 static const DECLARE_TLV_DB_SCALE(es8323_bypass_tlv2, -15, 300, 0);
120 SOC_ENUM("Playback De-emphasis", es8323_playback_deemphasis_enum),
159 /* Left Line Mux */
163 SOC_DAPM_ENUM("LLIN Mux", es8323_llin_enum);
165 /* Right Line Mux */
169 SOC_DAPM_ENUM("RLIN Mux", es8323_rlin_enum);
171 /* Differential Mux */
177 /* Mono ADC Mux */
181 SOC_DAPM_ENUM("Mono Mux", es8323_mono_adc_mux_enum);
204 SND_SOC_DAPM_MUX("Left PGA Mux", SND_SOC_NOPM, 0, 0, &es8323_left_dac_mux_controls),
205 SND_SOC_DAPM_MUX("Right PGA Mux", SND_SOC_NOPM, 0, 0, &es8323_right_dac_mux_controls),
206 SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0, &es8323_diffmux_controls),
207 SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0, &es8323_mono_adc_mux_controls),
208 SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0, &es8323_mono_adc_mux_controls),
209 SND_SOC_DAPM_MUX("Left Line Mux", SND_SOC_NOPM, 0, 0, &es8323_left_line_controls),
210 SND_SOC_DAPM_MUX("Right Line Mux", SND_SOC_NOPM, 0, 0, &es8323_right_line_controls),
212 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", SND_SOC_NOPM, 4, 1),
213 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", SND_SOC_NOPM, 5, 1),
224 SND_SOC_DAPM_PGA("Right ADC Power", SND_SOC_NOPM, 6, 1, NULL, 0),
225 SND_SOC_DAPM_PGA("Left ADC Power", SND_SOC_NOPM, 7, 1, NULL, 0),
242 {"Left PGA Mux", "Line 1L", "LINPUT1"},
243 {"Left PGA Mux", "Line 2L", "LINPUT2"},
244 {"Left PGA Mux", "DifferentialL", "Differential Mux"},
246 {"Right PGA Mux", "Line 1R", "RINPUT1"},
247 {"Right PGA Mux", "Line 2R", "RINPUT2"},
248 {"Right PGA Mux", "DifferentialR", "Differential Mux"},
250 {"Differential Mux", "Line 1", "LINPUT1"},
251 {"Differential Mux", "Line 1", "RINPUT1"},
252 {"Differential Mux", "Line 2", "LINPUT2"},
253 {"Differential Mux", "Line 2", "RINPUT2"},
255 {"Left ADC Mux", "Stereo", "Right PGA Mux"},
256 {"Left ADC Mux", "Stereo", "Left PGA Mux"},
257 {"Left ADC Mux", "Mono (Left)", "Left PGA Mux"},
259 {"Right ADC Mux", "Stereo", "Left PGA Mux"},
260 {"Right ADC Mux", "Stereo", "Right PGA Mux"},
261 {"Right ADC Mux", "Mono (Right)", "Right PGA Mux"},
263 {"Left ADC Power", NULL, "Left ADC Mux"},
264 {"Right ADC Power", NULL, "Right ADC Mux"},
265 {"Left ADC", NULL, "Left ADC Power"},
266 {"Right ADC", NULL, "Right ADC Power"},
268 {"Left Line Mux", "Line 1L", "LINPUT1"},
269 {"Left Line Mux", "Line 2L", "LINPUT2"},
270 {"Left Line Mux", "MicL", "Left PGA Mux"},
272 {"Right Line Mux", "Line 1R", "RINPUT1"},
273 {"Right Line Mux", "Line 2R", "RINPUT2"},
274 {"Right Line Mux", "MicR", "Right PGA Mux"},
277 {"Left Mixer", "Left Bypass Switch", "Left Line Mux"},
280 {"Right Mixer", "Right Bypass Switch", "Right Line Mux"},
389 return -EINVAL; in get_coeff()
395 struct snd_soc_component *component = codec_dai->component; in es8323_set_dai_sysclk()
403 es8323->sysclk_constraints = &constraints_112896; in es8323_set_dai_sysclk()
409 es8323->sysclk_constraints = &constraints_12288; in es8323_set_dai_sysclk()
413 es8323->sysclk_constraints = &constraints_12; in es8323_set_dai_sysclk()
416 return -EINVAL; in es8323_set_dai_sysclk()
419 es8323->sysclk = freq; in es8323_set_dai_sysclk()
425 struct snd_soc_component *component = codec_dai->component; in es8323_set_dai_fmt()
438 return -EINVAL; in es8323_set_dai_fmt()
461 return -EINVAL; in es8323_set_dai_fmt()
487 return -EINVAL; in es8323_set_dai_fmt()
500 struct snd_soc_component *component = dai->component; in es8323_pcm_startup()
503 if (es8323->sysclk) { in es8323_pcm_startup()
504 snd_pcm_hw_constraint_list(substream->runtime, 0, in es8323_pcm_startup()
506 es8323->sysclk_constraints); in es8323_pcm_startup()
516 struct snd_soc_component *component = dai->component; in es8323_pcm_hw_params()
523 coeff = get_coeff(es8323->sysclk, params_rate(params)); in es8323_pcm_hw_params()
525 coeff = get_coeff(es8323->sysclk / 2, params_rate(params)); in es8323_pcm_hw_params()
530 dev_err(component->dev, in es8323_pcm_hw_params()
532 params_rate(params), es8323->sysclk); in es8323_pcm_hw_params()
572 struct snd_soc_component *component = dai->component; in es8323_mute_stream()
616 es8323->component = component; in es8323_probe()
618 es8323->mclk = devm_clk_get_optional(component->dev, "mclk"); in es8323_probe()
619 if (IS_ERR(es8323->mclk)) { in es8323_probe()
620 dev_err(component->dev, "unable to get mclk\n"); in es8323_probe()
621 return PTR_ERR(es8323->mclk); in es8323_probe()
624 if (!es8323->mclk) in es8323_probe()
625 dev_warn(component->dev, "assuming static mclk\n"); in es8323_probe()
627 ret = clk_prepare_enable(es8323->mclk); in es8323_probe()
629 dev_err(component->dev, "unable to enable mclk\n"); in es8323_probe()
648 ret = clk_prepare_enable(es8323->mclk); in es8323_set_bias_level()
672 clk_disable_unprepare(es8323->mclk); in es8323_set_bias_level()
689 clk_disable_unprepare(es8323->mclk); in es8323_remove()
697 regcache_cache_only(es8323->regmap, true); in es8323_suspend()
698 regcache_mark_dirty(es8323->regmap); in es8323_suspend()
707 regcache_cache_only(es8323->regmap, false); in es8323_resume()
708 regcache_sync(es8323->regmap); in es8323_resume()
743 struct device *dev = &i2c_client->dev; in es8323_i2c_probe()
747 return -ENOMEM; in es8323_i2c_probe()
751 es8323->regmap = devm_regmap_init_i2c(i2c_client, &es8323_regmap); in es8323_i2c_probe()
752 if (IS_ERR(es8323->regmap)) in es8323_i2c_probe()
753 return PTR_ERR(es8323->regmap); in es8323_i2c_probe()