当前位置:网站首页>Stm32mp157 wm8960 audio driver debugging notes
Stm32mp157 wm8960 audio driver debugging notes
2022-04-23 18:15:00 【Talent、me】
This debugging wm8960 The audio driver has encountered many pits , After several days of research, I finally debugged .
Drive debugging steps
Whether the driver can be loaded successfully is the first step of debugging , It is also one of the most critical steps .
1. Check the hardware schematic diagram :

2. Open the corresponding device tree (stm32mp157a-xxx.dtsi):
because wm8960 It's mount to I2C4 On , So in the device tree I2C4 Add on node wm8960 Device node .
wm8960: [email protected]1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
#sound-dai-cells = <0>;
status = "okay";
wlf,shared-lrclk;
clocks = <&sai2a>;
clock-names = "mclk";
port {
#address-cells = <1>;
#size-cells = <0>;
wm8960_tx_endpoint: [email protected]0 {
reg = <0x0>;
remote-endpoint = <&sai2b_endpoint>;
frame-master;
bitclock-master;
};
wm8960_rx_endpoint: [email protected]1 {
reg = <0x1>;
remote-endpoint = <&sai2a_endpoint>;
frame-master;
bitclock-master;
};
};
};
Of the nodes clocks =< sai2a > You need to look at the schematic diagram and use SAI2A still SAI2B Master clock .
3.SAI2 To configure :
&sai2 {
clocks = <&rcc SAI2>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
clock-names = "pclk", "x8k", "x11k";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&sai2a_pins_a>, <&sai2b_pins_b>;
pinctrl-1 = <&sai2a_sleep_pins_a>, <&sai2b_sleep_pins_b>;
status = "okay";
sai2a: audio-[email protected]4400b004 {
dma-names = "rx";
#clock-cells = <0>;
clocks = <&rcc SAI2_K>;
clock-names = "sai_ck";
status = "okay";
sai2a_port: port {
sai2a_endpoint: endpoint {
remote-endpoint = <&wm8960_rx_endpoint>;
format = "i2s";
mclk-fs = <256>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <16>;
};
};
};
sai2b: audio-[email protected]4400b024 {
dma-names = "tx";
st,sync = <&sai2a 2>;
clocks = <&rcc SAI2_K>, <&sai2a>;
clock-names = "sai_ck", "MCLK";
status = "okay";
sai2b_port: port {
sai2b_endpoint: endpoint {
remote-endpoint = <&wm8960_tx_endpoint>;
format = "i2s";
mclk-fs = <256>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <16>;
};
};
};
};
The most important thing is sai2a,sai2b I / O problem of , The above schematic diagram describes sai2a As ADC(capture),sai2b As DAC(playback), therefore , here sai2a Nodes in the dma-names = ‘tx’,sai2b It is dma-names = ‘rx’, And then there is st,sync = <&sai2a 2>;
Here you can refer to the kernel source code path :Documentation/devicetree/bindings/sound/st,stm32-sai.txt file
4.sound Node configuration
sound: sound {
compatible = "audio-graph-card";
label = "wm8960-audio";
mclk-fs = <256>;
dai-format = "i2s";
widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
"Line", "Line Out",
"Speaker", "Speaker",
"Headphone", "Headphone Jack";
routing =
"Headphone Jack", "HP_L",
"Headphone Jack", "HP_R",
"Speaker", "SPK_LP",
"Speaker", "SPK_LN",
"Speaker", "SPK_RP",
"Speaker", "SPK_RN",
"LINPUT1", "MICB",
"LINPUT3", "MICB";
dais = <&sai2a_port &sai2b_port>;
status = "okay";
};
5. Configure pins (stm32mp15-pinctrl.dtsi):
sai2a_pins_a: sai2a-0 {
pins {
pinmux = <STM32_PINMUX('I', 6, AF10)>; /* SAI2_SD_A */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
};
sai2a_sleep_pins_a: sai2a-1 {
pins {
pinmux = <STM32_PINMUX('I', 6, ANALOG)>; /* SAI2_SD_A */
};
};
sai2b_pins_b: sai2b-2 {
pins {
pinmux = <STM32_PINMUX('E', 11, AF10)>, /* SAI2_SD_B */
<STM32_PINMUX('I', 5, AF10)>, /* SAI2_SCK_A */
<STM32_PINMUX('I', 7, AF10)>, /* SAI2_FS_A */
<STM32_PINMUX('E', 0, AF10)>; /* SAI2_MCLK_A */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
};
sai2b_sleep_pins_b: sai2b-3 {
pins {
pinmux = <STM32_PINMUX('E', 11, ANALOG)>, /* SAI2_SD_B */
<STM32_PINMUX('I', 5, ANALOG)>, /* SAI2_SCK_A */
<STM32_PINMUX('I', 7, ANALOG)>, /* SAI2_FS_A */
<STM32_PINMUX('E', 0, ANALOG)>; /* SAI2_MCLK_A */
};
};
6. View startup information :

If the above start printing message appears , prove wm8960 Driver loading succeeded . Next, let's see if there are any sound card nodes .
[[email protected]]:~# ls /dev/snd/
by-path/ controlC0 pcmC0D0c pcmC0D1p timer
pcmC0D0c It's a recording device
pcmC0D1p It's a playback device
[[email protected]]:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: wm8960audio [wm8960-audio], device 1: 4400b024.audio-controller-wm8960-hifi wm8960-hifi-1 [4400b024.audio-controller-wm8960-hifi wm8960-hifi-1]
Subdevices: 1/1
Subdevice #0: subdevice #0
[[email protected]]:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: wm8960audio [wm8960-audio], device 0: 4400b004.audio-controller-wm8960-hifi wm8960-hifi-0 [4400b004.audio-controller-wm8960-hifi wm8960-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
Sound card 0, equipment 0 --> It's a recording device
Sound card 0, equipment 1 --> It's a playback device
7. Trouble problem
If you use the command :aplay xxx.wav, Always stuck on the command line without ending , There is no error message , You need to check the schematic diagram , Whether it corresponds to the configuration problem of the device tree .
If aplay xxx.wav , The following error message appears :
[[email protected]]:~# aplay -Dhw:0.0 /usr/share/sounds/alsa/Rear_Right.wav
ALSA lib …/…/…/alsa-lib-1.2.1.2/src/pcm/pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
aplay: main:828: audio open error: No such device
Need to use aplay -l Check the playing device number , see /etc/asound.conf Whether the configuration is correct . You can use commands aplay -Dhw:0.1 xxx.wav To specify the device to play .
asound.conf The configuration file
Once the driver was loaded successfully , Just no sound , After checking the hardware and driver, there is no problem ,alsamixer Also set the sound level , Not yet. , Find out asound.conf It will have a certain impact .
pcm.dmix_44100{
type dmix
ipc_key 5678293
ipc_key_add_uid yes
slave{
pcm "hw:0,0"
period_time 40000
buffer_time 360000
format S16_LE
rate 44100
}
}
pcm.!dsnoop_44100{
type dsnoop
ipc_key 5778293
ipc_key_add_uid yes
slave{
pcm "hw:0,1"
period_time 40000
buffer_time 360000
format S16_LE
rate 44100
}
}
pcm.asymed{
type asym
playback.pcm "dmix_44100"
capture.pcm "dsnoop_44100"
}
pcm.dsp0{
type plug
slave.pcm "asymed"
}
pcm.!default{
type plug
route_policy "average"
slave.pcm "asymed"
}
ctl.!default{
type hw
card 0
}
ctl.mixer0{
type hw
card 0
}
Experience
When there is a problem , Don't worry , Driving the print message will help you find the reason for the failure , If it doesn't work , You can refer to the successful cases of others , Change the hardware circuit to the same , See if it's a hardware or chip problem .
Enclosed wm8960 Driver files and asound.conf Link to your profile :wm8960 Driver files and asound.conf The configuration file
版权声明
本文为[Talent、me]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610471682.html
边栏推荐
- Quantexa CDI(场景决策智能)Syneo平台介绍
- Robocode Tutorial 4 - robocode's game physics
- JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
- Robocode tutorial 7 - Radar locking
- The vivado project corresponding to the board is generated by TCL script
- 线上怎么确定期货账户安全的?
- Operators in C language
- 读取excel,int 数字时间转时间
- The difference between deep copy and shallow copy
- Correct opening method of option
猜你喜欢

硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
![[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)](/img/91/3272d5ad04cd1d8476c739546f4356.png)
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)
![解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]](/img/5f/a80951777a0473fcaa685cd6a8e5dd.png)
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Robocode tutorial 8 - advanced robot

【ACM】509. Fibonacci number (DP Trilogy)

Cygwin64 right click to add menu, and open cygwin64 here

STM32 learning record 0008 - GPIO things 1

SSD硬盘SATA接口和M.2接口区别(详细)总结

Deep learning classic network analysis and target detection (I): r-cnn

MATLAB小技巧(6)七种滤波方法比较
随机推荐
Install pyshp Library
【ACM】509. 斐波那契数(dp五部曲)
Feign requests the log to be printed uniformly
GDAL + ogr learning
Docker 安裝 Redis
7-21 wrong questions involve knowledge points.
Matlab tips (6) comparison of seven filtering methods
PowerDesigner various font settings; Preview font setting; SQL font settings
Vulnérabilité d'exécution de la commande de fond du panneau de commande JD - freefuck
线上怎么确定期货账户安全的?
Rust: how to implement a thread pool?
串口调试工具cutecom和minicom
A few lines of code teach you to crawl lol skin pictures
C medium? This form of
Hard core parsing promise object (do you know these seven common APIs and seven key questions?)
RC smart pointer in rust
Using transmittablethreadlocal to realize parameter cross thread transmission
函数递归以及趣味问题的解决
Gst-launch-1.0 usage notes
由tcl脚本生成板子对应的vivado工程