codec音频路由调试

Platform: RK3368

OS: Android 6.0

Kernel: 3.10.0

由于底层codec驱动都已实现相关ALSA相关 control,所以只需修改音频HAL中路由的配置即可实现麦克风输入的切换。源码位于hardware/rockchip/audio/tinyalsa_hal

查看当前音频路由:
$ logcat -s alsa_route
01-21 10:18:41.640   199   199 D alsa_route: Get route table for sound card0 RKES8316
使用amix命令查看所有mixer:

源码位于hardware/rockchip/audio/tinyalsa_hal/amix.c

# amix
Card:0
  id iface dev sub idx num perms     type   name
   1 MIXER   0   0   0   2 rw  R     INT32  HP Playback Volume: 0 0 { 0-0 }
   2 MIXER   0   0   0   2 rw  R     INT32  HPMixer Gain: 0 0 { 0-7 }
   3 MIXER   0   0   0   2 rw  R     INT32  DAC Playback Volume: 192 192 { 0-192 }
   4 MIXER   0   0   0   1 rw        BOOL   Enable DAC Soft Ramp: ON { OFF=0, ON=1 }
   5 MIXER   0   0   0   1 rw        INT32  DAC Soft Ramp Rate: 0 { 0-4 }
   6 MIXER   0   0   0   1 rw        ENUM   Playback Polarity: (0 Normal) { Normal=0, R Invert=1, L Invert=2, L + R Invert=3 }
   7 MIXER   0   0   0   1 rw        BOOL   DAC Notch Filter: OFF { OFF=0, ON=1 }
   8 MIXER   0   0   0   1 rw        BOOL   DAC Double Fs Mode: OFF { OFF=0, ON=1 }
   9 MIXER   0   0   0   1 rw        INT32  DAC Volume Control-LeR: 0 { 0-1 }
  10 MIXER   0   0   0   1 rw        INT32  DAC Stereo Enhancement: 0 { 0-7 }
  11 MIXER   0   0   0   1 rw  R     BOOL   MIC Boost: ON { OFF=0, ON=1 }
  12 MIXER   0   0   0   1 rw  R     INT32  Input PGA: 6 { 0-8 }
  13 MIXER   0   0   0   1 rw  R     INT32  ADC Capture Volume: 192 { 0-192 }
  14 MIXER   0   0   0   1 rw        BOOL   ADC Soft Ramp: ON { OFF=0, ON=1 }
  15 MIXER   0   0   0   1 rw        ENUM   Capture Polarity: (0 Normal) { Normal=0, Invert=1 }
  16 MIXER   0   0   0   1 rw        BOOL   ADC Double FS Mode: OFF { OFF=0, ON=1 }
  17 MIXER   0   0   0   1 rw        INT32  ALC Capture Target Volume: 10 { 0-10 }
  18 MIXER   0   0   0   1 rw        INT32  ALC Capture Max PGA: 13 { 0-28 }
  19 MIXER   0   0   0   1 rw        INT32  ALC Capture Min PGA: 8 { 0-28 }
  20 MIXER   0   0   0   1 rw        ENUM   ALC Capture Function: (1 On) { Off=0, On=1 }
  21 MIXER   0   0   0   1 rw        INT32  ALC Capture Hold Time: 0 { 0-10 }
  22 MIXER   0   0   0   1 rw        INT32  ALC Capture Decay Time: 0 { 0-10 }
  23 MIXER   0   0   0   1 rw        INT32  ALC Capture Attack Time: 5 { 0-10 }
  24 MIXER   0   0   0   1 rw        INT32  ALC Capture NG Threshold: 1 { 0-31 }
  25 MIXER   0   0   0   1 rw        ENUM   ALC Capture NG Type: (1 Mute ADC Output) { Constant PGA Gain=0, Mute ADC Output=1 }
  26 MIXER   0   0   0   1 rw        BOOL   ALC Capture NG Switch: ON { OFF=0, ON=1 }
  27 MIXER   0   0   0   1 rw        BOOL   RLIN Switch: OFF { OFF=0, ON=1 }
  28 MIXER   0   0   0   1 rw        BOOL   Right DAC Switch: OFF { OFF=0, ON=1 }
  29 MIXER   0   0   0   1 rw        BOOL   LLIN Switch: OFF { OFF=0, ON=1 }
  30 MIXER   0   0   0   1 rw        BOOL   Left DAC Switch: OFF { OFF=0, ON=1 }
  31 MIXER   0   0   0   1 rw        ENUM   Right Hp mux: (0 lin1-rin1) { lin1-rin1=0, lin2-rin2=1, lin-rin with Boost=2, lin-rin with Boost and PGA=3 }
  32 MIXER   0   0   0   1 rw        ENUM   Left Hp mux: (0 lin1-rin1) { lin1-rin1=0, lin2-rin2=1, lin-rin with Boost=2, lin-rin with Boost and PGA=3 }
  33 MIXER   0   0   0   1 rw        ENUM   DAC SRC Mux: (0 LDATA TO LDAC, RDATA TO RDAC) { LDATA TO LDAC, RDATA TO RDAC=0, LDATA TO LDAC, LDATA TO RDAC=1, RDATA TO LDAC, RDATA TO RDAC=2, RDATA TO LDAC, LDATA TO RDAC=3 }
  34 MIXER   0   0   0   1 rw        ENUM   Digital Mic Mux: (0 dmic disable) { dmic disable=0, dmic data at high level=1, dmic data at low level=2 }
  35 MIXER   0   0   0   1 rw        ENUM   Differential Mux: (0 lin1-rin1) { lin1-rin1=0, lin2-rin2=1, lin1-rin1 with 20db Boost=2, lin2-rin2 with 20db Boost=3 }

使用amix配置control:
# 例如设置es8316麦克风左右输入
amix -c 0 "Differential Mux" 2
使用代码配置control:

hardware/rockchip/audio/tinyalsa_hal/tinyalsa_hal/codec_config/es8316_config.h

+const struct config_control es8316_main_mic_capture_controls[] = {
+    {
+        .ctl_name = "Differential Mux",
+        .int_val = {2},
+    },
+};
+

你可能感兴趣的:(android,linux,rockchip)