当前位置:   article > 正文

Rockchip Android13 AudioCodecs ES8316调试心得

es8316

调试音频分为软件调试和驱动调试。

验证Andorid13 音频耳机输出的时候,用apk播放一个音频,发现耳机只有右耳机有输出,左耳机没有声音。根据调试经验,一般来说是驱动问题。

  1. 先试用tinyplay播放耳机,使用tinyplay,需要先tinymix切换到耳机通路:

  1. rk3588_t:/ # tinymix
  2. Mixer name: 'rockchip-es8316'
  3. Number of controls: 42
  4. ctl type num name value
  5. 0 ENUM 1 I2STDM Digital Loopback Mode Disabled
  6. 1 INT 2 Headphone Playback Volume 3 3
  7. 2 INT 2 Headphone Mixer Volume 0 0
  8. 3 ENUM 1 Playback Polarity Normal
  9. 4 INT 2 DAC Playback Volume 192 192
  10. 5 BOOL 1 DAC Soft Ramp Switch Off
  11. 6 INT 1 DAC Soft Ramp Rate 4
  12. 7 BOOL 1 DAC Notch Filter Switch Off
  13. 8 BOOL 1 DAC Double Fs Switch Off
  14. 9 INT 1 DAC Stereo Enhancement 0
  15. 10 BOOL 1 DAC Mono Mix Switch Off
  16. 11 ENUM 1 Capture Polarity Normal
  17. 12 BOOL 1 Mic Boost Switch On
  18. 13 INT 1 ADC Capture Volume 0
  19. 14 INT 1 ADC PGA Gain Volume 0
  20. 15 BOOL 1 ADC Soft Ramp Switch On
  21. 16 BOOL 1 ADC Double Fs Switch Off
  22. 17 BOOL 1 ALC Capture Switch On
  23. 18 INT 1 ALC Capture Max Volume 13
  24. 19 INT 1 ALC Capture Min Volume 8
  25. 20 INT 1 ALC Capture Target Volume 10
  26. 21 INT 1 ALC Capture Hold Time 0
  27. 22 INT 1 ALC Capture Decay Time 3
  28. 23 INT 1 ALC Capture Attack Time 2
  29. 24 BOOL 1 ALC Capture Noise Gate Switch Off
  30. 25 INT 1 ALC Capture Noise Gate Threshold 0
  31. 26 ENUM 1 ALC Capture Noise Gate Type Constant PGA Gain
  32. 27 BOOL 1 Headphone Jack On
  33. 28 BOOL 1 Headset Mic Jack Off
  34. 29 BOOL 1 Headphone Switch On
  35. 30 BOOL 1 Speaker Switch On
  36. 31 BOOL 1 Main Mic Switch On
  37. 32 BOOL 1 Headset Mic Switch Off
  38. 33 ENUM 1 Differential Mux lin1-rin1
  39. 34 ENUM 1 Digital Mic Mux dmic disable
  40. 35 ENUM 1 DAC Source Mux LDATA TO LDAC, RDATA TO RDAC
  41. 36 ENUM 1 Left Headphone Mux lin1-rin1
  42. 37 ENUM 1 Right Headphone Mux lin1-rin1
  43. 38 BOOL 1 Left Headphone Mixer LLIN Switch Off
  44. 39 BOOL 1 Left Headphone Mixer Left DAC Switch Off
  45. 40 BOOL 1 Right Headphone Mixer RLIN Switch Off
  46. 41 BOOL 1 Right Headphone Mixer Right DAC Switch Off

查找音频hal层代码codec config, hardware/rockchip/audio/tinyalsa_hal/codec_config. 在es8316_config.h中切换耳机输出描述:

  1. const struct config_control es8316_headphone_normal_controls[] = {
  2. {
  3. .ctl_name = "DAC Playback Volume",
  4. .int_val = {192, 192},
  5. },
  6. {
  7. .ctl_name = "Left Headphone Mixer Left DAC Switch",
  8. .int_val = {on},
  9. },
  10. {
  11. .ctl_name = "Right Headphone Mixer Right DAC Switch",
  12. .int_val = {on},
  13. },
  14. };

然后根据上述配置使用tinymix切换到耳机通路:

  1. tinymix 4 192 192
  2. tinymix 39 1
  3. 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代码对配置寄存器。

  1. diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
  2. old mode 100644
  3. new mode 100755
  4. index 609459077f9d..2aa290a2e46d
  5. --- a/sound/soc/codecs/es8316.c
  6. +++ b/sound/soc/codecs/es8316.c
  7. @@ -744,6 +744,15 @@ static int es8316_probe(struct snd_soc_component *component)
  8. */
  9. snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x32);
  10. + snd_soc_component_write(component, ES8316_CAL_HPLIV, 0x87);
  11. + snd_soc_component_write(component, ES8316_CAL_HPRIV, 0x8c);
  12. + snd_soc_component_write(component, ES8316_CAL_HPLMV, 0x00);
  13. + snd_soc_component_write(component, ES8316_CAL_HPRMV, 0xff);
  14. + //snd_soc_component_write(component, ES8316_SYS_PDN, 0x07);
  15. + snd_soc_component_write(component, ES8316_ADC_ALC1, 0xcd);
  16. + snd_soc_component_write(component, ES8316_ADC_ALC2, 0x08);
  17. + snd_soc_component_write(component, ES8316_ADC_ALC3, 0xa0);
  18. + es8316_enable_micbias_for_mic_gnd_short_detect(component);
  19. return 0;
  20. }

修改后,两个版本codec播放时的寄存器配置一致。发现android 13还是耳机输出有问题。怀疑是板子问题了,换了一块板子烧写就好了。

如果是Linux版本使用alsa utils工具amixer切换route:

  1. root@linaro-alip:/# amixer -c 0 contents
  2. numid=28,iface=CARD,name='Headphone Jack'
  3. ; type=BOOLEAN,access=r-------,values=1
  4. : values=on
  5. numid=29,iface=CARD,name='Headset Mic Jack'
  6. ; type=BOOLEAN,access=r-------,values=1
  7. : values=off
  8. numid=3,iface=MIXER,name='Headphone Mixer Volume'
  9. ; type=INTEGER,access=rw---R--,values=2,min=0,max=11,step=0
  10. : values=0,0
  11. | dBrange-
  12. rangemin=0,,rangemax=4
  13. | dBscale-min=-12.00dB,step=1.50dB,mute=0
  14. rangemin=8,,rangemax=11
  15. | dBscale-min=-4.50dB,step=1.50dB,mute=0
  16. numid=30,iface=MIXER,name='Headphone Switch'
  17. ; type=BOOLEAN,access=rw------,values=1
  18. : values=on
  19. numid=2,iface=MIXER,name='Headphone Playback Volume'
  20. ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  21. : values=3,3
  22. | dBrange-
  23. rangemin=0,,rangemax=0
  24. | dBscale-min=-48.00dB,step=0.00dB,mute=0
  25. rangemin=1,,rangemax=3
  26. | dBscale-min=-24.00dB,step=12.00dB,mute=0
  27. numid=13,iface=MIXER,name='Mic Boost Switch'
  28. ; type=BOOLEAN,access=rw------,values=1
  29. : values=on
  30. numid=17,iface=MIXER,name='ADC Double Fs Switch'
  31. ; type=BOOLEAN,access=rw------,values=1
  32. : values=off
  33. numid=15,iface=MIXER,name='ADC PGA Gain Volume'
  34. ; type=INTEGER,access=rw---R--,values=1,min=0,max=10,step=0
  35. : values=0
  36. | dBrange-
  37. rangemin=0,,rangemax=0
  38. | dBscale-min=-3.50dB,step=0.00dB,mute=0
  39. rangemin=1,,rangemax=1
  40. | dBscale-min=0.00dB,step=0.00dB,mute=0
  41. rangemin=2,,rangemax=2
  42. | dBscale-min=2.50dB,step=0.00dB,mute=0
  43. rangemin=3,,rangemax=3
  44. | dBscale-min=4.50dB,step=0.00dB,mute=0
  45. rangemin=4,,rangemax=7
  46. | dBscale-min=7.00dB,step=3.00dB,mute=0
  47. rangemin=8,,rangemax=10
  48. | dBscale-min=18.00dB,step=3.00dB,mute=0
  49. numid=16,iface=MIXER,name='ADC Soft Ramp Switch'
  50. ; type=BOOLEAN,access=rw------,values=1
  51. : values=on
  52. numid=14,iface=MIXER,name='ADC Capture Volume'
  53. ; type=INTEGER,access=rw---R--,values=1,min=0,max=192,step=0
  54. : values=0
  55. | dBscale-min=-96.00dB,step=0.50dB,mute=1
  56. numid=12,iface=MIXER,name='Capture Polarity'
  57. ; type=ENUMERATED,access=rw------,values=1,items=2
  58. ; Item #0 'Normal'
  59. ; Item #1 'Invert'
  60. : values=0
  61. numid=4,iface=MIXER,name='Playback Polarity'
  62. ; type=ENUMERATED,access=rw------,values=1,items=4
  63. ; Item #0 'Normal'
  64. ; Item #1 'R Invert'
  65. ; Item #2 'L Invert'
  66. ; Item #3 'L + R Invert'
  67. : values=0
  68. numid=1,iface=MIXER,name='I2STDM Digital Loopback Mode'
  69. ; type=ENUMERATED,access=rw------,values=1,items=4
  70. ; Item #0 'Disabled'
  71. ; Item #1 'Mode1'
  72. ; Item #2 'Mode2'
  73. ; Item #3 'Mode2 Swap'
  74. : values=0
  75. numid=24,iface=MIXER,name='ALC Capture Attack Time'
  76. ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0
  77. : values=2
  78. numid=23,iface=MIXER,name='ALC Capture Decay Time'
  79. ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0
  80. : values=3
  81. numid=22,iface=MIXER,name='ALC Capture Hold Time'
  82. ; type=INTEGER,access=rw------,values=1,min=0,max=10,step=0
  83. : values=0
  84. numid=19,iface=MIXER,name='ALC Capture Max Volume'
  85. ; type=INTEGER,access=rw---R--,values=1,min=0,max=28,step=0
  86. : values=13
  87. | dBscale-min=-6.50dB,step=1.50dB,mute=0
  88. numid=20,iface=MIXER,name='ALC Capture Min Volume'
  89. ; type=INTEGER,access=rw---R--,values=1,min=0,max=28,step=0
  90. : values=8
  91. | dBscale-min=-12.00dB,step=1.50dB,mute=0
  92. numid=25,iface=MIXER,name='ALC Capture Noise Gate Switch'
  93. ; type=BOOLEAN,access=rw------,values=1
  94. : values=off
  95. numid=26,iface=MIXER,name='ALC Capture Noise Gate Threshold'
  96. ; type=INTEGER,access=rw------,values=1,min=0,max=31,step=0
  97. : values=0
  98. numid=27,iface=MIXER,name='ALC Capture Noise Gate Type'
  99. ; type=ENUMERATED,access=rw------,values=1,items=2
  100. ; Item #0 'Constant PGA Gain'
  101. ; Item #1 'Mute ADC Output'
  102. : values=0
  103. numid=18,iface=MIXER,name='ALC Capture Switch'
  104. ; type=BOOLEAN,access=rw------,values=1
  105. : values=on
  106. numid=21,iface=MIXER,name='ALC Capture Target Volume'
  107. ; type=INTEGER,access=rw---R--,values=1,min=0,max=10,step=0
  108. : values=10
  109. | dBscale-min=-16.50dB,step=1.50dB,mute=0
  110. numid=9,iface=MIXER,name='DAC Double Fs Switch'
  111. ; type=BOOLEAN,access=rw------,values=1
  112. : values=off
  113. numid=11,iface=MIXER,name='DAC Mono Mix Switch'
  114. ; type=BOOLEAN,access=rw------,values=1
  115. : values=off
  116. numid=8,iface=MIXER,name='DAC Notch Filter Switch'
  117. ; type=BOOLEAN,access=rw------,values=1
  118. : values=off
  119. numid=5,iface=MIXER,name='DAC Playback Volume'
  120. ; type=INTEGER,access=rw---R--,values=2,min=0,max=192,step=0
  121. : values=152,152
  122. | dBscale-min=-96.00dB,step=0.50dB,mute=1
  123. numid=7,iface=MIXER,name='DAC Soft Ramp Rate'
  124. ; type=INTEGER,access=rw------,values=1,min=0,max=4,step=0
  125. : values=4
  126. numid=6,iface=MIXER,name='DAC Soft Ramp Switch'
  127. ; type=BOOLEAN,access=rw------,values=1
  128. : values=off
  129. numid=36,iface=MIXER,name='DAC Source Mux'
  130. ; type=ENUMERATED,access=rw------,values=1,items=4
  131. ; Item #0 'LDATA TO LDAC, RDATA TO RDAC'
  132. ; Item #1 'LDATA TO LDAC, LDATA TO RDAC'
  133. ; Item #2 'RDATA TO LDAC, RDATA TO RDAC'
  134. ; Item #3 'RDATA TO LDAC, LDATA TO RDAC'
  135. : values=0
  136. numid=10,iface=MIXER,name='DAC Stereo Enhancement'
  137. ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0
  138. : values=0
  139. numid=34,iface=MIXER,name='Differential Mux'
  140. ; type=ENUMERATED,access=rw------,values=1,items=4
  141. ; Item #0 'lin1-rin1'
  142. ; Item #1 'lin2-rin2'
  143. ; Item #2 'lin1-rin1 with 20db Boost'
  144. ; Item #3 'lin2-rin2 with 20db Boost'
  145. : values=0
  146. numid=35,iface=MIXER,name='Digital Mic Mux'
  147. ; type=ENUMERATED,access=rw------,values=1,items=3
  148. ; Item #0 'dmic disable'
  149. ; Item #1 'dmic data at high level'
  150. ; Item #2 'dmic data at low level'
  151. : values=0
  152. numid=33,iface=MIXER,name='Headset Mic Switch'
  153. ; type=BOOLEAN,access=rw------,values=1
  154. : values=off
  155. numid=39,iface=MIXER,name='Left Headphone Mixer LLIN Switch'
  156. ; type=BOOLEAN,access=rw------,values=1
  157. : values=off
  158. numid=40,iface=MIXER,name='Left Headphone Mixer Left DAC Switch'
  159. ; type=BOOLEAN,access=rw------,values=1
  160. : values=off
  161. numid=37,iface=MIXER,name='Left Headphone Mux'
  162. ; type=ENUMERATED,access=rw------,values=1,items=4
  163. ; Item #0 'lin1-rin1'
  164. ; Item #1 'lin2-rin2'
  165. ; Item #2 'lin-rin with Boost'
  166. ; Item #3 'lin-rin with Boost and PGA'
  167. : values=0
  168. numid=32,iface=MIXER,name='Main Mic Switch'
  169. ; type=BOOLEAN,access=rw------,values=1
  170. : values=on
  171. numid=41,iface=MIXER,name='Right Headphone Mixer RLIN Switch'
  172. ; type=BOOLEAN,access=rw------,values=1
  173. : values=off
  174. numid=42,iface=MIXER,name='Right Headphone Mixer Right DAC Switch'
  175. ; type=BOOLEAN,access=rw------,values=1
  176. : values=off
  177. numid=38,iface=MIXER,name='Right Headphone Mux'
  178. ; type=ENUMERATED,access=rw------,values=1,items=4
  179. ; Item #0 'lin1-rin1'
  180. ; Item #1 'lin2-rin2'
  181. ; Item #2 'lin-rin with Boost'
  182. ; Item #3 'lin-rin with Boost and PGA'
  183. : values=0
  184. numid=31,iface=MIXER,name='Speaker Switch'
  185. ; type=BOOLEAN,access=rw------,values=1
  186. : values=off

对比上面tinymix主要修改ctl如下:

  1. numid=5,iface=MIXER,name='DAC Playback Volume'
  2. ; type=INTEGER,access=rw---R--,values=2,min=0,max=192,step=0
  3. : values=152,152
  4. | dBscale-min=-96.00dB,step=0.50dB,mute=1
  5. .....
  6. numid=40,iface=MIXER,name='Left Headphone Mixer Left DAC Switch'
  7. ; type=BOOLEAN,access=rw------,values=1
  8. : values=off
  9. ......
  10. numid=42,iface=MIXER,name='Right Headphone Mixer Right DAC Switch'
  11. ; type=BOOLEAN,access=rw------,values=1
  12. : values=off

amixer修改如下:

  1. amixer -c 0 contents
  2. amixer -c 0 cset numid=5 192 192
  3. amixer -c 0 cset numid=40 1
  4. amixer -c 0 cset numid=42 1
  5. amixer -c 0 cset numid=2 3
  6. amixer -c 0 cset numid=31 1

3588 linux的codec寄存器命令:

cat /sys/kernel/debug/regmap/7-0010/registers

寄存器一致后,还是无声,对比linux 参考dts:rk3588-evb3-lp5.dtsi:

  1. &i2c7 {
  2. status = "okay";
  3. es8316: es8316@10 {
  4. status = "okay";
  5. #sound-dai-cells = <0>;
  6. compatible = "everest,es8316";
  7. reg = <0x10>;
  8. clocks = <&mclkout_i2s0>; //linux版本
  9. clock-names = "mclk";
  10. assigned-clocks = <&mclkout_i2s0>;
  11. assigned-clock-rates = <12288000>;
  12. pinctrl-names = "default";
  13. pinctrl-0 = <&i2s0_mclk>;
  14. };
  15. };

而android版本:

  1. es8316: es8316@10 {
  2. status = "okay";
  3. #sound-dai-cells = <0>;
  4. compatible = "everest,es8316";
  5. reg = <0x10>;
  6. clocks = <&cru I2S0_8CH_MCLKOUT>; // android版本
  7. clock-names = "mclk";
  8. assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
  9. assigned-clock-rates = <12288000>;
  10. pinctrl-names = "default";
  11. pinctrl-0 = <&i2s0_mclk>;
  12. };

修改后,aplay播放有声音了。

aplay -D hw:0,0 sdcard/48000_2channel.wav

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/311679
推荐阅读
相关标签
  

闽ICP备14008679号