Skip to contentSkip to conversation

SDM660 internal sound card support

PATCH Superseded Richard Acayan 6 participants 26 messages Feb 11 – Feb 24

Subsystems (5)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover SDM660 internal sound card support

This adds support for the SDM660 internal sound card. It is used on the Xiaomi Redmi Note 7 for headset (playback + capture) and earpiece. It is also used on the Google Pixel 3a for the headset.

Like MSM8916 and MSM8953, the SDM660 internal sound card connects to a digital and analog codec. Its connection to the digital codec is through special "internal" MI2S ports.

This series does not include devicetree patches.

Nickolay Goppen (1):
ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Richard Acayan (9):
ASoC: dt-bindings: qcom: q6dsp: add internal mi2s support
ASoC: dt-bindings: pm8916-analog-codec: Add PM660L compatible
ASoC: dt-bindings: msm8916-digital-codec: Add SDM660 compatible
ASoC: qdsp6: q6dsp-lpass-ports: add internal mi2s support
ASoC: qdsp6: q6afe: add internal mi2s support
ASoC: qdsp6: q6afe-dai: add internal mi2s support
ASoC: qdsp6: q6routing: add internal mi2s support
ASoC: qcom: add sdm660 internal sound card support
ASoC: msm8916-wcd-analog: add quirk for cajon 2.0

 .../sound/qcom,msm8916-wcd-digital-codec.yaml |   8 +-
 .../sound/qcom,pm8916-wcd-analog-codec.yaml   |   8 +-
 .../sound/qcom,q6dsp-lpass-ports.yaml         |   5 +-
 .../bindings/sound/qcom,sm8250.yaml           |   1 +
 .../sound/qcom,q6dsp-lpass-ports.h            |  14 +
 sound/soc/codecs/msm8916-wcd-analog.c         |  63 +++-
 sound/soc/qcom/Kconfig                        |  12 +
 sound/soc/qcom/Makefile                       |   2 +
 sound/soc/qcom/qdsp6/q6afe-dai.c              |  46 +++
 sound/soc/qcom/qdsp6/q6afe.c                  |  56 ++++
 sound/soc/qcom/qdsp6/q6afe.h                  |   2 +-
 sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c      | 200 +++++++++++++
 sound/soc/qcom/qdsp6/q6routing.c              |  78 ++++-
 sound/soc/qcom/sdm660-internal.c              | 271 ++++++++++++++++++
 14 files changed, 759 insertions(+), 7 deletions(-)
 create mode 100644 sound/soc/qcom/sdm660-internal.c
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/10 ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

---
 Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +1 -0
index 15f38622b98b..ad5add422c4d 100644
@@ -44,6 +44,7 @@ properties:
           - qcom,qrb5165-rb5-sndcard
           - qcom,sc7180-qdsp6-sndcard
           - qcom,sc8280xp-sndcard
+          - qcom,sdm660-internal-sndcard
           - qcom,sdm845-sndcard
           - qcom,sm8250-sndcard
           - qcom,sm8450-sndcard
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Quoted 22 lines
---
 Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +1 -0
index 15f38622b98b..ad5add422c4d 100644
@@ -44,6 +44,7 @@ properties:
           - qcom,qrb5165-rb5-sndcard
           - qcom,sc7180-qdsp6-sndcard
           - qcom,sc8280xp-sndcard
+          - qcom,sdm660-internal-sndcard
           - qcom,sdm845-sndcard
           - qcom,sm8250-sndcard
           - qcom,sm8450-sndcard
Signature · 1 line
2.53.0
Signature · 2 lines
With best wishes
Dmitry
#3 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 6 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

[1]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/sound/soc/msm/sdm660-internal.c

[2]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/arch/arm/boot/dts/qcom/msm-audio.dtsi#L835

[3]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/sound/soc/msm/sdm660-external.c

Quoted 2 lines

Best regards,
Krzysztof

Signature · 2 lines
Best regards,
Nickolay
#5 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 6 lines · Nickolay Goppen
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Dmitry Baryshkov
Quoted 2 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

It comes mainly from downstream driver name [1].

Downstream is antipattern, don't use it ever as argument for bindings. It is actually very good counter argument - if downstream does something in the bindings, then it is for sure wrong code.

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

In reply to Nickolay Goppen
Quoted 12 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

Quoted 5 lines

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

I also notice some details about a WCN slimbus channel (bt and FM radio?) in the internal one.

Konrad

Quoted 8 lines

[1]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/sound/soc/msm/sdm660-internal.c

[2]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/arch/arm/boot/dts/qcom/msm-audio.dtsi#L835

[3]: https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.8.2.r1-07500-sdm660.0/sound/soc/msm/sdm660-external.c

Quoted 2 lines

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 15 lines · Konrad Dybcio
Quoted 14 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

It comes mainly from downstream driver name [1].

Quoted 7 lines
Quoted 3 lines

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

Interesting you left out WCD9335 (codename tasha), is it never used in production on SDM660?

If it is used, the sound card might need to provide different configuration (e.g. channel map) based on the codec, or we might at least need a separate sound card driver for SDM660 with the tasha codec.

If not, a single SoC sound card driver can provide codec configuration based on the port without checking the codec.

Quoted 2 lines

I also notice some details about a WCN slimbus channel (bt and FM radio?) in the internal one.

I also notice BTFM in the external one, on SLIMBUS_7 and SLIMBUS_8. They don't conflict with tasha or tavil, on the other slimbus ports.

#8 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 18 lines · Richard Acayan
Quoted 17 lines · Konrad Dybcio
Quoted 16 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

There's also an sdm660-external sndcard [3].

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

Interesting you left out WCD9335 (codename tasha), is it never used in production on SDM660?

I don't know.

I think both were used with MSM8998, so I wouldn't rule that out being the case for 660 too

Konrad

#9 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 21 lines · Konrad Dybcio
Quoted 20 lines · Richard Acayan
Quoted 19 lines · Konrad Dybcio
Quoted 17 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

Interesting you left out WCD9335 (codename tasha), is it never used in production on SDM660?

I don't know.

msm-4.4 lists WCD8335 in sdm660-audio.dtsi. I'd assume that's the standard codec. On the development kits side, IFC6560 uses PM660L, while Open-Q 660 uSOM uses WCD9335.

Quoted 5 lines

I think both were used with MSM8998, so I wouldn't rule that out being the case for 660 too

Konrad

Signature · 2 lines
With best wishes
Dmitry
#10 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

Quoted 26 lines · Dmitry Baryshkov
Quoted 25 lines · Konrad Dybcio
Quoted 24 lines · Richard Acayan
Quoted 22 lines · Konrad Dybcio
Quoted 12 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

Quoted 5 lines

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Interesting you left out WCD9335 (codename tasha), is it never used in production on SDM660?

I don't know.

msm-4.4 lists WCD8335 in sdm660-audio.dtsi. I'd assume that's the standard codec. On the development kits side, IFC6560 uses PM660L, while Open-Q 660 uSOM uses WCD9335.

FWIW I think the SDM630 Sony phones use pm660l+wsa881x

Konrad

#11 lore raw

Re: [PATCH 01/10] ASoC: dt-bindings: qcom,sm8250: add compatible for sdm660-internal

In reply to Konrad Dybcio
Quoted 25 lines · Konrad Dybcio
Quoted 24 lines · Richard Acayan
Quoted 22 lines · Konrad Dybcio
Quoted 12 lines · Nickolay Goppen
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Dmitry Baryshkov
Quoted 3 lines · Richard Acayan

From: Nickolay Goppen <[email protected]>

Add compatibles for sdm660-internal based soundcards.

Why is it called "internal"?

Yeah... I am pretty sure there is no such sound card. You cannot have sound card internal to the soc, because you need the external components like codecs.

Quoted 5 lines

It comes mainly from downstream driver name [1].

Downstream also mentions it as int_codec [2].

There's also an sdm660-external sndcard [3].

It seems like "external" means "coupled with WCD934x+WSA881x" and "internal" means "coupled with (digital cdc on SoC and analog on PMIC)-over-intI2S plus optionally WSA881x".

Quoted 7 lines
Quoted 2 lines

Interesting you left out WCD9335 (codename tasha), is it never used in production on SDM660?

I don't know.

I think both were used with MSM8998, so I wouldn't rule that out being the case for 660 too

Okay. If the codec needs separate configuration, the sound card driver can just compare the codec name like in SC7180.

#12 lore raw

PATCH 2/10 ASoC: dt-bindings: qcom: q6dsp: add internal mi2s support

In reply to Richard Acayan

The internal MI2S ports are found on devices with the internal sound card for Snapdragon 660. Add support for them.

---
 .../bindings/sound/qcom,q6dsp-lpass-ports.yaml     |  5 ++++-
 include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,q6dsp-lpass-ports.yaml +4 -1
index 08c618e7e428..751913894dd4 100644
@@ -126,13 +126,16 @@ patternProperties:
             reg:
               contains:
                 # MI2S DAI ID range PRIMARY_MI2S_RX - QUATERNARY_MI2S_TX and
-                # QUINARY_MI2S_RX - QUINARY_MI2S_TX
+                # QUINARY_MI2S_RX - QUINARY_MI2S_TX and
+                # INT0_MI2S_RX - INT6_MI2S_TX
                 items:
                   oneOf:
                     - minimum: 16
                       maximum: 23
                     - minimum: 127
                       maximum: 128
+                    - minimum: 137
+                      maximum: 150
         then:
           required:
             - qcom,sd-lines
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +14 -0
index 6d1ce7f5da51..6753f7bf004b 100644
@@ -140,6 +140,20 @@
 #define DISPLAY_PORT_RX_6	134
 #define DISPLAY_PORT_RX_7	135
 #define USB_RX			136
+#define INT0_MI2S_RX		137
+#define INT0_MI2S_TX		138
+#define INT1_MI2S_RX		139
+#define INT1_MI2S_TX		140
+#define INT2_MI2S_RX		141
+#define INT2_MI2S_TX		142
+#define INT3_MI2S_RX		143
+#define INT3_MI2S_TX		144
+#define INT4_MI2S_RX		145
+#define INT4_MI2S_TX		146
+#define INT5_MI2S_RX		147
+#define INT5_MI2S_TX		148
+#define INT6_MI2S_RX		149
+#define INT6_MI2S_TX		150
 
 #define LPASS_CLK_ID_PRI_MI2S_IBIT	1
 #define LPASS_CLK_ID_PRI_MI2S_EBIT	2
Signature · 1 line
2.53.0
#13 lore raw

PATCH 3/10 ASoC: dt-bindings: pm8916-analog-codec: Add PM660L compatible

In reply to Richard Acayan

The PM8916 analog codec is also found on PM660L, typically connected to the SDM660 internal sound card via the digital codec. Provide a space for specific compatibles and add the compatible for PM660L.

---
 .../bindings/sound/qcom,pm8916-wcd-analog-codec.yaml      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,pm8916-wcd-analog-codec.yaml +7 -1
index 94e7a1860977..c7424d755cd8 100644
@@ -14,7 +14,13 @@ description:
 
 properties:
   compatible:
-    const: qcom,pm8916-wcd-analog-codec
+    oneOf:
+      - items:
+          - enum:
+              - qcom,pm660l-wcd-analog-codec
+          - const: qcom,pm8916-wcd-analog-codec
+
+      - const: qcom,pm8916-wcd-analog-codec
 
   reg:
     maxItems: 1
Signature · 1 line
2.53.0
Reviewed-by on v1 3/10
#14 lore raw

Re: [PATCH 03/10] ASoC: dt-bindings: pm8916-analog-codec: Add PM660L compatible

Quoted 8 lines · Richard Acayan

The PM8916 analog codec is also found on PM660L, typically connected to the SDM660 internal sound card via the digital codec. Provide a space for specific compatibles and add the compatible for PM660L.

---
 .../bindings/sound/qcom,pm8916-wcd-analog-codec.yaml      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH 03/10] ASoC: dt-bindings: pm8916-analog-codec: Add PM660L compatible

In reply to Richard Acayan
Quoted 14 lines · Richard Acayan

The PM8916 analog codec is also found on PM660L, typically connected to the SDM660 internal sound card via the digital codec. Provide a space for specific compatibles and add the compatible for PM660L.

---
 .../bindings/sound/qcom,pm8916-wcd-analog-codec.yaml      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,pm8916-wcd-analog-codec.yaml +0 -0
index 94e7a1860977..c7424d755cd8 100644

Documentation/devicetree/bindings/sound/qcom,pm8916-wcd-analog-codec.yaml description: · line 21

Quoted 9 lines
Documentation/devicetree/bindings/sound/qcom,pm8916-wcd-analog-codec.yaml +5 -1
@@ -14,7 +14,13 @@ description:
 
 properties:
   compatible:
-    const: qcom,pm8916-wcd-analog-codec
+    oneOf:
+      - items:
+          - enum:
+              - qcom,pm660l-wcd-analog-codec
+          - const: qcom,pm8916-wcd-analog-codec

I ran a quick diff and they're indeed surprisingly compatible

The revision fields have changed, as well as the subtype (hmm)

Other than that, there's 2 new intr sources (boost_ocp and lo_cnp)

MICB_2_en has a new field
the TEST_CTL registers changed a little
CDC_A_NCP_FBCTRL and CDC_A_NCP_VCTRL have new fields CDC_A_RX_COM_BIAS_DAC is slightly different (the 8916 driver doesn't touch that part today)

CDC_A_CURRENT_LIMIT has new fields

and some undescribed-today registers have new/different fields values otherwise it's seemingly the same

The digital part has a new rev/subtype value and some new undescribed-today registers are added, otherwise it's the same

Konrad

#16 lore raw

PATCH 4/10 ASoC: dt-bindings: msm8916-digital-codec: Add SDM660 compatible

In reply to Richard Acayan

The MSM8916 digital codec is also found on SDM660, typically connected to the SDM660 internal sound card. Provide a space
for specific compatibles and add the compatible for SDM660.

---
 .../bindings/sound/qcom,msm8916-wcd-digital-codec.yaml    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-digital-codec.yaml +7 -1
index a899c4e7c1c9..33bc23b6176a 100644
@@ -14,7 +14,13 @@ description:
 
 properties:
   compatible:
-    const: qcom,msm8916-wcd-digital-codec
+    oneOf:
+      - items:
+          - enum:
+              - qcom,sdm660-wcd-digital-codec
+          - const: qcom,msm8916-wcd-digital-codec
+
+      - const: qcom,msm8916-wcd-digital-codec
 
   reg:
     maxItems: 1
Signature · 1 line
2.53.0
Reviewed-by on v1 4/10
#17 lore raw

Re: [PATCH 04/10] ASoC: dt-bindings: msm8916-digital-codec: Add SDM660 compatible

Quoted 8 lines · Richard Acayan

The MSM8916 digital codec is also found on SDM660, typically connected to the SDM660 internal sound card. Provide a space
for specific compatibles and add the compatible for SDM660.

---
 .../bindings/sound/qcom,msm8916-wcd-digital-codec.yaml    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Best regards,
Krzysztof

#18 lore raw

PATCH 5/10 ASoC: qdsp6: q6dsp-lpass-ports: add internal mi2s support

In reply to Richard Acayan

Add the internal MI2S stream capabilities as specified by the audio kernel modules and configure the ports as MI2S ports.

---
 sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c | 200 +++++++++++++++++++++++
 1 file changed, 200 insertions(+)
sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c +200 -0
index 4eed54b071a5..fc79934fc1bf 100644
@@ -594,6 +594,205 @@ static struct snd_soc_dai_driver q6dsp_audio_fe_dais[] = {
 	Q6AFE_CDC_DMA_TX_DAI(TX_CODEC_DMA_TX_5),
 	Q6AFE_CDC_DMA_RX_DAI(RX_CODEC_DMA_RX_6),
 	Q6AFE_CDC_DMA_RX_DAI(RX_CODEC_DMA_RX_7),
+	{
+		.playback = {
+			.stream_name = "INT0 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
+				 SNDRV_PCM_RATE_192000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     192000,
+		},
+		.id = INT0_MI2S_RX,
+		.name = "INT0_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT0 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT0_MI2S_TX,
+		.name = "INT0_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT1 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT1_MI2S_RX,
+		.name = "INT1_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT1 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT1_MI2S_TX,
+		.name = "INT1_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT2 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT2_MI2S_RX,
+		.name = "INT2_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT2 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT2_MI2S_TX,
+		.name = "INT2_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT3 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT3_MI2S_RX,
+		.name = "INT3_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT3 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT3_MI2S_TX,
+		.name = "INT3_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT4 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
+				 SNDRV_PCM_RATE_192000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     192000,
+		},
+		.id = INT4_MI2S_RX,
+		.name = "INT4_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT4 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT4_MI2S_TX,
+		.name = "INT4_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT5 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT5_MI2S_RX,
+		.name = "INT5_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT5 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT5_MI2S_TX,
+		.name = "INT5_MI2S_TX",
+	}, {
+		.playback = {
+			.stream_name = "INT6 MI2S Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE |
+				   SNDRV_PCM_FMTBIT_S24_3LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT6_MI2S_RX,
+		.name = "INT6_MI2S_RX",
+	}, {
+		.capture = {
+			.stream_name = "INT6 MI2S Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+				 SNDRV_PCM_RATE_48000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.channels_min = 1,
+			.channels_max = 8,
+			.rate_min =     8000,
+			.rate_max =     48000,
+		},
+		.id = INT6_MI2S_TX,
+		.name = "INT6_MI2S_TX",
+	},
 };
 
 int q6dsp_audio_ports_of_xlate_dai_name(struct snd_soc_component *component,
@@ -636,6 +835,7 @@ struct snd_soc_dai_driver *q6dsp_audio_ports_set_config(struct device *dev,
 			break;
 		case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
 		case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
+		case INT0_MI2S_RX ... INT6_MI2S_TX:
 			q6dsp_audio_fe_dais[i].ops = cfg->q6i2s_ops;
 			break;
 		case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
Signature · 1 line
2.53.0
#19 lore raw

PATCH 6/10 ASoC: qdsp6: q6afe: add internal mi2s support

In reply to Richard Acayan

Add the port mappings for internal MI2S, found on the Snapdragon 660 internal sound card.

---
 sound/soc/qcom/qdsp6/q6afe.c | 56 ++++++++++++++++++++++++++++++++++++
 sound/soc/qcom/qdsp6/q6afe.h |  2 +-
 2 files changed, 57 insertions(+), 1 deletion(-)
sound/soc/qcom/qdsp6/q6afe.c +56 -0
index 0b01fc9e13a7..78d48f6cc926 100644
@@ -130,6 +130,20 @@
 #define AFE_PORT_ID_QUATERNARY_MI2S_TX      0x1007
 #define AFE_PORT_ID_QUINARY_MI2S_RX	    0x1016
 #define AFE_PORT_ID_QUINARY_MI2S_TX	    0x1017
+#define AFE_PORT_ID_INT0_MI2S_RX	    0x102e
+#define AFE_PORT_ID_INT0_MI2S_TX	    0x102f
+#define AFE_PORT_ID_INT1_MI2S_RX	    0x1030
+#define AFE_PORT_ID_INT1_MI2S_TX	    0x1031
+#define AFE_PORT_ID_INT2_MI2S_RX	    0x1032
+#define AFE_PORT_ID_INT2_MI2S_TX	    0x1033
+#define AFE_PORT_ID_INT3_MI2S_RX	    0x1034
+#define AFE_PORT_ID_INT3_MI2S_TX	    0x1035
+#define AFE_PORT_ID_INT4_MI2S_RX	    0x1036
+#define AFE_PORT_ID_INT4_MI2S_TX	    0x1037
+#define AFE_PORT_ID_INT5_MI2S_RX	    0x1038
+#define AFE_PORT_ID_INT5_MI2S_TX	    0x1039
+#define AFE_PORT_ID_INT6_MI2S_RX	    0x103a
+#define AFE_PORT_ID_INT6_MI2S_TX	    0x103b
 
 /* Start of the range of port IDs for TDM devices. */
 #define AFE_PORT_ID_TDM_PORT_RANGE_START	0x9000
@@ -925,6 +939,34 @@ static struct afe_port_map port_maps[AFE_PORT_MAX] = {
 	[RX_CODEC_DMA_RX_7] = { AFE_PORT_ID_RX_CODEC_DMA_RX_7,
 				RX_CODEC_DMA_RX_7, 1, 1},
 	[USB_RX] = { AFE_PORT_ID_USB_RX, USB_RX, 1, 1},
+	[INT0_MI2S_RX] = { AFE_PORT_ID_INT0_MI2S_RX,
+				INT0_MI2S_RX, 1, 1},
+	[INT0_MI2S_TX] = { AFE_PORT_ID_INT0_MI2S_TX,
+				INT0_MI2S_RX, 0, 1},
+	[INT1_MI2S_RX] = { AFE_PORT_ID_INT1_MI2S_RX,
+				INT1_MI2S_RX, 1, 1},
+	[INT1_MI2S_TX] = { AFE_PORT_ID_INT1_MI2S_TX,
+				INT1_MI2S_RX, 0, 1},
+	[INT2_MI2S_RX] = { AFE_PORT_ID_INT2_MI2S_RX,
+				INT2_MI2S_RX, 1, 1},
+	[INT2_MI2S_TX] = { AFE_PORT_ID_INT2_MI2S_TX,
+				INT2_MI2S_RX, 0, 1},
+	[INT3_MI2S_RX] = { AFE_PORT_ID_INT3_MI2S_RX,
+				INT3_MI2S_RX, 1, 1},
+	[INT3_MI2S_TX] = { AFE_PORT_ID_INT3_MI2S_TX,
+				INT3_MI2S_RX, 0, 1},
+	[INT4_MI2S_RX] = { AFE_PORT_ID_INT4_MI2S_RX,
+				INT4_MI2S_RX, 1, 1},
+	[INT4_MI2S_TX] = { AFE_PORT_ID_INT4_MI2S_TX,
+				INT4_MI2S_RX, 0, 1},
+	[INT5_MI2S_RX] = { AFE_PORT_ID_INT5_MI2S_RX,
+				INT5_MI2S_RX, 1, 1},
+	[INT5_MI2S_TX] = { AFE_PORT_ID_INT5_MI2S_TX,
+				INT5_MI2S_RX, 0, 1},
+	[INT6_MI2S_RX] = { AFE_PORT_ID_INT6_MI2S_RX,
+				INT6_MI2S_RX, 1, 1},
+	[INT6_MI2S_TX] = { AFE_PORT_ID_INT6_MI2S_TX,
+				INT6_MI2S_RX, 0, 1},
 };
 
 static void q6afe_port_free(struct kref *ref)
@@ -1779,6 +1821,20 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
 	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
 	case AFE_PORT_ID_QUINARY_MI2S_RX:
 	case AFE_PORT_ID_QUINARY_MI2S_TX:
+	case AFE_PORT_ID_INT0_MI2S_RX:
+	case AFE_PORT_ID_INT0_MI2S_TX:
+	case AFE_PORT_ID_INT1_MI2S_RX:
+	case AFE_PORT_ID_INT1_MI2S_TX:
+	case AFE_PORT_ID_INT2_MI2S_RX:
+	case AFE_PORT_ID_INT2_MI2S_TX:
+	case AFE_PORT_ID_INT3_MI2S_RX:
+	case AFE_PORT_ID_INT3_MI2S_TX:
+	case AFE_PORT_ID_INT4_MI2S_RX:
+	case AFE_PORT_ID_INT4_MI2S_TX:
+	case AFE_PORT_ID_INT5_MI2S_RX:
+	case AFE_PORT_ID_INT5_MI2S_TX:
+	case AFE_PORT_ID_INT6_MI2S_RX:
+	case AFE_PORT_ID_INT6_MI2S_TX:
 		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
 		break;
 	case AFE_PORT_ID_PRIMARY_TDM_RX ... AFE_PORT_ID_QUINARY_TDM_TX_7:
sound/soc/qcom/qdsp6/q6afe.h +1 -1
index a29abe4ce436..d61fda8e8985 100644
@@ -3,7 +3,7 @@
 #ifndef __Q6AFE_H__
 #define __Q6AFE_H__
 
-#define AFE_PORT_MAX		137
+#define AFE_PORT_MAX		151
 
 #define MSM_AFE_PORT_TYPE_RX 0
 #define MSM_AFE_PORT_TYPE_TX 1
Signature · 1 line
2.53.0
#20 lore raw

PATCH 7/10 ASoC: qdsp6: q6afe-dai: add internal mi2s support

In reply to Richard Acayan

Add the internal MI2S ports found on the SDM660 internal sound card.

---
 sound/soc/qcom/qdsp6/q6afe-dai.c | 46 ++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
sound/soc/qcom/qdsp6/q6afe-dai.c +46 -0
index 0f47aadaabe1..dfe964b1a341 100644
@@ -411,6 +411,7 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
 		break;
 	case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
 	case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
+	case INT0_MI2S_RX ... INT6_MI2S_TX:
 		rc = q6afe_i2s_port_prepare(dai_data->port[dai->id],
 			       &dai_data->port_config[dai->id].i2s_cfg);
 		if (rc < 0) {
@@ -662,6 +663,21 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
 
 	/* USB playback AFE port receives data for playback, hence use the RX port */
 	{"USB Playback", NULL, "USB_RX"},
+
+	{"INT0 MI2S Playback", NULL, "INT0_MI2S_RX"},
+	{"INT0_MI2S_TX", NULL, "INT0 MI2S Capture"},
+	{"INT1 MI2S Playback", NULL, "INT1_MI2S_RX"},
+	{"INT1_MI2S_TX", NULL, "INT1 MI2S Capture"},
+	{"INT2 MI2S Playback", NULL, "INT2_MI2S_RX"},
+	{"INT2_MI2S_TX", NULL, "INT2 MI2S Capture"},
+	{"INT3 MI2S Playback", NULL, "INT3_MI2S_RX"},
+	{"INT3_MI2S_TX", NULL, "INT3 MI2S Capture"},
+	{"INT4 MI2S Playback", NULL, "INT4_MI2S_RX"},
+	{"INT4_MI2S_TX", NULL, "INT4 MI2S Capture"},
+	{"INT5 MI2S Playback", NULL, "INT5_MI2S_RX"},
+	{"INT5_MI2S_TX", NULL, "INT5 MI2S Capture"},
+	{"INT6 MI2S Playback", NULL, "INT6_MI2S_RX"},
+	{"INT6_MI2S_TX", NULL, "INT6 MI2S Capture"},
 };
 
 static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
@@ -1006,6 +1022,35 @@ static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = {
 		0, SND_SOC_NOPM, 0, 0),
 
 	SND_SOC_DAPM_AIF_IN("USB_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+
+	SND_SOC_DAPM_AIF_IN("INT0_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT0_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT1_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT1_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT2_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT2_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT3_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT3_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT4_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT4_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT5_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT5_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("INT6_MI2S_RX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("INT6_MI2S_TX", "NULL",
+		0, SND_SOC_NOPM, 0, 0),
 };
 
 static const struct snd_soc_component_driver q6afe_dai_component = {
@@ -1039,6 +1084,7 @@ static void of_q6afe_parse_dai_data(struct device *dev,
 		/* MI2S specific properties */
 		case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
 		case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
+		case INT0_MI2S_RX ... INT6_MI2S_TX:
 			priv = &data->priv[id];
 			ret = of_property_read_variable_u32_array(node,
 							"qcom,sd-lines",
Signature · 1 line
2.53.0
#21 lore raw

PATCH 8/10 ASoC: qdsp6: q6routing: add internal mi2s support

In reply to Richard Acayan

Add the ASM-AFE routing for internal MI2S ports.

---
 sound/soc/qcom/qdsp6/q6routing.c | 78 +++++++++++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 1 deletion(-)
sound/soc/qcom/qdsp6/q6routing.c +77 -1
index aaa3af9f1993..f5d285c6590f 100644
@@ -127,7 +127,14 @@
 	{ mix_name, "TX_CODEC_DMA_TX_2", "TX_CODEC_DMA_TX_2"},	\
 	{ mix_name, "TX_CODEC_DMA_TX_3", "TX_CODEC_DMA_TX_3"},	\
 	{ mix_name, "TX_CODEC_DMA_TX_4", "TX_CODEC_DMA_TX_4"},	\
-	{ mix_name, "TX_CODEC_DMA_TX_5", "TX_CODEC_DMA_TX_5"}
+	{ mix_name, "TX_CODEC_DMA_TX_5", "TX_CODEC_DMA_TX_5"},	\
+	{ mix_name, "INT0_MI2S_TX", "INT0_MI2S_TX" },		\
+	{ mix_name, "INT1_MI2S_TX", "INT1_MI2S_TX" },		\
+	{ mix_name, "INT2_MI2S_TX", "INT2_MI2S_TX" },		\
+	{ mix_name, "INT3_MI2S_TX", "INT3_MI2S_TX" },		\
+	{ mix_name, "INT4_MI2S_TX", "INT4_MI2S_TX" },		\
+	{ mix_name, "INT5_MI2S_TX", "INT5_MI2S_TX" },		\
+	{ mix_name, "INT6_MI2S_TX", "INT6_MI2S_TX" }
 
 #define Q6ROUTING_TX_MIXERS(id)						\
 	SOC_SINGLE_EXT("PRI_MI2S_TX", PRIMARY_MI2S_TX,			\
@@ -320,6 +327,27 @@
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),				\
 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_5", TX_CODEC_DMA_TX_5,		\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT0_MI2S_TX", INT0_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT1_MI2S_TX", INT1_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT2_MI2S_TX", INT2_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT3_MI2S_TX", INT3_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT4_MI2S_TX", INT4_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT5_MI2S_TX", INT5_MI2S_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("INT6_MI2S_TX", INT6_MI2S_TX,			\
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),
 
@@ -709,6 +737,26 @@ static const struct snd_kcontrol_new rxcodec_dma_rx_6_mixer_controls[] = {
 static const struct snd_kcontrol_new rx_codec_dma_rx_7_mixer_controls[] = {
 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_7) };
 
+static const struct snd_kcontrol_new int0_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT0_MI2S_RX) };
+
+static const struct snd_kcontrol_new int1_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT1_MI2S_RX) };
+
+static const struct snd_kcontrol_new int2_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT2_MI2S_RX) };
+
+static const struct snd_kcontrol_new int3_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT3_MI2S_RX) };
+
+static const struct snd_kcontrol_new int4_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT4_MI2S_RX) };
+
+static const struct snd_kcontrol_new int5_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT5_MI2S_RX) };
+
+static const struct snd_kcontrol_new int6_mi2s_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(INT6_MI2S_RX) };
 
 static const struct snd_kcontrol_new mmul1_mixer_controls[] = {
 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA1) };
@@ -938,6 +986,27 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
 	SND_SOC_DAPM_MIXER("USB_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
 			   usb_rx_mixer_controls,
 			   ARRAY_SIZE(usb_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT0_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int0_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int0_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT1_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int1_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int1_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT2_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int2_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int2_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT3_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int3_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int3_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT4_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int4_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int4_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT5_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int5_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int5_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("INT6_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+		int6_mi2s_rx_mixer_controls,
+		ARRAY_SIZE(int6_mi2s_rx_mixer_controls)),
 	SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0,
 		mmul1_mixer_controls, ARRAY_SIZE(mmul1_mixer_controls)),
 	SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0,
@@ -1031,6 +1100,13 @@ static const struct snd_soc_dapm_route intercon[] = {
 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_6 Audio Mixer", "RX_CODEC_DMA_RX_6"),
 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_7 Audio Mixer", "RX_CODEC_DMA_RX_7"),
 	Q6ROUTING_RX_DAPM_ROUTE("USB_RX Audio Mixer", "USB_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT0_MI2S_RX Audio Mixer", "INT0_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT1_MI2S_RX Audio Mixer", "INT1_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT2_MI2S_RX Audio Mixer", "INT2_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT3_MI2S_RX Audio Mixer", "INT3_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT4_MI2S_RX Audio Mixer", "INT4_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT5_MI2S_RX Audio Mixer", "INT5_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("INT6_MI2S_RX Audio Mixer", "INT6_MI2S_RX"),
 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia1 Mixer"),
 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia2 Mixer"),
 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia3 Mixer"),
Signature · 1 line
2.53.0
#22 lore raw

PATCH 9/10 ASoC: qcom: add sdm660 internal sound card support

In reply to Richard Acayan

The Snapdragon 670 and Snapdragon 660 both share the same drivers for the sound cards. These different sound cards are tasha, tavil, and internal. Add support for the internal sound card.

---
 sound/soc/qcom/Kconfig           |  12 ++
 sound/soc/qcom/Makefile          |   2 +
 sound/soc/qcom/sdm660-internal.c | 271 +++++++++++++++++++++++++++++++
 3 files changed, 285 insertions(+)
 create mode 100644 sound/soc/qcom/sdm660-internal.c
sound/soc/qcom/Kconfig +12 -0
index e6e24f3b9922..86b2778adc1a 100644
@@ -167,6 +167,18 @@ config SND_SOC_MSM8996
 	  APQ8096 SoC-based systems.
 	  Say Y if you want to use audio device on this SoCs
 
+config SND_SOC_SDM660_INT
+	tristate "SoC Machine driver for SDM660 and SDM670 boards"
+	depends on QCOM_APR
+	depends on OF
+	depends on PM
+	select SND_SOC_QDSP6
+	select SND_SOC_QCOM_COMMON
+	help
+	  This adds support for audio on Qualcomm Technologies Inc.
+	  SDM660 and SDM670 SoC-based systems.
+	  Say Y if you want to use audio devices on these SoCs.
+
 config SND_SOC_SDM845
 	tristate "SoC Machine driver for SDM845 boards"
 	depends on QCOM_APR && I2C && SOUNDWIRE
sound/soc/qcom/Makefile +2 -0
index 985ce2ae286b..9a0da6279299 100644
@@ -24,6 +24,7 @@ snd-soc-apq8016-sbc-y := apq8016_sbc.o
 snd-soc-apq8096-y := apq8096.o
 snd-soc-sc7180-y := sc7180.o
 snd-soc-sc7280-y := sc7280.o
+snd-soc-sdm660-int-y := sdm660-internal.o
 snd-soc-sdm845-y := sdm845.o
 snd-soc-sm8250-y := sm8250.o
 snd-soc-sc8280xp-y := sc8280xp.o
@@ -38,6 +39,7 @@ obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o
 obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o
 obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o
 obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o
+obj-$(CONFIG_SND_SOC_SDM660_INT) += snd-soc-sdm660-int.o
 obj-$(CONFIG_SND_SOC_SDM845) += snd-soc-sdm845.o
 obj-$(CONFIG_SND_SOC_SM8250) += snd-soc-sm8250.o
 obj-$(CONFIG_SND_SOC_QCOM_COMMON) += snd-soc-qcom-common.o
sound/soc/qcom/sdm660-internal.c new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
2.53.0
#23 lore raw

Re: [PATCH 09/10] ASoC: qcom: add sdm660 internal sound card support

Quoted 2 lines · Richard Acayan

The Snapdragon 670 and Snapdragon 660 both share the same drivers for the sound cards. These different sound cards are tasha, tavil, and

tasha, tavil are codecs, most of differences is pretty much taken care at dt level.

Quoted 9 lines

internal. Add support for the internal sound card.

---
 sound/soc/qcom/Kconfig           |  12 ++
 sound/soc/qcom/Makefile          |   2 +
 sound/soc/qcom/sdm660-internal.c | 271 +++++++++++++++++++++++++++++++
 3 files changed, 285 insertions(+)
 create mode 100644 sound/soc/qcom/sdm660-internal.c

internal name really looks odd.

Any reason why totally new driver without resusing the existing ones or even the helper functions from existing code?

Quoted 91 lines
sound/soc/qcom/Kconfig +12 -0
index e6e24f3b9922..86b2778adc1a 100644
@@ -167,6 +167,18 @@ config SND_SOC_MSM8996
 	  APQ8096 SoC-based systems.
 	  Say Y if you want to use audio device on this SoCs
 
+config SND_SOC_SDM660_INT
+	tristate "SoC Machine driver for SDM660 and SDM670 boards"
+	depends on QCOM_APR
+	depends on OF
+	depends on PM
+	select SND_SOC_QDSP6
+	select SND_SOC_QCOM_COMMON
+	help
+	  This adds support for audio on Qualcomm Technologies Inc.
+	  SDM660 and SDM670 SoC-based systems.
+	  Say Y if you want to use audio devices on these SoCs.
+
 config SND_SOC_SDM845
 	tristate "SoC Machine driver for SDM845 boards"
 	depends on QCOM_APR && I2C && SOUNDWIRE
sound/soc/qcom/Makefile +2 -0
index 985ce2ae286b..9a0da6279299 100644
@@ -24,6 +24,7 @@ snd-soc-apq8016-sbc-y := apq8016_sbc.o
 snd-soc-apq8096-y := apq8096.o
 snd-soc-sc7180-y := sc7180.o
 snd-soc-sc7280-y := sc7280.o
+snd-soc-sdm660-int-y := sdm660-internal.o
 snd-soc-sdm845-y := sdm845.o
 snd-soc-sm8250-y := sm8250.o
 snd-soc-sc8280xp-y := sc8280xp.o
@@ -38,6 +39,7 @@ obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o
 obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o
 obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o
 obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o
+obj-$(CONFIG_SND_SOC_SDM660_INT) += snd-soc-sdm660-int.o
 obj-$(CONFIG_SND_SOC_SDM845) += snd-soc-sdm845.o
 obj-$(CONFIG_SND_SOC_SM8250) += snd-soc-sm8250.o
 obj-$(CONFIG_SND_SOC_QCOM_COMMON) += snd-soc-qcom-common.o
sound/soc/qcom/sdm660-internal.c new file +41 -0
new file mode 100644
index 000000000000..beb810aa4eb9
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023, Richard Acayan. All rights reserved.
+ */
+
+#include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/jack.h>
+#include <sound/soc.h>
+#include <sound/soc-card.h>
+#include <sound/soc-dai.h>
+#include <sound/soc-dapm.h>
+#include <sound/soc-jack.h>
+
+#include "common.h"
+#include "qdsp6/q6afe.h"
+
+#define DEFAULT_SAMPLE_RATE_48K		48000
+#define DEFAULT_INT_MCLK_RATE		9600000
+#define MI2S_BCLK_RATE			1536000
+
+struct sdm660_int_snd_data {
+	struct snd_soc_jack jack;
+	bool jack_setup;
+	uint32_t int0_mi2s_clk_count;
+	uint32_t int3_mi2s_clk_count;
+};
+
+static int snd_sdm660_int_startup(struct snd_pcm_substream *stream)
+{
+	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(stream);
+	struct sdm660_int_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *cpu = snd_soc_rtd_to_cpu(rtd, 0);
+
+	switch (cpu->id) {
+	case INT0_MI2S_RX:

sound/soc/qcom/sdm660-internal.c line 51

Quoted 10 lines
sound/soc/qcom/sdm660-internal.c new file +10 -0
+		data->int0_mi2s_clk_count++;
+		if (data->int0_mi2s_clk_count == 1)
+			snd_soc_dai_set_sysclk(cpu,
+				Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
+				MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+
+		/*
+		 * Downstream specifies that the AFE is a clock consumer, but
+		 * the sound is distorted (loud on the right channel and sped
+		 * up) unless we set it as a producer.

This comment does not make any value, Who is driving the bit clk and frame clock is totally depended on the hw setup on the platform, Driving incorrect clock would lead to such issues. Does the codec drive on the platform that you are testing?

Quoted 57 lines
sound/soc/qcom/sdm660-internal.c new file +57 -0
+		 */
+		snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBP_CFP);
+
+		break;
+	case INT3_MI2S_TX:
+		data->int3_mi2s_clk_count++;
+		if (data->int3_mi2s_clk_count == 1)
+			snd_soc_dai_set_sysclk(cpu,
+				Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT,
+				MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+
+		/*
+		 * Downstream specifies that the AFE is a clock consumer, but
+		 * the sound is distorted (slowed down) unless we set it as a
+		 * producer.
+		 */
+		snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBP_CFP);
+
+		break;
+	default:
+		dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__,
+			cpu->id);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void snd_sdm660_int_shutdown(struct snd_pcm_substream *stream)
+{
+	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(stream);
+	struct sdm660_int_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *cpu = snd_soc_rtd_to_cpu(rtd, 0);
+
+	switch (cpu->id) {
+	case INT0_MI2S_RX:
+		data->int0_mi2s_clk_count--;
+		if (data->int0_mi2s_clk_count == 0)
+			snd_soc_dai_set_sysclk(cpu,
+				Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
+				0, SNDRV_PCM_STREAM_PLAYBACK);
+
+		break;
+	case INT3_MI2S_TX:
+		data->int3_mi2s_clk_count--;
+		if (data->int3_mi2s_clk_count == 0)
+			snd_soc_dai_set_sysclk(cpu,
+				Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT,
+				0, SNDRV_PCM_STREAM_PLAYBACK);
+
+		break;
+	default:
+		dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__,
+			cpu->id);
+		break;
+	}
+}

sound/soc/qcom/sdm660-internal.c line 118

Quoted 10 lines
sound/soc/qcom/sdm660-internal.c new file +10 -0
+
+static int snd_sdm660_int_hw_free(struct snd_pcm_substream *stream)
+{
+	return 0;
+}
+
+static int snd_sdm660_int_prepare(struct snd_pcm_substream *stream)
+{
+	return 0;
+}

Why dummy functions?

Quoted 69 lines
sound/soc/qcom/sdm660-internal.c new file +69 -0
+
+static const struct snd_soc_ops sdm660_int_ops = {
+	.startup = snd_sdm660_int_startup,
+	.shutdown = snd_sdm660_int_shutdown,
+	.hw_free = snd_sdm660_int_hw_free,
+	.prepare = snd_sdm660_int_prepare,
+};
+
+static int sdm660_int_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+					 struct snd_pcm_hw_params *params)
+{
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+	struct snd_interval *channels = hw_param_interval(params,
+			SNDRV_PCM_HW_PARAM_CHANNELS);
+	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
+
+	rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K;
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
+
+	channels->min = channels->max = 2;
+
+	return 0;
+}
+
+static void sdm660_int_jack_free(struct snd_jack *jack)
+{
+	struct snd_soc_component *component = jack->private_data;
+
+	snd_soc_component_set_jack(component, NULL, NULL);
+}
+
+static int sdm660_int_dai_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_card *card = rtd->card;
+	struct sdm660_int_snd_data *data = snd_soc_card_get_drvdata(card);
+	struct snd_soc_dai *cpu = snd_soc_rtd_to_cpu(rtd, 0);
+	/* first codec on INT0_MI2S_RX must be the analog codec */
+	struct snd_soc_dai *codec = snd_soc_rtd_to_codec(rtd, 0);
+	struct snd_jack *jack;
+	int ret;
+
+	if (!data->jack_setup) {
+		/* headset buttons not tested */
+		ret = snd_soc_card_jack_new(card, "Headset Jack",
+					    SND_JACK_HEADSET | SND_JACK_BTN_0
+					  | SND_JACK_BTN_1 | SND_JACK_BTN_2
+					  | SND_JACK_BTN_3 | SND_JACK_BTN_4,
+					    &data->jack);
+		if (ret < 0) {
+			dev_err(card->dev, "could not create headset jack\n");
+			return ret;
+		}
+
+		data->jack_setup = true;
+	}
+
+	switch (cpu->id) {
+	case INT0_MI2S_RX:
+		jack = data->jack.jack;
+
+		jack->private_data = codec->component;
+		jack->private_free = sdm660_int_jack_free;
+
+		ret = snd_soc_component_set_jack(codec->component,
+						 &data->jack,
+						 NULL);
+		if (ret < 0) {
+			dev_err(card->dev, "could not set headset jack\n");

sound/soc/qcom/sdm660-internal.c line 197

Quoted 10 lines
sound/soc/qcom/sdm660-internal.c new file +10 -0
+			return ret;
+		}
+
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}

looks like common.c has something pretty much identicaly, can you not use it or make it usable?

Quoted 9 lines
sound/soc/qcom/sdm660-internal.c new file +9 -0
+
+static void snd_sdm660_int_add_ops(struct snd_soc_card *card)
+{
+	struct snd_soc_dai_link *link;
+	int i;
+
+	for_each_card_prelinks(card, i, link) {
+		if (link->no_pcm == 1) {
+			link->ops = &sdm660_int_ops;

sound/soc/qcom/sdm660-internal.c line 216

Quoted 10 lines
sound/soc/qcom/sdm660-internal.c new file +10 -0
+			link->be_hw_params_fixup = sdm660_int_be_hw_params_fixup;
+		}
+
+		link->init = sdm660_int_dai_init;
+	}
+}
+
+static const struct snd_soc_dapm_widget snd_sdm660_int_dapm_widgets[] = {
+};
+

??

Quoted 25 lines
sound/soc/qcom/sdm660-internal.c new file +25 -0
+static int snd_sdm660_int_probe(struct platform_device *pdev)
+{
+	struct snd_soc_card *card;
+	struct sdm660_int_snd_data *data;
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	card = devm_kzalloc(dev, sizeof(struct snd_soc_card), GFP_KERNEL);
+	if (!card)
+		return -ENOMEM;
+
+	data = devm_kzalloc(dev, sizeof(struct sdm660_int_snd_data), GFP_KERNEL);
+	if (!card)
+		return -ENOMEM;
+
+	card->driver_name = "sdm660-internal";
+	card->dapm_widgets = snd_sdm660_int_dapm_widgets;
+	card->num_dapm_widgets = ARRAY_SIZE(snd_sdm660_int_dapm_widgets);
+	card->dev = dev;
+	card->owner = THIS_MODULE;
+
+	ret = qcom_snd_parse_of(card);
+	if (ret)
+		return ret;
+

sound/soc/qcom/sdm660-internal.c line 251

Quoted 10 lines
sound/soc/qcom/sdm660-internal.c new file +10 -0
+	snd_soc_card_set_drvdata(card, data);
+
+	snd_sdm660_int_add_ops(card);
+
+	return devm_snd_soc_register_card(dev, card);
+}
+
+static void snd_sdm660_int_remove(struct platform_device *pdev)
+{
+}

Why do we need this empty function.

Quoted 20 lines
sound/soc/qcom/sdm660-internal.c new file +20 -0
+
+static const struct of_device_id snd_sdm660_int_device_id[] = {
+	{ .compatible = "qcom,sdm660-internal-sndcard", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, snd_sdm660_int_device_id);
+
+static struct platform_driver snd_sdm660_int_driver = {
+	.probe = snd_sdm660_int_probe,
+	.remove = snd_sdm660_int_remove,
+	.driver = {
+		.name = "sdm660-int-sndcard",
+		.of_match_table = snd_sdm660_int_device_id,
+		.pm = &snd_soc_pm_ops,
+	},
+};
+module_platform_driver(snd_sdm660_int_driver);
+
+MODULE_DESCRIPTION("sdm660 Internal ASoC Machine Driver");
+MODULE_LICENSE("GPL");
#24 lore raw

Re: [PATCH 09/10] ASoC: qcom: add sdm660 internal sound card support

Quoted 1 line · Srinivas Kandagatla

On 2/11/26 2:03 AM, Richard Acayan wrote:

(snip)

Quoted 7 lines
Quoted 7 lines
sound/soc/qcom/sdm660-internal.c new file +7 -0
+	case INT0_MI2S_RX:
+		data->int0_mi2s_clk_count++;
+		if (data->int0_mi2s_clk_count == 1)
+			snd_soc_dai_set_sysclk(cpu,
+				Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
+				MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+
Quoted 8 lines

sound/soc/qcom/sdm660-internal.c line 51

Quoted 4 lines
sound/soc/qcom/sdm660-internal.c new file +4 -0
+		/*
+		 * Downstream specifies that the AFE is a clock consumer, but
+		 * the sound is distorted (loud on the right channel and sped
+		 * up) unless we set it as a producer.

This comment does not make any value, Who is driving the bit clk and frame clock is totally depended on the hw setup on the platform, Driving incorrect clock would lead to such issues. Does the codec drive on the platform that you are testing?

I dug into the downstream Q6AFE driver a bit more. It actually inverts the logic and specifies that the codec is a clock consumer (instead of taking Q6AFE's perspective), so it is equivalent to setting SND_SOC_DAIFMT_CBP_CFP.

Downstream (https://android.googlesource.com/kernel/msm-extra/+/530cffa4cc977a348753831b163eb9d3302b954a/asoc/msm-dai-q6-v2.c#4347):

	case SND_SOC_DAIFMT_CBS_CFS:
		mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
		mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
		break;

Mainline (sound/soc/qcom/q6afe.c):

	#define AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL	0x1
	...
	case SND_SOC_DAIFMT_BP_FP:
		pcfg->i2s_cfg.ws_src = AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL;
		break;

I don't think the downstream code needs to be explained so I would simply drop these code comments.

Quoted 2 lines
Quoted 2 lines
(quoted diff) +2 -0
+		 */
+		snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBP_CFP);
#25 lore raw

PATCH 10/10 ASoC: msm8916-wcd-analog: add quirk for cajon 2.0

In reply to Richard Acayan

The codec version CAJON_2_0 on the Snapdragon 670 requires touching the HPH test registers. Add the quirk so this driver can also support SDM670.

---
 sound/soc/codecs/msm8916-wcd-analog.c | 63 ++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 2 deletions(-)
sound/soc/codecs/msm8916-wcd-analog.c +61 -2
index 9ca381812975..6fe111e6d686 100644
@@ -217,9 +217,11 @@
 #define CDC_A_RX_HPH_BIAS_LDO_OCP	(0xf195)
 #define CDC_A_RX_HPH_BIAS_CNP		(0xf196)
 #define CDC_A_RX_HPH_CNP_EN		(0xf197)
+#define CDC_A_RX_HPH_L_TEST		(0xf19A)
 #define CDC_A_RX_HPH_L_PA_DAC_CTL	(0xf19B)
 #define RX_HPA_L_PA_DAC_CTL_DATA_RESET_MASK	BIT(1)
 #define RX_HPA_L_PA_DAC_CTL_DATA_RESET_RESET	BIT(1)
+#define CDC_A_RX_HPH_R_TEST		(0xf19C)
 #define CDC_A_RX_HPH_R_PA_DAC_CTL	(0xf19D)
 #define RX_HPH_R_PA_DAC_CTL_DATA_RESET	BIT(1)
 #define RX_HPH_R_PA_DAC_CTL_DATA_RESET_MASK BIT(1)
@@ -696,6 +698,59 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
 	return 0;
 }
 
+static int pm8916_wcd_analog_enable_hphl_pa(struct snd_soc_dapm_widget *w,
+					    struct snd_kcontrol *kcontrol,
+					    int event)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev);
+
+	/* This quirk is not required for revisions prior to CAJON_2_0 */
+	if (priv->codec_version < 4)
+		return 0;
+
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:
+		usleep_range(7000, 7100);
+		snd_soc_component_update_bits(component, CDC_A_RX_HPH_L_TEST,
+				0x04, 0x04);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		/* wait 20 ms after the digital codec has powered down */
+		msleep(20);
+		snd_soc_component_update_bits(component, CDC_A_RX_HPH_L_TEST,
+				0x04, 0x00);
+		break;
+	}
+	return 0;
+}
+
+static int pm8916_wcd_analog_enable_hphr_pa(struct snd_soc_dapm_widget *w,
+					    struct snd_kcontrol *kcontrol,
+					    int event)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev);
+
+	/* This quirk is not required for revisions prior to CAJON_2_0 */
+	if (priv->codec_version < 4)
+		return 0;
+
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:
+		usleep_range(7000, 7100);
+		snd_soc_component_update_bits(component, CDC_A_RX_HPH_R_TEST,
+				0x04, 0x04);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		msleep(20);
+		snd_soc_component_update_bits(component, CDC_A_RX_HPH_R_TEST,
+				0x04, 0x00);
+		break;
+	}
+	return 0;
+}
+
 static const struct reg_default wcd_reg_defaults_2_0[] = {
 	{CDC_A_RX_COM_OCP_CTL, 0xD1},
 	{CDC_A_RX_COM_OCP_COUNT, 0xFF},
@@ -883,11 +938,15 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = {
 	SND_SOC_DAPM_MUX("EAR_S", SND_SOC_NOPM, 0, 0, &ear_mux),
 	SND_SOC_DAPM_SUPPLY("EAR CP", CDC_A_NCP_EN, 4, 0, NULL, 0),
 
-	SND_SOC_DAPM_PGA("HPHL PA", CDC_A_RX_HPH_CNP_EN, 5, 0, NULL, 0),
+	SND_SOC_DAPM_PGA_E("HPHL PA", CDC_A_RX_HPH_CNP_EN, 5, 0, NULL, 0,
+			   pm8916_wcd_analog_enable_hphl_pa,
+			   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 	SND_SOC_DAPM_MUX("HPHL", SND_SOC_NOPM, 0, 0, &hphl_mux),
 	SND_SOC_DAPM_MIXER("HPHL DAC", CDC_A_RX_HPH_L_PA_DAC_CTL, 3, 0, NULL,
 			   0),
-	SND_SOC_DAPM_PGA("HPHR PA", CDC_A_RX_HPH_CNP_EN, 4, 0, NULL, 0),
+	SND_SOC_DAPM_PGA_E("HPHR PA", CDC_A_RX_HPH_CNP_EN, 4, 0, NULL, 0,
+			   pm8916_wcd_analog_enable_hphr_pa,
+			   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 	SND_SOC_DAPM_MUX("HPHR", SND_SOC_NOPM, 0, 0, &hphr_mux),
 	SND_SOC_DAPM_MIXER("HPHR DAC", CDC_A_RX_HPH_R_PA_DAC_CTL, 3, 0, NULL,
 			   0),
Signature · 1 line
2.53.0