为方便安卓设备测试,要支持adb命令录音
tinycap和tinymix 是tinyalsa下的可执行程序,源码在external\tinyalsa下
我们只需要在对应平台的device下的mk 内添加
PRODUCT_PACKAGES += tinycap
PRODUCT_PACKAGES += tinymix
编译即可
类似文件为./device/xx/xx.mk
还需要配置权限,否则需要root权限,无root权限会运行出如下错误
$ tinymix
Failed to open mixer
$ tinycap /sdcard/Music/22.wav -D 0 -d 0 -r 16000 -b 16 -T 5
Unable to open PCM device (cannot open device ‘/dev/snd/pcmC0D0c’: Permission denied)
Captured 0 frames
在device下的对应平台mk中,添加类似如下内容
chmod 666 /dev/snd/controlC0
chmod 666 /dev/snd/pcmC0D0c
再编译出固件烧录进设备,再执行tinycap指令就正常.
录音与播放需要使用tinymix修改功放寄存器,确定tinymix参数可使用两种方法
一种是根据驱动代码确认
另一种
diff -uN /tmp/1.txt /tmp/2.txt
--- /tmp/1.txt 2023-06-06 14:36:36.000000000 +0800
+++ /tmp/2.txt 2023-06-06 14:35:29.941530661 +0800
@@ -17,7 +17,7 @@
12 INT 1 VBC_SRC_FM 0
13 INT 2 VBC DAC0 DG Set 0 0
14 INT 2 VBC DAC1 DG Set 0 0
-15 INT 2 VBC ADC0 DG Set 0 0
+15 INT 2 VBC ADC0 DG Set 46 46
16 INT 2 VBC ADC1 DG Set 0 0
17 INT 2 VBC ADC2 DG Set 0 0
18 INT 2 VBC ADC3 DG Set 0 0
@@ -88,8 +88,8 @@
83 ENUM 1 VBC_UL_MUTE disable
84 ENUM 1 VBC_DL_MUTE disable
85 ENUM 1 VBC IIS Master Setting disable_iis0
-86 BOOL 1 agdsp_access_en Off
-87 BOOL 1 agdsp_access_a2dp_en Off
+86 BOOL 1 agdsp_access_en On
+87 BOOL 1 agdsp_access_a2dp_en On
88 INT 1 VBC_VOLUME 0
89 INT 1 Audio Structure Profile Update 1
90 INT 1 DSP VBC Profile Update 1
@@ -104,7 +104,7 @@
99 ENUM 1 VBC_IIS_TX2_WD_SEL WD_16BIT
100 ENUM 1 VBC_IIS_RX0_WD_SEL WD_24BIT
101 ENUM 1 VBC_IIS_RX1_WD_SEL WD_24BIT
-102 ENUM 1 VBC_IIS_RX2_WD_SEL WD_16BIT
+102 ENUM 1 VBC_IIS_RX2_WD_SEL WD_24BIT
103 ENUM 1 VBC_IIS_RX3_WD_SEL WD_16BIT
104 ENUM 1 VBC_IIS_TX0_LRMOD_SEL LEFT_HIGH
105 ENUM 1 VBC_IIS_TX1_LRMOD_SEL LEFT_HIGH
@@ -123,7 +123,7 @@
118 ENUM 1 VBC_DSP_MAINMIC_REF_PATH_SEL MAINMIC_FROM_LEFT
119 ENUM 1 IVSENCE_FUNC_DSP disable
120 ENUM 1 ag_iis0_ext_sel disable
-121 ENUM 1 ag_iis1_ext_sel disable
+121 ENUM 1 ag_iis1_ext_sel enable
122 ENUM 1 ag_iis2_ext_sel disable
123 ENUM 1 SYS_IIS0 vbc_iis0
124 ENUM 1 SYS_IIS1 vbc_iis0
@@ -143,8 +143,8 @@
138 ENUM 1 Aud Codec Info (null)
139 INT 1 Inter PA Config 303
140 ENUM 1 DAC LRCLK Select normal
-141 ENUM 1 ADC LRCLK Select normal
-142 ENUM 1 ADC1 LRCLK Select normal
+141 ENUM 1 ADC LRCLK Select invert
+142 ENUM 1 ADC1 LRCLK Select invert
143 INT 1 HP mix mode 0
144 INT 1 SPK DG fall 1
145 ENUM 1 DAS Input Mux L+R
@@ -156,7 +156,7 @@
151 BOOL 1 Earpiece Function Off
152 BOOL 1 HeadPhone Function Off
153 BOOL 1 Line Function Off
-154 BOOL 1 Mic Function Off
+154 BOOL 1 Mic Function On
155 BOOL 1 Aux Mic Function Off
156 BOOL 1 HP Mic Function Off
157 BOOL 1 DMic Function Off
@@ -167,18 +167,18 @@
162 BOOL 1 HeadPhone Mute Off
163 BOOL 1 Earpiece Mute Off
164 ENUM 1 SmartAmp Boost Bypass
-165 BOOL 1 ADCL Mixer MainMICADCL Switch Off
+165 BOOL 1 ADCL Mixer MainMICADCL Switch On
166 BOOL 1 ADCL Mixer HPMICADCL Switch Off
167 BOOL 1 ADCL Mixer VSENSEL Switch Off
168 BOOL 1 ADCR Mixer AuxMICADCR Switch Off
169 BOOL 1 ADCR Mixer HPMICADCR Switch Off
170 BOOL 1 ADCR Mixer ISENSER Switch Off
-171 BOOL 1 AUD ADC0L Switch Off
-172 BOOL 1 AUD ADC0R Switch Off
+171 BOOL 1 AUD ADC0L Switch On
+172 BOOL 1 AUD ADC0R Switch On
173 BOOL 1 AUD ADC1L Switch Off
174 BOOL 1 AUD ADC1R Switch Off
-175 INT 1 ADCL Gain ADCL Capture Volume 0
-176 INT 1 ADCR Gain ADCR Capture Volume 0
+175 INT 1 ADCL Gain ADCL Capture Volume 6
+176 INT 1 ADCR Gain ADCR Capture Volume 6
177 INT 1 DAC Gain DAC Playback Volume 0
178 INT 1 SPKL Gain SPKL Playback Volume 0
179 BOOL 1 SPKL Mixer DACLSPKL Switch Off
@@ -200,19 +200,19 @@
195 ENUM 1 Digital ADC In Sel ADC
196 ENUM 1 Digital ADC1 In Sel ADC
197 BOOL 1 S_NORMAL_AP01_P_CODEC SWITCH Off
-198 BOOL 1 S_NORMAL_AP01_C_CODEC SWITCH Off
+198 BOOL 1 S_NORMAL_AP01_C_CODEC SWITCH On
199 BOOL 1 S_NORMAL_AP23_P_CODEC SWITCH Off
-200 BOOL 1 S_NORMAL_AP23_C_CODEC SWITCH Off
-201 BOOL 1 S_CAPTURE_DSP_CODEC SWITCH Off
+200 BOOL 1 S_NORMAL_AP23_C_CODEC SWITCH On
+201 BOOL 1 S_CAPTURE_DSP_CODEC SWITCH On
202 BOOL 1 S_FAST_P_CODEC SWITCH Off
203 BOOL 1 S_OFFLOAD_CODEC SWITCH Off
204 BOOL 1 S_VOICE_P_CODEC SWITCH Off
-205 BOOL 1 S_VOICE_C_CODEC SWITCH Off
+205 BOOL 1 S_VOICE_C_CODEC SWITCH On
206 BOOL 1 S_VOIP_P_CODEC SWITCH Off
-207 BOOL 1 S_VOIP_C_CODEC SWITCH Off
+207 BOOL 1 S_VOIP_C_CODEC SWITCH On
208 BOOL 1 S_FM_CODEC SWITCH Off
209 BOOL 1 S_LOOP_P_CODEC SWITCH Off
-210 BOOL 1 S_LOOP_C_CODEC SWITCH Off
+210 BOOL 1 S_LOOP_C_CODEC SWITCH On
211 BOOL 1 S_FM_DSP_CODEC SWITCH Off
212 BOOL 1 S_NORMAL_AP01_P_USB SWITCH Off
213 BOOL 1 S_NORMAL_AP01_C_USB SWITCH Off
可根据差异打印,得出tinymix参数
比如上面一处差异
-207 BOOL 1 S_VOIP_C_CODEC SWITCH Off
+207 BOOL 1 S_VOIP_C_CODEC SWITCH On
则命令为
adb shell tinymix -D 0 “S_VOIP_C_CODEC SWITCH” 1
其他省略,有一些参数显示有差异但是可能不需要
设置完,调用tinycap开始录音
adb shell tinycap /data/mmic.wav -D -0 -d 0 -r 16000 -b 16 -T 3
作者:帅得不敢出门