首先交代下运行环境:
RK3288+Android5.1 mid版本 原来开发板上用的音频Codec是RT5631,现在板子上换了RT5640,拿到板子后首先Google一把,收到了CSDN的一篇文章,按他的说法是RT3224和RT5640是pin2pin的,软硬件完全兼容,使用RT3261的驱动即可,我实际在Android5.1上测试不行。于是还是使用了RT5640试了下,发现有有有声音,一路没有声音。修改过程记录如下:1.修改config
路径kernel/arch/arm/configs/rockchip_defconfig:
CONFIG_SND_RK_SOC_RT5640=y2.添加DTS
路径kernel/arch/arm/boot/dts/rk3288-tb_8846.dts:
rockchip-rt5640 { status = “okay”; compatible = “rockchip-rt5640”; dais { dai0 { audio-codec = <&rt5640>; audio-controller = <&i2s>; format = “i2s”; //continuous-clock; //bitclock-inversion; //frame-inversion; //bitclock-master; //frame-master; }; dai1 { audio-codec = <&rt5640>; audio-controller = <&i2s>; //format = “i2s”; format = “dsp_a”; //continuous-clock; bitclock-inversion; //frame-inversion; //bitclock-master; //frame-master; }; }; }; &i2c2 { status = “okay”; rt5640: rt5640@1c { compatible = “rt5640”; reg = <0x1c>; codec-en-gpio = <1>;//sdk default high level spk-num= <2>; modem-input-mode = <1>; lout-to-modem_mode = <1>; spk-amplify = <2>; playback-if1-data_control = <0>; playback-if2-data_control = <0>; status = “okay”; }; };<
编译完成后烧写进去IN1P IN1N可以出声音了,但是IN2P IN2N死活没有声音,经过2天读RT5640 datasheet,终于搞定了问题,需要在kernel/sound/soc/codecs/rt5640.c里面做如下修改:
static struct rt5640_init_reg init_list[] = { {RT5640_GEN_CTRL1 , 0x3f01},//fa[12:13] = 1b; fa[8~11]=1; fa[0]=1 {RT5640_ADDA_CLK1 , 0x1114},//73[2] = 1b {RT5640_MICBIAS , 0x3030},//93[5:4] = 11b ….. …. {RT5640_REC_L2_MIXER , 0x007d},//Mic1 -> RECMIXL // {RT5640_REC_R2_MIXER , 0x007d},//Mic1 -> RECMIXR // close by lwx // {RT5640_REC_L2_MIXER , 0x006f},//Mic2 -> RECMIXL {RT5640_REC_R2_MIXER , 0x006f},//Mic2 -> RECMIXR // open by lwx {RT5640_STO_ADC_MIXER , 0x3020},//ADC -> Sto ADC mixer ….. …..修改完成后IN2P IN2N也可以输入声音了。
3.调试技巧
调试工具就是tinycap tinymix tinyplay编译进android系统即可
#采集声音 tinycap test.wav #播放声音 tinyplay test.wav #控制并改特定的寄存器 tinymix还有2个超级有用的命令,可以实时修改codec的寄存器,可写,对于调试codec来说实在太方便了。
#读寄存器 cat sys/kernel/debug/asoc/RK_RT5640/rt5640.2-001c/codec_reg #写寄存器 echo 01 007D > sys/kernel/debug/asoc/RK_RT5640/rt5640.2-001c/codec_reg免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:RK3288 Android5.1下的RT5640调试 https://www.yhzz.com.cn/a/16128.html