Skip to content

Commit 1e6f4fc

Browse files
Ricard Wanderlofbroonie
authored andcommitted
ASoC: adau17x1: Workaround for noise bug in ADC
The ADC in the ADAU1361 (and possibly other Analog Devices codecs) exhibits a cyclic variation in the noise floor (in our test setup between -87 and -93 dB), a new value being attained within this range whenever a new capture stream is started. The cycle repeats after about 10 or 11 restarts. The workaround recommended by the manufacturer is to toggle the ADOSR bit in the Converter Control 0 register each time a new capture stream is started. I have verified that the patch fixes this problem on the ADAU1361, and according to the manufacturer toggling the bit in question in this manner will at least have no detrimental effect on other chips served by this driver. Signed-off-by: Ricard Wanderlof <ricardw@axis.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 7051334 commit 1e6f4fc

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

sound/soc/codecs/adau17x1.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ static int adau17x1_pll_event(struct snd_soc_dapm_widget *w,
9090
return 0;
9191
}
9292

93+
static int adau17x1_adc_fixup(struct snd_soc_dapm_widget *w,
94+
struct snd_kcontrol *kcontrol, int event)
95+
{
96+
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
97+
struct adau *adau = snd_soc_codec_get_drvdata(codec);
98+
99+
/*
100+
* If we are capturing, toggle the ADOSR bit in Converter Control 0 to
101+
* avoid losing SNR (workaround from ADI). This must be done after
102+
* the ADC(s) have been enabled. According to the data sheet, it is
103+
* normally illegal to set this bit when the sampling rate is 96 kHz,
104+
* but according to ADI it is acceptable for this workaround.
105+
*/
106+
regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
107+
ADAU17X1_CONVERTER0_ADOSR, ADAU17X1_CONVERTER0_ADOSR);
108+
regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
109+
ADAU17X1_CONVERTER0_ADOSR, 0);
110+
111+
return 0;
112+
}
113+
93114
static const char * const adau17x1_mono_stereo_text[] = {
94115
"Stereo",
95116
"Mono Left Channel (L+R)",
@@ -121,7 +142,8 @@ static const struct snd_soc_dapm_widget adau17x1_dapm_widgets[] = {
121142
SND_SOC_DAPM_MUX("Right DAC Mode Mux", SND_SOC_NOPM, 0, 0,
122143
&adau17x1_dac_mode_mux),
123144

124-
SND_SOC_DAPM_ADC("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0),
145+
SND_SOC_DAPM_ADC_E("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0,
146+
adau17x1_adc_fixup, SND_SOC_DAPM_POST_PMU),
125147
SND_SOC_DAPM_ADC("Right Decimator", NULL, ADAU17X1_ADC_CONTROL, 1, 0),
126148
SND_SOC_DAPM_DAC("Left DAC", NULL, ADAU17X1_DAC_CONTROL0, 0, 0),
127149
SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0),

sound/soc/codecs/adau17x1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,7 @@ bool adau17x1_has_dsp(struct adau *adau);
129129

130130
#define ADAU17X1_CONVERTER0_CONVSR_MASK 0x7
131131

132+
#define ADAU17X1_CONVERTER0_ADOSR BIT(3)
133+
132134

133135
#endif

0 commit comments

Comments
 (0)