Skip to contentSkip to conversation

ASoC: cs4265: SOC_SINGLE register value error fix

PATCH Superseded Matt Flax 3 participants 14 messages Aug 26, 2018 – Aug 29, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Matt Flax

author
#0 lore raw

PATCH 1/3 ASoC: cs4265: SOC_SINGLE register value error fix

The cs4265 driver declares the "MMTLR Data Switch" register setting with a 0 register value rather then the 0x12 register (CS4265_SPDIF_CTL2). This incorrect value causes alsamixer to fault with the output :
cannot load mixer controls: Input/output error

This patch corrects the register value. alsamixer now runs.

---
 sound/soc/codecs/cs4265.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/cs4265.c +1 -2
index 275677de..15b4ae04 100644
@@ -157,8 +157,7 @@ static const struct snd_kcontrol_new cs4265_snd_controls[] = {
 	SOC_SINGLE("Validity Bit Control Switch", CS4265_SPDIF_CTL2,
 				3, 1, 0),
 	SOC_ENUM("SPDIF Mono/Stereo", spdif_mono_stereo_enum),
-	SOC_SINGLE("MMTLR Data Switch", 0,
-				1, 1, 0),
+	SOC_SINGLE("MMTLR Data Switch", CS4265_SPDIF_CTL2, 0, 1, 0),
 	SOC_ENUM("Mono Channel Select", spdif_mono_select_enum),
 	SND_SOC_BYTES("C Data Buffer", CS4265_C_DATA_BUFF, 24),
 };
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 ASoC: cs4265: Add native 32bit I2S transport

The cs4265 uses 32 bit transport on the I2S bus. This patch enables native 32 bit mode for machine drivers which use this sound card driver.

---
 sound/soc/codecs/cs4265.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/cs4265.c +2 -1
index 15b4ae04..17d7e6f0 100644
@@ -495,7 +495,8 @@ static int cs4265_set_bias_level(struct snd_soc_component *component,
 			SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
 
 #define CS4265_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \
-			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE)
+			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE | \
+			SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE)
 
 static const struct snd_soc_dai_ops cs4265_ops = {
 	.hw_params	= cs4265_pcm_hw_params,
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

Quoted 13 lines · Matt Flax

The cs4265 uses 32 bit transport on the I2S bus. This patch enables native 32 bit mode for machine drivers which use this sound card driver.

---
 sound/soc/codecs/cs4265.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/cs4265.c +0 -0
index 15b4ae04..17d7e6f0 100644

sound/soc/codecs/cs4265.c static int cs4265_set_bias_level(struct snd_soc_component *component, · line 499

Quoted 6 lines
sound/soc/codecs/cs4265.c +2 -1
@@ -495,7 +495,8 @@ static int cs4265_set_bias_level(struct snd_soc_component *component,
 			SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
 
 #define CS4265_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \
-			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE)
+			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE | \
+			SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE)

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

Quoted 5 lines
sound/soc/codecs/cs4265.c +0 -0
 static const struct snd_soc_dai_ops cs4265_ops = {
 	.hw_params	= cs4265_pcm_hw_params,
Signature · 1 line
2.17.1

Thanks,
Charles

author
#3 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

Quoted 16 lines · Charles Keepax
Quoted 15 lines · Matt Flax

The cs4265 uses 32 bit transport on the I2S bus. This patch enables native 32 bit mode for machine drivers which use this sound card driver.

---
  sound/soc/codecs/cs4265.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/cs4265.c +0 -0
index 15b4ae04..17d7e6f0 100644
@@ -495,7 +495,8 @@ static int cs4265_set_bias_level(struct snd_soc_component *component,
  			SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
 
Quoted 8 lines

sound/soc/codecs/cs4265.c static int cs4265_set_bias_level(struct snd_soc_component *component, · line 499

Quoted 4 lines
sound/soc/codecs/cs4265.c +2 -1
  #define CS4265_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \
-			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE)
+			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE | \
+			SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE)

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

I will check this to make sure - leave it with me.

Quoted 11 lines
Quoted 5 lines
sound/soc/codecs/cs4265.c +0 -0
  static const struct snd_soc_dai_ops cs4265_ops = {
  	.hw_params	= cs4265_pcm_hw_params,
Signature · 1 line
2.17.1

Thanks,
Charles
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#4 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

In reply to Charles Keepax
Quoted 4 lines · Charles Keepax

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

No, they're not. They're expected to be 32 bit in memory and 24 bit on the bus.

author
#5 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

Quoted 9 lines · Mark Brown
Quoted 4 lines · Charles Keepax

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

No, they're not. They're expected to be 32 bit in memory and 24 bit on the bus.

If this is the case, then I would assume that 32bit formats are forced through ALSA plughw.

If operation is forced through plughw, then this patch is necessary to allow native 32 operation on the bus. The codec drops the 8 LSBs during operation as it reads/writes the 24 MSBs.

Matt

author
#6 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

Quoted 9 lines · Matt Flax
Quoted 6 lines · Mark Brown
Quoted 4 lines · Charles Keepax

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

Quoted 8 lines
Quoted 3 lines

No, they're not.  They're expected to be 32 bit in memory and 24 bit on the bus.

If this is the case, then I would assume that 32bit formats are forced through ALSA plughw.

If operation is forced through plughw, then this patch is necessary to allow native 32 operation on the bus. The codec drops the 8 LSBs during operation as it reads/writes the 24 MSBs.

Just to confirm this patch is necessary to support 32 bit audio formats naively with the cs4265 codec. I did the following tests.

Without the codec patch, limiting to 24 and 16 bit formats :

$ aplay -v tone.48k.1s.2ch.32bit.wav
aplay: set_params:1233: Sample format non available
Available formats:
- S16_LE
- S24_LE

With the codec patch, 32 bits are allowed on the I2S bus it plays as expected :

$ aplay -v tone.48k.1s.2ch.32bit.wav
Playing WAVE 'tone.48k.1s.2ch.32bit.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
#7 lore raw

Re: [PATCH 2/3] ASoC: cs4265: Add native 32bit I2S transport

In reply to Matt Flax
Quoted 13 lines · Matt Flax
Quoted 9 lines · Mark Brown
Quoted 4 lines · Charles Keepax

Are you sure this is correct? The datasheet for the part only says it supports up to 24-bit audio and I thought the defines SNDRV_PCM_FMTBIT_S24_LE and U24 are expected to have 32-bits in the slot whilst on the bus.

No, they're not. They're expected to be 32 bit in memory and 24 bit on the bus.

Quoted 7 lines

If this is the case, then I would assume that 32bit formats are forced through ALSA plughw.

If operation is forced through plughw, then this patch is necessary to allow native 32 operation on the bus. The codec drops the 8 LSBs during operation as it reads/writes the 24 MSBs.

Yeah apologies for the confusion I imagine this patch is then fine.

Thanks,
Charles

author
#8 lore raw

PATCH 3/3 ASoC: cs4265: Add a SPDIF enable actl

In reply to Matt Flax

This patch adds a SPDIF enable/disable toggle switch to the sound controls.

---
 sound/soc/codecs/cs4265.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/codecs/cs4265.c +8 -0
index 17d7e6f0..cdfcca9c 100644
@@ -112,6 +112,13 @@ static const char * const cam_mono_stereo_text[] = {
 static SOC_ENUM_SINGLE_DECL(spdif_mono_stereo_enum, CS4265_SPDIF_CTL2, 2,
 		cam_mono_stereo_text);
 
+static const char * const spdif_enable_text[] = {
+	"Enabled", "Disabled"
+};
+
+static SOC_ENUM_SINGLE_DECL(spdif_enable_enum, CS4265_SPDIF_CTL2, 5,
+		spdif_enable_text);
+
 static const char * const mono_select_text[] = {
 	"Channel A", "Channel B"
 };
@@ -151,6 +158,7 @@ static const struct snd_kcontrol_new cs4265_snd_controls[] = {
 				1, 1),
 	SOC_SINGLE("ADC Soft Ramp Switch", CS4265_ADC_CTL2, 7,
 				1, 0),
+	SOC_ENUM("SPDIF Enable", spdif_enable_enum),
 	SOC_SINGLE("E to F Buffer Disable Switch", CS4265_SPDIF_CTL1,
 				6, 1, 0),
 	SOC_ENUM("C Data Access", cam_mode_enum),
Signature · 1 line
2.17.1
#9 lore raw

Re: [PATCH 3/3] ASoC: cs4265: Add a SPDIF enable actl

Quoted 13 lines · Matt Flax

This patch adds a SPDIF enable/disable toggle switch to the sound controls.

---
 sound/soc/codecs/cs4265.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/codecs/cs4265.c +0 -0
index 17d7e6f0..cdfcca9c 100644

sound/soc/codecs/cs4265.c static const char * const cam_mono_stereo_text[] = { · line 117

Quoted 6 lines
sound/soc/codecs/cs4265.c +3 -0
@@ -112,6 +112,13 @@ static const char * const cam_mono_stereo_text[] = {
 static SOC_ENUM_SINGLE_DECL(spdif_mono_stereo_enum, CS4265_SPDIF_CTL2, 2,
 		cam_mono_stereo_text);
 
+static const char * const spdif_enable_text[] = {
+	"Enabled", "Disabled"
+};

If the values are just on/off would not a SOC_SINGLE be more appropriate?

sound/soc/codecs/cs4265.c static const struct snd_kcontrol_new cs4265_snd_controls[] = { · line 161

Quoted 12 lines
sound/soc/codecs/cs4265.c +5 -0
+
+static SOC_ENUM_SINGLE_DECL(spdif_enable_enum, CS4265_SPDIF_CTL2, 5,
+		spdif_enable_text);
+
 static const char * const mono_select_text[] = {
 	"Channel A", "Channel B"
 };
@@ -151,6 +158,7 @@ static const struct snd_kcontrol_new cs4265_snd_controls[] = {
 				1, 1),
 	SOC_SINGLE("ADC Soft Ramp Switch", CS4265_ADC_CTL2, 7,
 				1, 0),
+	SOC_ENUM("SPDIF Enable", spdif_enable_enum),

Although you would want to then call this something like "SPDIF Switch".

Quoted 5 lines
sound/soc/codecs/cs4265.c +0 -0
 	SOC_SINGLE("E to F Buffer Disable Switch", CS4265_SPDIF_CTL1,
 				6, 1, 0),
 	SOC_ENUM("C Data Access", cam_mode_enum),
Signature · 1 line
2.17.1

Thanks,
Charles

author
#10 lore raw

Re: [PATCH 3/3] ASoC: cs4265: Add a SPDIF enable actl

Quoted 17 lines · Charles Keepax
Quoted 16 lines · Matt Flax

This patch adds a SPDIF enable/disable toggle switch to the sound controls.

---
  sound/soc/codecs/cs4265.c | 8 ++++++++
  1 file changed, 8 insertions(+)
sound/soc/codecs/cs4265.c +0 -0
index 17d7e6f0..cdfcca9c 100644
@@ -112,6 +112,13 @@ static const char * const cam_mono_stereo_text[] = {
  static SOC_ENUM_SINGLE_DECL(spdif_mono_stereo_enum, CS4265_SPDIF_CTL2, 2,
  		cam_mono_stereo_text);
 
Quoted 5 lines

sound/soc/codecs/cs4265.c static const char * const cam_mono_stereo_text[] = { · line 117

Quoted 3 lines
sound/soc/codecs/cs4265.c +3 -0
+static const char * const spdif_enable_text[] = {
+	"Enabled", "Disabled"
+};

If the values are just on/off would not a SOC_SINGLE be more appropriate?

OK that sounds like a better idea, I will implement a SOC_SINGLE. Thanks for the guidance.

Quoted 15 lines

sound/soc/codecs/cs4265.c static const struct snd_kcontrol_new cs4265_snd_controls[] = { · line 161

Quoted 13 lines
sound/soc/codecs/cs4265.c +5 -0
+
+static SOC_ENUM_SINGLE_DECL(spdif_enable_enum, CS4265_SPDIF_CTL2, 5,
+		spdif_enable_text);
+
  static const char * const mono_select_text[] = {
  	"Channel A", "Channel B"
  };
@@ -151,6 +158,7 @@ static const struct snd_kcontrol_new cs4265_snd_controls[] = {
  				1, 1),
  	SOC_SINGLE("ADC Soft Ramp Switch", CS4265_ADC_CTL2, 7,
  				1, 0),
+	SOC_ENUM("SPDIF Enable", spdif_enable_enum),

Although you would want to then call this something like "SPDIF Switch".

Yes, sounds good.

Quoted 12 lines
Quoted 6 lines
sound/soc/codecs/cs4265.c +0 -0
  	SOC_SINGLE("E to F Buffer Disable Switch", CS4265_SPDIF_CTL1,
  				6, 1, 0),
  	SOC_ENUM("C Data Access", cam_mode_enum),
Signature · 1 line
2.17.1

Thanks,
Charles
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Reviewed-by on v1 1/3
#11 lore raw
In reply to Matt Flax
Quoted 9 lines · Matt Flax

The cs4265 driver declares the "MMTLR Data Switch" register setting with a 0 register value rather then the 0x12 register (CS4265_SPDIF_CTL2). This incorrect value causes alsamixer to fault with the output :
cannot load mixer controls: Input/output error

This patch corrects the register value. alsamixer now runs.

---

Thanks,
Charles

maintainer
#12 lore raw
In reply to Matt Flax
Quoted 4 lines · Matt Flax

The cs4265 driver declares the "MMTLR Data Switch" register setting with a 0 register value rather then the 0x12 register (CS4265_SPDIF_CTL2). This incorrect value causes alsamixer to fault with the output :
cannot load mixer controls: Input/output error

How is this patch series different to the apparently identical three patch series you sent a few minutes earlier?

author
#13 lore raw
Quoted 8 lines · Mark Brown
Quoted 4 lines · Matt Flax

The cs4265 driver declares the "MMTLR Data Switch" register setting with a 0 register value rather then the 0x12 register (CS4265_SPDIF_CTL2). This incorrect value causes alsamixer to fault with the output :
cannot load mixer controls: Input/output error

How is this patch series different to the apparently identical three patch series you sent a few minutes earlier?

The identical patch series were sent from the wrong email address and didn't go through to the list - because of moderation. I apologise for the first mistake.

Matt