[PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Codec requires enabling of left and right ADCs in the same I2C write
operation which isn't fullfilled when controlled from DAPM and
causes unexpected behaviour of codec. The similar applies to DACs.
Enable ADCs and DACs once at startup and never switch them off
to solve the issue.

Citation from MAX9867 datasheet:
(DALEN - Left DAC Enable, ADLEN - Left ADC Enable)
- Enabling the right DAC must be done in the same I2C write operation
that enables the left DAC. Right DAC operation requires DALEN = 1.
- Enabling the right ADC must be done in the same I2C write operation
that enables the left ADC. The right ADC can be enabled while the left
ADC is running if used for DC measurements. SHDN must be toggled
to disable the right ADC in this case. Right ADC operation requires
ADLEN = 1.

Signed-off-by: Pavel Dobias <dobias@xxxxx>
---
 sound/soc/codecs/max9867.c | 14 ++++++++------
 sound/soc/codecs/max9867.h |  2 ++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 535cfea6bcde..9fa2acc73e18 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -115,8 +115,8 @@ static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 	SND_SOC_DAPM_MIXER_NAMED_CTL("Input Mixer", SND_SOC_NOPM, 0, 0,
 				     max9867_input_mixer_controls,
 				     ARRAY_SIZE(max9867_input_mixer_controls)),
-	SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", MAX9867_PWRMAN, 1, 0),
-	SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", MAX9867_PWRMAN, 0, 0),
+	SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", SND_SOC_NOPM, 0, 0),
 
 	SND_SOC_DAPM_MIXER("Digital", SND_SOC_NOPM, 0, 0,
 			   max9867_sidetone_mixer_controls,
@@ -124,8 +124,8 @@ static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 	SND_SOC_DAPM_MIXER_NAMED_CTL("Output Mixer", SND_SOC_NOPM, 0, 0,
 				     max9867_output_mixer_controls,
 				     ARRAY_SIZE(max9867_output_mixer_controls)),
-	SND_SOC_DAPM_DAC("DACL", "HiFi Playback", MAX9867_PWRMAN, 3, 0),
-	SND_SOC_DAPM_DAC("DACR", "HiFi Playback", MAX9867_PWRMAN, 2, 0),
+	SND_SOC_DAPM_DAC("DACL", "HiFi Playback", SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_DAC("DACR", "HiFi Playback", SND_SOC_NOPM, 0, 0),
 	SND_SOC_DAPM_SWITCH("Master Playback", SND_SOC_NOPM, 0, 0,
 			    &max9867_line_out_control),
 	SND_SOC_DAPM_OUTPUT("LOUT"),
@@ -429,14 +429,16 @@ static int max9867_set_bias_level(struct snd_soc_component *component,
 				return err;
 
 			err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN,
-						 MAX9867_SHTDOWN, MAX9867_SHTDOWN);
+				MAX9867_SHTDOWN | MAX9867_ADCEN | MAX9867_DACEN,
+				MAX9867_SHTDOWN | MAX9867_ADCEN | MAX9867_DACEN
+				);
 			if (err)
 				return err;
 		}
 		break;
 	case SND_SOC_BIAS_OFF:
 		err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN,
-					 MAX9867_SHTDOWN, 0);
+			MAX9867_SHTDOWN | MAX9867_ADCEN | MAX9867_DACEN, 0);
 		if (err)
 			return err;
 
diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h
index d459d49449cb..a6051200455b 100644
--- a/sound/soc/codecs/max9867.h
+++ b/sound/soc/codecs/max9867.h
@@ -59,6 +59,8 @@
 #define MAX9867_MODECONFIG   0x16
 #define MAX9867_PWRMAN       0x17
 #define MAX9867_SHTDOWN      0x80
+#define MAX9867_ADCEN        0x03
+#define MAX9867_DACEN        0x0c
 #define MAX9867_REVISION     0xff
 
 #define MAX9867_CACHEREGNUM 10
-- 
2.20.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux