From 7a2a6a332dd6eafda705947e31bfe25693a68494 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Fri, 2 Oct 2020 17:07:18 +0800 Subject: [PATCH] ASoC: es8311: add handling the optional property 'adc-pga-gain' Signed-off-by: Xing Zheng Change-Id: I2da3f8f0bc310fc2c25517633f1803e9f9482a16 --- sound/soc/codecs/es8311.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/codecs/es8311.c b/sound/soc/codecs/es8311.c index 92da82ea0c44..1c589812a6a2 100644 --- a/sound/soc/codecs/es8311.c +++ b/sound/soc/codecs/es8311.c @@ -41,6 +41,7 @@ struct es8311_priv { struct gpio_desc *spk_ctl_gpio; struct regmap *regmap; /* Optional properties: */ + int adc_pga_gain; int adc_volume; int dac_volume; int aec_mode; @@ -568,6 +569,9 @@ static int es8311_probe(struct snd_soc_component *component) if (es8311->aec_mode) snd_soc_component_update_bits(component, ES8311_GPIO_REG44, 0x70, es8311->aec_mode << 4); + if (es8311->adc_pga_gain) + snd_soc_component_write(component, ES8311_SYSTEM_REG14, + es8311->adc_pga_gain); if (es8311->adc_volume) snd_soc_component_write(component, ES8311_ADC_REG17, es8311->adc_volume); @@ -610,6 +614,15 @@ static int es8311_parse_dt(struct i2c_client *client, if (!np) return -EINVAL; + es8311->adc_pga_gain = 0; /* ADC PGA Gain is 0dB by default reset. */ + if (!of_property_read_u32(np, "adc-pga-gain", &v)) { + if (v >= 0 && v <= 10) + es8311->adc_pga_gain = v; + else + dev_warn(&client->dev, + "adc-pga-gain (%d) is out of range\n", v); + } + es8311->adc_volume = 0; /* ADC Volume is -95dB by default reset. */ if (!of_property_read_u32(np, "adc-volume", &v)) { if (v >= 0 && v <= 0xff)