Sample code for 3rd I2S audio codec which is succesfully integrated on Orin Nano/NX platform

Hi NV team,
Do you have sample code for I2S audio codec that is succesfully integrated on Orin Nano/NX?
Our SW team is frustrated when dealing with 3rd party I2S audio codec: Realtek ALC5616 on Orin Nano, and we are currently seaking technical help from Realtek one side , but it sounds that we need both NVIDIA team and Realtek for co-tuning ALC5616, so do you have some technical engineer contact window for that tuning issue, i am very aprreciated if you may provide related engineer email window for technical discussion, thanks.

Jasper
20241023

Hi Jasperni,
You are at right place. We are happy to help your team to resolve the issue.

Before we can provide some valuable feedback or solution, would like to know couple of details from your side.

  1. Jetpack version used
  2. Where are you exactly stuck in the RT5616 integration flow for e.g is it code integration or no sound issue or any other. Please provide specific info here
  3. Attach the files (DT and driver) changed to support RT5616
  4. Kernel log
  5. cat /sys/kernel/debug/asoc/components
  6. zcat /proc/config.gz | grep 5616
  7. cat /proc/asound/cards

Hi mkumard,
thanks for your prompt response!

Our SW engineer will provide related information for your team’s deep analysis.

Here first provide related HW design schematic if you need your HW engineer to check first. we use I2C2 to communicate with ALC5616(rt5616), and its ok for I2C2 recoginition.

ALC5616-schematic.pdf (201.8 KB)

Jasper
20241023

Hi Jasperni,
As you mentioned I2C2 recognition is successful. I believe for SW Sound Card registration this should be good. Let me wait for your SW engineer on the details asked in my first comment.

Hi, mkumard,
Thank you very much for helping us.

1.Jetpack5.1.3(Jetson Linux 35.5)
2.The current issue is that the sound card is playing without any sound.
I executed the following command

amixer -c1 cset name=“I2S2 Mux” “ADMAIF2”
amixer -c1 cset name=‘DAC MIXL INF1 Switch’ 1
amixer -c1 cset name=‘DAC MIXR INF1 Switch’ 1
amixer -c1 cset name=‘Stereo DAC MIXL DAC L1 Switch’ 1
amixer -c1 cset name=‘Stereo DAC MIXR DAC R1 Switch’ 1
amixer -c1 cset name=‘HPO MIX DAC1 Switch’ 1
amixer -c1 cset name=‘HP Playback Volume’ 39
speaker-test -D hw:APE,0 -r 48000 -c 1 -F S32_LE -t sine -f 1000

If it is APE.0, the playback will be fast and there will be no sound. If it is APE.1, the speed is normal but there is still no sound.

root@tegra-ubuntu:/home/blakesu# speaker-test -D hw:APE,0 -r 48000 -c 1 -F S32_LE -t sine -f 1000

speaker-test 1.2.2

Playback device is hw:APE,0
Stream parameters are 48000Hz, S32_LE, 1 channels
Sine wave rate is 1000.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 8192
Period size range from 32 to 4096
Using max buffer size 8192
Periods = 4
was set period_size = 2048
was set buffer_size = 8192
0 - Front Left
Time per period = 0.053350
0 - Front Left
Time per period = 0.056119
0 - Front Left
Time per period = 0.056134
0 - Front Left
Time per period = 0.056135
0 - Front Left
^CTime per period = 0.009699
root@tegra-ubuntu:/home/blakesu# cat /sys/kernel/debug/tracing/trace_pipe | grep *
speaker-test-3601 [001] … 5558.352488: snd_soc_dapm_path: *ADMAIF1 XBAR-Playback ← (direct) ← tegra-dlink-44-playback
speaker-test-3601 [001] … 5558.352490: snd_soc_dapm_path: *ADMAIF1 XBAR-Playback ← (direct) ← ADMAIF1 Playback
^C
root@tegra-ubuntu:/home/blakesu#
root@tegra-ubuntu:/home/blakesu# speaker-test -D hw:APE,1 -r 48000 -c 1 -F S32_LE -t sine -f 1000
speaker-test 1.2.2

Playback device is hw:APE,1
Stream parameters are 48000Hz, S32_LE, 1 channels
Sine wave rate is 1000.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 8192
Period size range from 32 to 4096
Using max buffer size 8192
Periods = 4
was set period_size = 2048
was set buffer_size = 8192
0 - Front Left
^CTime per period = 0.312262
root@tegra-ubuntu:/home/blakesu# cat /sys/kernel/debug/tracing/trace_pipe | grep *
speaker-test-3605 [002] … 5622.331573: snd_soc_dapm_path: *ADMAIF2 XBAR-RX ← (direct) ← ADMAIF2 XBAR-Playback
speaker-test-3605 [002] … 5622.331631: snd_soc_dapm_path: *I2S4 Mux ← ADMAIF2 ← ADMAIF2 XBAR-RX
speaker-test-3605 [002] … 5622.331658: snd_soc_dapm_path: *I2S2 Mux ← ADMAIF2 ← ADMAIF2 XBAR-RX
speaker-test-3605 [002] … 5622.331658: snd_soc_dapm_path: *I2S4 XBAR-TX ← (direct) ← I2S4 Mux
speaker-test-3605 [002] … 5622.331659: snd_soc_dapm_path: *I2S4 XBAR-Capture ← (direct) ← I2S4 XBAR-TX
speaker-test-3605 [002] … 5622.331660: snd_soc_dapm_path: *tegra-dlink-67-playback ← (direct) ← I2S4 XBAR-Capture
speaker-test-3605 [002] … 5622.331662: snd_soc_dapm_path: *I2S4 CIF-Playback ← (direct) ← tegra-dlink-67-playback
speaker-test-3605 [002] … 5622.331663: snd_soc_dapm_path: *I2S4 RX ← (direct) ← I2S4 CIF-Playback
speaker-test-3605 [002] … 5622.331664: snd_soc_dapm_path: *I2S4 DAP-Capture ← (direct) ← I2S4 RX
speaker-test-3605 [002] … 5622.331665: snd_soc_dapm_path: *tegra-dlink-79-playback ← (direct) ← I2S4 DAP-Capture
speaker-test-3605 [002] … 5622.331666: snd_soc_dapm_path: *I2S4 Dummy-Playback ← (direct) ← tegra-dlink-79-playback
speaker-test-3605 [002] … 5622.331667: snd_soc_dapm_path: *I2S4 SPK ← (direct) ← I2S4 Dummy-Playback
speaker-test-3605 [003] … 5622.646820: snd_soc_dapm_path: *ADMAIF2 XBAR-Playback ← (direct) ← tegra-dlink-45-playback
speaker-test-3605 [003] … 5622.646822: snd_soc_dapm_path: *ADMAIF2 XBAR-Playback ← (direct) ← ADMAIF2 Playback
speaker-test-3605 [003] … 5622.646824: snd_soc_dapm_path: *ADMAIF2 XBAR-RX ← (direct) ← ADMAIF2 XBAR-Playback
speaker-test-3605 [003] … 5622.646888: snd_soc_dapm_path: *I2S4 Mux ← ADMAIF2 ← ADMAIF2 XBAR-RX
speaker-test-3605 [003] … 5622.646891: snd_soc_dapm_path: *I2S4 XBAR-TX ← (direct) ← I2S4 Mux
speaker-test-3605 [003] … 5622.646893: snd_soc_dapm_path: *I2S4 XBAR-Capture ← (direct) ← I2S4 XBAR-TX
speaker-test-3605 [003] … 5622.646895: snd_soc_dapm_path: *tegra-dlink-67-playback ← (direct) ← I2S4 XBAR-Capture
speaker-test-3605 [003] … 5622.646896: snd_soc_dapm_path: *I2S4 CIF-Playback ← (direct) ← tegra-dlink-67-playback
speaker-test-3605 [003] … 5622.646898: snd_soc_dapm_path: *I2S4 RX ← (direct) ← I2S4 CIF-Playback
speaker-test-3605 [003] … 5622.646900: snd_soc_dapm_path: *I2S4 DAP-Capture ← (direct) ← I2S4 RX
speaker-test-3605 [003] … 5622.646901: snd_soc_dapm_path: *tegra-dlink-79-playback ← (direct) ← I2S4 DAP-Capture
speaker-test-3605 [003] … 5622.646902: snd_soc_dapm_path: *I2S4 Dummy-Playback ← (direct) ← tegra-dlink-79-playback
speaker-test-3605 [003] … 5622.646904: snd_soc_dapm_path: *I2S4 SPK ← (direct) ← I2S4 Dummy-Playback
^C

3.I have modified the following files, do I need to modify any other files?
tegra234-p3767-common-audio.dtsi.log (7.9 KB)
tegra234-soc-i2c.dtsi.txt (8.5 KB)
rt5616.c.log (41.1 KB)
4. Kernel log
dmesg.log (65.5 KB)
5.cat /sys/kernel/debug/asoc/component
components.log (879 Bytes)
6. zcat /proc/config.gz | grep 5616
config.log (24 Bytes)
7. cat /proc/asound/cards
cards.log (241 Bytes)

Hi mkumard,

Added our custom carrier board hw info: firstly we still not got right GPIO09_I2S0_MCLK(around 11.29MHz)/I2S0_SCLK(1.41MHz)/I2S0_LRCLK(44.1KHz)clocks,so I think some SW configuration must be ignored here.

Thanks for your kind help.

Jasper
20241023

Hi,
Thanks for the information. Here is the findings.

  1. Sound card registration is completed. So we are good from driver integration perspective.

amixer -c1 cset name=“I2S2 Mux” “ADMAIFx”

For “speaker-test -D hw:APE,n” , where n is always (x-1), as you have connected ADMAIF2, the right command to use is “speaker-test -D hw:APE,1 <>”

  1. Am suspecting DAPM path issue, as I don’t see nvidia-audio-card,widgets and nvidia-audio-card,routing property added in the DT file for sound node

Please take the modified file for couple of fix in DT
tegra234-soc-i2c.dtsi.txt (8.6 KB)
tegra234-p3767-common-audio.dtsi.log (8.6 KB)

  1. For enabling I2S2 Pinmux, I noticed you have added below entry which is not actually required.

pinctrl-names = default;
pinctrl-0 = <&hdr40_pinmux>;

Please refer Configuring the Jetson Expansion Headers — Jetson Linux Developer Guide documentation which can help you to enable I2S2 pinmux using Jetson-IO tool.

Please confirm with all this changes you could be able to probe I2S2 signals out of 40 Pin header

Note: With my change the Codec mixer controls would be prefixed with CVB-RT, So please take care while executing the route path with mixer controls before running usecase

Hi Jasper,
I noticed similar query created from your team member [2639376969] @ Codec - Jetson & Embedded Systems / Jetson Orin Nano - NVIDIA Developer Forums

If this is true, would you help to close it as we are already tracking here. So, this would avoid duplicate tracking.

Hi mkumard

OK, we will close @ Codec - Jetson & Embedded Systems / Jetson Orin Nano - NVIDIA Developer Forums tomorrow

jasper
20241023

Hi, mkumard,
Thank you for providing the modification information, After following your modifications, the current situation is as follows:

root@tegra-ubuntu:/home/blakesu# speaker-test -D hw:APE,1 -r 48000 -c 1 -F S32_LE -t sine -f 1000

speaker-test 1.2.2

Playback device is hw:APE,1
Stream parameters are 48000Hz, S32_LE, 1 channels
Sine wave rate is 1000.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 8192
Period size range from 32 to 4096
Using max buffer size 8192
Periods = 4
[ 59.969235] rt5616 0-001b: rt5616: Unsupported clock setting
[ 59.975101] rt5616 0-001b: ASoC: error at snd_soc_dai_hw_params on rt5616-aif1: -22
[ 59.983033] tegra-asoc: sound: ASoC: PRE_PMU: rt5616-playback-playback event failed: -22
was set period_size = 2048
was set buffer_size = 8192
0 - Front Left
Time per period = 1.407275
0 - Front Left
Time per period = 1.493434
0 - Front Left
^CTime per period = 0.339604

root@tegra-ubuntu:/home/blakesu# dmesg | grep 5616
[ 6.561672] iommu_context_dev 13e40000.host1x:niso1_ctx3: initialized (streamid=56, iommu=smmu.0x0000000008000000)
[ 7.401437] RT5616_DEVICE_ID: 0x6281
[ 12.636759] rt5616: enter rt5616_probe
[ 12.636778] rt5616: exit rt5616_probe
[ 59.969220] rt5616: enter rt5616_hw_params
[ 59.969228] rt5616: rt5616->sysclk: 0
[ 59.969230] rt5616: rt5616->sysclk: 48000
[ 59.969235] rt5616 0-001b: rt5616: Unsupported clock setting
[ 59.975101] rt5616 0-001b: ASoC: error at snd_soc_dai_hw_params on rt5616-aif1: -22
[ 59.983033] tegra-asoc: sound: ASoC: PRE_PMU: rt5616-playback-playback event failed: -22

It seems that the clock has not been paired yet. Where can I modify the clock?
Here is the file I have modified:
tegra234-mb1-bct-pinmux-p3767-dp-a03.dtsi.log (65.8 KB)
tegra234-p3767-common-audio.dtsi.log (8.8 KB)
tegra234-soc-i2c.dtsi.log (8.5 KB)
dmesg.log (66.0 KB)

Hi,
I believe the codec sysclk configuration is missing in the machine driver.

Can you provide the output of below command
cat /sys/kernel/debug/clk/clk_summary

Also, we need to make sure we set right cock rate with snd_soc_dai_set_sysclk(), Please check the other codec support under kernel/sound/soc/tegra/tegra_codecs.c , can you try adding similar callback for RT5616

you can attach the change file if you already have same.

Hi, mkumard,
There are no errors in the execution now, but there is still no sound.
We measured GPIO09_S2S0-MCLK to be 12.28MHz, but I2S0_LRCK and I2S0_SCLK did not measure the signal。
tegra_codecs.c.log (7.4 KB)
tegra234-mb1-bct-pinmux-p3767-dp-a03.dtsi.log (65.8 KB)
tegra234-p3767-common-audio.dtsi.log (8.7 KB)

This is my Pimmux configuration:
pinconf-groups.log (39.3 KB)

root@tegra-ubuntu:/sys/kernel/debug/regmap/0-001b# speaker-test -D hw:APE,1 -r 44100 -c 1 -F S16_LE -t sine -f 1000

speaker-test 1.2.2

Playback device is hw:APE,1
Stream parameters are 44100Hz, S16_LE, 1 channels
Sine wave rate is 1000.0000Hz
Rate set to 44100Hz (requested 44100Hz)
Buffer size range from 64 to 16384
Period size range from 64 to 8192
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
0 - Front Left
Time per period = 1.299463
0 - Front Left
^CTime per period = 0.526450

root@tegra-ubuntu:/sys/kernel/debug/asoc/NVIDIA Jetson Orin nano APE# grep -rns ‘On’
290e400.arad/dapm/Lane6 SIG:1:Lane6 SIG: On in 1 out 0
290e400.arad/dapm/Lane5 SIG:1:Lane5 SIG: On in 1 out 0
290e400.arad/dapm/Lane4 SIG:1:Lane4 SIG: On in 1 out 0
290e400.arad/dapm/Lane3 SIG:1:Lane3 SIG: On in 1 out 0
290e400.arad/dapm/Lane2 SIG:1:Lane2 SIG: On in 1 out 0
290e400.arad/dapm/Lane1 SIG:1:Lane1 SIG: On in 1 out 0
rt5616.0-001b/dapm/CVB-RT AIF1 Playback:1:CVB-RT AIF1 Playback: On in 1 out 8
rt5616.0-001b/dapm/CVB-RT HPOR:1:CVB-RT HPOR: On in 4 out 1
rt5616.0-001b/dapm/CVB-RT HPOL:1:CVB-RT HPOL: On in 4 out 1
rt5616.0-001b/dapm/CVB-RT Charge Pump:1:CVB-RT Charge Pump: On in 0 out 0
rt5616.0-001b/dapm/CVB-RT HP amp:1:CVB-RT HP amp: On in 4 out 2
rt5616.0-001b/dapm/CVB-RT HPO MIX:1:CVB-RT HPO MIX: On in 4 out 2
rt5616.0-001b/dapm/CVB-RT DAC 1:1:CVB-RT DAC 1: On in 4 out 2
rt5616.0-001b/dapm/CVB-RT DAC R1:1:CVB-RT DAC R1: On in 2 out 2 - R97(0x61) mask 0x800
rt5616.0-001b/dapm/CVB-RT DAC L1:1:CVB-RT DAC L1: On in 2 out 2 - R97(0x61) mask 0x1000
rt5616.0-001b/dapm/CVB-RT Stereo DAC MIXR:1:CVB-RT Stereo DAC MIXR: On in 2 out 2
rt5616.0-001b/dapm/CVB-RT Stereo DAC MIXL:1:CVB-RT Stereo DAC MIXL: On in 2 out 2
rt5616.0-001b/dapm/CVB-RT Stero1 DAC Power:1:CVB-RT Stero1 DAC Power: On in 0 out 0 - R98(0x62) mask 0x800
rt5616.0-001b/dapm/CVB-RT DAC MIXR:1:CVB-RT DAC MIXR: On in 1 out 4
rt5616.0-001b/dapm/CVB-RT DAC MIXL:1:CVB-RT DAC MIXL: On in 1 out 4
rt5616.0-001b/dapm/CVB-RT Audio DSP:1:CVB-RT Audio DSP: On in 2 out 4
rt5616.0-001b/dapm/CVB-RT AIF1RX:1:CVB-RT AIF1RX: On in 1 out 8
rt5616.0-001b/dapm/CVB-RT IF1 DAC1 R:1:CVB-RT IF1 DAC1 R: On in 1 out 4
rt5616.0-001b/dapm/CVB-RT IF1 DAC1 L:1:CVB-RT IF1 DAC1 L: On in 1 out 4
rt5616.0-001b/dapm/CVB-RT IF1 DAC:1:CVB-RT IF1 DAC: On in 1 out 8
rt5616.0-001b/dapm/CVB-RT I2S1:1:CVB-RT I2S1: On in 0 out 0 - R97(0x61) mask 0x8000
rt5616.0-001b/dapm/bias_level:1:On
2901300.i2s/dapm/I2S4 Dummy-Playback:1:I2S4 Dummy-Playback: On in 1 out 1
2901300.i2s/dapm/I2S4 DAP-Capture:1:I2S4 DAP-Capture: On in 1 out 1
2901300.i2s/dapm/I2S4 CIF-Playback:1:I2S4 CIF-Playback: On in 1 out 1
2901300.i2s/dapm/I2S4 SPK:1:I2S4 SPK: On in 1 out 1
2901300.i2s/dapm/I2S4 RX:1:I2S4 RX: On in 1 out 1 - R0(0x0) mask 0x1
2901300.i2s/dapm/bias_level:1:On
2901100.i2s/dapm/I2S2 DAP-Capture:1:I2S2 DAP-Capture: On in 1 out 8
2901100.i2s/dapm/I2S2 CIF-Playback:1:I2S2 CIF-Playback: On in 1 out 8
2901100.i2s/dapm/I2S2 RX:1:I2S2 RX: On in 1 out 8 - R0(0x0) mask 0x1
2901100.i2s/dapm/bias_level:1:On
2900800.ahub/dapm/I2S4 XBAR-Capture:1:I2S4 XBAR-Capture: On in 1 out 1
2900800.ahub/dapm/I2S2 XBAR-Capture:1:I2S2 XBAR-Capture: On in 1 out 8
2900800.ahub/dapm/ADMAIF2 XBAR-Playback:1:ADMAIF2 XBAR-Playback: On in 1 out 9
2900800.ahub/dapm/I2S4 Mux:1:I2S4 Mux: On in 1 out 1
2900800.ahub/dapm/I2S4 XBAR-TX:1:I2S4 XBAR-TX: On in 1 out 1
2900800.ahub/dapm/I2S2 Mux:1:I2S2 Mux: On in 1 out 8
2900800.ahub/dapm/I2S2 XBAR-TX:1:I2S2 XBAR-TX: On in 1 out 8
2900800.ahub/dapm/ADMAIF2 XBAR-RX:1:ADMAIF2 XBAR-RX: On in 1 out 9
2900800.ahub/dapm/bias_level:1:On
290f000.admaif/dapm/ADMAIF2 Playback:1:ADMAIF2 Playback: On in 1 out 9
290f000.admaif/dapm/bias_level:1:On
dapm/tegra-dlink-79-playback:1:tegra-dlink-79-playback: On in 1 out 1
dapm/rt5616-playback-playback:1:rt5616-playback-playback: On in 1 out 8
dapm/tegra-dlink-67-playback:1:tegra-dlink-67-playback: On in 1 out 1
dapm/tegra-dlink-65-playback:1:tegra-dlink-65-playback: On in 1 out 8
dapm/CVB-RT Headphone Jack:1:CVB-RT Headphone Jack: On in 8 out 1

Hi mkumard,
Thanks for ur technical guidance,the codec runs OK,so i will close this issue,many thanks!

Jasper
202410026

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.