当前位置:网站首页>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
边栏推荐
- Linux installs MySQL in RPM (super simple)
- Quantexa CDI(场景决策智能)Syneo平台介绍
- Rust: how to implement a thread pool?
- JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
- 登录和发布文章功能测试
- QT reading and writing XML files (including source code + comments)
- Docker installation MySQL
- Qtablewidget usage explanation
- Crawl the product data of cicada mother data platform
- RC smart pointer in rust
猜你喜欢
MySQL auto start settings start with systemctl start mysqld
Docker 安装 Redis
【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
【ACM】509. Fibonacci number (DP Trilogy)
MATLAB小技巧(6)七种滤波方法比较
Dynamically add default fusing rules to feign client based on sentinel + Nacos
解决允许在postman中写入注释请求接口方法
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
SSD硬盘SATA接口和M.2接口区别(详细)总结
mysql自动启动设置用Systemctl start mysqld启动
随机推荐
xlsxwriter. exceptions. Filecreateerror: [errno 13] permission denied
Implement a simple function to calculate the sum of all integers between M ~ n (m < n)
JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞
读取excel,int 数字时间转时间
Queue solving Joseph problem
ArcGIS license error -15 solution
.105Location
Mode of interprocess communication
C language input and output (printf and scanf functions, putchar and getchar functions)
Jenkspy package installation
Robocode tutorial 5 - enemy class
Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
登录和发布文章功能测试
Resolves the interface method that allows annotation requests to be written in postman
Multi thread safe reference arc of rust
word frequency count
【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))
Robocode tutorial 3 - Robo machine analysis
【ACM】509. Fibonacci number (DP Trilogy)
proxy server