Closed lloovve closed 5 years ago
this bug is because es8328 driver did not update register 0x03 correctly. microphone bias did not enabled. once we record audio it change 0x03 from 0xfc to 0x0c but this 0x0c should be 0x00. I will looking into this later.
i try this work for few days ,maybe this bug we shuld work on register ES8328_DACCONTROL21(reg 43) slrck lrck_sel ES8328_ADCCONTROL3 (reg 11) TRI
ES8328_DACCONTROL21=0x80 ES8328_ADCCONTROL3=0x00 ASDOUT has i2s date out ,but rec flie paly is noise
I use a simple logic analyser do this. I tried your register, looks like it work more or less, at least switch is all on, but noise output it should be some volume control is not turned to max
http://dl.radxa.com/rock2/docs/hw/ds/ES8388%20user%20Guide.pdf
maybe help
I have bought esp32-lyrat ,hope some help to do this
actually once I make it work, 20170527 version, but not using es8328 driver, directly hard coded into driver.
03 0c -> 03 00 0d 22 -> 0d 33(272) 18 22 -> 18 33 19 24 -> 19 20
After fix the upper register, it works But es8328 driver modify the registers to default...so still need to code and understand the driver to make it work ;)
I noticed that es8388 datasheet ,slave mode not support 272 Ratio ,and es8388 in slave mode will auto detect MCLK/LRCK ratio.
i change es8388 as master mode and 7688 slaver mode rec is ok, so the problem is above
all set
/ / //复位所有寄存器
snd_soc_write(codec, ES8328_CONTROL1, 0x80);
//MCLK 分频系数设置
snd_soc_write(codec, ES8328_CONTROL1, 0x75);
//停止状态机 DLL
snd_soc_write(codec, ES8328_CHIPPOWER, 0xF3);
//主机模式
snd_soc_write(codec, ES8328_MASTERMODE, 0x80);
//DAC slrck 控制 same LRCK
snd_soc_write(codec, ES8328_DACCONTROL21, 0x80);
//reg 0 参考电压
snd_soc_write(codec, ES8328_CONTROL1, 0x05);//75
//reg 1 参考电压
snd_soc_write(codec, ES8328_CONTROL2, 0x40);
//ADC 电源管理 全部开启
snd_soc_write(codec, ES8328_ADCPOWER, 0x00);
//DAC 电源开启
snd_soc_write(codec, ES8328_DACPOWER, 0x00);
//ADC PGA控制增益
snd_soc_write(codec, ES8328_ADCCONTROL1, 0x7F);
//ADC 路径 LR 差分输入
snd_soc_write(codec, ES8328_ADCCONTROL2, 0xF0);
//ADC 路径 LINPUT1-RINPUT1 差分引脚对 立体声 ASDOUT 输出
snd_soc_write(codec, ES8328_ADCCONTROL3, 0x00);
//ADC control4 ADC数据格式 i2s 数据格式 ADC数据长度
//全部为左声道数据 16bit i2s格式
snd_soc_write(codec, ES8328_ADCCONTROL4, 0x0C);
//reg 24 DACFsRatio=272
snd_soc_write(codec, ES8328_DACCONTROL2, 0x13);
//ADC control5 MCLK 控制 双速模式ADCFsRatio=13 272
snd_soc_write(codec, ES8328_ADCCONTROL5, 0x13);
//ADC daigial 数字音量 L 左声道 ADC control 9
snd_soc_write(codec, ES8328_ADCCONTROL8, 0x00);
//ADC daigial 数字音量 R 右声道 ADC control 9
snd_soc_write(codec, ES8328_ADCCONTROL9, 0x00);
//ADCRampRate=0.5 ADCSoftRamp=1 ADCLeR=1 ADCMute=0
snd_soc_write(codec, 0x0F, 0x30);//ADC音量0x30 0x04 静音ADC
//参考电压 DAC = off ADC =on DAC DLL=off ADC DLL= on STM DAC =off STM ADC = on
//ADC DEM = on
//DAC DEM = off
snd_soc_write(codec, ES8328_CHIPPOWER, 0x00);
DTS file ,i am not sure
sound { compatible = "simple-audio-card"; simple-audio-card,name = "soundcard"; simple-audio-card,format = "i2s"; simple-audio-card,bitclock-master = <&sound_master>; simple-audio-card,frame-master = <&sound_master>; simple-audio-card,widgets = "Microphone", "Microphone Jack", "Headphone", "Headphone Jack"; simple-audio-card,routing = "LINPUT1", "Microphone Jack", "RINPUT1", "Microphone Jack", "Headphone Jack", "LOUT1", "Headphone Jack", "ROUT1"; simple-audio-card,mclk-fs = <272>;
simple-audio-card,cpu {
sound-dai = <&i2s>;
};
sound_master:simple-audio-card,codec {
sound-dai = <&codec>;
};
};
not that problem. I can record normally now, later I will submit patch.
emm, still have noise use master mode..
works normal now, closed
i use this code, play wav file is ok,but record no voice? need help