I2S can not capture the audio data

Hi,Sir

My HW is TX2 +TLV320aic3254.
Headphone and LineOut can play the sound normally used the ‘aplay’.
But unable to capture audio data by ‘arecord’, MCLK, BCLK, LRCLK, SDOUT,SDIN can be observed by oscilloscope,they all look normal.
Please help me find out why.

sudo grep “aud_mclk|dap1” /sys/kernel/debug/tegra_pinctrl_reg
Bank: 0 Reg: 0x02431020 Val: 0x00000400 → aud_mclk_pj4
Bank: 0 Reg: 0x02431028 Val: 0x00000440 → dap1_fs_pj3
Bank: 0 Reg: 0x02431030 Val: 0x00000458 → dap1_din_pj2
Bank: 0 Reg: 0x02431038 Val: 0x00000400 → dap1_dout_pj1
Bank: 0 Reg: 0x02431040 Val: 0x00000400 → dap1_sclk_pj0

nvidia@nvidia-desktop:~$ sudo cat /sys/kernel/debug/tracing/trace

tracer: nop

entries-in-buffer/entries-written: 36/36 #P:4

_-----=> irqs-off

/ _----=> need-resched

| / _—=> hardirq/softirq

|| / _–=> preempt-depth

||| / delay

TASK-PID CPU# |||| TIMESTAMP FUNCTION

| | | |||| | |

     arecord-7902  [000] ....  1032.678264: snd_soc_dapm_widget_power: widget=Capture 1 val=1
     arecord-7902  [000] ....  1032.678269: snd_soc_dapm_widget_power: widget=ADMAIF1 Transmit val=1
     arecord-7902  [000] ....  1032.678271: snd_soc_dapm_widget_power: widget=ADMAIF1 TX val=1
     arecord-7902  [000] ....  1032.678272: snd_soc_dapm_widget_power: widget=ADMAIF1 Mux val=1
     arecord-7902  [000] ....  1032.678288: snd_soc_dapm_widget_power: widget=I2S1 RX val=1
     arecord-7902  [000] ....  1032.678290: snd_soc_dapm_widget_power: widget=I2S1 Receive val=1
     arecord-7902  [000] ....  1032.678291: snd_soc_dapm_widget_power: widget=I2S1 CIF Transmit-I2S1 Receive val=1
     arecord-7902  [000] ....  1032.678293: snd_soc_dapm_widget_power: widget=I2S1 CIF Transmit val=1
     arecord-7902  [000] ....  1032.678294: snd_soc_dapm_widget_power: widget=I2S1 CIF TX val=1
     arecord-7902  [000] ....  1032.678295: snd_soc_dapm_widget_power: widget=I2S1 DAP RX val=1
     arecord-7902  [000] ....  1032.678296: snd_soc_dapm_widget_power: widget=I2S1 DAP Receive val=1
     arecord-7902  [000] ....  1032.678297: snd_soc_dapm_widget_power: widget=x Capture-I2S1 DAP Receive val=1
     arecord-7902  [000] ....  1032.678299: snd_soc_dapm_widget_power: widget=x Capture val=1
     arecord-7902  [000] ....  1032.678300: snd_soc_dapm_widget_power: widget=x Right ADC val=1
     arecord-7902  [000] ....  1032.678301: snd_soc_dapm_widget_power: widget=x Left ADC val=1
     arecord-7902  [000] ....  1032.678303: snd_soc_dapm_widget_power: widget=x IN2_L to Right Mixer Positive Resistor val=1
     arecord-7902  [000] ....  1032.678305: snd_soc_dapm_widget_power: widget=x IN1_L to Left Mixer Positive Resistor val=1
     arecord-7902  [000] ....  1032.678306: snd_soc_dapm_widget_power: widget=x IN2_L val=1

I can see the data change on SDIN by oscilloscope.But ‘aplay ./my.wav’ no sound output.
It seems that there is no data in file ‘my.wav’ ,when I open the ‘my.wav’ by Cool Edit Pro’ on window10.


Open the file ‘my.wav’ used the WinHex, the audio data is empty.
The logic analyzer shows that there is have data on the I2S bus.
It looks like the I2S chip on TX2 doesn’t work,unable to collect the I2S signal.

Image 3

Hello!

The good news is that we have validated both audio playback and capture with I2S on all Jetson platforms and so we are confident that this works fine. And I recall that there was another user using this codec successfully with Jetson TX2 in the past.

Are you able to share your device-tree changes? From the trace I don’t see any route from the codec DAPM inputs IN1_L and IN2_L to the Tegra machine driver.

Regards,
Jon

Hi,Jon
Thank you for your reply. Here is the configuration:

#if TEGRA_AUDIO_BUS_DT_VERSION >= DT_VERSION_2
aconnect@2a41000 {
#endif
ahub {
i2s@2901000 {/I2S1/
status = “okay”;
bclk-ratio = <4>;
};

	admaif@290f000 {
		dma-buffer-size = <32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>,
					<32768>, <32768>, <32768>, <32768>;
	};
};

#if TEGRA_AUDIO_BUS_DT_VERSION >= DT_VERSION_2
};
#endif
hda@3510000 {
status = “okay”;
};

tegra_sound: sound {
	compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
	nvidia,model = "tegra-snd-t186ref-mobile-rt565x";
	nvidia,num-codec-link = <12>;

/* modif by geng 2021-02-20
clocks = <&tegra_car TEGRA186_CLK_PLLA>,
<&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA186_CLK_AUD_MCLK>;
clock-names = “pll_a”, “pll_a_out0”, “extern1”;
assigned-clocks = <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA186_CLK_AUD_MCLK>;
assigned-clock-parents = <&tegra_car TEGRA186_CLK_PLLA>,
<&tegra_car TEGRA186_CLK_PLL_A_OUT0>;
*/
clocks = <&tegra_car TEGRA186_CLK_PLLA>,
<&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA186_CLK_AHUB>,
<&tegra_car TEGRA186_CLK_AUD_MCLK>;
clock-names = “pll_a”, “pll_a_out0”, “ahub”, “extern1”;
assigned-clocks = <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA186_CLK_AUD_MCLK>;
assigned-clock-parents = <&tegra_car TEGRA186_CLK_PLLA>,
<&tegra_car TEGRA186_CLK_PLLP_OUT0>;
assigned-clock-rates = <0>, <12000000>;

	resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
	reset-names = "extern1_rst";

	status = "okay";
	nvidia,audio-routing =

		"x Headphone",		"x LOL",
		"x Headphone",		"x LOR",
		"x Headphone",		"x HPL",
		"x Headphone",		"x HPR",

		"x Left DAC",		"x Playback",
		"x Right DAC",		"x Playback",

		"x Mic Bias",		"x Mic",
		"x IN1_L",		"x Mic",
		"x IN1_R",		"x Mic",
		"x IN2_L",		"x Mic",
		"x IN2_R",		"x Mic",

		"x Capture",		"x Left ADC",
		"x Capture",		"x Right ADC",

		"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",
		"d3 Headphone",		"d3 OUT";

	nvidia,xbar = <&tegra_axbar>;

/* mclk-fs = <256>; */

/*
rt565x_dai_link: nvidia,dai-link-1 {
link-name = “spdif-dit-0”;
cpu-dai = <&tegra_i2s1>;
codec-dai = <&spdif_dit0>;
cpu-dai-name = “I2S1”;
codec-dai-name = “dit-hifi”;
format = “i2s”;
bit-format = “s16_le”;
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = “x”;
status = “okay”;
};
//modif by geng 2021-02-20
*/
rt565x_dai_link: nvidia,dai-link-1 {
link-name = “ti-tlv320aic3254”;
cpu-dai = <&tegra_i2s1>;
codec-dai = <&aic32x4>;
cpu-dai-name = “I2S1”;
codec-dai-name = “tlv320aic32x4-hifi”;
format = “i2s”;
bit-format = “s16_le”;
bclk_ratio = <1>;
tx-mask = <0xFF>;
rx-mask = <0xFF>;
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
srate = <48000>;
//srate = <44100>;
num-channel = <2>;
ignore_suspend;
name-prefix = “x”;
status = “okay”;
};

	nvidia,dai-link-2 {
		link-name = "spdif-dit-1";
		cpu-dai = <&tegra_i2s2>;
		codec-dai = <&spdif_dit1>;
		cpu-dai-name = "I2S2";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "y";
		status = "okay";
	};
	nvidia,dai-link-3 {
		link-name = "spdif-dit-2";
		cpu-dai = <&tegra_i2s3>;
		codec-dai = <&spdif_dit2>;
		cpu-dai-name = "I2S3";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "z";
		status = "okay";
	};
	nvidia,dai-link-4 {
		link-name = "spdif-dit-3";
		cpu-dai = <&tegra_i2s4>;
		codec-dai = <&spdif_dit3>;
		cpu-dai-name = "I2S4";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "m";
		status = "okay";
	};
	nvidia,dai-link-5 {
		link-name = "spdif-dit-4";
		cpu-dai = <&tegra_i2s5>;
		codec-dai = <&spdif_dit4>;
		cpu-dai-name = "I2S5";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "n";
		status = "okay";
	};
	nvidia,dai-link-6 {
		link-name = "spdif-dit-6";
		cpu-dai = <&tegra_i2s6>;
		codec-dai = <&spdif_dit6>;
		cpu-dai-name = "I2S6";
		codec-dai-name = "dit-hifi";
		tx-mask = <0xFF>;
		rx-mask = <0xFF>;
		format = "dsp_a";
		bitclock-inversion;
		bit-format = "s16_le";
		srate = <8000>;
		num-channel = <1>;
		ignore_suspend;
		name-prefix = "o";
		status = "okay";
	};
	nvidia,dai-link-7 {
		link-name = "spdif-dit-7";
		cpu-dai = <&tegra_dmic1>;
		codec-dai = <&spdif_dit7>;
		cpu-dai-name = "DMIC1";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		ignore_suspend;
		num-channel = <2>;
		name-prefix = "a";
		status = "okay";
	};
	nvidia,dai-link-8 {
		link-name = "spdif-dit-8";
		cpu-dai = <&tegra_dmic2>;
		codec-dai = <&spdif_dit8>;
		cpu-dai-name = "DMIC2";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		ignore_suspend;
		num-channel = <2>;
		name-prefix = "b";
		status = "okay";
	};
	nvidia,dai-link-9 {
		link-name = "spdif-dit-9";
		cpu-dai = <&tegra_dmic3>;
		codec-dai = <&spdif_dit9>;
		cpu-dai-name = "DMIC3";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		ignore_suspend;
		num-channel = <2>;
		name-prefix = "c";
		status = "okay";
	};
	nvidia,dai-link-10 {
		link-name = "spdif-dit-10";
		cpu-dai = <&tegra_dmic4>;
		codec-dai = <&spdif_dit10>;
		cpu-dai-name = "DMIC4";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		ignore_suspend;
		num-channel = <2>;
		name-prefix = "d";
		status = "okay";
	};
	nvidia,dai-link-11 {
		link-name = "dspk1-playback";
		cpu-dai = <&tegra_dspk1>;
		codec-dai = <&spdif_dit13>;
		cpu-dai-name = "DSPK1";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "d3";
		status = "okay";
	};
	dspk_1_dai_link: nvidia,dai-link-12 {
		link-name = "dspk-playback-l";
		cpu-dai = <&tegra_dspk2>;
		codec-dai = <&spdif_dit11>;
		cpu-dai-name = "DSPK2";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "d1";
		status = "okay";
	};
	dspk_2_dai_link: nvidia,dai-link-13 {
		link-name = "dspk-playback-r";
		cpu-dai = <&tegra_dspk2>;
		codec-dai = <&spdif_dit12>;
		cpu-dai-name = "DSPK2";
		codec-dai-name = "dit-hifi";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;
		num-channel = <2>;
		ignore_suspend;
		name-prefix = "d2";
		status = "okay";
            };
};

Hello!

Apologies for the delay. I see that you do have route from the “x IN1/2” to the machine driver “x Mic”. Were you able to figure out why this is not working? My next guess would be a setting in the codec that needs to be configured.

Regards,
Jon

I can see the change on SDIN by oscilloscope, as the microphone captures the sound when run ‘arecord’ command, so I think codec configured is ok.
I have no idea now.

Hello!

Yes it all looks good. Can you …

  1. Share the exact arecord command you are using?
  2. Clarify which pins you are using on the Jetson TX2 to connect the codec
  3. Share the output from ‘dmesg’

Thanks
Jon

Hi, Jon

  1. arecord -D hw:tegrasndt186ref,0 -f S16_LE -c2 -r 48000 lb.wav -v
    2.

3.See attachment.
sys.log (59.8 KB)

Thanks for you help!

Hello!

That looks fine. Is there any reason why you made the following changes to the clocks?

Thanks
Jon

Because codec’ mclk need a fixed 12Mhz colck.

Hello!

If that is the case, then the codec should be the bitclock and frame master and not slave. Below the codec is configured as the slave …

Regards,
Jon

I have good news. I can record the sound normally after reflash the whole.It’s a strange phenomenon.
At present, we are not sure about the specific reasons. I am in the process of confirmation.