[XavierNX][RT5640]Auido playback exit immediately

When playback a wave file, it will always exit immediately without error and sound by entering following commnad.

root@linux:~# aplay -D plughw:1,2 1kHz.wav -v
Playing WAVE ‘1kHz.wav’ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Plug PCM: Hardware PCM card 1 ‘tegra-snd-t186ref-mobile-rt5640’ device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 8192
period_size : 2048
period_time : 46439
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 8192
stop_threshold : 8192
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
appl_ptr : 0
hw_ptr : 0

Sound Cards

 root@linux:~# cat /proc/asound/cards
  0 [tegrahdaxnx    ]: tegra-hda-xnx - tegra-hda-xnx
                       tegra-hda-xnx at 0x3518000 irq 65
  1 [tegrasndt186ref]: tegra-snd-t186r - tegra-snd-t186ref-mobile-rt5640
                       tegra-snd-t186ref-mobile-rt5640

Audio Widget

amixer -c 1 cset name="I2S3 Mux" "ADMAIF1"
amixer -c 1 cset name="x HP Playback Volume" "0x1e"
amixer -c 1 cset name="x Stereo DAC MIXR DAC R1 Switch" "on"
amixer -c 1 cset name="x Stereo DAC MIXL DAC L1 Switch" "on"
amixer -c 1 cset name="x HP R Playback Switch" "on"
amixer -c 1 cset name="x HP L Playback Switch" "on"

Audio Route

root@linux:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 117/117   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
          amixer-8574  [000] ....   201.791258: snd_soc_dapm_path: *ADMAIF1 RX <- (direct) <- ADMAIF1 Receive
          amixer-8574  [000] ....   201.791264: snd_soc_dapm_path:  I2S3 Mux <- ARAD1 <- ARAD1 RX
          amixer-8574  [000] ....   201.791265: snd_soc_dapm_path:  I2S3 Mux <- ADX4-4 <- ADX4-4 RX
          amixer-8574  [000] ....   201.791266: snd_soc_dapm_path:  I2S3 Mux <- ADX4-3 <- ADX4-3 RX
          amixer-8574  [000] ....   201.791267: snd_soc_dapm_path:  I2S3 Mux <- ADX4-2 <- ADX4-2 RX
          amixer-8574  [000] ....   201.791268: snd_soc_dapm_path:  I2S3 Mux <- ADX4-1 <- ADX4-1 RX
          amixer-8574  [000] ....   201.791290: snd_soc_dapm_path:  I2S3 Mux <- AMX4 <- AMX4 RX
          amixer-8574  [000] ....   201.791292: snd_soc_dapm_path:  I2S3 Mux <- ADX3-4 <- ADX3-4 RX
          amixer-8574  [000] ....   201.791293: snd_soc_dapm_path:  I2S3 Mux <- ADX3-3 <- ADX3-3 RX
          amixer-8574  [000] ....   201.791294: snd_soc_dapm_path:  I2S3 Mux <- ADX3-2 <- ADX3-2 RX
          amixer-8574  [000] ....   201.791294: snd_soc_dapm_path:  I2S3 Mux <- ADX3-1 <- ADX3-1 RX
          amixer-8574  [000] ....   201.791295: snd_soc_dapm_path:  I2S3 Mux <- AMX3 <- AMX3 RX
          amixer-8574  [000] ....   201.791296: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-6 <- ASRC1-6 RX
          amixer-8574  [000] ....   201.791297: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-5 <- ASRC1-5 RX
          amixer-8574  [000] ....   201.791298: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-4 <- ASRC1-4 RX
          amixer-8574  [000] ....   201.791299: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-3 <- ASRC1-3 RX
          amixer-8574  [000] ....   201.791300: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-2 <- ASRC1-2 RX
          amixer-8574  [000] ....   201.791301: snd_soc_dapm_path:  I2S3 Mux <- ASRC1-1 <- ASRC1-1 RX
          amixer-8574  [000] ....   201.791302: snd_soc_dapm_path:  I2S3 Mux <- I2S6 <- I2S6 RX
          amixer-8574  [000] ....   201.791302: snd_soc_dapm_path:  I2S3 Mux <- DMIC4 <- DMIC4 RX
          amixer-8574  [000] ....   201.791303: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF20 <- ADMAIF20 RX
          amixer-8574  [000] ....   201.791304: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF19 <- ADMAIF19 RX
          amixer-8574  [000] ....   201.791305: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF18 <- ADMAIF18 RX
          amixer-8574  [000] ....   201.791306: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF17 <- ADMAIF17 RX
          amixer-8574  [000] ....   201.791307: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF16 <- ADMAIF16 RX
          amixer-8574  [000] ....   201.791308: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF15 <- ADMAIF15 RX
          amixer-8574  [000] ....   201.791308: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF14 <- ADMAIF14 RX
          amixer-8574  [000] ....   201.791309: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF13 <- ADMAIF13 RX
          amixer-8574  [000] ....   201.791310: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF12 <- ADMAIF12 RX
          amixer-8574  [000] ....   201.791311: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF11 <- ADMAIF11 RX
          amixer-8574  [000] ....   201.791312: snd_soc_dapm_path:  I2S3 Mux <- ADX2-4 <- ADX2-4 RX
          amixer-8574  [000] ....   201.791312: snd_soc_dapm_path:  I2S3 Mux <- ADX2-3 <- ADX2-3 RX
          amixer-8574  [000] ....   201.791313: snd_soc_dapm_path:  I2S3 Mux <- ADX2-2 <- ADX2-2 RX
          amixer-8574  [000] ....   201.791314: snd_soc_dapm_path:  I2S3 Mux <- ADX2-1 <- ADX2-1 RX
          amixer-8574  [000] ....   201.791315: snd_soc_dapm_path:  I2S3 Mux <- AMX2 <- AMX2 RX
          amixer-8574  [000] ....   201.791316: snd_soc_dapm_path:  I2S3 Mux <- ADX1-4 <- ADX1-4 RX
          amixer-8574  [000] ....   201.791317: snd_soc_dapm_path:  I2S3 Mux <- ADX1-3 <- ADX1-3 RX
          amixer-8574  [000] ....   201.791317: snd_soc_dapm_path:  I2S3 Mux <- ADX1-2 <- ADX1-2 RX
          amixer-8574  [000] ....   201.791318: snd_soc_dapm_path:  I2S3 Mux <- ADX1-1 <- ADX1-1 RX
          amixer-8574  [000] ....   201.791319: snd_soc_dapm_path:  I2S3 Mux <- AMX1 <- AMX1 RX
          amixer-8574  [000] ....   201.791320: snd_soc_dapm_path:  I2S3 Mux <- DMIC3 <- DMIC3 RX
          amixer-8574  [000] ....   201.791321: snd_soc_dapm_path:  I2S3 Mux <- DMIC2 <- DMIC2 RX
          amixer-8574  [000] ....   201.791321: snd_soc_dapm_path:  I2S3 Mux <- DMIC1 <- DMIC1 RX
          amixer-8574  [000] ....   201.791322: snd_soc_dapm_path:  I2S3 Mux <- IQC2-2 <- IQC2-2 RX
          amixer-8574  [000] ....   201.791323: snd_soc_dapm_path:  I2S3 Mux <- IQC2-1 <- IQC2-1 RX
          amixer-8574  [000] ....   201.791324: snd_soc_dapm_path:  I2S3 Mux <- IQC1-2 <- IQC1-2 RX
          amixer-8574  [000] ....   201.791325: snd_soc_dapm_path:  I2S3 Mux <- IQC1-1 <- IQC1-1 RX
          amixer-8574  [000] ....   201.791339: snd_soc_dapm_path:  I2S3 Mux <- MVC2 <- MVC2 RX
          amixer-8574  [000] ....   201.791340: snd_soc_dapm_path:  I2S3 Mux <- MVC1 <- MVC1 RX
          amixer-8574  [000] ....   201.791341: snd_soc_dapm_path:  I2S3 Mux <- OPE1 <- OPE1 RX
          amixer-8574  [000] ....   201.791342: snd_soc_dapm_path:  I2S3 Mux <- AFC6 <- AFC6 RX
          amixer-8574  [000] ....   201.791343: snd_soc_dapm_path:  I2S3 Mux <- AFC5 <- AFC5 RX
          amixer-8574  [000] ....   201.791343: snd_soc_dapm_path:  I2S3 Mux <- AFC4 <- AFC4 RX
          amixer-8574  [000] ....   201.791344: snd_soc_dapm_path:  I2S3 Mux <- AFC3 <- AFC3 RX
          amixer-8574  [000] ....   201.791345: snd_soc_dapm_path:  I2S3 Mux <- AFC2 <- AFC2 RX
          amixer-8574  [000] ....   201.791346: snd_soc_dapm_path:  I2S3 Mux <- AFC1 <- AFC1 RX
          amixer-8574  [000] ....   201.791347: snd_soc_dapm_path:  I2S3 Mux <- MIXER1-5 <- MIXER1-5 RX
          amixer-8574  [000] ....   201.791348: snd_soc_dapm_path:  I2S3 Mux <- MIXER1-4 <- MIXER1-4 RX
          amixer-8574  [000] ....   201.791349: snd_soc_dapm_path:  I2S3 Mux <- MIXER1-3 <- MIXER1-3 RX
          amixer-8574  [000] ....   201.791349: snd_soc_dapm_path:  I2S3 Mux <- MIXER1-2 <- MIXER1-2 RX
          amixer-8574  [000] ....   201.791350: snd_soc_dapm_path:  I2S3 Mux <- MIXER1-1 <- MIXER1-1 RX
          amixer-8574  [000] ....   201.791351: snd_soc_dapm_path:  I2S3 Mux <- SFC4 <- SFC4 RX
          amixer-8574  [000] ....   201.791352: snd_soc_dapm_path:  I2S3 Mux <- SFC3 <- SFC3 RX
          amixer-8574  [000] ....   201.791354: snd_soc_dapm_path:  I2S3 Mux <- SFC2 <- SFC2 RX
          amixer-8574  [000] ....   201.791355: snd_soc_dapm_path:  I2S3 Mux <- SFC1 <- SFC1 RX
          amixer-8574  [000] ....   201.791355: snd_soc_dapm_path:  I2S3 Mux <- I2S5 <- I2S5 RX
          amixer-8574  [000] ....   201.791356: snd_soc_dapm_path:  I2S3 Mux <- I2S4 <- I2S4 RX
          amixer-8574  [000] ....   201.791357: snd_soc_dapm_path:  I2S3 Mux <- I2S3 <- I2S3 RX
          amixer-8574  [000] ....   201.791358: snd_soc_dapm_path:  I2S3 Mux <- I2S2 <- I2S2 RX
          amixer-8574  [000] ....   201.791359: snd_soc_dapm_path:  I2S3 Mux <- I2S1 <- I2S1 RX
          amixer-8574  [000] ....   201.791359: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF10 <- ADMAIF10 RX
          amixer-8574  [000] ....   201.791360: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF9 <- ADMAIF9 RX
          amixer-8574  [000] ....   201.791361: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF8 <- ADMAIF8 RX
          amixer-8574  [000] ....   201.791362: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF7 <- ADMAIF7 RX
          amixer-8574  [000] ....   201.791363: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF6 <- ADMAIF6 RX
          amixer-8574  [000] ....   201.791364: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF5 <- ADMAIF5 RX
          amixer-8574  [000] ....   201.791365: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF4 <- ADMAIF4 RX
          amixer-8574  [000] ....   201.791365: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF3 <- ADMAIF3 RX
          amixer-8574  [000] ....   201.791366: snd_soc_dapm_path:  I2S3 Mux <- ADMAIF2 <- ADMAIF2 RX
          amixer-8574  [000] ....   201.791367: snd_soc_dapm_path: *I2S3 Mux <- ADMAIF1 <- ADMAIF1 RX
          amixer-8575  [002] ....   207.267569: snd_soc_dapm_path: *x DAC MIXR <- INF1 Switch <- x IF1 DAC R
          amixer-8575  [002] ....   207.267575: snd_soc_dapm_path: *x IF1 DAC R <- (direct) <- x IF1 DAC
          amixer-8575  [002] ....   207.267577: snd_soc_dapm_path: *x IF1 DAC <- (direct) <- x DAI1 RX Mux
          amixer-8575  [002] ....   207.267579: snd_soc_dapm_path:  x DAI1 RX Mux <- 1:2|2:2 <- x AIF2RX
          amixer-8575  [002] ....   207.267580: snd_soc_dapm_path:  x DAI1 RX Mux <- 1:2|2:1 <- x AIF2RX
          amixer-8575  [002] ....   207.267581: snd_soc_dapm_path:  x DAI1 RX Mux <- 1:1|2:1 <- x AIF1RX
          amixer-8575  [002] ....   207.267582: snd_soc_dapm_path: *x DAI1 RX Mux <- 1:1|2:2 <- x AIF1RX
          amixer-8575  [002] ....   207.267584: snd_soc_dapm_path: *x AIF1RX <- (direct) <- x AIF1 Playback
          amixer-8575  [002] ....   207.267585: snd_soc_dapm_path: *x AIF1 Playback <- (direct) <- I2S3 DAP Transmit-x AIF1 Playback
          amixer-8575  [002] ....   207.267587: snd_soc_dapm_path: *I2S3 DAP Transmit-x AIF1 Playback <- (direct) <- I2S3 DAP Transmit
          amixer-8575  [002] ....   207.267588: snd_soc_dapm_path: *I2S3 DAP Transmit <- (direct) <- I2S3 DAP TX
          amixer-8575  [002] ....   207.267590: snd_soc_dapm_path: *I2S3 DAP TX <- (direct) <- I2S3 CIF RX
          amixer-8575  [002] ....   207.267591: snd_soc_dapm_path: *I2S3 CIF RX <- (direct) <- I2S3 CIF Receive
          amixer-8575  [002] ....   207.267592: snd_soc_dapm_path: *I2S3 CIF Receive <- (direct) <- I2S3 Transmit-I2S3 CIF Receive
          amixer-8575  [002] ....   207.267594: snd_soc_dapm_path: *I2S3 Transmit-I2S3 CIF Receive <- (direct) <- I2S3 Transmit
          amixer-8575  [002] ....   207.267614: snd_soc_dapm_path: *I2S3 Transmit <- (direct) <- I2S3 TX
          amixer-8575  [002] ....   207.267616: snd_soc_dapm_path: *I2S3 TX <- (direct) <- I2S3 Mux
          amixer-8575  [002] ....   207.267618: snd_soc_dapm_path:  x DAC MIXR <- Stereo ADC Switch <- x Stereo ADC MIXR
          amixer-8575  [002] ....   207.267619: snd_soc_dapm_path: *x Stereo DAC MIXR <- DAC R1 Switch <- x DAC MIXR
          amixer-8575  [002] ....   207.267620: snd_soc_dapm_path:  x Stereo DAC MIXR <- ANC Switch <- x ANC
          amixer-8575  [002] ....   207.267621: snd_soc_dapm_path:  x Stereo DAC MIXR <- DAC R2 Switch <- x DAC R2 Mux
          amixer-8576  [003] ....   212.628506: snd_soc_dapm_path: *x DAC MIXL <- INF1 Switch <- x IF1 DAC L
          amixer-8576  [003] ....   212.628512: snd_soc_dapm_path: *x IF1 DAC L <- (direct) <- x IF1 DAC
          amixer-8576  [003] ....   212.628514: snd_soc_dapm_path:  x DAC MIXL <- Stereo ADC Switch <- x Stereo ADC MIXL
          amixer-8576  [003] ....   212.628516: snd_soc_dapm_path: *x Stereo DAC MIXL <- DAC L1 Switch <- x DAC MIXL
          amixer-8576  [003] ....   212.628517: snd_soc_dapm_path:  x Stereo DAC MIXL <- ANC Switch <- x ANC
          amixer-8576  [003] ....   212.628518: snd_soc_dapm_path:  x Stereo DAC MIXL <- DAC L2 Switch <- x DAC L2 Mux
          amixer-8578  [000] ....   224.371380: snd_soc_dapm_path: *x HP Amp -> Switch -> x HP R Playback
          amixer-8578  [000] ....   224.371386: snd_soc_dapm_path: *x HP R Playback -> (direct) -> x HPOR
          amixer-8578  [000] ....   224.371388: snd_soc_dapm_path: *x HPOR -> (direct) -> x Headphone
          amixer-8578  [000] ....   224.371390: snd_soc_dapm_path:  x HPOR -> HPOR Switch -> x RECMIXR
          amixer-8578  [000] ....   224.371391: snd_soc_dapm_path:  x HP Amp -> Switch -> x HP L Playback
          amixer-8579  [002] ....   231.052104: snd_soc_dapm_path: *x HP Amp -> Switch -> x HP R Playback
          amixer-8579  [002] ....   231.052110: snd_soc_dapm_path: *x HP Amp -> Switch -> x HP L Playback
          amixer-8579  [002] ....   231.052111: snd_soc_dapm_path: *x HP L Playback -> (direct) -> x HPOL
          amixer-8579  [002] ....   231.052113: snd_soc_dapm_path: *x HPOL -> (direct) -> x Headphone
          amixer-8579  [002] ....   231.052115: snd_soc_dapm_path:  x HPOL -> HPOL Switch -> x RECMIXL

Using I2S3
dap3

Device Tree
device_tree.txt (2.0 KB)

Schematic
rt5640_schematic.pdf (64.3 KB)

AUD_MCLK (GPIO09) - 11.3M

Hi charles.huang,

Mixer settings seem incomplete. Please refer The audio ALC5640 can't work on I2S0 and I2C2 for Xaiver NX - #15 by lcc0610 and use right mixer controls.

Also ensure pinmux for DAP3 is set appropriately as per link below

Thanks,
Sharad

Hi Sharad,
It’s work!!!
According to your suggestion, I made the following chnaged.

Audio Route,

amixer -c 1 cset name="I2S3 Mux" "ADMAIF3"
amixer -c 1 cset name="x HP Playback Volume" "0x1e"
amixer -c 1 cset name="x Stereo DAC MIXR DAC R1 Switch" "1"
amixer -c 1 cset name="x Stereo DAC MIXL DAC L1 Switch" "1"
amixer -c 1 cset name="x HPO MIX HPVOL Switch" "1"
amixer -c 1 cset name="x HPO MIX DAC1 Switch" "1"
amixer -c 1 cset name="x HP R Playback Switch" "on"
amixer -c 1 cset name="x HP L Playback Switch" "on"
amixer -c 1 cset name="x HP Playback Volume" "0x20"

Pinmux

root@linux:~# cat /sys/kernel/debug/tegra_pinctrl_reg | grep 'aud\|dap3'
Bank: 0 Reg: 0x02431020 Val: 0x00000400 -> aud_mclk_ps4
Bank: 0 Reg: 0x02431048 Val: 0x00000440 -> dap3_fs_pt4
Bank: 0 Reg: 0x02431050 Val: 0x00000450 -> dap3_din_pt3
Bank: 0 Reg: 0x02431058 Val: 0x00000400 -> dap3_dout_pt2
Bank: 0 Reg: 0x02431060 Val: 0x00000440 -> dap3_sclk_pt1

Thank you for your kindly help.

Hi Sharad,
Could you please tell me what is the audio route while do capture process?
Thank you.

Please refer to The audio ALC5640 can't work on I2S0 and I2C2 for Xaiver NX - #27 by lcc0610 for the mixer controls and DAPM routes required for mic capture.

Thanks,
Sharad

Hi Sharad,
In fact, our audio mclk is coming from an oscillator (12MHz) and the AUD_MCLK(11.28MHz) from CPU. We found that playback quality is fined using AUD_MCLK. However, it will get weird sound using an oscillator. Which configuration we have to modify?

Hi Sharadg,
Thank you for your instruction. It’s work.

amixer -c tegrasndt186ref cset name="ADMAIF3 Mux" I2S3
amixer -c 1 cset name="x ADC Capture Switch" "1"
amixer -c 1 cset name="x ADC IF1 Data Switch" "1"
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"