当前位置:网站首页>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
边栏推荐
- Multi thread safe reference arc of rust
- STM32学习记录0008——GPIO那些事1
- JD freefuck Jingdong HaoMao control panel background Command Execution Vulnerability
- 解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 【ACM】509. 斐波那契数(dp五部曲)
- A few lines of code teach you to crawl lol skin pictures
- 【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
- Excel opens large CSV format data
- idea中安装YapiUpload 插件将api接口上传到yapi文档上
- Operators in C language
猜你喜欢

C medium? This form of

Docker 安装 MySQL

Installation du docker redis

Implementation of k8s redis one master multi slave dynamic capacity expansion
![[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)](/img/ae/cbfc01fbcc816915b1794a9d70247a.png)
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)

Robocode tutorial 8 - advanced robot

Jenkspy package installation

Differences between SSD hard disk SATA interface and m.2 interface (detailed summary)

Win1远程出现“这可能是由于credssp加密oracle修正”解决办法

Auto. JS custom dialog box
随机推荐
解决允许在postman中写入注释请求接口方法
Solving the problem of displaying too many unique values in ArcGIS partition statistics failed
由tcl脚本生成板子对应的vivado工程
14 py games source code share the second bullet
消费者灰度实现思路
SSD硬盘SATA接口和M.2接口区别(详细)总结
Crack sliding verification code
Docker installation MySQL
Serialization scheme of serde - trust
NVIDIA Jetson: GStreamer and openmax (GST OMX) plug-ins
Cells in rust share variable pointers
Robocode tutorial 7 - Radar locking
【ACM】70. 爬楼梯
JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
Dock installation redis
Crawl the product data of cicada mother data platform
According to the result set queried by SQL statement, it is encapsulated as JSON
Matlab tips (6) comparison of seven filtering methods
Climbing watermelon video URL
How to ensure the security of futures accounts online?