All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Ricard Wanderlof <ricardw@axis.com>,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH 3.18 07/27] ASoC: adau17x1: Workaround for noise bug in ADC
Date: Mon,  6 Nov 2017 12:27:52 +0100	[thread overview]
Message-ID: <20171106112736.903436593@linuxfoundation.org> (raw)
In-Reply-To: <20171106112736.529730803@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ricard Wanderlof <ricard.wanderlof@axis.com>

commit 1e6f4fc06f6411adf98bbbe7fcd79442cd2b2a75 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/codecs/adau17x1.c |   24 +++++++++++++++++++++++-
 sound/soc/codecs/adau17x1.h |    2 ++
 2 files changed, 25 insertions(+), 1 deletion(-)

--- a/sound/soc/codecs/adau17x1.c
+++ b/sound/soc/codecs/adau17x1.c
@@ -88,6 +88,27 @@ static int adau17x1_pll_event(struct snd
 	return 0;
 }
 
+static int adau17x1_adc_fixup(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+
+	/*
+	 * If we are capturing, toggle the ADOSR bit in Converter Control 0 to
+	 * avoid losing SNR (workaround from ADI). This must be done after
+	 * the ADC(s) have been enabled. According to the data sheet, it is
+	 * normally illegal to set this bit when the sampling rate is 96 kHz,
+	 * but according to ADI it is acceptable for this workaround.
+	 */
+	regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
+		ADAU17X1_CONVERTER0_ADOSR, ADAU17X1_CONVERTER0_ADOSR);
+	regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
+		ADAU17X1_CONVERTER0_ADOSR, 0);
+
+	return 0;
+}
+
 static const char * const adau17x1_mono_stereo_text[] = {
 	"Stereo",
 	"Mono Left Channel (L+R)",
@@ -119,7 +140,8 @@ static const struct snd_soc_dapm_widget
 	SND_SOC_DAPM_MUX("Right DAC Mode Mux", SND_SOC_NOPM, 0, 0,
 		&adau17x1_dac_mode_mux),
 
-	SND_SOC_DAPM_ADC("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0),
+	SND_SOC_DAPM_ADC_E("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0,
+			   adau17x1_adc_fixup, SND_SOC_DAPM_POST_PMU),
 	SND_SOC_DAPM_ADC("Right Decimator", NULL, ADAU17X1_ADC_CONTROL, 1, 0),
 	SND_SOC_DAPM_DAC("Left DAC", NULL, ADAU17X1_DAC_CONTROL0, 0, 0),
 	SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0),
--- a/sound/soc/codecs/adau17x1.h
+++ b/sound/soc/codecs/adau17x1.h
@@ -119,5 +119,7 @@ bool adau17x1_has_dsp(struct adau *adau)
 
 #define ADAU17X1_CONVERTER0_CONVSR_MASK		0x7
 
+#define ADAU17X1_CONVERTER0_ADOSR		BIT(3)
+
 
 #endif

  parent reply	other threads:[~2017-11-06 11:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 11:27 [PATCH 3.18 00/27] 3.18.80-stable review Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 01/27] blk-mq: fix race between timeout and freeing request Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 02/27] ALSA: timer: Add missing mutex lock for compat ioctls Greg Kroah-Hartman
2017-11-06 11:27   ` Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 03/27] ALSA: seq: Fix nested rwsem annotation for lockdep splat Greg Kroah-Hartman
2017-11-06 11:27   ` Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 04/27] cifs: check MaxPathNameComponentLength != 0 before using it Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 05/27] KEYS: return full count in keyring_read() if buffer is too small Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 06/27] KEYS: fix out-of-bounds read during ASN.1 parsing Greg Kroah-Hartman
2017-11-06 11:27 ` Greg Kroah-Hartman [this message]
2017-11-06 11:27 ` [PATCH 3.18 08/27] arm64: ensure __dump_instr() checks addr_limit Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 09/27] ARM: 8715/1: add a private asm/unaligned.h Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 10/27] ocfs2: fstrim: Fix start offset of first cluster group during fstrim Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 11/27] drm/msm: Fix potential buffer overflow issue Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 12/27] drm/msm: fix an integer overflow test Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 13/27] x86/microcode/intel: Disable late loading on model 79 Greg Kroah-Hartman
2017-11-06 11:27 ` [PATCH 3.18 14/27] mmc: s3cmci: include linux/interrupt.h for tasklet_struct Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 15/27] staging: rtl8712u: Fix endian settings for structs describing network packets Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 16/27] ext4: fix stripe-unaligned allocations Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 17/27] ext4: do not use stripe_width if it is not set Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 18/27] i2c: riic: correctly finish transfers Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 19/27] cx231xx: Fix I2C on Internal Master 3 Bus Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 20/27] xen/manage: correct return value check on xenbus_scanf() Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 21/27] platform/x86: intel_mid_thermal: Fix module autoload Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 22/27] staging: lustre: hsm: stack overrun in hai_dump_data_field Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 23/27] staging: lustre: ptlrpc: skip lock if export failed Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 24/27] s390/dasd: check for device error pointer within state change interrupts Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 25/27] bt8xx: fix memory leak Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 26/27] xen: dont print error message in case of missing Xenstore entry Greg Kroah-Hartman
2017-11-06 11:28 ` [PATCH 3.18 27/27] staging: r8712u: Fix Sparse warning in rtl871x_xmit.c Greg Kroah-Hartman
2017-11-06 14:35 ` [PATCH 3.18 00/27] 3.18.80-stable review Guenter Roeck
2017-11-06 14:44   ` Greg Kroah-Hartman
     [not found]     ` <CALpmF+H7QrgQDWdYCHHMD-kpxCrPVp14T72p51L8gNWfNq2x1g@mail.gmail.com>
2017-11-07 10:34       ` Greg Kroah-Hartman
2017-11-06 21:16 ` Guenter Roeck
2017-11-07 10:34   ` Greg Kroah-Hartman
2017-11-06 21:57 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171106112736.903436593@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ricardw@axis.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.