I2S 接口
I2S全称Inter-IC Sound, Integrated Interchip Sound,或简写IIS,是飞利浦在1986年定义(1996年修订)的数字音频传输标准,用于数字音频数据在系统内部器件之间传输,例如编解码器CODEC、DSP、数字输入/输出接口、ADC、DAC和数字滤波器等
主控端的Audio接口
音频解码芯片(苏州顺芯半导体有限公司)
功率放大器芯片
TI-TPA3113D2 是德州仪器(Texas Instruments, TI)出品的一款高效立体声D类音频功率放大器
耳机接口
音频驱动
kernel/sound/soc/codecs/es8323.c
./arch/arm/boot/dts/rk3288-evb.dtsi
/ {
sound: sound {
status = "okay";
compatible = "simple-audio-card";
simple-audio-card,format = "i2s";
simple-audio-card,name = "rockchip,es8323-codec";
simple-audio-card,mclk-fs = <512>;
simple-audio-card,widgets =
"Microphone", "Microphone Jack",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
"MIC1", "Microphone Jack",
"MIC2", "Microphone Jack",
"Microphone Jack", "micbias1",
"Headphone Jack", "HPOL",
"Headphone Jack", "HPOR";
simple-audio-card,dai-link@0 {
format = "i2s";
cpu {
sound-dai = <&i2s>;
};
codec {
sound-dai = <&es8323>;
};
};
};
};
&i2c2 {
status = "okay";
es8323: es8323@10 {
status = "okay";
compatible = "everest,es8323";
reg = <0x10>;
spk-con-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>; //SPK_EN GPIO5_C3
//hp-det-gpio = <&gpio7 10 GPIO_ACTIVE_LOW>;
clock-names = "mclk";
clocks = <&cru SCLK_I2S0_OUT>;
pinctrl-names = "default";
pinctrl-0 = <&i2s0_mclk>;
#sound-dai-cells = <0>;
};
};
声卡调试
rk3288:/ $ cat /proc/asound/cards
0 [rockchipes8323c]: rockchip_es8323 - rockchip,es8323-codec
rockchip,es8323-codec
安卓音频框架
HAL层代码
hardware/rockchip/audio/tinyalsa_hal/
这个目录下的代码通常指的是基于TinyALSA的音频HAL实现。TinyALSA是针对嵌入式系统优化的小型ALSA库,它简化了与底层音频驱动的交互,提供了更轻量级的API,使得Android音频系统能够更容易地与Rockchip平台上的音频硬件进行通信。这里的HAL层负责将Android音频框架的高级接口转换为可以直接与硬件交互的命令和数据格式。
在RK3288平台上,TinyALSA HAL可能会处理音频路由设置、音量控制、PCM数据流的读写以及其他与音频相关的硬件控制逻辑。
adb shell dumpsys media.audio_flinger
HDMI接入屏幕之后喇叭噪音问题
commit 8a6f285c2eada60cef1170de8e3cfe6529582ae8
Author: xiaogang.li <xiaogang.li@xintiangui.com>
Date: Wed Mar 20 11:59:16 2024 +0800
rt5640和es8323音频芯片冲突问题修改
diff --git a/android/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c b/android/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c
index 0a35b8090f..f249c2ae69 100755
--- a/android/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c
+++ b/android/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c
@@ -588,7 +588,7 @@ static int start_output_stream(struct stream_out *out)
char value[PROPERTY_VALUE_MAX] = "";
struct audio_device *adev = out->dev;
int type;
- bool connect_hdmi = true;
+ bool connect_hdmi = false;
int ret = 0;
ALOGD("%s",__FUNCTION__);
@@ -629,7 +629,7 @@ static int start_output_stream(struct stream_out *out)
#endif
out_dump(out, 0);
#endif
- connect_hdmi = true;
+ connect_hdmi = false;
route_pcm_open(getRouteFromDevice(out->device));
if (out->device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
diff --git a/android/hardware/rockchip/audio/tinyalsa_hal/codec_config/config_list.h b/android/hardware/rockchip/audio/tinyalsa_hal/codec_config/config_list.h
index b02e790434..4126280775 100755
--- a/android/hardware/rockchip/audio/tinyalsa_hal/codec_config/config_list.h
+++ b/android/hardware/rockchip/audio/tinyalsa_hal/codec_config/config_list.h
@@ -93,6 +93,10 @@ struct alsa_sound_card_config sound_card_config_list[] = {
{
.sound_card_name = "rkhdmianalogsnd",
.route_table = &hdmi_analog_config_table,
+ },
+ {
+ .sound_card_name = "rockchipes8323c",
+ .route_table = &es8316_config_table,
}
};
diff --git a/android/kernel/arch/arm/boot/dts/rk3288-android.dtsi b/android/kernel/arch/arm/boot/dts/rk3288-android.dtsi
index 48ef7ea996..5a6b0ffc1a 100755
--- a/android/kernel/arch/arm/boot/dts/rk3288-android.dtsi
+++ b/android/kernel/arch/arm/boot/dts/rk3288-android.dtsi
@@ -374,9 +374,9 @@
status = "disabled";
compatible = "rockchip,rk3288-hdmi-analog",
"rockchip,rk3368-hdmi-analog";
- rockchip,model = "rockchip,rt5640-codec";
+ rockchip,model = "rockchip,es8323-codec";
rockchip,cpu = <&i2s>;
- rockchip,codec = <&rt5640>, <&hdmi>;
+ rockchip,codec = <&es8323>, <&hdmi>;
rockchip,widgets =
"Microphone", "Microphone Jack",
"Headphone", "Headphone Jack";
diff --git a/android/kernel/arch/arm/boot/dts/rk3288-evb.dtsi b/android/kernel/arch/arm/boot/dts/rk3288-evb.dtsi
index c155c568b1..59fb24b19f 100755
--- a/android/kernel/arch/arm/boot/dts/rk3288-evb.dtsi
+++ b/android/kernel/arch/arm/boot/dts/rk3288-evb.dtsi
@@ -91,17 +91,6 @@
sound-dai = <&es8323>;
};
};
-
- simple-audio-card,dai-link@1 {
- format = "i2s";
- cpu {
- sound-dai = <&i2s>;
- };
-
- codec {
- sound-dai = <&hdmi>;
- };
- };
};
ext_gmac: external-gmac-clock {
@@ -314,6 +303,7 @@
status = "okay";
rt5640: rt5640@1c {
+ status = "disabled";
#sound-dai-cells = <0>;
compatible = "realtek,rt5640";
reg = <0x1c>;
diff --git a/android/kernel/arch/arm/boot/dts/rk3288-wif-hdmi-kfh.dts b/android/kernel/arch/arm/boot/dts/rk3288-wif-hdmi-kfh.dts
index d1888f0939..6a52b81d8f 100755
--- a/android/kernel/arch/arm/boot/dts/rk3288-wif-hdmi-kfh.dts
+++ b/android/kernel/arch/arm/boot/dts/rk3288-wif-hdmi-kfh.dts
@@ -123,10 +123,10 @@
//};
&hdmi_analog_sound {
- status = "okay";
+ status = "disabled";
};
&sound{
+ status = "okay";
};
&i2c0 {
clock-frequency = <400000>;
@@ -356,7 +356,7 @@ status = "okay";
status = "okay";
es8323: es8323@10 {
- status = "disabled";
+ status = "okay";
compatible = "everest,es8323";
reg = <0x10>;
spk-con-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>;