问题描述:
ES8388 喇叭+PDM回采 4+2配置如下:
解决方案:
c
// MIC
pdmics: dummy-codec {
status = "okay";
compatible = "rockchip,dummy-codec";
#sound-dai-cells = <0>;
};
// MIC
pdm_mic_array: pdm-mic-array {
status = "okay";
compatible = "simple-audio-card";
simple-audio-card,name = "rockchip,pdm-mic-array";
simple-audio-card,cpu {
sound-dai = <&pdm0>;
};
simple-audio-card,codec {
sound-dai = <&pdmics>;
};
};
// 声卡ES8388
es8388_sound: es8388-sound {
status = "okay";
compatible = "rockchip,multicodecs-card";
rockchip,card-name = "rockchip-es8388";
// hp-det-gpio = <&gpio1 RK_PC4 GPIO_ACTIVE_HIGH>;
io-channels = <&saradc 3>;
io-channel-names = "adc-detect";
keyup-threshold-microvolt = <1800000>;
poll-interval = <100>;
// SPK_CTL_H 喇叭脚自行配置
spk-con-gpio = <&gpioX RK_PXX GPIO_ACTIVE_HIGH>;
// 耳机控制GPIO
// hp-con-gpio = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
linein-type = <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 = <&es_det>;
play-pause-key {
label = "playpause";
linux,code = <KEY_PLAYPAUSE>;
press-threshold-microvolt = <2000>;
};
};
&i2c7 {
status = "okay";
//这里需要根据新老SDK配置 clock部分的配置不一样
//新SDK如下
es8388: es8388@11 {
status = "okay";
#sound-dai-cells = <0>;
compatible = "everest,es8388", "everest,es8323";
reg = <0x11>;
clocks = <&mclkout_i2s0>;
clock-names = "mclk";
assigned-clocks = <&mclkout_i2s0>;
assigned-clock-rates = <12288000>;
pinctrl-names = "default";
pinctrl-0 = <&i2s0_mclk>;
};
//旧SDK如下
es8388: es8388@11 {
status = "disabled";
#sound-dai-cells = <0>;
compatible = "everest,es8388", "everest,es8323";
reg = <0x11>;
clocks = <&cru I2S0_8CH_MCLKOUT>;
clock-names = "mclk";
assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
assigned-clock-rates = <12288000>;
pinctrl-names = "default";
pinctrl-0 = <&i2s0_mclk>;
};
// 根据原理图自行配置clk 和sdi通路 有几路配置几路
&pdm0 {
status = "okay";
// 通道顺序 自行配置
//rockchip,path-map = <0 1 2 3>;
pinctrl-names = "default";
pinctrl-0 = <&pdm0m0_clk1
&pdm0m0_sdi0 &pdm0m0_sdi2>;
};
使用查看声音命令 cat /proc/asound/cards 如下
如声卡未能注册成功,自行使用 dmesg | grep pdm 检查相关声音注册是否有报错,需要注意pdm的sdio脚是否有复用,如果复用需要去除。
以上声卡注册成功后,使用命令进行录音采集。因为回采使用系统的录音应用是录制不到声音的。
使用 tinycap /mnt/rec.wav -D 1 -d 0 --c 4 对声卡1进行声音录制。
使用adb pull /mnt/rec.wav E:\ 将声音转出
最后使用电脑端的Audacity软件播放声音查看声道如下:
这里可以看到声音被正常录制到,左右声道正常。