对于当前模块不是很清楚,刚好有个项目这方面有点问题,根据展锐支持文档一步步检查就可以了。首先得先弄清楚硬件具体是怎么连接的,比如文档提到的案例:sprd codec speaker output 连接外部 PA。
耳机接的是什么,speaker接的是什么,receive接的是什么。
本文可能涉及到的文件路径信息参考如下:
kernel/arch/<arch name>/boot/dts/sprd-sound-xxx.dtsi
kernel/arch/<arch name>/boot/dts/<board>.dts
kernel/sound/soc/sprd/sprd-asoc-card-utils.c
kernel/sound/soc/sprd/sprd-asoc-card-utils-hook.c
kernel/sound/soc/sprd/sprd-asoc-card-utils-legacy.c
kernel/sound/soc/sprd/include/sprd-asoc-card-utils.h
kernel/sound/soc/sprd/include/sprd-asoc-card-utils-legacy.h
device/sprd/<chip>/<board>/rootdir/system/etc/audio_params/tiny_hw.xml
device/sprd/<chip>/<board>/rootdir/system/etc/audio_params/codec_pga.xml
device/sprd/<chip>/<board>/rootdir/system/etc/audio_params/audio_para
device/sprd/<chip>/<board>/BoardConfig.mk
这里只做简单记录,详细信息可看展锐提供的文档。
Kernel部分
sprd-sound-xxx.dtsi 中已配置了 common 配置信息,与 common 有差异的配置在对应板级 DTS 中修改,板级 DTS 配置信息会覆盖 common中的定义。
1、sprd-audio-card widgets 配置
不使用外部 PA,需要定义 headphone、speaker、earpiece 三个 widgets。
使用外部 PA,需要定义一个 widgets 表示一个外部 speaker,该 widgets 的 event 可以控制外部 PA 的开关。
2、sprd-audio-card routing 配置
3、sprd spk-ext-pa-info 配置
4、sprd spk-ext-pa-gpio 配置
5、sprd spk-ext-pa-names 配置
HAL 部分
1 Xml 文件配置
.1 Codec 通路配置
这里记录一下正常情况下的配置文件吧
speaker->喇叭,headphone->耳机,earpiece->听筒
tiny_hw.xml<device name="speaker"><path name="on"><ctl name="SPKL Mixer DACLSPKL Switch" val="1" /><ctl name="Speaker Function" val="1" /></path><path name="off"><ctl name="Speaker Function" val="0" /><ctl name="SPKL Mixer DACLSPKL Switch" val="0" /></path>
</device><device name="headphone"><path name="on"><ctl name="HPL EAR Sel" val="HPL" /><ctl name="HPL Mixer DACLHPL Switch" val="1" /><ctl name="HPR Mixer DACRHPR Switch" val="1" /><ctl name="HeadPhone Function" val="1" /></path><path name="off"><ctl name="HeadPhone Function" val="0" /><ctl name="HPL Mixer DACLHPL Switch" val="0" /><ctl name="HPR Mixer DACRHPR Switch" val="0" /><ctl name="HPL EAR Sel" val="EAR" /></path>
</device><device name="earpiece"><path name="on"><ctl name="EAR Mixer DACLEAR Switch" val="1"/><ctl name="Earpiece Function" val="1" /></path><path name="off"><ctl name="Earpiece Function" val="0" /><ctl name="EAR Mixer DACLEAR Switch" val="0"/></path>
</device>
.2 Codec 参数配置
2 Property 属性配置
ro.vendor.audio_tunning.dual_spk 属性 含义ro.vendor.audio_tunning.dual_spk = 0 默认调试模式。ro.vendor.audio_tunning.dual_spk = 1 双 SPK-HPR+HPL 。ro.vendor.audio_tunning.dual_spk = 2 单 SPK-HPL/HPR 。ro.vendor.audio_tunning.dual_spk = 3 听筒喇叭二合一。
3 代码修改
开启ENABLE_DEVICES_CTL_ON宏开关
最后补充两个方法:
1、耳机测试AT命令----AT+SPVLOOP
Description:Audio frequency loopback testSet command:AT+ SPVLOOP= <cmd>,<mode>< volume ><loopbacktype><voiceformat><delaytime><outdevice><indevice>Return :
OKParameter:<cmd>:cmdDescription0 DISABLE1 EABLE2 SETMODE3 SETVOLUME4 SETDEVICE<mode>:Optional mode exists 0-70 : handhold 1 : handfree 2: earphone<volume>: the size of volume<loopbacktype>:0: AD->DA loop,1: AD->ul_process->dl_process->DA loop,2: AD->ul_process->encoder->decoder->dl_process->DA loop<voiceformat>: (1-3)1: EFS vocoder2: HR Vocoder3: AMR Vocoder<delaytime>: (0-1000) ms<outdevice>:1 ear2 spk4 hp<indevice>1 mic_02 mic_14 mic_hp
完整命令:AT+SPVLOOP=1,4,8,2,3,0
2、查看当前音频设备状态----tinymix
C:\Users\lichang>adb shell
sl8541e_1h10_32b:/ # tinymix
Mixer name: 'sprdphone'
Number of controls: 135
ctl type num name value0 ENUM 1 VBC Switch AP
1 ENUM 1 VBC INT Switch AP
2 ENUM 1 VBC DMA Switch AP_AON
3 BOOL 1 VBC DA EQ Switch On
4 BOOL 1 VBC AD01 EQ Switch Off
5 BOOL 1 VBC AD02 EQ Switch Off
6 ENUM 1 VBC EQ FW Name vbc_eq
7 ENUM 1 VBC EQ Update loaded
8 INT 2 VBC DAC01 MIXERDG 0 0
9 INT 2 VBC DAC23 MIXERDG 0 0
10 INT 1 VBC MIXERDG_DA01 STEP 4096
11 INT 1 VBC MIXERDG_DA23 STEP 1
12 INT 1 VBC DACL DG Set 35
13 INT 1 VBC DACR DG Set 35
14 INT 1 VBC ADCL DG Set 16
15 INT 1 VBC ADCR DG Set 16
16 INT 1 VBC ADC23L DG Set 24
17 INT 1 VBC ADC23R DG Set 24
18 INT 1 VBC STL DG Set 24
19 INT 1 VBC STR DG Set 24
20 BOOL 1 VBC DACL DG Switch On
21 BOOL 1 VBC DACR DG Switch On
22 BOOL 1 VBC ADCL DG Switch On
23 BOOL 1 VBC ADCR DG Switch On
24 BOOL 1 VBC ADC23L DG Switch Off
25 BOOL 1 VBC ADC23R DG Switch Off
26 BOOL 1 VBC STL HPF Switch Off
27 BOOL 1 VBC STR HPF Switch Off
28 INT 1 VBC STL HPF Set 3
29 INT 1 VBC STR HPF Set 3
30 BOOL 1 VBC AD0 DG Mux Off
31 BOOL 1 VBC AD1 DG Mux Off
32 BOOL 1 VBC AD2 DG Mux Off
33 BOOL 1 VBC AD3 DG Mux Off
34 ENUM 1 VBC DA IIS Mux AUDIIS0
35 INT 1 VBC DA EQ Profile Select 0
36 INT 1 VBC AD01 EQ Profile Select -1
37 INT 1 VBC AD23 EQ Profile Select -1
38 INT 1 VBC_DA_SRC 0
39 BOOL 1 VBC_FM_MUTE_DIRECT Off
40 BOOL 1 VBC_FM_UNMUTE_SMOOTH Off
41 INT 1 VBC FM_MUTE_SMOOTHDG STEP 1
42 BOOL 1 VBC_IIS_WIDTH_SEL Off
43 BOOL 1 VBC_DA_IIS_LRMOD_SEL Off
44 BOOL 1 VBC_AD01_IIS_LRMOD_SEL Off
45 BOOL 1 VBC_AD23_IIS_LRMOD_SEL Off
46 ENUM 1 SYS_IIS0 ap_iis0
47 ENUM 1 SYS_IIS1 vbc_iis1
48 ENUM 1 SYS_IIS2 vbc_iis1
49 ENUM 1 SYS_IIS3 vbc_iis1
50 ENUM 1 SYS_IIS4 vbc_iis1
51 BOOL 1 IIS_BT_FM_LOOP Off
52 BOOL 1 vbc_access_en Off
53 ENUM 1 VBC DAC0 Mixer Mux Sel by eq
54 ENUM 1 VBC DAC1 Mixer Mux Sel by eq
55 ENUM 1 VBC ST0 Mixer Mux Sel by eq
56 ENUM 1 VBC ST1 Mixer Mux Sel by eq
57 ENUM 1 VBC DAC0 Mixer Out Sel by eq
58 ENUM 1 VBC DAC1 Mixer Out Sel by eq
59 ENUM 1 VBC ST0 Mixer Out Sel by eq
60 ENUM 1 VBC ST1 Mixer Out Sel by eq
61 INT 1 SPKL Playback Volume 3
62 INT 1 HPL Playback Volume 1
63 INT 1 HPR Playback Volume 7
64 INT 1 EAR Playback Volume 6
65 INT 1 ADCL Capture Volume 6
66 INT 1 ADCR Capture Volume 6
67 INT 1 DAC Playback Volume 2
68 INT 1 Inter PA Config 2
69 BOOL 1 DACL Switch On
70 BOOL 1 DACR Switch On
71 BOOL 1 MIC Bias Switch Off
72 BOOL 1 HEADMIC Bias Switch Off
73 BOOL 1 DACLSPKL Enable On
74 BOOL 1 DACRSPKL Enable On
75 ENUM 1 Aud Codec Info (null)
76 ENUM 1 DAC LRCLK Select normal
77 ENUM 1 ADC LRCLK Select normal
78 ENUM 1 ADC1 LRCLK Select normal
79 ENUM 1 DAS Input Mux L+R
80 INT 1 PCM_TOTAL_NORMAL 0
81 INT 1 PCM_TOTAL_DEEPBUF 0
82 BOOL 1 Speaker Function Off
83 BOOL 1 Speaker1 Function Off
84 BOOL 1 Earpiece Function Off
85 BOOL 1 HeadPhone Function On
86 BOOL 1 Line Function Off
87 BOOL 1 Mic Function Off
88 BOOL 1 Aux Mic Function On
89 BOOL 1 HP Mic Function Off
90 BOOL 1 DMic Function Off
91 BOOL 1 DMic1 Function Off
92 BOOL 1 Digital FM Function Off
93 BOOL 1 Speaker Mute Off
94 BOOL 1 Speaker2 Mute Off
95 BOOL 1 HeadPhone Mute Off
96 BOOL 1 Earpiece Mute Off
97 ENUM 1 SmartAmp Boost Bypass
98 ENUM 1 ST0 CHAN MUX AD01
99 ENUM 1 ST1 CHAN MUX AD01
100 ENUM 1 ST0 INMUX AD0(2)ST0
101 ENUM 1 ST1 INMUX AD1(3)ST1
102 ENUM 1 AD0 INMUX IIS0AD0
103 ENUM 1 AD1 INMUX IIS1AD1
104 ENUM 1 AD2 INMUX IIS2AD2
105 ENUM 1 AD3 INMUX IIS3AD3
106 ENUM 1 AD IISMUX DIGFM
107 ENUM 1 AD23 IISMUX AUDIIS1
108 ENUM 1 DA0 ADDFM MUX BYPASS(ST)
109 ENUM 1 DA1 ADDFM MUX BYPASS(ST)
110 ENUM 1 DA0 ADDST MUX BYPASS(ST)
111 ENUM 1 DA1 ADDST MUX BYPASS(ST)
112 BOOL 1 Aud Loop in VBC Switch Off
113 BOOL 1 Aud1 Loop in VBC Switch Off
114 ENUM 1 HPL EAR Sel EAR
115 BOOL 1 HPL Mixer DACLHPL Switch Off
116 BOOL 1 HPR Mixer DACRHPR Switch Off
117 BOOL 1 SPKL Mixer DACLSPKL Switch On
118 BOOL 1 SPKL Mixer ADCLSPKL Switch Off
119 BOOL 1 SPKL Mixer ADCRSPKL Switch Off
120 BOOL 1 SPKR Mixer ADCLSPKR Switch Off
121 BOOL 1 SPKR Mixer ADCRSPKR Switch Off
122 BOOL 1 EAR Mixer DACLEAR Switch Off
123 BOOL 1 ADCL Mixer MainMICADCL Switch Off
124 BOOL 1 ADCL Mixer AuxMICADCL Switch Off
125 BOOL 1 ADCL Mixer HPMICADCL Switch On
126 BOOL 1 ADCR Mixer MainMICADCR Switch Off
127 BOOL 1 ADCR Mixer AuxMICADCR Switch Off
128 BOOL 1 ADCR Mixer HPMICADCR Switch On
129 BOOL 1 ADC-DAC Adie Loop switch Off
130 BOOL 1 ADC1-DAC Adie Loop switch Off
131 BOOL 1 ADC-DAC Digital Loop switch Off
132 BOOL 1 ADC1-DAC Digital Loop switch Off
133 BOOL 1 Virt Output Switch On
134 BOOL 1 Virt HP Jack Switch Off
或者
针对某一条通路开关手动开关或者读取状态。