前言
今天,调试一下音频
硬件焊接
硬件部分核心是 LM4871 音频功放芯片
对于 SOC 来讲很简单,就一个引脚 HPOUTL(单声道);对于扬声器来讲也很简单,就两个引脚,插上就可以了。
另外一个关键点是电容和电阻要焊到位,有没有噪音,音质好坏,全屏电容电阻打下手。
设备树
arch/arm/boot/dts/sun8i-v3s.dtsi
dma: dma-controller@01c02000 {compatible = "allwinner,sun8i-v3s-dma";reg = <0x01c02000 0x1000>;interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;clocks = <&ccu CLK_BUS_DMA>;resets = <&ccu RST_BUS_DMA>;#dma-cells = <1>;};codec_analog: codec-analog@01c23000 {compatible = "allwinner,sun8i-v3s-codec-analog";reg = <0x01c23000 0x4>;};codec: codec@01c22c00 {#sound-dai-cells = <0>;compatible = "allwinner,sun8i-v3s-codec";reg = <0x01c22c00 0x400>;interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;clock-names = "apb", "codec";resets = <&ccu RST_BUS_CODEC>;dmas = <&dma 15>, <&dma 15>;dma-names = "rx", "tx";allwinner,codec-analog-controls = <&codec_analog>;status = "disabled";};
arch/arm/boot/dts/sun8i-v3s-licheepi-zero-dock.dts
&codec {allwinner,audio-routing ="Headphone", "HP","Headphone", "HPCOM","MIC1", "Mic","Mic", "HBIAS";status = "okay";
};
驱动
使能内核编译选项
> Device Drivers > Sound card support > Advanced Linux Sound Architecture > ALSA for SoC audio support > Allwinner SoC Audio support
<*> Allwinner sun8i Codec Analog Controls Support
应用程序
参照《v3S驱动音频》移植 alsa-lib 和 alsa-utils
测试
1、查看设备信息
# ls /dev/snd/
controlC0 pcmC0D0c pcmC0D0p timer
#
# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Codec [V3s Audio Codec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]Subdevices: 1/1Subdevice #0: subdevice #0
#
设备驱动正常
2、取消静音
# ./amixer -c 0 sset 'Headphone',0 100% unmute
3、调节音量
4、播放音乐
# aplay dlj-yldbwdx.wav
Playing WAVE 'dlj-yldbwdx.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
扬声器播放音乐
至此,音频调试 OK