The audio ALC5640 can't work on I2S0 and I2C2 for Xaiver NX

Hi,

RT5640 codec probe is not happening because I2C address is wrong in your change.

i2c@3160000 {
status = “okay”;

        rt5640_codec: rt5640_codec@1c {
            compatible = "realtek,rt5640";
            reg = <0x1c>;
            status = "okay";
        };
};

Along with this, you will have to fix DAPM widget routing (nvidia,audio-routing) in the device tree based on the latest RT5640 codec driver. You may refer audio codec 5640 in tx2 (uses older version of codec driver). DAPM widgets name might be different in latest driver. Hope this helps.

Thanks,
Sharad

Hi NV,
amixer.txt (46.2 KB)
dmesg.txt (68.2 KB)
tegra194-audio-se70.dtsi (2.7 KB)
tegra194-se70-common.dtsi (13.8 KB)

Now, we follow the reference to do modification.

Our I2S and tegra_sound DTS setup as the attachments “tegra194-audio-se70.dtsi” and ”tegra194-se70-common.dtsi”.

Dmesg as the attachment “dmesg.txt”

Now, Sound Built-in audio analog output was initialize successfully.

But, test analog output is no function.

How to setup amixer for output sound?

(Jetson Xavier NX Sound card “jetsonxaviernxa” amixer as the attachment amixer.txt)

Thanks.

waveform
Upload the audio waveform
Yellow: MCLK (12.288MHz)
Green: LRCK (No signal)
Blue: SDOUT (No signal)

[ 5.617181] tegra-asoc: sound: ASoC: no source widget found for x OUT
[ 5.617187] tegra-asoc: sound: ASoC: Failed to add route x OUT → direct → x Headphone
[ 5.617217] tegra-asoc: sound: ASoC: no sink widget found for x IN
[ 5.617220] tegra-asoc: sound: ASoC: Failed to add route x Mic → direct → x IN
[ 5.617303] tegra-asoc: sound: ASoC: no source widget found for z OUT

DAMP route needs fixing. Kindly fix that.

As I mentioned in my previous comment, please refer to the codec driver to find correct widget names. You may try below as well:

nvidia,audio-routing =
		"x Headphone",          "x HPOR",
		"x Headphone",          "x HPOL",
		"x Int Spk", 		"SPORP",
 		"x Int Spk", 		"SPORN",
 		"x Int Spk", 		"SPOLP",
 		"x Int Spk", 		"SPOLN",
		"x IN1P",               "x Mic",
		"y Headphone",          "y OUT",
		"y IN",                 "y Mic",
		"z Headphone",          "z OUT",
		"z IN",                 "z Mic",
		"m Headphone",          "m OUT",
		"m IN",                 "m Mic",
		"n Headphone",          "n OUT",
		"n IN",                 "n Mic",
		"o Headphone",          "o OUT",
		"o IN",                 "o Mic",
		"a IN",                 "a Mic",
		"b IN",                 "b Mic",
		"c IN",                 "c Mic",
		"d IN",                 "d Mic",
		"d1 Headphone",         "d1 OUT",

Also this post is bit confusing. Seems like you are using I2S5 and not I2S0.

Kindly refer to the BSP documentation - https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/asoc_driver.19.2.html#wwpID0E03V0HA.

Thanks,
Sharad

20210610.log (66.2 KB)


ALC5640-VB DataSheet_0.91.pdf (3.6 MB)
hardware.tgz (516.4 KB)

nvidia.tgz (25.7 MB)

Hi Sharad,
We checked your comments, but the audio still not work.
Yes, we use I2S5 from SoC view, and I2S0 is the pinout from SoM view (SODIMM net name). Sorry for confuse you!

I upload my configurations and dmesg and hardware design, please kindly help to check for us.
Our L4T Sources download from

Then decompress public_sources.tbz2 as below path: public_sources/Linux_for_Tegra/source/public

Hardware folder is attached as Hardware.tgz (DTS)
kernel/nvidia folder is attached as Nvidia.tgz (C Code)
for your check.

SE70 Audio Schematics is alc5640.png and jetsonnx.png
ALC5640 datasheet is ALC5640-VB DataSheet_0.91.pdf

Thanks.

Hi lcc0610,

DAPM widget names are not correct, many errors reported in attached log.
Jeston NX + audio Codec RT5640 cant work Can you please refer to this query and fix DAPM widgets.

Also attach RT5640 codec driver here.

Thanks,
Sharad

Kindly fix few obvious errors in the code :

--- tegra194-audio-se70_org.dtsi        2021-06-09 07:25:11.000000000 +0530
+++ tegra194-audio-se70.dtsi    2021-06-15 16:20:31.522839499 +0530
@@ -51,27 +51,13 @@
                nvidia,audio-routing =
                        "x Headphone",          "x HPOR",
                        "x Headphone",          "x HPOL",
-                       "x Int Spk",          "SPORP",
-                       "x Int Spk",          "SPORN",
-                       "x Int Spk",          "SPOLP",
-                       "x Int Spk",          "SPOLN",
+                       "x Int Spk",          "x SPORP",
+                       "x Int Spk",          "x SPORN",
+                       "x Int Spk",          "x SPOLP",
+                       "x Int Spk",          "x SPOLN",
                        "x IN1P",               "x Mic",
                        "n Headphone",          "n OUT",
@@ -84,7 +70,7 @@
                        cpu-dai = <&tegra_i2s5>;
                        codec-dai = <&rt5640_codec>;
                        cpu-dai-name = "I2S5";
-                       codec-dai-name = "rt5640_codec";
+                       codec-dai-name = "rt5640-aif1";
                        format = "i2s";
                        bitclock-slave;
                        frame-slave;

Please attach RT5640 codec driver and dmesg log after making above modification.

20210616.log (65.1 KB)
rt5640.c (79.1 KB)
rt5640.h (72.7 KB)
tegra194-audio-se70.dtsi (2.8 KB)

Hi Sharad,
We fixed the errors that you mentioned, but audio still no function.I attached RT5640 codec driver and dmesg log for your check again. Thank you!

Hi lcc0610,
Can you try with the fixes applied on the attached dtsi file.
tegra194-audio-se70.dtsi (2.2 KB)

20210616-2.log (62.6 KB)
Hi mkumard,
I tried the dtsi file but audio still no work. Attached dmesg file for check. Thank you!

Hi lcc0610,
The Widget routing issue is still not resolved from the log.

Can you please override with the below audio routing entries in the dtsi file and check again.

		nvidia,audio-routing =
						"x Headphone", "x HPOR",
						"x Headphone", "x HPOL",
						"x Int Spk", "x SPORP",
						"x Int Spk", "x SPORN",
						"x Int Spk", "x SPOLP",
						"x Int Spk", "x SPOLN",
						"x IN1P", "x Mic",
						"y Headphone", "y OUT",
						"y IN", "y Mic";

Please attach dmesg and output dump of command " amixer -c 1"

20210617.log (62.1 KB)
20210617-amixer.log (235.0 KB)
tegra194-audio-se70.dtsi (2.3 KB)
Hi mkumard,
After made these changes, we can see widget router for RT5640 in the system. But it seems no audio output. How cloud we check the audio and speaker functions work? Thank you!

Hi lcc0610,
That’s great news to hear.

The no audio issue would be related to not setting right mixer controls for the codec playback. Can you please provide the details on mixer controls set before the playback.

Please provide output of command " amixer -c 1 controls"

20210617-amixer-ctrl.log (52.7 KB)
Hi mkumard,
This is the log for command " amixer -c 1 controls". Thanks for your help!

Hi lcc0610,
Can you give a try by setting below commands before starting the playback.

#For speaker playback
      amixer -c 1 cset name="x Stereo DAC MIXL DAC L1 Switch" "1"
      amixer -c 1 cset name="x Stereo DAC MIXR DAC R1 Switch" "1"
      amixer -c 1 cset name="x Speaker L Playback Switch" "1"
      amixer -c 1 cset name="x Speaker R Playback Switch" "1"
      amixer -c 1 cset name="x SPOL MIX SPKVOL L Switch" "1"
      amixer -c 1 cset name="x SPOR MIX SPKVOL R Switch" "1"
      amixer -c 1 cset name="x SPOL MIX DAC L1 Switch" "1"
      amixer -c 1 cset name="x SPOR MIX DAC R1 Switch" "1"
      amixer -c 1 cset name="x Speaker Playback Volume" "0x20"

#For headphone playback
      amixer -c 1 cset name="x Stereo DAC MIXL DAC L1 Switch" "1"
      amixer -c 1 cset name="x Stereo DAC MIXR DAC R1 Switch" "1"
      amixer -c 1 cset name="x HPO MIX HPVOL Switch" "1"
      amixer -c 1 cset name="x HP L Playback Switch" "1"
      amixer -c 1 cset name="x HP R Playback Switch" "1"
      amixer -c 1 cset name="x HPO MIX DAC1 Switch" "1"
      amixer -c 1 cset name="x HP Playback Volume" "0x20"

Hi mkumard,
Good news, we try these commands let headphone can play voice now. And we would find a speaker for try also.
Please also adive how to check input micphone? Thank you!

Hi lcc0610,
From the mixer controls details shared for codec, We are seeing below control might help in Mic capture. Please give a try with it.

amixer -c 1 cset name="x RECMIXL BST1 Switch" "1"
amixer -c 1 cset name="x RECMIXR BST1 Switch" "1"
amixer -c 1 cset name="x Stereo ADC MIXL ADC1 Switch" "1"
amixer -c 1 cset name="x Stereo ADC MIXR ADC1 Switch" "1"

20210617-mic.log (83.7 KB)

Hi mkumard,
We try to recording voice from the microphone, but play the record file no hear any voice. Please help! I attached the dmesg and terminal also.

Hi lcc0610,
The log file has the below errors which points to playing or capturing at unsupported sampling rate for codec. Can you try with 48000 Hz sampling rate for Playback and Capture.

[ 823.323434] rt5640 0-001c: Unsupported clock setting 44100 for DAI 0
[ 823.323582] rt5640 0-001c: ASoC: can’t set rt5640-aif1 hw params: -22
[ 823.323697] tegra-asoc: sound: ASoC: PRE_PMU: I2S5 DAP Transmit-x AIF1 Playback event failed: -22

Also please make sure to set mixer controls for both Playback and Capture provided earlier.

Looking at your terminal snap shot, shows the arecord is performed at 48KHz, but the log file pointing to different errors. Can you provide us the dmesg log again after the reboot and usecase execution.

20210617-arecord.log (67.6 KB)
20210617-boot.log (67.2 KB)
20210617-csetamixer.log (67.4 KB)

Hi mkumard,
20210617-boot.log after reboot
20210617-csetamixer.log after cset
20210617-arecord.log after arecord.log