Lines Matching +full:pga +full:- +full:gain
1 // SPDX-License-Identifier: GPL-2.0
3 * es8311.c -- ES8311/ES8312 ALSA SoC Audio Codec
7 * Authors: David Yang(yangxiaohua@everest-semi.com)
10 * Based on es8374.c by David Yang(yangxiaohua@everest-semi.com)
52 -9550, 50, true);
54 -9550, 50, true);
62 -3600, 200, false);
64 -3600, 200, false);
66 -9600, 600, false);
126 SOC_SINGLE_TLV("MIC PGA GAIN", ES8311_SYSTEM_REG14,
236 SND_SOC_DAPM_PGA("INPUT PGA", ES8311_SYSTEM_REG0E,
263 {"INPUT PGA", NULL, "AMIC"},
264 {"MONO ADC", NULL, "INPUT PGA"},
279 struct snd_soc_component *component = codec_dai->component; in es8311_set_dai_fmt()
297 return -EINVAL; in es8311_set_dai_fmt()
327 return -EINVAL; in es8311_set_dai_fmt()
357 return -EINVAL; in es8311_set_dai_fmt()
371 struct snd_soc_component *component = dai->component; in es8311_pcm_startup()
374 clk_prepare_enable(es8311->mclk_in); in es8311_pcm_startup()
382 struct snd_soc_component *component = dai->component; in es8311_pcm_shutdown()
385 clk_disable_unprepare(es8311->mclk_in); in es8311_pcm_shutdown()
392 struct snd_soc_component *component = dai->component; in es8311_pcm_hw_params()
395 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in es8311_pcm_hw_params()
446 if (IS_ERR(es8311->mclk_in)) in es8311_set_bias_level()
450 clk_disable_unprepare(es8311->mclk_in); in es8311_set_bias_level()
452 ret = clk_prepare_enable(es8311->mclk_in); in es8311_set_bias_level()
469 struct snd_soc_component *component = dai->component; in es8311_set_tristate()
482 struct snd_soc_component *component = dai->component; in es8311_mute()
488 if (es8311->spk_ctl_gpio) in es8311_mute()
489 gpiod_direction_output(es8311->spk_ctl_gpio, 0); in es8311_mute()
493 if (es8311->spk_ctl_gpio) { in es8311_mute()
494 gpiod_direction_output(es8311->spk_ctl_gpio, 1); in es8311_mute()
495 if (es8311->delay_pa_drv_ms) in es8311_mute()
496 msleep(es8311->delay_pa_drv_ms); in es8311_mute()
565 /* ensure select Mic1p-Mic1n by default. */ in es8311_regs_init()
576 es8311->component = component; in es8311_probe()
580 if (es8311->aec_mode) in es8311_probe()
582 0x70, es8311->aec_mode << 4); in es8311_probe()
583 if (es8311->adc_pga_gain) in es8311_probe()
585 0x0f, es8311->adc_pga_gain); in es8311_probe()
586 if (es8311->adc_volume) in es8311_probe()
588 es8311->adc_volume); in es8311_probe()
589 if (es8311->dac_volume) in es8311_probe()
591 es8311->dac_volume); in es8311_probe()
625 np = client->dev.of_node; in es8311_parse_dt()
627 return -EINVAL; in es8311_parse_dt()
629 es8311->delay_pa_drv_ms = 0; in es8311_parse_dt()
630 es8311->spk_ctl_gpio = devm_gpiod_get_optional(&client->dev, "spk-ctl", in es8311_parse_dt()
632 if (!es8311->spk_ctl_gpio) { in es8311_parse_dt()
633 dev_info(&client->dev, "Don't need spk-ctl gpio\n"); in es8311_parse_dt()
634 } else if (IS_ERR(es8311->spk_ctl_gpio)) { in es8311_parse_dt()
635 ret = PTR_ERR(es8311->spk_ctl_gpio); in es8311_parse_dt()
636 dev_err(&client->dev, "Unable to claim gpio spk-ctl\n"); in es8311_parse_dt()
639 ret = of_property_read_s32(np, "delay-pa-drv-ms", in es8311_parse_dt()
640 &es8311->delay_pa_drv_ms); in es8311_parse_dt()
641 if (ret < 0 && ret != -EINVAL) { in es8311_parse_dt()
642 dev_err(&client->dev, in es8311_parse_dt()
643 "Failed to read 'rockchip,delay-pa-drv-ms': %d\n", in es8311_parse_dt()
648 es8311->adc_pga_gain = 0; /* ADC PGA Gain is 0dB by default reset. */ in es8311_parse_dt()
649 if (!of_property_read_u32(np, "adc-pga-gain", &v)) { in es8311_parse_dt()
651 es8311->adc_pga_gain = v; in es8311_parse_dt()
653 dev_warn(&client->dev, in es8311_parse_dt()
654 "adc-pga-gain (%d) is out of range\n", v); in es8311_parse_dt()
657 es8311->adc_volume = 0; /* ADC Volume is -95dB by default reset. */ in es8311_parse_dt()
658 if (!of_property_read_u32(np, "adc-volume", &v)) { in es8311_parse_dt()
660 es8311->adc_volume = v; in es8311_parse_dt()
662 dev_warn(&client->dev, in es8311_parse_dt()
663 "adc-volume (0x%02x) is out of range\n", v); in es8311_parse_dt()
666 es8311->dac_volume = 0; /* DAC Volume is -95dB by default reset. */ in es8311_parse_dt()
667 if (!of_property_read_u32(np, "dac-volume", &v)) { in es8311_parse_dt()
669 es8311->dac_volume = v; in es8311_parse_dt()
671 dev_warn(&client->dev, in es8311_parse_dt()
672 "dac-volume (0x%02x) is out of range\n", v); in es8311_parse_dt()
675 es8311->aec_mode = 0; /* ADCDAT: 0 is ADC + ADC (default) */ in es8311_parse_dt()
676 if (!of_property_read_string(np, "aec-mode", &str)) { in es8311_parse_dt()
681 es8311->aec_mode = i; in es8311_parse_dt()
697 es8311 = devm_kzalloc(&i2c_client->dev, in es8311_i2c_probe()
700 return -ENOMEM; in es8311_i2c_probe()
708 es8311->mclk_in = devm_clk_get(&i2c_client->dev, "mclk"); in es8311_i2c_probe()
709 if (IS_ERR(es8311->mclk_in)) in es8311_i2c_probe()
710 return PTR_ERR(es8311->mclk_in); in es8311_i2c_probe()
714 dev_err(&i2c_client->dev, "Parse DT failed: %d\n", ret); in es8311_i2c_probe()
718 return devm_snd_soc_register_component(&i2c_client->dev, in es8311_i2c_probe()
728 snd_soc_component_write(es8311->component, ES8311_I2C_REGFA, 0x01); in es8311_i2c_shutdown()
755 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");