Debugging audio is divided into software debugging and driver debugging.
When verifying the output of the Andorid13 audio headset, using the apk to play an audio, it was found that only the right headset has output and the left headset has no sound. According to debugging experience, it is generally a driver problem.
First try tinyplay to play headphones. To use tinyplay, you need to switch tinymix to the headphone channel first:
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
Find the audio hal layer code codec config, hardware/rockchip/audio/tinyalsa_hal/codec_config. Switch the headphone output description in 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},
},
};
Then use tinymix to switch to the headphone channel according to the above configuration:
tinymix 4 192 192
tinymix 39 1
tinymix 41 1
Then use tinyplay to play the es8316 sound card and test the headphone output:
tinyplay data/48000_2channel.wav -D 0 -d 0 -n 3 -p 480
At this time, when I heard the earphones, only the right earphone had output, after confirming that there was no problem with the earphones. Confirm that the codec is normal when comparing Android 12, and compare the codec registers during playback of the two versions.
/d/regmap/7-0010 # cat registers // es8316挂在到i2c7总线上
The comparison registers are different as follows:
Compare the difference register values and modify the codec code to the configuration register.
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;
}
After modification, the register configurations during playback of the two versions of codec are consistent. I found that there is still a problem with the headphone output in Android 13. I suspect it's a board problem. Just replace it with another board and it will be fine.
If it is a Linux version, use the alsa utils tool amixer to switch routes:
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
Compared with the above tinymix, the main modifications to ctl are as follows:
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 is modified as follows:
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 register command:
cat /sys/kernel/debug/regmap/7-0010/registers
After the registers are consistent, there is still no sound. Compared with Linux, refer to 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>;
};
};
And the android version:
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>;
};
After modification, aplay now has sound.
aplay -D hw:0,0 sdcard/48000_2channel.wav