All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] ASoC: max9867: fix ADC level control
@ 2020-05-20  7:18 Pavel Dobias
  2020-05-20  7:19 ` [PATCH 2/6] ASoC: max9867: don't use regmap defaults Pavel Dobias
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:18 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

Fix swapped channels in ADC level control.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 2e4aa23b5a60..6d49a1cc98c6 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -58,7 +58,7 @@ static const struct snd_kcontrol_new max9867_snd_controls[] = {
 			max9867_dac_tlv),
 	SOC_SINGLE_TLV("Digital Boost Playback Volume", MAX9867_DACLEVEL, 4, 3, 0,
 			max9867_dacboost_tlv),
-	SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 0, 4, 15, 1,
+	SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 4, 0, 15, 1,
 			max9867_adc_tlv),
 	SOC_ENUM("Speaker Mode", max9867_spkmode),
 	SOC_SINGLE("Volume Smoothing Switch", MAX9867_MODECONFIG, 6, 1, 0),
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] ASoC: max9867: don't use regmap defaults
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
@ 2020-05-20  7:19 ` Pavel Dobias
  2020-05-20  7:19 ` [PATCH 3/6] ASoC: max9867: add filter controls Pavel Dobias
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

MAX9867 codec doesn't have reset pin, so the registers don't
have default values in the case of reboot without powering off.
Remove the reg_defaults struct and let the regmap read initial
state of the registers at startup instead of taking them from
reg_defaults struct.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 6d49a1cc98c6..93431646f2c7 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -463,35 +463,10 @@ static bool max9867_volatile_register(struct device *dev, unsigned int reg)
 	}
 }
 
-static const struct reg_default max9867_reg[] = {
-	{ 0x04, 0x00 },
-	{ 0x05, 0x00 },
-	{ 0x06, 0x00 },
-	{ 0x07, 0x00 },
-	{ 0x08, 0x00 },
-	{ 0x09, 0x00 },
-	{ 0x0A, 0x00 },
-	{ 0x0B, 0x00 },
-	{ 0x0C, 0x00 },
-	{ 0x0D, 0x00 },
-	{ 0x0E, 0x40 },
-	{ 0x0F, 0x40 },
-	{ 0x10, 0x00 },
-	{ 0x11, 0x00 },
-	{ 0x12, 0x00 },
-	{ 0x13, 0x00 },
-	{ 0x14, 0x00 },
-	{ 0x15, 0x00 },
-	{ 0x16, 0x00 },
-	{ 0x17, 0x00 },
-};
-
 static const struct regmap_config max9867_regmap = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
 	.max_register	= MAX9867_REVISION,
-	.reg_defaults	= max9867_reg,
-	.num_reg_defaults = ARRAY_SIZE(max9867_reg),
 	.volatile_reg	= max9867_volatile_register,
 	.cache_type	= REGCACHE_RBTREE,
 };
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] ASoC: max9867: add filter controls
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
  2020-05-20  7:19 ` [PATCH 2/6] ASoC: max9867: don't use regmap defaults Pavel Dobias
@ 2020-05-20  7:19 ` Pavel Dobias
  2020-05-20  7:19 ` [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

Adding missing codec controls - ADC/DAC IIR filter selection.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 93431646f2c7..535cfea6bcde 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -23,8 +23,21 @@ static const char *const max9867_spmode[] = {
 };
 static const char *const max9867_filter_text[] = {"IIR", "FIR"};
 
+static const char *const max9867_adc_dac_filter_text[] = {
+	"Disabled",
+	"Elliptical/16/256",
+	"Butterworth/16/500",
+	"Elliptical/8/256",
+	"Butterworth/8/500",
+	"Butterworth/8-24"
+};
+
 static SOC_ENUM_SINGLE_DECL(max9867_filter, MAX9867_CODECFLTR, 7,
 	max9867_filter_text);
+static SOC_ENUM_SINGLE_DECL(max9867_dac_filter, MAX9867_CODECFLTR, 0,
+	max9867_adc_dac_filter_text);
+static SOC_ENUM_SINGLE_DECL(max9867_adc_filter, MAX9867_CODECFLTR, 4,
+	max9867_adc_dac_filter_text);
 static SOC_ENUM_SINGLE_DECL(max9867_spkmode, MAX9867_MODECONFIG, 0,
 	max9867_spmode);
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(max9867_master_tlv,
@@ -64,6 +77,8 @@ static const struct snd_kcontrol_new max9867_snd_controls[] = {
 	SOC_SINGLE("Volume Smoothing Switch", MAX9867_MODECONFIG, 6, 1, 0),
 	SOC_SINGLE("Line ZC Switch", MAX9867_MODECONFIG, 5, 1, 0),
 	SOC_ENUM("DSP Filter", max9867_filter),
+	SOC_ENUM("ADC Filter", max9867_adc_filter),
+	SOC_ENUM("DAC Filter", max9867_dac_filter),
 };
 
 /* Input mixer */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
  2020-05-20  7:19 ` [PATCH 2/6] ASoC: max9867: don't use regmap defaults Pavel Dobias
  2020-05-20  7:19 ` [PATCH 3/6] ASoC: max9867: add filter controls Pavel Dobias
@ 2020-05-20  7:19 ` Pavel Dobias
  2020-05-20 13:01   ` Mark Brown
  2020-05-20  7:19 ` [PATCH 5/6] ASoC: max9867: add mono playback switch Pavel Dobias
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

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@2n.cz>
---
 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] ASoC: max9867: add mono playback switch
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
                   ` (2 preceding siblings ...)
  2020-05-20  7:19 ` [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
@ 2020-05-20  7:19 ` Pavel Dobias
  2020-05-20  7:19 ` [PATCH 6/6] ASoC: max9867: add digital microphone controls Pavel Dobias
  2020-05-20 17:17 ` [PATCH 1/6] ASoC: max9867: fix ADC level control Mark Brown
  5 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

Add Mono Playback switch to codec controls which enables codec's
capability of mixing left and right channel at the DAC output.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 9fa2acc73e18..902b1387b797 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -79,6 +79,7 @@ static const struct snd_kcontrol_new max9867_snd_controls[] = {
 	SOC_ENUM("DSP Filter", max9867_filter),
 	SOC_ENUM("ADC Filter", max9867_adc_filter),
 	SOC_ENUM("DAC Filter", max9867_dac_filter),
+	SOC_SINGLE("Mono Playback Switch", MAX9867_IFC1B, 3, 1, 0),
 };
 
 /* Input mixer */
@@ -361,7 +362,8 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai,
 	}
 
 	regmap_write(max9867->regmap, MAX9867_IFC1A, iface1A);
-	regmap_write(max9867->regmap, MAX9867_IFC1B, iface1B);
+	regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
+			   MAX9867_IFC1B_BCLK_MASK, iface1B);
 
 	return 0;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/6] ASoC: max9867: add digital microphone controls
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
                   ` (3 preceding siblings ...)
  2020-05-20  7:19 ` [PATCH 5/6] ASoC: max9867: add mono playback switch Pavel Dobias
@ 2020-05-20  7:19 ` Pavel Dobias
  2020-05-20 17:17 ` [PATCH 1/6] ASoC: max9867: fix ADC level control Mark Brown
  5 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-20  7:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

MAX9867 codec has a possibility of connecting digital microphones.
Add DAPM controls to be able to enable them.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 902b1387b797..1946dcfa48e1 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -104,10 +104,24 @@ static const struct snd_kcontrol_new max9867_line_out_control =
 	SOC_DAPM_DOUBLE_R("Switch",
 			  MAX9867_LEFTVOL, MAX9867_RIGHTVOL, 6, 1, 1);
 
+/* DMIC mux */
+static const char *const dmic_mux_text[] = {
+	"ADC", "DMIC"
+};
+static SOC_ENUM_SINGLE_DECL(left_dmic_mux_enum,
+			    MAX9867_MICCONFIG, 5, dmic_mux_text);
+static SOC_ENUM_SINGLE_DECL(right_dmic_mux_enum,
+			    MAX9867_MICCONFIG, 4, dmic_mux_text);
+static const struct snd_kcontrol_new max9867_left_dmic_mux =
+	SOC_DAPM_ENUM("DMICL Mux", left_dmic_mux_enum);
+static const struct snd_kcontrol_new max9867_right_dmic_mux =
+	SOC_DAPM_ENUM("DMICR Mux", right_dmic_mux_enum);
 
 static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 	SND_SOC_DAPM_INPUT("MICL"),
 	SND_SOC_DAPM_INPUT("MICR"),
+	SND_SOC_DAPM_INPUT("DMICL"),
+	SND_SOC_DAPM_INPUT("DMICR"),
 	SND_SOC_DAPM_INPUT("LINL"),
 	SND_SOC_DAPM_INPUT("LINR"),
 
@@ -116,6 +130,10 @@ 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_MUX("DMICL Mux", SND_SOC_NOPM, 0, 0,
+			 &max9867_left_dmic_mux),
+	SND_SOC_DAPM_MUX("DMICR Mux", SND_SOC_NOPM, 0, 0,
+			 &max9867_right_dmic_mux),
 	SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", SND_SOC_NOPM, 0, 0),
 	SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", SND_SOC_NOPM, 0, 0),
 
@@ -140,8 +158,12 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = {
 	{"Input Mixer", "Mic Capture Switch", "MICR"},
 	{"Input Mixer", "Line Capture Switch", "Left Line Input"},
 	{"Input Mixer", "Line Capture Switch", "Right Line Input"},
-	{"ADCL", NULL, "Input Mixer"},
-	{"ADCR", NULL, "Input Mixer"},
+	{"DMICL Mux", "DMIC", "DMICL"},
+	{"DMICR Mux", "DMIC", "DMICR"},
+	{"DMICL Mux", "ADC", "Input Mixer"},
+	{"DMICR Mux", "ADC", "Input Mixer"},
+	{"ADCL", NULL, "DMICL Mux"},
+	{"ADCR", NULL, "DMICR Mux"},
 
 	{"Digital", "Sidetone Switch", "ADCL"},
 	{"Digital", "Sidetone Switch", "ADCR"},
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on
  2020-05-20  7:19 ` [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
@ 2020-05-20 13:01   ` Mark Brown
  2020-05-22 14:29     ` [PATCH v2 0/2] " Pavel Dobias
  0 siblings, 1 reply; 12+ messages in thread
From: Mark Brown @ 2020-05-20 13:01 UTC (permalink / raw)
  To: Pavel Dobias; +Cc: alsa-devel, ladis

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

On Wed, May 20, 2020 at 09:19:02AM +0200, Pavel Dobias wrote:

> 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.

It will be normally when the two channels are updated simultaneously
though that doesn't stop the user doing something to update them
separately.  In any case this would be better handled through moving the
power control to either supply widgets or event callbacks rather than
just giving up on power control entirely.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] ASoC: max9867: fix ADC level control
  2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
                   ` (4 preceding siblings ...)
  2020-05-20  7:19 ` [PATCH 6/6] ASoC: max9867: add digital microphone controls Pavel Dobias
@ 2020-05-20 17:17 ` Mark Brown
  5 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2020-05-20 17:17 UTC (permalink / raw)
  To: Pavel Dobias, alsa-devel; +Cc: ladis

On Wed, 20 May 2020 09:18:59 +0200, Pavel Dobias wrote:
> Fix swapped channels in ADC level control.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: max9867: fix ADC level control
      commit: 53a58bf96bcdd47c670a957920f3a1bcf7215b39
[2/5] ASoC: max9867: don't use regmap defaults
      commit: d0de8c69f90196fb872f1739756bb0348144d18c
[3/5] ASoC: max9867: add filter controls
      commit: af53d5738cb0fd61da0bc3f5a884df7af237d20d
[4/5] ASoC: max9867: add mono playback switch
      commit: 80b9fa4dead406f9a0aef5b364eb237872986c2c
[5/5] ASoC: max9867: add digital microphone controls
      (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/2] ASoC: max9867: keep ADCs and DACs always on
  2020-05-20 13:01   ` Mark Brown
@ 2020-05-22 14:29     ` Pavel Dobias
  2020-05-22 14:29       ` [PATCH v2 1/2] ASoC: max9867: add digital microphone controls Pavel Dobias
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-22 14:29 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

On 20. 05. 20 15:01, Mark Brown wrote:
> On Wed, May 20, 2020 at 09:19:02AM +0200, Pavel Dobias wrote:
>> 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.
> It will be normally when the two channels are updated simultaneously
> though that doesn't stop the user doing something to update them
> separately.  In any case this would be better handled through moving the
> power control to either supply widgets or event callbacks rather than
> just giving up on power control entirely.

I found out that the codec requires toggling shutdown bit on each change
of the power management register (stated in the datasheet). I tried
that and it worked, even updating the two channels separately worked,
but toggling the shutdown bit causes a loud speaker crackling which
can't be suppressed by muting the DACs. It seems to me that
the best choice is to avoid changing the power management register
during the codec's operation to suppress speaker crackling.


Pavel Dobias (2):
  ASoC: max9867: add digital microphone controls
  ASoC: max9867: keep ADCs and DACs always on

 sound/soc/codecs/max9867.c | 45 ++++++++++++++++++++++++++++----------
 sound/soc/codecs/max9867.h |  1 -
 2 files changed, 33 insertions(+), 13 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] ASoC: max9867: add digital microphone controls
  2020-05-22 14:29     ` [PATCH v2 0/2] " Pavel Dobias
@ 2020-05-22 14:29       ` Pavel Dobias
  2020-05-22 14:29       ` [PATCH v2 2/2] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
  2020-05-22 19:00       ` [PATCH v2 0/2] " Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-22 14:29 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

MAX9867 codec has a possibility of connecting digital microphones.
Add DAPM controls to be able to enable them.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 7e58c73552c7..3efaa6d8dc3f 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -104,10 +104,24 @@ static const struct snd_kcontrol_new max9867_line_out_control =
 	SOC_DAPM_DOUBLE_R("Switch",
 			  MAX9867_LEFTVOL, MAX9867_RIGHTVOL, 6, 1, 1);
 
+/* DMIC mux */
+static const char *const dmic_mux_text[] = {
+	"ADC", "DMIC"
+};
+static SOC_ENUM_SINGLE_DECL(left_dmic_mux_enum,
+			    MAX9867_MICCONFIG, 5, dmic_mux_text);
+static SOC_ENUM_SINGLE_DECL(right_dmic_mux_enum,
+			    MAX9867_MICCONFIG, 4, dmic_mux_text);
+static const struct snd_kcontrol_new max9867_left_dmic_mux =
+	SOC_DAPM_ENUM("DMICL Mux", left_dmic_mux_enum);
+static const struct snd_kcontrol_new max9867_right_dmic_mux =
+	SOC_DAPM_ENUM("DMICR Mux", right_dmic_mux_enum);
 
 static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 	SND_SOC_DAPM_INPUT("MICL"),
 	SND_SOC_DAPM_INPUT("MICR"),
+	SND_SOC_DAPM_INPUT("DMICL"),
+	SND_SOC_DAPM_INPUT("DMICR"),
 	SND_SOC_DAPM_INPUT("LINL"),
 	SND_SOC_DAPM_INPUT("LINR"),
 
@@ -116,6 +130,10 @@ 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_MUX("DMICL Mux", SND_SOC_NOPM, 0, 0,
+			 &max9867_left_dmic_mux),
+	SND_SOC_DAPM_MUX("DMICR Mux", SND_SOC_NOPM, 0, 0,
+			 &max9867_right_dmic_mux),
 	SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", MAX9867_PWRMAN, 1, 0),
 	SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", MAX9867_PWRMAN, 0, 0),
 
@@ -140,8 +158,12 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = {
 	{"Input Mixer", "Mic Capture Switch", "MICR"},
 	{"Input Mixer", "Line Capture Switch", "Left Line Input"},
 	{"Input Mixer", "Line Capture Switch", "Right Line Input"},
-	{"ADCL", NULL, "Input Mixer"},
-	{"ADCR", NULL, "Input Mixer"},
+	{"DMICL Mux", "DMIC", "DMICL"},
+	{"DMICR Mux", "DMIC", "DMICR"},
+	{"DMICL Mux", "ADC", "Input Mixer"},
+	{"DMICR Mux", "ADC", "Input Mixer"},
+	{"ADCL", NULL, "DMICL Mux"},
+	{"ADCR", NULL, "DMICR Mux"},
 
 	{"Digital", "Sidetone Switch", "ADCL"},
 	{"Digital", "Sidetone Switch", "ADCR"},
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] ASoC: max9867: keep ADCs and DACs always on
  2020-05-22 14:29     ` [PATCH v2 0/2] " Pavel Dobias
  2020-05-22 14:29       ` [PATCH v2 1/2] ASoC: max9867: add digital microphone controls Pavel Dobias
@ 2020-05-22 14:29       ` Pavel Dobias
  2020-05-22 19:00       ` [PATCH v2 0/2] " Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Pavel Dobias @ 2020-05-22 14:29 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, ladis, Pavel Dobias

Updating power management register requires toggling the shutdown
bit otherwise it causes unexpected behavior of the codec.
However, toggling the shutdown bit results in loud speaker crackling.
Setup the power management register only at startup to avoid that.

Signed-off-by: Pavel Dobias <dobias@2n.cz>
---
 sound/soc/codecs/max9867.c | 19 +++++++++----------
 sound/soc/codecs/max9867.h |  1 -
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 3efaa6d8dc3f..c72cb2888c21 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -125,8 +125,8 @@ static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 	SND_SOC_DAPM_INPUT("LINL"),
 	SND_SOC_DAPM_INPUT("LINR"),
 
-	SND_SOC_DAPM_PGA("Left Line Input", MAX9867_PWRMAN, 6, 0, NULL, 0),
-	SND_SOC_DAPM_PGA("Right Line Input", MAX9867_PWRMAN, 5, 0, NULL, 0),
+	SND_SOC_DAPM_PGA("Left Line Input", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_PGA("Right Line Input", SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER_NAMED_CTL("Input Mixer", SND_SOC_NOPM, 0, 0,
 				     max9867_input_mixer_controls,
 				     ARRAY_SIZE(max9867_input_mixer_controls)),
@@ -134,8 +134,8 @@ static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = {
 			 &max9867_left_dmic_mux),
 	SND_SOC_DAPM_MUX("DMICR Mux", SND_SOC_NOPM, 0, 0,
 			 &max9867_right_dmic_mux),
-	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,
@@ -143,8 +143,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"),
@@ -452,15 +452,14 @@ static int max9867_set_bias_level(struct snd_soc_component *component,
 			if (err)
 				return err;
 
-			err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN,
-						 MAX9867_SHTDOWN, MAX9867_SHTDOWN);
+			err = regmap_write(max9867->regmap,
+					   MAX9867_PWRMAN, 0xff);
 			if (err)
 				return err;
 		}
 		break;
 	case SND_SOC_BIAS_OFF:
-		err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN,
-					 MAX9867_SHTDOWN, 0);
+		err = regmap_write(max9867->regmap, MAX9867_PWRMAN, 0);
 		if (err)
 			return err;
 
diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h
index d459d49449cb..3092c3b99075 100644
--- a/sound/soc/codecs/max9867.h
+++ b/sound/soc/codecs/max9867.h
@@ -58,7 +58,6 @@
 #define MAX9867_MICCONFIG    0x15
 #define MAX9867_MODECONFIG   0x16
 #define MAX9867_PWRMAN       0x17
-#define MAX9867_SHTDOWN      0x80
 #define MAX9867_REVISION     0xff
 
 #define MAX9867_CACHEREGNUM 10
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 0/2] ASoC: max9867: keep ADCs and DACs always on
  2020-05-22 14:29     ` [PATCH v2 0/2] " Pavel Dobias
  2020-05-22 14:29       ` [PATCH v2 1/2] ASoC: max9867: add digital microphone controls Pavel Dobias
  2020-05-22 14:29       ` [PATCH v2 2/2] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
@ 2020-05-22 19:00       ` Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2020-05-22 19:00 UTC (permalink / raw)
  To: Pavel Dobias, alsa-devel; +Cc: ladis

On Fri, 22 May 2020 16:29:55 +0200, Pavel Dobias wrote:
> On 20. 05. 20 15:01, Mark Brown wrote:
> > On Wed, May 20, 2020 at 09:19:02AM +0200, Pavel Dobias wrote:
> >> 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.
> > It will be normally when the two channels are updated simultaneously
> > though that doesn't stop the user doing something to update them
> > separately.  In any case this would be better handled through moving the
> > power control to either supply widgets or event callbacks rather than
> > just giving up on power control entirely.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: max9867: add digital microphone controls
      commit: 980b63f8d040a791e8d751b8065d12ad7865f976
[2/2] ASoC: max9867: keep ADCs and DACs always on
      commit: 29c859df7b52080f0809b8a0b9d7b86fff379ef9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-05-22 19:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  7:18 [PATCH 1/6] ASoC: max9867: fix ADC level control Pavel Dobias
2020-05-20  7:19 ` [PATCH 2/6] ASoC: max9867: don't use regmap defaults Pavel Dobias
2020-05-20  7:19 ` [PATCH 3/6] ASoC: max9867: add filter controls Pavel Dobias
2020-05-20  7:19 ` [PATCH 4/6] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
2020-05-20 13:01   ` Mark Brown
2020-05-22 14:29     ` [PATCH v2 0/2] " Pavel Dobias
2020-05-22 14:29       ` [PATCH v2 1/2] ASoC: max9867: add digital microphone controls Pavel Dobias
2020-05-22 14:29       ` [PATCH v2 2/2] ASoC: max9867: keep ADCs and DACs always on Pavel Dobias
2020-05-22 19:00       ` [PATCH v2 0/2] " Mark Brown
2020-05-20  7:19 ` [PATCH 5/6] ASoC: max9867: add mono playback switch Pavel Dobias
2020-05-20  7:19 ` [PATCH 6/6] ASoC: max9867: add digital microphone controls Pavel Dobias
2020-05-20 17:17 ` [PATCH 1/6] ASoC: max9867: fix ADC level control Mark Brown

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.