Jetson Nano Audio Codec Debug(NAU88C22)

参考资料
介绍:数字音频接口DAI
docs.nvidia.jetson.ASoC - 非常重要
Nuvoton NAU88C22资料(或其他如RT5659\WM8960等等)

软件版本
JetPack4.2.1 (R32.2.0)
Jetson Nano Upstream
Linux-4.9 Version

硬件连接

The I2S and AUDIO_MCLK are mapped to the following GPIOs:

  • AUDIO_MCLK --> GPIO BB.00 (Audio Master Clock---12.288MHz)
  • DAP4_SCLK --> GPIO J.07 (I2S4 BitClock---1.5/1.4MHz)
  • DAP4_FS --> GPIO J.04 (I2S4 FS---48/44.1KHz)
  • DAP4_DIN --> GPIO J.05 (I2S4 Data In from Codec)
  • DAP4_DOUT --> GPIO J.06 (I2S4 Data Out to Codec)

1、介绍Jetson Audio ALSA

ALSA software hierarchy .png
audio path.png

2、音频调试Audio Debugging
Step1. Jetson Nano output MCLK (12.288MHz or ...) and I2S4 configuration

默认default(无MCLK输出):
nvidia@nana-tw:~$ sudo grep "Name:\|J:\|BB:" /sys/kernel/debug/tegra_gpio  
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 J: 2:1 f0 00 00 00 00 00 000000
BB: 6:3 01 00 00 00 00 00 000000

修改默认GPIO配置(开机后输出MCLK):
#JetPack4.2.1修改u-boot
u-boot/board/nvidia/p3450-porg/pinmux-config-p3450-porg.h
#JetPack4.2 及以前版本修改dts(pinmux & default gpio)
hardware\nvidia\platform\t210\porg\kernel-dts\porg-platforms\tegra210-porg-pinmux-p3448-0000-a02.dtsi
hardware\nvidia\platform\t210\porg\kernel-dts\porg-platforms\tegra210-porg-gpio-p3448-0000-a02.dtsi

nvidia@nana-tw:~$ sudo grep "Name:\|J:\|BB:" /sys/kernel/debug/tegra_gpio  
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 J: 2:1 00 00 00 00 00 00 000000
BB: 6:3 00 00 00 00 00 00 000000
(启动后MCLK自动输出默认FS*256,如:48KHz*256 = 12.288MHz)
I2S4 Function功能配置
nvidia@nana-tw:~$ sudo grep dap4 /sys/kernel/debug/tegra_pinctrl_reg
Bank: 1 Reg: 0x70003144 Val: 0x00000044 -> dap4_fs_pj4
Bank: 1 Reg: 0x70003148 Val: 0x00000044 -> dap4_din_pj5
Bank: 1 Reg: 0x7000314c Val: 0x00000044 -> dap4_dout_pj6
Bank: 1 Reg: 0x70003150 Val: 0x00000044 -> dap4_sclk_pj7

#JetPack4.2.1修改u-boot
u-boot/board/nvidia/p3450-porg/pinmux-config-p3450-porg.h

#JetPack4.2 及以前版本修改dts(pinmux & default gpio)
hardware\nvidia\platform\t210\porg\kernel-dts\porg-platforms\tegra210-porg-pinmux-p3448-0000-a02.dtsi
hardware\nvidia\platform\t210\porg\kernel-dts\porg-platforms\tegra210-porg-gpio-p3448-0000-a02.dtsi

Step2. Check I2C communication & codecs probe

案例:通信采用GEN3_SDA/SCL地址0x1a(i2c-2)
$sudo cat /sys/bus/i2c/devices/2-001a/uevent
$sudo cat /sys/bus/i2c/devices/2-001a/name 
$sudo i2cdetect -y -r 2   (GEN2_SDA/SCL)
$sudo cat /sys/kernel/debug/asoc/codecs 
$sudo cat /sys/kernel/debug/asoc/dais 
输出内容:
nvidia@nano-tw:~$ sudo i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --        
nvidia@nano-tw:~$ sudo cat /sys/bus/i2c/devices/2-001a/uevent
DRIVER=nau8822
OF_NAME=nau88c22
OF_FULLNAME=/i2c@7000c400/nau88c22@1a
OF_COMPATIBLE_0=nuvoton,nau8822
OF_COMPATIBLE_N=1
MODALIAS=i2c:nau8822
nvidia@nano-tw:~$ sudo cat /sys/bus/i2c/devices/1-001a/name 
`nau8822`
nvidia@nano-tw:~$ sudo cat /sys/kernel/debug/asoc/codecs 
tegra210-ope.1
。。。(省略其他codecs描述)
`nau8822.1-001a`
snd-soc-dummy
nvidia@nano-tw:~$ sudo cat /sys/kernel/debug/asoc/dais 
OPE OUT。。。 (省略其他dai)
ADMAIF1
dit-hifi
`nau8822-hifi`
snd-soc-dummy-dai

Step3. Check dai routes and sound cards

修改dts 配置,添加Sound CARD:
$aplay -l
root@jetson-nano:# aplay -l
**** List of PLAYBACK Hardware Devices ****
Home directory not accessible: Permission denied
card 0: tegrahda [tegra-hda], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-nau882], device 0: ADMAIF1 CIF ADMAIF1-0 []
  Subdevices: 1/1
...

运行speker-test to test Speaker or Headphone output
$speaker-test -c2 -twav -D plughw:CARD=tegrasndt210ref,DEV=0

播放1KHz 标准正弦波WAV 
$aplay -D plughw:CARD=tegrasndt210ref,DEV=0 test.wav  (建议1KHz 正弦波音频方便测量波形和听取声音)
root@jetson-nano:/sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-nau8822/codec:nau8822.2-001a/dapm# ls
 bias_level            'x AUXOUT1'  'x Left ADC'            'x Left Input Mixer'   'x LMICP'     'x R2'                 'x Right Capture PGA'    'x Right Speaker Out'
'x AUX1 Out'           'x AUXOUT2'  'x Left Boost Mixer'    'x Left Output Mixer'  'x LSPK'      'x RAUX'               'x Right DAC'            'x RMICN'
'x AUX1 Output Mixer'  'x Capture'  'x Left Capture PGA'    'x Left Speaker Out'   'x Mic Bias'  'x RHP'                'x Right Headphone Out'  'x RMICP'
'x AUX2 Out'           'x L2'       'x Left DAC'            'x LHP'                'x Playback'  'x Right ADC'          'x Right Input Mixer'    'x RSPK'
'x AUX2 Output Mixer'  'x LAUX'     'x Left Headphone Out'  'x LMICN'              'x PLL'       'x Right Boost Mixer'  'x Right Output Mixer'

附录:
1. 调试过程的Buglist

1、No mclk --- 参考Step1
2、I2S 无信号输出 --- 参考Step3

2.Jetson ASoC Audio Hub Introduction

The audio hub contains the modules I2S, SPDIF, and the Digital MIC Controller (DMIC) that interface with the external world. The audio hub also contains:
• Mixer
• Sampling Frequency Converter (SFC)
• Master Volume Control (MVC)
• Output Processing Engine (OPE)
• Audio Multiplexers (AMX)
• Audio Demultiplexers (ADX)
• Audio Flow Controllers (AFC)
• An Audio Direct Memory Access (ADMA) component is included (ADMAIF-DMA) to communicate with memory.
The Crossbar (XBAR) facilitates the routing of audio samples through these modules using a proprietary protocol called Audio Client Interface (ACIF).

4. Ubuntu Shell 播放MP3

1、打开一个终端输入如下命令:sudo apt-get install sox
2、安装SOX,可播放它所支持的音频格式文件:sudo apt-get install sox libsox-fmt-all
3、比如要播放系统中所有音频文件,可以采用这个命令:play *mp3
4、播放的时候,可以按下 Ctrl+C 来终端当前音频的播放转到下一个音频
5、使用 man 命令来查看详细的介绍:man sox


5. Tegra210 --- DAMP 列表

ls -l /sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-rt565x/damp/

-r--r--r-- 1 root root 0 Jan  1  1970 'a Capture-DMIC1 DMIC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF10 CIF Receive-ADMAIF10 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF10 Transmit-ADMAIF10 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF1 CIF Receive-ADMAIF1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF1 Transmit-ADMAIF1 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF2 CIF Receive-ADMAIF2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF2 Transmit-ADMAIF2 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF3 CIF Receive-ADMAIF3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF3 Transmit-ADMAIF3 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF4 CIF Receive-ADMAIF4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF4 Transmit-ADMAIF4 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF5 CIF Receive-ADMAIF5 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF5 Transmit-ADMAIF5 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF6 CIF Receive-ADMAIF6 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF6 Transmit-ADMAIF6 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF7 CIF Receive-ADMAIF7 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF7 Transmit-ADMAIF7 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF8 CIF Receive-ADMAIF8 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF8 Transmit-ADMAIF8 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF9 CIF Receive-ADMAIF9 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADMAIF9 Transmit-ADMAIF9 CIF Transmit'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX1 OUT1 Transmit-ADX1-1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX1 OUT2 Transmit-ADX1-2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX1 OUT3 Transmit-ADX1-3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX1 OUT4 Transmit-ADX1-4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX1 Transmit-ADX1 IN Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX2 OUT1 Transmit-ADX2-1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX2 OUT2 Transmit-ADX2-2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX2 OUT3 Transmit-ADX2-3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX2 OUT4 Transmit-ADX2-4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'ADX2 Transmit-ADX2 IN Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC1 AFC Transmit-AFC1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC1 Transmit-AFC1 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC2 AFC Transmit-AFC2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC2 Transmit-AFC2 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC3 AFC Transmit-AFC3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC3 Transmit-AFC3 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC4 AFC Transmit-AFC4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC4 Transmit-AFC4 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC5 AFC Transmit-AFC5 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC5 Transmit-AFC5 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC6 AFC Transmit-AFC6 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AFC6 Transmit-AFC6 AFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'a Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX1-1 Transmit-AMX1 IN1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX1-2 Transmit-AMX1 IN2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX1-3 Transmit-AMX1 IN3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX1-4 Transmit-AMX1 IN4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX1 OUT Transmit-AMX1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX2-1 Transmit-AMX2 IN1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX2-2 Transmit-AMX2 IN2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX2-3 Transmit-AMX2 IN3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX2-4 Transmit-AMX2 IN4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'AMX2 OUT Transmit-AMX2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'b Capture-DMIC2 DMIC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970  bias_level
-r--r--r-- 1 root root 0 Jan  1  1970 'b Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'c Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'd1 Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'd2 Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'd Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'DMIC1 DMIC Transmit-DMIC1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'DMIC2 DMIC Transmit-DMIC2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S3 CIF Transmit-I2S3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S3 DAP Transmit-y Playback'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S3 Transmit-I2S3 CIF Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S4 CIF Transmit-I2S4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S4 DAP Transmit-x Playback'
-r--r--r-- 1 root root 0 Jan  1  1970 'I2S4 Transmit-I2S4 CIF Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'Int Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'l Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'l Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'm Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-10 Transmit-RX10 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-1 Transmit-RX1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-2 Transmit-RX2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-3 Transmit-RX3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-4 Transmit-RX4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-5 Transmit-RX5 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-6 Transmit-RX6 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-7 Transmit-RX7 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-8 Transmit-RX8 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MIXER1-9 Transmit-RX9 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'm Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'MVC1 MVC Transmit-MVC1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MVC1 Transmit-MVC1 MVC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MVC2 MVC Transmit-MVC2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'MVC2 Transmit-MVC2 MVC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'n Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'n Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'o Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'o Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'OPE1 OPE Transmit-OPE1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'OPE1 Transmit-OPE1 OPE Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'OPE2 OPE Transmit-OPE2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'OPE2 Transmit-OPE2 OPE Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC1 SFC Transmit-SFC1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC1 Transmit-SFC1 SFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC2 SFC Transmit-SFC2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC2 Transmit-SFC2 SFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC3 SFC Transmit-SFC3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC3 Transmit-SFC3 SFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC4 SFC Transmit-SFC4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'SFC4 Transmit-SFC4 SFC Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 's Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 's Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'TX1 Transmit-MIXER1-1 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'TX2 Transmit-MIXER1-2 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'TX3 Transmit-MIXER1-3 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'TX4 Transmit-MIXER1-4 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'TX5 Transmit-MIXER1-5 Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'w Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'w Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Capture-I2S4 DAP Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Headphone Jack'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Int Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Int Spk'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'x Mic Jack'
-r--r--r-- 1 root root 0 Jan  1  1970 'y Capture-I2S3 DAP Receive'
-r--r--r-- 1 root root 0 Jan  1  1970 'y Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'y Mic'
-r--r--r-- 1 root root 0 Jan  1  1970 'z Headphone'
-r--r--r-- 1 root root 0 Jan  1  1970 'z Mic'

root@tw-Nano:/sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-rt565x/codec:0.spdif-dit.0/dapm# cat 'x OUT' 
x OUT: Off  in 0 out 1
 out  "static" "x Headphone"
 in  "static" "x Playback"
 
 root@tw-Nano:/sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-rt565x/codec:0.spdif-dit.0/dapm# cat 'x Playback' 
x Playback: Off  in 0 out 1
 stream Playback inactive
 out  "static" "x OUT"
 in  "static" "I2S4 DAP Transmit-x Playback"

 root@tw-Nano:/sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-rt565x/codec:0.spdif-dit.0/dapm# cat 'x Capture' 
x Capture: Off  in 1 out 0
 stream Capture inactive
 out  "static" "x Capture-I2S4 DAP Receive"
 in  "static" "x IN"
 
root@tw-Nano:/sys/kernel/debug/asoc/tegra-snd-t210ref-mobile-rt565x/codec:0.spdif-dit.0/dapm# cat 'x IN' 
x IN: Off  in 1 out 0
 out  "static" "x Capture"
 in  "static" "x Mic"

你可能感兴趣的:(Jetson Nano Audio Codec Debug(NAU88C22))