本次调试es8388语音编解码IC,按照以下思路(如果出现内核崩溃的问题,建议可以同步下rk原厂代码):
1、dts的配置
&i2c7 { //i2c总线确认
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&i2c7m0_xfer>; //总线IO要配置对
es8388: es8388@11 {
status = "okay";
#sound-dai-cells = <0>;
compatible = "everest,es8388", "everest,es8323";
reg = <0x11>;
clocks = <&cru I2S0_8CH_MCLKOUT>;
clock-names = "mclk";
// sda-gpios = <&gpio1 RK_PD1 GPIO_ACTIVE_HIGH>;
// scl-gpios = <&gpio1 RK_PD0 GPIO_ACTIVE_HIGH>;
assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
assigned-clock-rates = <12288000>;
pinctrl-names = "default";
pinctrl-0 = <&i2s0_mclk>;
};
};
es8388_sound: es8388-sound {
status = "okay";
compatible = "rockchip,multicodecs-card";
rockchip,card-name = "rockchip,es8388";
hp-det-gpio = <&gpio1 2 1>;
spk-con-gpio = <&gpio1 3 0>;
hp-con-gpio = <&gpio0 8 0>;
rockchip,format = "i2s";
rockchip,mclk-fs = <256>;
rockchip,cpu = <&i2s0_8ch>;
rockchip,codec = <&es8388>;
rockchip,audio-routing =
"Headphone", "LOUT1",
"Headphone", "ROUT1",
"Speaker", "LOUT2",
"Speaker", "ROUT2",
"Headphone", "Headphone Power",
"Headphone", "Headphone Power",
"Speaker", "Speaker Power",
"Speaker", "Speaker Power",
"LINPUT1", "Main Mic",
"LINPUT2", "Main Mic",
"RINPUT1", "Headset Mic",
"RINPUT2", "Headset Mic";
pinctrl-names = "default";
pinctrl-0 = <&hp_det>;
};
&i2s0_8ch {
status = "okay";
pinctrl-0 = <&i2s0_lrck //I2S0的pin的配置,注意使用哪个就添加哪个,注意IO不要跟其他配置冲突
&i2s0_sclk
&i2s0_sdi0
&i2s0_sdo0>;
};
2 确认i2s0打开,对应的GPIO没有复用,可以通过以下命令确认(硬件原理方面对应原理图确认):
cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins
cat /sys/kernel/debug/gpio
以及查找dts编译后的文件确认:.rk3588-evb3-lp5-v10-linux.dtb.dts.tmp
3、验证过程:
查看声卡设备:
root@VC-RK3588:/# cat /proc/asound/cards
0 [rockchipes8388 ]: rockchip_es8388 - rockchip,es8388
rockchip,es8388
root@VC-RK3588:/#
1、安装工具
① apt-get update
② apt install ffmpeg
③ apt install alsa-utils
ffmpeg -f alsa -i hw:0,0 out.wav //录音
aplay -D hw:0,0 out.wav //放音
如果播放单声道音频文件(mono)要加plug:
aplay -D plughw:0,0 zangyuquli.wav
hw:0,0 声卡0和设备0的确定,使用 aplay -l 查看:
root@VC-RK3588:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: rockchipes8388 [rockchip,es8388], device 0: dailink-multicodecs ES8323.7-0011-0 [dailink-multicodecs ES8323.7-0011-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
从上面可以看出我的audio设备是:
card 0: rockchipes8388 [rockchip,es8388], device 0: dailink-multicodecs ES8323.7-0011-0 [dailink-multicodecs ES8323.7-0011-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
声卡id为0(因为是card 0),设备id为0(device 0),所以aplay -D plughw:0,0 xxx.wav 即可。