Skip to contentSkip to conversation

ASoC: max98090: support 20-bit and 24-bit audio format

PATCH In review Tzung-Bi Shih 2 participants 3 messages Jan 28, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: max98090: support 20-bit and 24-bit audio format

Quoted 1 line

From datasheet of max98090:

If RJ = 1,
WS = 00, 16 bits
WS = 01, 20 bits
WS = 10, 24 bits

---
 sound/soc/codecs/max98090.c | 16 +++++++++++++++-
 sound/soc/codecs/max98090.h |  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +15 -1
index c97f21836c66..0ecc2f1accb5 100644
@@ -1942,7 +1942,21 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream,
 	switch (params_width(params)) {
 	case 16:
 		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
-			M98090_WS_MASK, 0);
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S16_LE);
+		break;
+	case 20:
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S20_LE;
+		break;
+	case 24:
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S24_LE);
 		break;
 	default:
 		return -EINVAL;
sound/soc/codecs/max98090.h +3 -0
index b1572a2d19da..9088f9d64ff2 100644
@@ -706,6 +706,9 @@
 #define M98090_WS_SHIFT			0
 #define M98090_WS_WIDTH			2
 #define M98090_WS_NUM			(1<<M98090_WS_WIDTH)
+#define M98090_FORMAT_S16_LE		(0<<0)
+#define M98090_FORMAT_S20_LE		(1<<0)
+#define M98090_FORMAT_S24_LE		(2<<0)
 
 /*
  * M98090_REG_TDM_CONTROL
Signature · 1 line
2.20.1.495.gaa96b0ce6b-goog
#1 lore raw

Missing a parenthesis for M98090_FORMAT_S20_LE. Please ignore this patch.

Quoted 64 lines · Tzung-Bi Shih

From datasheet of max98090:
If RJ = 1,
WS = 00, 16 bits
WS = 01, 20 bits
WS = 10, 24 bits

---
 sound/soc/codecs/max98090.c | 16 +++++++++++++++-
 sound/soc/codecs/max98090.h |  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +6 -1
index c97f21836c66..0ecc2f1accb5 100644
@@ -1942,7 +1942,21 @@ static int max98090_dai_hw_params(struct
 snd_pcm_substream *substream,
        switch (params_width(params)) {
        case 16:
                snd_soc_component_update_bits(component,
 M98090_REG_INTERFACE_FORMAT,
-                       M98090_WS_MASK, 0);
+                       M98090_RJ_MASK, M98090_RJ_MASK);
+               snd_soc_component_update_bits(component,
 M98090_REG_INTERFACE_FORMAT,
+                       M98090_WS_MASK, M98090_FORMAT_S16_LE);
+               break;
+       case 20:
+               snd_soc_component_update_bits(component,

M98090_REG_INTERFACE_FORMAT,

sound/soc/codecs/max98090.c +2 -0
+                       M98090_RJ_MASK, M98090_RJ_MASK);
+               snd_soc_component_update_bits(component,

M98090_REG_INTERFACE_FORMAT,

sound/soc/codecs/max98090.c +4 -0
+                       M98090_WS_MASK, M98090_FORMAT_S20_LE;
+               break;
+       case 24:
+               snd_soc_component_update_bits(component,

M98090_REG_INTERFACE_FORMAT,

sound/soc/codecs/max98090.c +2 -0
+                       M98090_RJ_MASK, M98090_RJ_MASK);
+               snd_soc_component_update_bits(component,

M98090_REG_INTERFACE_FORMAT,

sound/soc/codecs/max98090.c +1 -0
+                       M98090_WS_MASK, M98090_FORMAT_S24_LE);
                break;
        default:
                return -EINVAL;
sound/soc/codecs/max98090.h +3 -1
index b1572a2d19da..9088f9d64ff2 100644
@@ -706,6 +706,9 @@
 #define M98090_WS_SHIFT                        0
 #define M98090_WS_WIDTH                        2
 #define M98090_WS_NUM                  (1<<M98090_WS_WIDTH)
+#define M98090_FORMAT_S16_LE           (0<<0)
+#define M98090_FORMAT_S20_LE           (1<<0)
+#define M98090_FORMAT_S24_LE           (2<<0)
 
 /*
  * M98090_REG_TDM_CONTROL
--

2.20.1.495.gaa96b0ce6b-goog

#2 lore raw
In reply to Tzung-Bi Shih
Quoted 5 lines · Tzung-Bi Shih

From datasheet of max98090:
If RJ = 1,
WS = 00, 16 bits
WS = 01, 20 bits
WS = 10, 24 bits

Yes, but there is a if (Right Justified)

DAI Input Data Word Size (TDM = 0)

If RJ = 1: 00: 16 bits 01: 20 bits 10: 24 bits 11: Reserved

If RJ = 0: 00: 16 bits 01, 10, 11: 20 bits

You can't arbitrarily set the RJ bit without having the SOC know about it - this should be conditional on the DAI format already used elsewhere:

case SND_SOC_DAIFMT_RIGHT_J:
            regval |= M98090_RJ_MASK;
            break;

I also vaguely recall there were limitations on capture with an odd format being used?

Quoted 39 lines
---
  sound/soc/codecs/max98090.c | 16 +++++++++++++++-
  sound/soc/codecs/max98090.h |  3 +++
  2 files changed, 18 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +15 -1
index c97f21836c66..0ecc2f1accb5 100644
@@ -1942,7 +1942,21 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream,
  	switch (params_width(params)) {
  	case 16:
  		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
-			M98090_WS_MASK, 0);
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S16_LE);
+		break;
+	case 20:
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S20_LE;
+		break;
+	case 24:
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_RJ_MASK, M98090_RJ_MASK);
+		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
+			M98090_WS_MASK, M98090_FORMAT_S24_LE);
  		break;
  	default:
  		return -EINVAL;
sound/soc/codecs/max98090.h +0 -0
index b1572a2d19da..9088f9d64ff2 100644

sound/soc/codecs/max98090.h line 714

Quoted 9 lines
sound/soc/codecs/max98090.h +3 -0
@@ -706,6 +706,9 @@
  #define M98090_WS_SHIFT			0
  #define M98090_WS_WIDTH			2
  #define M98090_WS_NUM			(1<<M98090_WS_WIDTH)
+#define M98090_FORMAT_S16_LE		(0<<0)
+#define M98090_FORMAT_S20_LE		(1<<0)
+#define M98090_FORMAT_S24_LE		(2<<0)
 
  /*
   * M98090_REG_TDM_CONTROL

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