Orin NX wm8904 audio capture dosen't work

Hi,
I have Orin NX 16GB module on our custom carrier board and I’m using wm8904 audio codec connected I2S1.
I check audio in settings->sound GUI.

Output works well with below command.
amixer -c APE cset name=“I2S1 Mux” “ADMAIF1”

I run the commands below for an audio capture test and confirmed that data was loaded on the DAI line with an oscilloscope, but it does not work at all on the GUI.
amixer -c APE cset name=“ADMAIF1 Mux” “I2S1”
amixer -c APE cset name=“WM Capture Switch” on
amixer -c APE cset name=“WM Right Capture Inverting Mux” 1

Using arecord, it dosen’t work.
u@tegra-ubuntu:~$ arecord -D hw:CARD=APE,DEV=0 -c 1 -r 48000 -f S16_LE -d 15 test.wav
Recording WAVE ‘test.wav’ : Signed 16 bit Little Endian, Rate 48000 Hz, Mono test.wav
arecord: pcm_read:2221: read error: Input/output error
u@tegra-ubuntu:~$

Hi,

Please check below items and provide asked inputs to help further

  1. Ensure that I2S1 pinmux is set (especially DIN pin) as record is failing. Refer Jetson Orin NX and Nano Series — NVIDIA Jetson Linux Developer Guide 1 documentation for configuring pinmux
  2. Guessing that DAPM setup for record path may not be complete. Provide DAPM trace by referring documentation at Audio Setup and Development — NVIDIA Jetson Linux Developer Guide 1 documentation

In addition, share dmesg for any other error logs.

Thanks and Regards

Hi,

  1. I think pinmux is set properly. It’s pin configuration result using jetson-io.py
u@tegra-ubuntu:~$ sudo /opt/nvidia/jetson-io/jetson-io.py

 =================== Jetson Expansion Header Tool ===================
 |                                                                    |
 |                                                                    |
 |                      3.3V (  1) .. (  2) 5V                        |
 |                      i2c8 (  3) .. (  4) 5V                        |
 |                      i2c8 (  5) .. (  6) GND                       |
 |                  aud_mclk (  7) .. (  8) uarta                     |
 |                       GND (  9) .. ( 10) uarta                     |
 |                    unused ( 11) .. ( 12) i2s2_sclk                 |
 |                  spi3_sck ( 13) .. ( 14) GND                       |
 |                    unused ( 15) .. ( 16) spi3_cs1                  |
 |                      3.3V ( 17) .. ( 18) spi3_cs0                  |
 |                 spi1_dout ( 19) .. ( 20) GND                       |
 |                  spi1_din ( 21) .. ( 22) spi3_din                  |
 |                  spi1_sck ( 23) .. ( 24) spi1_cs0                  |
 |                       GND ( 25) .. ( 26) spi1_cs1                  |
 |                      i2c2 ( 27) .. ( 28) i2c2                      |
 |                    unused ( 29) .. ( 30) GND                       |
 |                    unused ( 31) .. ( 32) unused                    |
 |                    unused ( 33) .. ( 34) GND                       |
 |                   i2s2_fs ( 35) .. ( 36) unused                    |
 |                 spi3_dout ( 37) .. ( 38) i2s2_din                  |
 |                       GND ( 39) .. ( 40) i2s2_dout                 |
                                                                      |
 |                                                                    |
 |                        Jetson 40pin Header:                        |
 |                                                                    |
 |                 Configure for compatible hardware                  |
 |                   Configure header pins manually                   |
 |                                Back                                |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
 |                                                                    |
  ====================================================================

And read pinmux register of DAI pin(SOC_GPIO43).

u@tegra-ubuntu:~$ sudo busybox devmem 0x02434098
0x00001455
u@tegra-ubuntu:~$
  1. It’s a DAPM tracing result.
root@tegra-ubuntu:/home/u# amixer -c APE cset name="ADMAIF1 Mux" "I2S1"
root@tegra-ubuntu:/home/u# amixer -c APE cset name="WM Capture Switch" on
root@tegra-ubuntu:/home/u# amixer -c APE cset name="WM Right Capture Inverting Mux" 1
root@tegra-ubuntu:/home/u# cat /sys/kernel/debug/tracing/trace_pipe | grep \*
          amixer-5265    [002] .......  2257.259043: snd_soc_dapm_path: *I2S1 XBAR-RX -> I2S1 -> ADMAIF1 Mux
          amixer-5265    [002] .......  2257.259045: snd_soc_dapm_path: *ADMAIF1 Mux -> (direct) -> ADMAIF1 XBAR-TX
          amixer-5265    [002] .......  2257.259046: snd_soc_dapm_path: *ADMAIF1 XBAR-TX -> (direct) -> ADMAIF1 XBAR-Capture
          amixer-5267    [003] .......  2271.118148: snd_soc_dapm_path: *WM IN2R <- (direct) <- WM Mic Jack
          amixer-5267    [003] .......  2271.118150: snd_soc_dapm_path: *WM IN2R -> IN2R -> WM Right Capture Inverting Mux
          amixer-5267    [003] .......  2271.118151: snd_soc_dapm_path: *WM Right Capture Inverting Mux -> Single-Ended -> WM Right Capture Mode
          amixer-5267    [003] .......  2271.118152: snd_soc_dapm_path: *WM Right Capture Mode -> (direct) -> WM Right Capture PGA
          amixer-5267    [003] .......  2271.118153: snd_soc_dapm_path: *WM Right Capture PGA -> (direct) -> WM Right Bypass
          amixer-5267    [003] .......  2271.118153: snd_soc_dapm_path: *WM Right Capture PGA -> (direct) -> WM ADCR
          amixer-5267    [003] .......  2271.118156: snd_soc_dapm_path: *WM ADCR -> Right -> WM AIFOUTR Mux
          amixer-5267    [003] .......  2271.118156: snd_soc_dapm_path: *WM AIFOUTR Mux -> (direct) -> WM AIFOUTR
          amixer-5267    [003] .......  2271.118157: snd_soc_dapm_path: *WM AIFOUTR -> (direct) -> WM Capture
          amixer-5267    [003] .......  2271.118158: snd_soc_dapm_path: *WM Capture -> (direct) -> wm8904-playback-capture
          amixer-5267    [003] .......  2271.118158: snd_soc_dapm_path: *wm8904-playback-capture -> (direct) -> I2S1 DAP-Playback
          amixer-5267    [003] .......  2271.118159: snd_soc_dapm_path: *I2S1 DAP-Playback -> (direct) -> I2S1 TX
          amixer-5267    [003] .......  2271.118159: snd_soc_dapm_path: *I2S1 TX -> (direct) -> I2S1 CIF-Capture
          amixer-5267    [003] .......  2271.118160: snd_soc_dapm_path: *I2S1 CIF-Capture -> (direct) -> tegra-dlink-40-capture
          amixer-5267    [003] .......  2271.118161: snd_soc_dapm_path: *tegra-dlink-40-capture -> (direct) -> I2S1 XBAR-Playback
          amixer-5267    [003] .......  2271.118162: snd_soc_dapm_path: *I2S1 XBAR-Playback -> (direct) -> I2S1 XBAR-RX
          amixer-5267    [003] .......  2271.118164: snd_soc_dapm_path: *WM IN2R -> IN2R -> WM Right Capture Mux
          amixer-5267    [003] .......  2271.118165: snd_soc_dapm_path: *WM Right Capture Inverting Mux <- IN2R <- WM IN2R

I attach a dmesg. There is no error about audio.
dmesg.txt (68.5 KB)

Thanks.

Hi,

Apologies for delayed reply. Could you share the DTS sound node where the audio routes are mentioned

Thanks

Hi,
Sorry for late reply.

Belows are DTS sound node that I modified.

/ {
	bus@0 {

		aconnect@2900000 {
			ahub@2900800 {
-				i2s@2901100 {
+				i2s@2901000 {				
					ports {
						port@1 {
							hdr40_snd_i2s_dap_ep: endpoint {
+								dai-format = "i2s";
+								remote-endpoint = <&wm8904_ep>;
							};
						};
					};
				};
			};
		};

	};

	tegra_sound_graph: tegra_sound: sound {
		compatible = "nvidia,tegra186-audio-graph-card",
			     "nvidia,tegra186-ape";
		clocks = <&bpmp TEGRA234_CLK_PLLA>,
			 <&bpmp TEGRA234_CLK_PLLA_OUT0>,
			 <&bpmp TEGRA234_CLK_AUD_MCLK>;
		clock-names = "pll_a", "plla_out0", "extern1";
		assigned-clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
		assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLA_OUT0>;
+		assigned-clock-rates = <11289600>;

		nvidia-audio-card,name = "NVIDIA Jetson Orin NX APE";

-		hdr40_snd_link_i2s: nvidia-audio-card,dai-link@77 { };
+		hdr40_snd_link_i2s: nvidia-audio-card,dai-link@76 { };
	};
};

+	sound {
+		nvidia-audio-card,widgets =
+			"Headphone",	"WM Headphone Jack",
+			"Microphone",	"WM Mic Jack";
+
+		nvidia-audio-card,routing =
+			"WM Headphone Jack",     "WM HPOUTL",
+			"WM Headphone Jack",     "WM HPOUTR",
+			"WM Mic Jack", "WM MICBIAS",
+			"WM IN2R", "WM Mic Jack";			
+	
+		nvidia-audio-card,dai-link@76 {
+			link-name = "wm8904-playback";
+			bitclock-master;
+		  	frame-master;
+		  	
+			codec {
+				sound-dai = <&wm8904 0>;
+				prefix = "WM";
+			};
+		};
+	};

+		i2c@3160000 {
+			status = "okay";
+			wm8904: wm8904_codec@1a {
+				compatible = "wlf,wm8904";
+				#sound-dai-cells = <1>;
+				status ="okay";
+				reg = <0x1a>;
+				clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
+				clock-frequency = <11289600>;
+				clock-names = "mclk";
+
+				port {
+					wm8904_ep: endpoint {
+						remote-endpoint = <&i2s1_dap>;
+						mclk-fs = <256>;
+						link-name = "wm8904-playback";
+					};
+				};
+			};
+		};

And I have one more question.
How to change default interface from “I2S2” to “I2S1”?
After booting, I checked with the amixer command and found that all playback/capture interfaces set in ADMAIF1 are “I2S2”.

u@tegra-ubuntu:~$ amixer -c APE cget name="ADMAIF1 Mux"
numid=1158,iface=MIXER,name='ADMAIF1 Mux'
  ; type=ENUMERATED,access=rw------,values=1,items=81
  ; Item #0 'None'
  ; Item #1 'ADMAIF1'
  ; Item #2 'ADMAIF2'
  ; Item #3 'ADMAIF3'
  ; Item #4 'ADMAIF4'
  ; Item #5 'ADMAIF5'
  ; Item #6 'ADMAIF6'
  ; Item #7 'ADMAIF7'
  ; Item #8 'ADMAIF8'
  ; Item #9 'ADMAIF9'
  ; Item #10 'ADMAIF10'
  ; Item #11 'ADMAIF11'
  ; Item #12 'ADMAIF12'
  ; Item #13 'ADMAIF13'
  ; Item #14 'ADMAIF14'
  ; Item #15 'ADMAIF15'
  ; Item #16 'ADMAIF16'
  ; Item #17 'I2S1'
  ; Item #18 'I2S2'
  ; Item #19 'I2S3'
  ; Item #20 'I2S4'
  ; Item #21 'I2S5'
  ; Item #22 'I2S6'
  ; Item #23 'SFC1'
  ; Item #24 'SFC2'
  ; Item #25 'SFC3'
  ; Item #26 'SFC4'
  ; Item #27 'MIXER1 TX1'
  ; Item #28 'MIXER1 TX2'
  ; Item #29 'MIXER1 TX3'
  ; Item #30 'MIXER1 TX4'
  ; Item #31 'MIXER1 TX5'
  ; Item #32 'AMX1'
  ; Item #33 'AMX2'
  ; Item #34 'AMX3'
  ; Item #35 'AMX4'
  ; Item #36 'ARAD1'
  ; Item #37 'AFC1'
  ; Item #38 'AFC2'
  ; Item #39 'AFC3'
  ; Item #40 'AFC4'
  ; Item #41 'AFC5'
  ; Item #42 'AFC6'
  ; Item #43 'OPE1'
  ; Item #44 'SPKPROT1'
  ; Item #45 'MVC1'
  ; Item #46 'MVC2'
  ; Item #47 'IQC1-1'
  ; Item #48 'IQC1-2'
  ; Item #49 'IQC2-1'
  ; Item #50 'IQC2-2'
  ; Item #51 'DMIC1'
  ; Item #52 'DMIC2'
  ; Item #53 'DMIC3'
  ; Item #54 'DMIC4'
  ; Item #55 'ADX1 TX1'
  ; Item #56 'ADX1 TX2'
  ; Item #57 'ADX1 TX3'
  ; Item #58 'ADX1 TX4'
  ; Item #59 'ADX2 TX1'
  ; Item #60 'ADX2 TX2'
  ; Item #61 'ADX2 TX3'
  ; Item #62 'ADX2 TX4'
  ; Item #63 'ADX3 TX1'
  ; Item #64 'ADX3 TX2'
  ; Item #65 'ADX3 TX3'
  ; Item #66 'ADX3 TX4'
  ; Item #67 'ADX4 TX1'
  ; Item #68 'ADX4 TX2'
  ; Item #69 'ADX4 TX3'
  ; Item #70 'ADX4 TX4'
  ; Item #71 'ADMAIF17'
  ; Item #72 'ADMAIF18'
  ; Item #73 'ADMAIF19'
  ; Item #74 'ADMAIF20'
  ; Item #75 'ASRC1 TX1'
  ; Item #76 'ASRC1 TX2'
  ; Item #77 'ASRC1 TX3'
  ; Item #78 'ASRC1 TX4'
  ; Item #79 'ASRC1 TX5'
  ; Item #80 'ASRC1 TX6'
  : values=18

u@tegra-ubuntu:~$ amixer -c APE cget name="I2S2 Mux"
numid=1169,iface=MIXER,name='I2S2 Mux'
  ; type=ENUMERATED,access=rw------,values=1,items=81
  ; Item #0 'None'
  ; Item #1 'ADMAIF1'
  ; Item #2 'ADMAIF2'
  ; Item #3 'ADMAIF3'
  ; Item #4 'ADMAIF4'
  ; Item #5 'ADMAIF5'
  ; Item #6 'ADMAIF6'
  ; Item #7 'ADMAIF7'
  ; Item #8 'ADMAIF8'
  ; Item #9 'ADMAIF9'
  ; Item #10 'ADMAIF10'
  ; Item #11 'ADMAIF11'
  ; Item #12 'ADMAIF12'
  ; Item #13 'ADMAIF13'
  ; Item #14 'ADMAIF14'
  ; Item #15 'ADMAIF15'
  ; Item #16 'ADMAIF16'
  ; Item #17 'I2S1'
  ; Item #18 'I2S2'
  ; Item #19 'I2S3'
  ; Item #20 'I2S4'
  ; Item #21 'I2S5'
  ; Item #22 'I2S6'
  ; Item #23 'SFC1'
  ; Item #24 'SFC2'
  ; Item #25 'SFC3'
  ; Item #26 'SFC4'
  ; Item #27 'MIXER1 TX1'
  ; Item #28 'MIXER1 TX2'
  ; Item #29 'MIXER1 TX3'
  ; Item #30 'MIXER1 TX4'
  ; Item #31 'MIXER1 TX5'
  ; Item #32 'AMX1'
  ; Item #33 'AMX2'
  ; Item #34 'AMX3'
  ; Item #35 'AMX4'
  ; Item #36 'ARAD1'
  ; Item #37 'AFC1'
  ; Item #38 'AFC2'
  ; Item #39 'AFC3'
  ; Item #40 'AFC4'
  ; Item #41 'AFC5'
  ; Item #42 'AFC6'
  ; Item #43 'OPE1'
  ; Item #44 'SPKPROT1'
  ; Item #45 'MVC1'
  ; Item #46 'MVC2'
  ; Item #47 'IQC1-1'
  ; Item #48 'IQC1-2'
  ; Item #49 'IQC2-1'
  ; Item #50 'IQC2-2'
  ; Item #51 'DMIC1'
  ; Item #52 'DMIC2'
  ; Item #53 'DMIC3'
  ; Item #54 'DMIC4'
  ; Item #55 'ADX1 TX1'
  ; Item #56 'ADX1 TX2'
  ; Item #57 'ADX1 TX3'
  ; Item #58 'ADX1 TX4'
  ; Item #59 'ADX2 TX1'
  ; Item #60 'ADX2 TX2'
  ; Item #61 'ADX2 TX3'
  ; Item #62 'ADX2 TX4'
  ; Item #63 'ADX3 TX1'
  ; Item #64 'ADX3 TX2'
  ; Item #65 'ADX3 TX3'
  ; Item #66 'ADX3 TX4'
  ; Item #67 'ADX4 TX1'
  ; Item #68 'ADX4 TX2'
  ; Item #69 'ADX4 TX3'
  ; Item #70 'ADX4 TX4'
  ; Item #71 'ADMAIF17'
  ; Item #72 'ADMAIF18'
  ; Item #73 'ADMAIF19'
  ; Item #74 'ADMAIF20'
  ; Item #75 'ASRC1 TX1'
  ; Item #76 'ASRC1 TX2'
  ; Item #77 'ASRC1 TX3'
  ; Item #78 'ASRC1 TX4'
  ; Item #79 'ASRC1 TX5'
  ; Item #80 'ASRC1 TX6'
  : values=1

If I set “I2S2 Mux” to “None” in audio setting GUI, all audio signal is off.
Please check it also.

Thanks.

Hi,

Greetings! I need few information.

  1. Did you connect WM8904 to I2S1 or I2S2

I2S2 is the i2s interface available on 40 pin header. Jetson-IO tool can set pinmux for I2S2 alone. For I2S1, you may have to set pinmux via Jetson Orin NX and Nano Series — NVIDIA Jetson Linux Developer Guide 1 documentation which I had pointed before

Please confirm on the I2S port you are using for connecting the codec

  1. If it is I2S2, setting via Jetson-IO and reboot will suffice. If it is I2S1 share the pinmux settings through below command
    cat /sys/kernel/debug/pinctrl/.pinmux/pinconf-groups

Further, your audio routes seem fine but from reference, below is recommended

	nvidia-audio-card,routing =		
		"WM IN2L", "WM Line In Jack",			
		"WM IN2R", "WM Line In Jack",		
		"WM Mic", "WM MICBIAS",			
		"WM IN1L", "WM Mic",
		"WM Headphone Jack", "WM HPOUTL",
		"WM Headphone Jack", "WM HPOUTR";

hdr40_snd_link_i2s is always nvidia-audio-card,dai-link@77 { }; Please do not alter it

But if you want to modify dai link associated with I2S1, you could modify nvidia-audio-card,dai-link@76 directly as you have been doing in the DL change

  1. I see that you have configured codec as master. Is this intended?

If so, you need to use below mixer control as well before capture

amixer -c APE cset name==“I2S1 codec master mode” “cbm-cfm”

If codec is master, one needs to ensure all clocks are supplied at required rate

How to change default interface from “I2S2” to “I2S1”?

Setting routes from command line below playback/capture will help override default settings in a given boot session. If you wish to automate, you could put this in .bashrc or other alsa conf files. But this information is generic and can be found from internet

amixer -c APE cset name=“I2S1 Mux” “ADMAIF1”
amixer -c APE cset name=“ADMAIF1 Mux” “I2S1”

Further remove

assigned-clock-rates = <11289600>;

PLLA_OUT0 rate gets adjusted by driver per usecase

Also, advise to go through

  1. codec integration guide at Audio Setup and Development — NVIDIA Jetson Linux Developer Guide 1 documentation thoroughly to understand the codec integration process
  2. Examples at Audio Setup and Development — NVIDIA Jetson Linux Developer Guide 1 documentation
  3. TroubleShooting at Audio Setup and Development — NVIDIA Jetson Linux Developer Guide 1 documentation

Check if any of above infomration helps in resolving the issue. Otherwise, please get in touch for follow up

Regards

Hi,

As per your comment, I changed I2S1 to I2S2 in the DTS sound node as shown below and confirmed that speak out and capture operate normally.

/ {
	bus@0 {

		aconnect@2900000 {
			ahub@2900800 {
				i2s@2901100 {
					ports {
						port@1 {
							hdr40_snd_i2s_dap_ep: endpoint {
								dai-format = "i2s";
								remote-endpoint = <&wm8904_ep>;
							};
						};
					};
				};
			};
		};

	};

	tegra_sound_graph: tegra_sound: sound {
		compatible = "nvidia,tegra186-audio-graph-card",
			     "nvidia,tegra186-ape";
		clocks = <&bpmp TEGRA234_CLK_PLLA>,
			 <&bpmp TEGRA234_CLK_PLLA_OUT0>,
			 <&bpmp TEGRA234_CLK_AUD_MCLK>;
		clock-names = "pll_a", "plla_out0", "extern1";
		assigned-clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
		assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLA_OUT0>;
		assigned-clock-rates = <11289600>;

		nvidia-audio-card,name = "NVIDIA Jetson Orin NX APE";

		hdr40_snd_link_i2s: nvidia-audio-card,dai-link@77 { };
	};
};

	sound {
		nvidia-audio-card,widgets =
			"Headphone",	"WM Headphone Jack",
			"Microphone",	"WM Mic Jack";

		nvidia-audio-card,routing =
			"WM Headphone Jack",     "WM HPOUTL",
			"WM Headphone Jack",     "WM HPOUTR",
			"WM Mic Jack", "WM MICBIAS",
			"WM IN2R", "WM Mic Jack";			
	
		nvidia-audio-card,dai-link@77 {
			link-name = "wm8904-playback";
			bitclock-master;
		  	frame-master;
		  	
			codec {
				sound-dai = <&wm8904 0>;
				prefix = "WM";
			};
		};
	};

		i2c@3160000 {
			status = "okay";
			wm8904: wm8904_codec@1a {
				compatible = "wlf,wm8904";
				#sound-dai-cells = <1>;
				status ="okay";
				reg = <0x1a>;
				clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
				clock-frequency = <11289600>;
				clock-names = "mclk";

				port {
					wm8904_ep: endpoint {
						remote-endpoint = <&i2s2_dap>;
						mclk-fs = <256>;
						link-name = "wm8904-playback";
					};
				};
			};
		};

Thank you for supporting.

1 Like

Glad to know that audio is working now. Good job in getting it up and running!

Regards