< >
首先交代下运行环境:
RK3288 + Android5.1 mid版本
原来开发主板用的音频Codec是RT5631,现在板子上换了RT5640,拿到板子后首先Google一把,收到了CSDN的文章,按他的说法是RT3224和RT5640是pin2pin的,软硬件完全兼容,使用RT3261的驱动即可,我实际在Android5.1上测试不行。于是还是使用了RT5640试了下,发现有有声音,一路没有声音。修改过程记录如下:
1.修改配置
路径内核/ arch / arm / configs / rockchip_defconfig:
CONFIG_SND_RK_SOC_RT5640 = y
2.添加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数据表,终于搞定了问题,需要在kernel / sound / soc / codecs / rt5640.c里面做如下修改:
static struct rt5640_init_reg init_list[] = {
{RT5640_GEN_CTRL1 , 0x3f01},//fa[12:13] = 1'b; fa[8~11]=1; fa[0]=1
{RT5640_ADDA_CLK1 , 0x1114},//73[2] = 1'b
{RT5640_MICBIAS , 0x3030},//93[5:4] = 11'b
.....
....
{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 mid版本
原来开发主板用的音频Codec是RT5631,现在板子上换了RT5640,拿到板子后首先Google一把,收到了CSDN的文章,按他的说法是RT3224和RT5640是pin2pin的,软硬件完全兼容,使用RT3261的驱动即可,我实际在Android5.1上测试不行。于是还是使用了RT5640试了下,发现有有声音,一路没有声音。修改过程记录如下:
1.修改配置
路径内核/ arch / arm / configs / rockchip_defconfig:
CONFIG_SND_RK_SOC_RT5640 = y
2.添加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数据表,终于搞定了问题,需要在kernel / sound / soc / codecs / rt5640.c里面做如下修改:
static struct rt5640_init_reg init_list[] = {
{RT5640_GEN_CTRL1 , 0x3f01},//fa[12:13] = 1'b; fa[8~11]=1; fa[0]=1
{RT5640_ADDA_CLK1 , 0x1114},//73[2] = 1'b
{RT5640_MICBIAS , 0x3030},//93[5:4] = 11'b
.....
....
{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
举报