ADC PCM1865 in 4ch TDM mode on TX2

Hello, NVpeople.
I try to get 4ch sound from ADC PCM1865.
But I get no record.
my dts:

tegra_sound: sound {
compatible = “nvidia,tegra-audio-t186ref-mobile-rt565x”;
nvidia,model = “tegra-snd-t186ref-mobile-rt565x”;
nvidia,num-codec-link = <1>;
nvidia,mclk-fs = <256>;
nvidia,audio-routing =
“x VINL1”, “x Mic”,
“x VINR1”, “x Mic”,
“x VINL2”, “x Mic”,
“x VINR2”, “x Mic”,
“x VINL3”, “x Mic”,
“x VINR3”, “x Mic”,
“x VINL4”, “x Mic”,
“x VINR4”, “x Mic”,
“x Capture”, “x ADC1”,
“x Capture”, “x ADC2”;
nvidia,xbar = <&tegra_axbar>;
mclk-fs = <256>;
hdr40_snd_link_i2s: i2s_dai_link1: nvidia,dai-link-1 {
link-name = “codec_pcm1865”;
cpu-dai = <&tegra_i2s1>;
codec-dai = <&pcm1865>;
cpu-dai-name = “I2S1”;
codec-dai-name = “pcm1865-aif”;
format = “dsp_b”;
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
bit-format = “s32_le”;
srate = <48000>;
num-channel = <4>;
ignore_suspend;
name-prefix = “x”;
status = “okay”;
};
};

PCM1865 registers registers.txt (569.4 KB)

dmesg:

nvidia@nvidia:~$ dmesg | grep -E “(pcm1|asoc)”
[ 21.376805] pcm186x 0-004a: probing a PCM186x device
[ 21.382011] pcm186x 0-004a: supplies requested successfully
[ 21.389822] pcm186x 0-004a: supplies enabled
[ 21.394227] pcm186x 0-004a: device reset
[ 21.398443] pcm186x 0-004a: PCM186X_CLK_CTRL
[ 21.402964] pcm186x 0-004a: PCM186X_LRK_DIV
[ 21.407394] pcm186x 0-004a: PCM186X_TDM_TX_SEL
[ 21.412085] pcm186x 0-004a: ADC1 Left Mux set to {VIN1P,VIN1M}[DIFF]
[ 21.418686] pcm186x 0-004a: ADC1 Right Mux set to {VIN2P,VIN2M}[DIFF]
[ 21.425373] pcm186x 0-004a: ADC1 Left Mux set to {VIN3P,VIN3M}[DIFF]
[ 21.431976] pcm186x 0-004a: ADC2 Right Mux set to {VIN4P,VIN4M}[DIFF]
[ 21.438425] pcm186x 0-004a: supplies disabled
[ 21.442784] pcm186x 0-004a: switching type
[ 21.446891] pcm186x 0-004a: codec registered as pcm1865
[ 21.595648] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[ 21.595724] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[ 21.595802] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[ 21.595868] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[ 21.595936] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[ 21.596003] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[ 21.596066] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[ 21.596133] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[ 21.596199] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[ 21.596264] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[ 21.596332] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[ 21.596398] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[ 21.596464] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[ 21.596534] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[ 21.596599] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[ 21.596664] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[ 21.596737] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[ 21.596802] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[ 21.596874] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[ 21.596940] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
[ 21.599375] pcm186x 0-004a: pcm186x_set_fmt() format=0x4005
[ 21.604965] pcm186x 0-004a: operating in slave mode
[ 21.622068] pcm186x 0-004a: ## pcm186x_set_bias_level: 0 -> 1
[ 27.099203] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.105076] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=1
[ 27.113339] pcm186x 0-004a: pcm186x: width : 16
[ 27.118232] pcm186x 0-004a: ASoC: can’t set pcm1865-aif hw params: -22
[ 27.124821] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -22
[ 27.133515] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.269882] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.276689] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 27.292127] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.297960] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=2
[ 27.306195] pcm186x 0-004a: pcm186x: width : 16
[ 27.314228] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.429782] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.435914] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 27.556631] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.562433] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=1
[ 27.570634] pcm186x 0-004a: pcm186x: width : 16
[ 27.575250] pcm186x 0-004a: ASoC: can’t set pcm1865-aif hw params: -22
[ 27.581790] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -22
[ 27.590477] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.599671] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.605789] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 27.613060] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.618958] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=2
[ 27.627152] pcm186x 0-004a: pcm186x: width : 16
[ 27.632488] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.638789] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.644985] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 27.756569] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.762373] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=1
[ 27.770565] pcm186x 0-004a: pcm186x: width : 16
[ 27.775118] pcm186x 0-004a: ASoC: can’t set pcm1865-aif hw params: -22
[ 27.781654] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -22
[ 27.790263] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.801968] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.808061] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 27.817066] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 27.822921] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=2
[ 27.831180] pcm186x 0-004a: pcm186x: width : 16
[ 27.836638] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 27.845291] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 27.851453] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1
[ 28.007817] pcm186x 0-004a: ## pcm186x_set_bias_level: 1 -> 2
[ 28.013721] pcm186x 0-004a: pcm186x_hw_params() rate=44100 format=0x2 width=16 channels=2
[ 28.021997] pcm186x 0-004a: pcm186x: width : 16
[ 28.027371] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 3
[ 33.183837] pcm186x 0-004a: ## pcm186x_set_bias_level: 3 -> 2
[ 33.190229] pcm186x 0-004a: ## pcm186x_set_bias_level: 2 -> 1

nvidia@nvidia:~ echo 0 | sudo tee /sys/kernel/debug/tracing/trace 0 nvidia@nvidia:~ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
0
nvidia@nvidia:~ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on 1 nvidia@nvidia:~ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_path/enable
1
nvidia@nvidia:~ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable 1 nvidia@nvidia:~ arecord -Dhw:tegrasndt186ref,0 -c 4 -r 48000 -f S32_LE -d 5 out.wav
Recording WAVE ‘out.wav’ : Signed 32 bit Little Endian, Rate 48000 Hz, Channels 4

nvidia@nvidiasudo cat /sys/kernel/debug/tracing/trace
trace.txt (268.8 KB)

Hello!

Sorry for the delay. When you say that you get ‘no record’ do you mean that the audio captured to the out.wav is silent? I can see from the trace that everything starts up and arecord captures audio for 5 seconds. Therefore, I would expect that the out.wav is not zero size.

Have you check the pinmux configuration for the I2S pins? The following command will show what functions are enbled on the 40-pin header …

$ sudo /opt/nvidia/jetson-io/config-by-function.py -l enabled

If I2S is not enabled, then you can enable by …

$ sudo /opt/nvidia/jetson-io/config-by-function.py -o dtb i2s1
$ sudo reboot

How is the PCM1865 device clocked? I see it has an MCLK input but can also be clock by an external crystal. You can use the AUD_MCLK output from Jetson to drive the MCLK on the codec which by default operates at 256 * fs. You will need to check the codec clocking requirements.

Regards,
Jon

Hi John
At the moment I have solved this problem. I have four-channel audio in TDM mode.
But another problem arose. Sometimes the ADC does not initialize after starting Linux. I use Jetson not on a devkit, I have my own board. But I did not change Linux, I added only the driver. And I think that initialization is not happening due to attempts to initialize missing devices. Is there any Linux customization tool for JetsonTX2?

Regards, Dmitry.

Hello!

Unfortunately, there is no such tool for customising Linux. If the initialisation of the DAC is not always happening, then check for errors in the dmesg output and if possible probe the I2C/SPI pins for the codec to see the commands are being sent to configure the DAC. It could also be worth checking power/clocks/reset on the DAC to ensure everything looks good.

Regards,
Jon