本帖最后由 chenyuanwei 于 2024-11-11 11:27 编辑
背景: 平台:MT6768 (MT8786) 内核版本:kernel-5.10
下面($project)以AGN_4313R_RD_MX12832_69U的双pa做例子 一、配置流程 1.1 device/agenew/($project)/ - ProjectConfig.mk
- MTK_AUDIO_NUMBER_OF_SPEAKER = 2 //按照实际的pa数配置
- MTK_AUDIO_SPEAKER_PATH = smartpa_awinic_aw883xx//音频通道
- MTK_AUDIO_AWINIC_EFFECT_SUPPORT = yes
- //添加固件路径 按照实际情况添加32bit还是双pa
- device.mk
- ifeq ($(MTK_AUDIO_AWINIC_EFFECT_SUPPORT),yes)
- PRODUCT_COPY_FILES += kernel-5.10/sound/soc/codecs/aw883xx/config/aw88395/32bit/stereo/aw883xx_acf.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/aw883xx_acf.bin
- PRODUCT_COPY_FILES += vendor/mediatek/proprietary/hardware/smartpa/awinic/awinic_params.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/awinic_params.bin
- PRODUCT_COPY_FILES += vendor/mediatek/proprietary/hardware/smartpa/awinic/awinic_params_mute.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/awinic_params_mute.bin
- PRODUCT_PACKAGES += libawinic.audio.effect.skt3
- endif
- //添加ko加载
- ko_order_table.csv
- snd-soc-aw883xx.ko,/sound/soc/codecs/aw883xx/snd-soc-aw883xx.ko ,vendor,Y,N,user/userdebug/eng
复制代码
1.2 kernel-5.10 1.2.1 修改dts - //按实际的i2c和管脚来配置 记得检测有没有冲突的gpio
- arch/arm64/boot/dts/mediatek/AGN_4313R_RD_MX12832_69U.dts
- &i2c3 {
- aw883xx_smartpa_0: aw883xx_smartpa@34 {
- compatible = "awinic,aw883xx_smartpa";
- #sound-dai-cells = <0>;
- reg = <0x34>;
- reset-gpio = <&pio 152 0>;
- irq-gpio = <&pio 39 0x0>;
- sound-channel = <0>;
- re-min = <1000>;
- re-max= <40000>;
- /*aw-cali-check = <1>;*/
- status = "okay";
- };
- aw883xx_smartpa_1: aw883xx_smartpa@37 {
- compatible = "awinic,aw883xx_smartpa";
- #sound-dai-cells = <0>;
- reg = <0x37>;
- reset-gpio = <&pio 153 0>;
- irq-gpio = <&pio 10 0x0>;
- sound-channel = <1>;
- re-min = <1000>;
- re-max= <40000>;
- /*aw-cali-check = <1>;*/
- status = "okay";
- };
- };
- //修改sound-dai 接口
- &sound {
- mediatek,speaker-codec {
- - sound-dai = <&mt6660>;
- + sound-dai = <&aw883xx_smartpa_0 &aw883xx_smartpa_1>;
复制代码
1.2.2 修改固件加载和平台注册声卡 - arch/arm64/configs/AGN_4313R_RD_MX12832_69U_defconfig
- CONFIG_SND_SOC_AW883XX=m
- drivers/base/firmware_loader/main.c
- //fw_decompress_xz 底下添加固件路径
- static const char * const fw_path[] = {
- fw_path_para,
- + "/vendor/firmware",
- A sound/soc/codecs/aw883xx/
- M sound/soc/mediatek/mt6768/mt6768-mt6358.c
- //通路配置 注意3-0034和aif-3-34 这里的3是对应i2c地址的 请按实际i2c或看log打印的名字确认
- SND_SOC_DAILINK_DEFS(i2s0,
- DAILINK_COMP_ARRAY(COMP_CPU("I2S0")),
- +#if IS_ENABLED(CONFIG_SND_SOC_AW883XX)
- + DAILINK_COMP_ARRAY(COMP_CODEC("aw883xx_smartpa.3-0034", "aw883xx-aif-3-34"),
- + COMP_CODEC("aw883xx_smartpa.3-0037", "aw883xx-aif-3-37")),
- +#else
- DAILINK_COMP_ARRAY(COMP_DUMMY()),
- +#endif
- DAILINK_COMP_ARRAY(COMP_EMPTY()));
- SND_SOC_DAILINK_DEFS(i2s1,
- DAILINK_COMP_ARRAY(COMP_CPU("I2S1")),
- @@ -557,7 +562,12 @@ SND_SOC_DAILINK_DEFS(i2s2,
- DAILINK_COMP_ARRAY(COMP_EMPTY()));
- SND_SOC_DAILINK_DEFS(i2s3,
- DAILINK_COMP_ARRAY(COMP_CPU("I2S3")),
- +#if IS_ENABLED(CONFIG_SND_SOC_AW883XX)
- + DAILINK_COMP_ARRAY(COMP_CODEC("aw883xx_smartpa.3-0034", "aw883xx-aif-3-34"),
- + COMP_CODEC("aw883xx_smartpa.3-0037", "aw883xx-aif-3-37")),
- +#else
- DAILINK_COMP_ARRAY(COMP_DUMMY()),
- +#endif
- DAILINK_COMP_ARRAY(COMP_EMPTY()));
- SND_SOC_DAILINK_DEFS(hw_gain1,
- DAILINK_COMP_ARRAY(COMP_CPU("HW Gain 1")),
复制代码 1.2.3 在以下路径添加驱动文件aw883xx sound/soc/codecs/aw883xx/
1.3 dws的修改 下面两个路径做到一致 vendor/mediatek/proprietary/tools/dct
/vendor/mediatek/proprietary/bootable/bootloader/preloader
- + <gpio36>
- + <eint_mode>false</eint_mode>
- + <def_mode>2</def_mode>
- + <inpull_en>false</inpull_en>
- + <inpull_selhigh>false</inpull_selhigh>
- + <def_dir>OUT</def_dir>
- + <out_high>false</out_high>
- + <varName0>GPIO_SMARTPA_I2S_BCK_PIN</varName0>
- + <smt>false</smt>
- + <ies>true</ies>
- + </gpio36>
- + <gpio37>
- + <eint_mode>false</eint_mode>
- + <def_mode>2</def_mode>
- + <inpull_en>false</inpull_en>
- + <inpull_selhigh>false</inpull_selhigh>
- + <def_dir>OUT</def_dir>
- + <out_high>false</out_high>
- + <varName0>GPIO_SMARTPA_LRCK_PIN</varName0>
- + <smt>false</smt>
- + <ies>true</ies>
- + </gpio37>
- + <gpio38>
- + <eint_mode>false</eint_mode>
- + <def_mode>2</def_mode>
- + <inpull_en>false</inpull_en>
- + <inpull_selhigh>false</inpull_selhigh>
- + <def_dir>OUT</def_dir>
- + <out_high>false</out_high>
- + <varName0>GPIO_SMARTPA_I2S_DOUT_PIN</varName0>
- + <smt>false</smt>
- + <ies>true</ies>
- + </gpio38>
- <gpio39>
- + <eint_mode>true</eint_mode>
- + <def_mode>0</def_mode>
- + <inpull_en>true</inpull_en>
- + <inpull_selhigh>true</inpull_selhigh>
- + <def_dir>IN</def_dir>
- + <out_high>false</out_high>
- + <varName0>GPIO_EINT_SMARTPA_PIN</varName0>
- <smt>true</smt>
- + <ies>true</ies>
- </gpio39>
- + <gpio40>
- + <eint_mode>false</eint_mode>
- + <def_mode>2</def_mode>
- + <inpull_en>true</inpull_en>
- + <inpull_selhigh>false</inpull_selhigh>
- + <def_dir>IN</def_dir>
- + <out_high>false</out_high>
- + <varName0>GPIO_SMARTPA_I2S_DIN_PIN</varName0>
- + <smt>false</smt>
- + <ies>true</ies>
- + </gpio40>
- <gpio41>
- <eint_mode>true</eint_mode>
- <def_mode>0</def_mode>
- @@ -1422,7 +1474,7 @@
- <inpull_en>false</inpull_en>
- <inpull_selhigh>false</inpull_selhigh>
- <def_dir>OUT</def_dir>
- - <out_high>true</out_high>
- + <out_high>false</out_high>
- <smt>false</smt>
- <ies>true</ies>
复制代码二、测试流程 2.1、看log 2.1.1 i2c通信成功 可以看到有这个log:aw883xx_i2c_probe: dev_cnt 1 probe completed successfully
2.1.2 声卡注册成功: aw883xx_codec_probe :enter
2.1.3 bin 文件加载成功: get vaild profile: get baild profile:2
2.1.4 播放音乐,PA 发声:
aw883xx_start_pa: start successs
2.2 用MMITest 通过adb root tinymix |grep aw 可以看到音频现在工作模式
|