赞
踩
调试音频分为软件调试和驱动调试。
验证Andorid13 音频耳机输出的时候,用apk播放一个音频,发现耳机只有右耳机有输出,左耳机没有声音。根据调试经验,一般来说是驱动问题。
先试用tinyplay播放耳机,使用tinyplay,需要先tinymix切换到耳机通路:
rk3588_t:/ # tinymix Mixer name: 'rockchip-es8316' Number of controls: 42 ctl type num name value 0 ENUM 1 I2STDM Digital Loopback Mode Disabled 1 INT 2 Headphone Playback Volume 3 3 2 INT 2 Headphone Mixer Volume 0 0 3 ENUM 1 Playback Polarity Normal 4 INT 2 DAC Playback Volume 192 192 5 BOOL 1 DAC Soft Ramp Switch Off 6 INT 1 DAC Soft Ramp Rate 4 7 BOOL 1 DAC Notch Filter Switch Off 8 BOOL 1 DAC Double Fs Switch Off 9 INT 1 DAC Stereo Enhancement 0 10 BOOL 1 DAC Mono Mix Switch Off 11 ENUM 1 Capture Polarity Normal 12 BOOL 1 Mic Boost Switch On 13 INT 1 ADC Capture Volume 0 14 INT 1 ADC PGA Gain Volume 0 15 BOOL 1 ADC Soft Ramp Switch On 16 BOOL 1 ADC Double Fs Switch Off 17 BOOL 1 ALC Capture Switch On 18 INT 1 ALC Capture Max Volume 13 19 INT 1 ALC Capture Min Volume 8 20 INT 1 ALC Capture Target Volume 10 21 INT 1 ALC Capture Hold Time 0 22 INT 1 ALC Capture Decay Time 3 23 INT 1 ALC Capture Attack Time 2 24 BOOL 1 ALC Capture Noise Gate Switch Off 25 INT 1 ALC Capture Noise Gate Threshold 0 26 ENUM 1 ALC Capture Noise Gate Type Constant PGA Gain 27 BOOL 1 Headphone Jack On 28 BOOL 1 Headset Mic Jack Off 29 BOOL 1 Headphone Switch On 30 BOOL 1 Speaker Switch On 31 BOOL 1 Main Mic Switch On 32 BOOL 1 Headset Mic Switch Off 33 ENUM 1 Differential Mux lin1-rin1 34 ENUM 1 Digital Mic Mux dmic disable 35 ENUM 1 DAC Source Mux LDATA TO LDAC, RDATA TO RDAC 36 ENUM 1 Left Headphone Mux lin1-rin1 37 ENUM 1 Right Headphone Mux lin1-rin1 38 BOOL 1 Left Headphone Mixer LLIN Switch Off 39 BOOL 1 Left Headphone Mixer Left DAC Switch Off 40 BOOL 1 Right Headphone Mixer RLIN Switch Off 41 BOOL 1 Right Headphone Mixer Right DAC Switch Off
查找音频hal层代码codec config, hardware/rockchip/audio/tinyalsa_hal/codec_config. 在es8316_config.h中切换耳机输出描述:
- const struct config_control es8316_headphone_normal_controls[] = {
- {
- .ctl_name = "DAC Playback Volume",
- .int_val = {192, 192},
- },
- {
- .ctl_name = "Left Headphone Mixer Left DAC Switch",
- .int_val = {on},
- },
- {
- .ctl_name = "Right Headphone Mixer Right DAC Switch",
- .int_val = {on},
- },
- };
然后根据上述配置使用tinymix切换到耳机通路:
- tinymix 4 192 192
- tinymix 39 1
- tinymix 41 1
然后使用tinyplay播放es8316声卡,测试耳机输出:
tinyplay data/48000_2channel.wav -D 0 -d 0 -n 3 -p 480
这时候听到耳机也是只有右耳机有输出,在确认耳机没问题的情况下。确认对比android 12的时候codec是正常的,对比两个版本的播放时的codec寄存器。
/d/regmap/7-0010 # cat registers // es8316挂在到i2c7总线上
对比寄存器如下不同:
对比差寄存器值,修改codec代码对配置寄存器。
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c old mode 100644 new mode 100755 index 609459077f9d..2aa290a2e46d --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -744,6 +744,15 @@ static int es8316_probe(struct snd_soc_component *component) */ snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x32); + snd_soc_component_write(component, ES8316_CAL_HPLIV, 0x87); + snd_soc_component_write(component, ES8316_CAL_HPRIV, 0x8c); + snd_soc_component_write(component, ES8316_CAL_HPLMV, 0x00); + snd_soc_component_write(component, ES8316_CAL_HPRMV, 0xff); + //snd_soc_component_write(component, ES8316_SYS_PDN, 0x07); + snd_soc_component_write(component, ES8316_ADC_ALC1, 0xcd); + snd_soc_component_write(component, ES8316_ADC_ALC2, 0x08); + snd_soc_component_write(component, ES8316_ADC_ALC3, 0xa0); + es8316_enable_micbias_for_mic_gnd_short_detect(component); return 0; }
修改后,两个版本codec播放时的寄存器配置一致。发现android 13还是耳机输出有问题。怀疑是板子问题了,换了一块板子烧写就好了。
如果是Linux版本使用alsa utils工具amixer切换route:
root@linaro-alip:/# amixer -c 0 contents numid=28,iface=CARD,name='Headphone Jack' ; type=BOOLEAN,access=r-------,values=1 : values=on numid=29,iface=CARD,name='Headset Mic Jack' ; type=BOOLEAN,access=r-------,values=1 : values=off numid=3,iface=MIXER,name='Headphone Mixer Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=11,step=0 : values=0,0 | dBrange- rangemin=0,,rangemax=4 | dBscale-min=-12.00dB,step=1.50dB,mute=0 rangemin=8,,rangemax=11 | dBscale-min=-4.50dB,step=1.50dB,mute=0 numid=30,iface=MIXER,name='Headphone Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=2,iface=MIXER,name='Headphone Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0 : values=3,3 | dBrange- rangemin=0,,rangemax=0 | dBscale-min=-48.00dB,step=0.00dB,mute=0 rangemin=1,,rangemax=3 | dBscale-min=-24.00dB,step=12.00dB,mute=0 numid=13,iface=MIXER,name='Mic Boost Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=17,iface=MIXER,name='ADC Double Fs Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=15,iface=MIXER,name='ADC PGA Gain Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=10,step=0 : values=0 | dBrange- rangemin=0,,rangemax=0 | dBscale-min=-3.50dB,step=0.00dB,mute=0 rangemin=1,,rangemax=1 | dBscale-min=0.00dB,step=0.00dB,mute=0 rangemin=2,,rangemax=2 | dBscale-min=2.50dB,step=0.00dB,mute=0 rangemin=3,,rangemax=3 | dBscale-min=4.50dB,step=0.00dB,mute=0 rangemin=4,,rangemax=7 | dBscale-min=7.00dB,step=3.00dB,mute=0 rangemin=8,,rangemax=10 | dBscale-min=18.00dB,step=3.00dB,mute=0 numid=16,iface=MIXER,name='ADC Soft Ramp Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=14,iface=MIXER,name='ADC Capture Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=192,step=0 : values=0 | dBscale-min=-96.00dB,step=0.50dB,mute=1 numid=12,iface=MIXER,name='Capture Polarity' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'Normal' ; Item #1 'Invert' : values=0 numid=4,iface=MIXER,name='Playback Polarity' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'Normal' ; Item #1 'R Invert' ; Item #2 'L Invert' ; Item #3 'L + R Invert' : values=0 numid=1,iface=MIXER,name='I2STDM Digital Loopback Mode' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'Disabled' ; Item #1 'Mode1' ; Item #2 'Mode2' ; Item #3 'Mode2 Swap' : values=0 numid=24,iface=MIXER,name='ALC Capture Attack Time' ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0 : values=2 numid=23,iface=MIXER,name='ALC Capture Decay Time' ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0 : values=3 numid=22,iface=MIXER,name='ALC Capture Hold Time' ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0 : values=0 numid=19,iface=MIXER,name='ALC Capture Max Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=28,step=0 : values=13 | dBscale-min=-6.50dB,step=1.50dB,mute=0 numid=20,iface=MIXER,name='ALC Capture Min Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=28,step=0 : values=8 | dBscale-min=-12.00dB,step=1.50dB,mute=0 numid=25,iface=MIXER,name='ALC Capture Noise Gate Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=26,iface=MIXER,name='ALC Capture Noise Gate Threshold' ; type=INTEGER,access=rw------,values=1,min=0,max=31,step=0 : values=0 numid=27,iface=MIXER,name='ALC Capture Noise Gate Type' ; type=ENUMERATED,access=rw------,values=1,items=2 ; Item #0 'Constant PGA Gain' ; Item #1 'Mute ADC Output' : values=0 numid=18,iface=MIXER,name='ALC Capture Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=21,iface=MIXER,name='ALC Capture Target Volume' ; type=INTEGER,access=rw---R--,values=1,min=0,max=10,step=0 : values=10 | dBscale-min=-16.50dB,step=1.50dB,mute=0 numid=9,iface=MIXER,name='DAC Double Fs Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=11,iface=MIXER,name='DAC Mono Mix Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=8,iface=MIXER,name='DAC Notch Filter Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=5,iface=MIXER,name='DAC Playback Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=192,step=0 : values=152,152 | dBscale-min=-96.00dB,step=0.50dB,mute=1 numid=7,iface=MIXER,name='DAC Soft Ramp Rate' ; type=INTEGER,access=rw------,values=1,min=0,max=4,step=0 : values=4 numid=6,iface=MIXER,name='DAC Soft Ramp Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=36,iface=MIXER,name='DAC Source Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'LDATA TO LDAC, RDATA TO RDAC' ; Item #1 'LDATA TO LDAC, LDATA TO RDAC' ; Item #2 'RDATA TO LDAC, RDATA TO RDAC' ; Item #3 'RDATA TO LDAC, LDATA TO RDAC' : values=0 numid=10,iface=MIXER,name='DAC Stereo Enhancement' ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0 : values=0 numid=34,iface=MIXER,name='Differential Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'lin1-rin1' ; Item #1 'lin2-rin2' ; Item #2 'lin1-rin1 with 20db Boost' ; Item #3 'lin2-rin2 with 20db Boost' : values=0 numid=35,iface=MIXER,name='Digital Mic Mux' ; type=ENUMERATED,access=rw------,values=1,items=3 ; Item #0 'dmic disable' ; Item #1 'dmic data at high level' ; Item #2 'dmic data at low level' : values=0 numid=33,iface=MIXER,name='Headset Mic Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=39,iface=MIXER,name='Left Headphone Mixer LLIN Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=40,iface=MIXER,name='Left Headphone Mixer Left DAC Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=37,iface=MIXER,name='Left Headphone Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'lin1-rin1' ; Item #1 'lin2-rin2' ; Item #2 'lin-rin with Boost' ; Item #3 'lin-rin with Boost and PGA' : values=0 numid=32,iface=MIXER,name='Main Mic Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=41,iface=MIXER,name='Right Headphone Mixer RLIN Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=42,iface=MIXER,name='Right Headphone Mixer Right DAC Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off numid=38,iface=MIXER,name='Right Headphone Mux' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'lin1-rin1' ; Item #1 'lin2-rin2' ; Item #2 'lin-rin with Boost' ; Item #3 'lin-rin with Boost and PGA' : values=0 numid=31,iface=MIXER,name='Speaker Switch' ; type=BOOLEAN,access=rw------,values=1 : values=off
对比上面tinymix主要修改ctl如下:
- numid=5,iface=MIXER,name='DAC Playback Volume'
- ; type=INTEGER,access=rw---R--,values=2,min=0,max=192,step=0
- : values=152,152
- | dBscale-min=-96.00dB,step=0.50dB,mute=1
- .....
- numid=40,iface=MIXER,name='Left Headphone Mixer Left DAC Switch'
- ; type=BOOLEAN,access=rw------,values=1
- : values=off
- ......
- numid=42,iface=MIXER,name='Right Headphone Mixer Right DAC Switch'
- ; type=BOOLEAN,access=rw------,values=1
- : values=off
amixer修改如下:
- amixer -c 0 contents
- amixer -c 0 cset numid=5 192 192
- amixer -c 0 cset numid=40 1
- amixer -c 0 cset numid=42 1
- amixer -c 0 cset numid=2 3
- amixer -c 0 cset numid=31 1
3588 linux的codec寄存器命令:
cat /sys/kernel/debug/regmap/7-0010/registers
寄存器一致后,还是无声,对比linux 参考dts:rk3588-evb3-lp5.dtsi:
- &i2c7 {
- status = "okay";
- es8316: es8316@10 {
- status = "okay";
- #sound-dai-cells = <0>;
- compatible = "everest,es8316";
- reg = <0x10>;
- clocks = <&mclkout_i2s0>; //linux版本
- clock-names = "mclk";
- assigned-clocks = <&mclkout_i2s0>;
- assigned-clock-rates = <12288000>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2s0_mclk>;
- };
- };
而android版本:
- es8316: es8316@10 {
- status = "okay";
- #sound-dai-cells = <0>;
- compatible = "everest,es8316";
- reg = <0x10>;
- clocks = <&cru I2S0_8CH_MCLKOUT>; // android版本
- clock-names = "mclk";
- assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
- assigned-clock-rates = <12288000>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2s0_mclk>;
- };
修改后,aplay播放有声音了。
aplay -D hw:0,0 sdcard/48000_2channel.wav
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。