From cfb4b8e9b2701bf9e56b134fec7d1b3f52014db8 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Sat, 28 Apr 2018 19:52:43 +0800 Subject: [PATCH] ASoC: rk3308_codec: fix the incorrect description for ADC1/ADC2 From the broken spec from vendor, the PGA GAIN description for MIC-IN should be like this: * 0x0 - MIC1~MIC8 0dB * 0x1 - MIC1~MIC2 are invalid, MIC3~MIC8 6.6dB * 0x2 - MIC1~MIC2 are invalid, MIC3~MIC8 13dB * 0x3 - MIC1~MIC8 20dB Therefore, we need to update the MIC-INs dapm controls: - MIC1 / MIC2: numid=25,iface=MIXER,name='ADC MIC Group 0 Left Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=3,step=0 : values=0 | dBrange- rangemin=0,,rangemax=0 | dBminmax-min=0.00dB,max=0.00dB rangemin=3,,rangemax=3 | dBminmax-min=20.00dB,max=20.00dB - MIC3 ~ MIC8: numid=27,iface=MIXER,name='ADC MIC Group 1 Left Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=3,step=0 : values=0 | dBrange- rangemin=0,,rangemax=0 | dBminmax-min=0.00dB,max=0.00dB rangemin=1,,rangemax=1 | dBminmax-min=6.60dB,max=6.60dB rangemin=2,,rangemax=2 | dBminmax-min=13.00dB,max=13.00dB rangemin=3,,rangemax=3 | dBminmax-min=20.00dB,max=20.00dB Change-Id: I977179fdf33d6bb7e27708baef37cc308c3d0a71 Signed-off-by: Xing Zheng --- sound/soc/codecs/rk3308_codec.c | 28 ++++++++++++++++++---------- sound/soc/codecs/rk3308_codec.h | 22 +++++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/rk3308_codec.c b/sound/soc/codecs/rk3308_codec.c index fd9b1934b02c..68e9c45a8a3c 100644 --- a/sound/soc/codecs/rk3308_codec.c +++ b/sound/soc/codecs/rk3308_codec.c @@ -107,8 +107,6 @@ static const DECLARE_TLV_DB_SCALE(rk3308_codec_alc_agc_grp_max_gain_tlv, -1350, 600, 2850); static const DECLARE_TLV_DB_SCALE(rk3308_codec_alc_agc_grp_min_gain_tlv, -1800, 600, 2400); -static const DECLARE_TLV_DB_SCALE(rk3308_codec_adc_mic_gain_tlv, - 0, 600, 3000); static const DECLARE_TLV_DB_SCALE(rk3308_codec_adc_alc_gain_tlv, -1800, 150, 2850); static const DECLARE_TLV_DB_SCALE(rk3308_codec_dac_lineout_gain_tlv, @@ -117,6 +115,16 @@ static const DECLARE_TLV_DB_SCALE(rk3308_codec_dac_hpout_gain_tlv, -3900, 150, 600); static const DECLARE_TLV_DB_SCALE(rk3308_codec_dac_hpmix_gain_tlv, -600, 600, 0); +static const DECLARE_TLV_DB_RANGE(rk3308_codec_adc_1_2_mic_gain_tlv, + 0, 0, TLV_DB_MINMAX_ITEM(0, 0), + 3, 3, TLV_DB_MINMAX_ITEM(2000, 2000), +); +static const DECLARE_TLV_DB_RANGE(rk3308_codec_adc_3_8_mic_gain_tlv, + 0, 0, TLV_DB_MINMAX_ITEM(0, 0), + 1, 1, TLV_DB_MINMAX_ITEM(660, 660), + 2, 2, TLV_DB_MINMAX_ITEM(1300, 1300), + 3, 3, TLV_DB_MINMAX_ITEM(2000, 2000), +); static const struct snd_kcontrol_new rk3308_codec_dapm_controls[] = { /* ALC AGC Group */ @@ -284,49 +292,49 @@ static const struct snd_kcontrol_new rk3308_codec_dapm_controls[] = { RK3308_ADC_CH1_MIC_GAIN_SFT, RK3308_ADC_CH1_MIC_GAIN_MIN, RK3308_ADC_CH1_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_1_2_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 0 Right Volume", RK3308_ADC_ANA_CON01(0), RK3308_ADC_CH2_MIC_GAIN_SFT, RK3308_ADC_CH2_MIC_GAIN_MIN, RK3308_ADC_CH2_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_1_2_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 1 Left Volume", RK3308_ADC_ANA_CON01(1), RK3308_ADC_CH1_MIC_GAIN_SFT, RK3308_ADC_CH1_MIC_GAIN_MIN, RK3308_ADC_CH1_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 1 Right Volume", RK3308_ADC_ANA_CON01(1), RK3308_ADC_CH2_MIC_GAIN_SFT, RK3308_ADC_CH2_MIC_GAIN_MIN, RK3308_ADC_CH2_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 2 Left Volume", RK3308_ADC_ANA_CON01(2), RK3308_ADC_CH1_MIC_GAIN_SFT, RK3308_ADC_CH1_MIC_GAIN_MIN, RK3308_ADC_CH1_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 2 Right Volume", RK3308_ADC_ANA_CON01(2), RK3308_ADC_CH2_MIC_GAIN_SFT, RK3308_ADC_CH2_MIC_GAIN_MIN, RK3308_ADC_CH2_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 3 Left Volume", RK3308_ADC_ANA_CON01(3), RK3308_ADC_CH1_MIC_GAIN_SFT, RK3308_ADC_CH1_MIC_GAIN_MIN, RK3308_ADC_CH1_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), SOC_SINGLE_RANGE_TLV("ADC MIC Group 3 Right Volume", RK3308_ADC_ANA_CON01(3), RK3308_ADC_CH2_MIC_GAIN_SFT, RK3308_ADC_CH2_MIC_GAIN_MIN, RK3308_ADC_CH2_MIC_GAIN_MAX, - 0, rk3308_codec_adc_mic_gain_tlv), + 0, rk3308_codec_adc_3_8_mic_gain_tlv), /* ADC ALC */ SOC_SINGLE_RANGE_TLV("ADC ALC Group 0 Left Volume", diff --git a/sound/soc/codecs/rk3308_codec.h b/sound/soc/codecs/rk3308_codec.h index bea4f451c0dc..586400f9905e 100644 --- a/sound/soc/codecs/rk3308_codec.h +++ b/sound/soc/codecs/rk3308_codec.h @@ -614,22 +614,30 @@ #define RK3308_ADC_CH1_BUF_REF_EN (0x1 << 0) #define RK3308_ADC_CH1_BUF_REF_DIS (0x0 << 0) -/* RK3308_ADC_ANA_CON01 - REG: 0x0344 */ +/* RK3308_ADC_ANA_CON01 - REG: 0x0344 + * + * The PGA of MIC-INs: + * 0x0 - MIC1~MIC8 0dB + * 0x1 - MIC1~MIC2 are invalid, MIC3~MIC8 6.6dB + * 0x2 - MIC1~MIC2 are invalid, MIC3~MIC8 13dB + * 0x3 - MIC1~MIC8 20dB + */ #define RK3308_ADC_CH2_MIC_GAIN_MAX 0x3 #define RK3308_ADC_CH2_MIC_GAIN_MIN 0 #define RK3308_ADC_CH2_MIC_GAIN_SFT 4 #define RK3308_ADC_CH2_MIC_GAIN_MSK (0x3 << RK3308_ADC_CH2_MIC_GAIN_SFT) -#define RK3308_ADC_CH2_MIC_GAIN_30DB (0x3 << RK3308_ADC_CH2_MIC_GAIN_SFT) -#define RK3308_ADC_CH2_MIC_GAIN_20DB (0x2 << RK3308_ADC_CH2_MIC_GAIN_SFT) -#define RK3308_ADC_CH2_MIC_GAIN_6DB (0x1 << RK3308_ADC_CH2_MIC_GAIN_SFT) +#define RK3308_ADC_CH2_MIC_GAIN_20DB (0x3 << RK3308_ADC_CH2_MIC_GAIN_SFT) +#define RK3308_ADC_3_8_CH2_MIC_GAIN_13DB (0x2 << RK3308_ADC_CH2_MIC_GAIN_SFT) +#define RK3308_ADC_3_8_CH2_MIC_GAIN_6_6DB (0x1 << RK3308_ADC_CH2_MIC_GAIN_SFT) #define RK3308_ADC_CH2_MIC_GAIN_0DB (0x0 << RK3308_ADC_CH2_MIC_GAIN_SFT) + #define RK3308_ADC_CH1_MIC_GAIN_MAX 0x3 #define RK3308_ADC_CH1_MIC_GAIN_MIN 0 #define RK3308_ADC_CH1_MIC_GAIN_SFT 0 #define RK3308_ADC_CH1_MIC_GAIN_MSK (0x3 << RK3308_ADC_CH1_MIC_GAIN_SFT) -#define RK3308_ADC_CH1_MIC_GAIN_30DB (0x3 << RK3308_ADC_CH1_MIC_GAIN_SFT) -#define RK3308_ADC_CH1_MIC_GAIN_20DB (0x2 << RK3308_ADC_CH1_MIC_GAIN_SFT) -#define RK3308_ADC_CH1_MIC_GAIN_6DB (0x1 << RK3308_ADC_CH1_MIC_GAIN_SFT) +#define RK3308_ADC_CH1_MIC_GAIN_20DB (0x3 << RK3308_ADC_CH1_MIC_GAIN_SFT) +#define RK3308_ADC_3_8_CH1_MIC_GAIN_13DB (0x2 << RK3308_ADC_CH1_MIC_GAIN_SFT) +#define RK3308_ADC_3_8_CH1_MIC_GAIN_6_6DB (0x1 << RK3308_ADC_CH1_MIC_GAIN_SFT) #define RK3308_ADC_CH1_MIC_GAIN_0DB (0x0 << RK3308_ADC_CH1_MIC_GAIN_SFT) /* RK3308_ADC_ANA_CON02 - REG: 0x0348 */