当前位置:网站首页>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
边栏推荐
- Log4j2 cross thread print traceid
- Interpretation and compilation of JVM
- Multi thread safe reference arc of rust
- Svn simple operation command
- What are the relationships and differences between threads and processes
- Array rotation
- Multifunctional toolbox wechat applet source code
- Quantexa CDI(场景决策智能)Syneo平台介绍
- 登录和发布文章功能测试
- idea中安装YapiUpload 插件将api接口上传到yapi文档上
猜你喜欢
Resolves the interface method that allows annotation requests to be written in postman
Closure type of rust (difference between FN, fnmut and fnone)
Matlab tips (6) comparison of seven filtering methods
Random number generation of C #
powerdesigner各种字体设置;preview字体设置;sql字体设置
Install pyshp Library
由tcl脚本生成板子对应的vivado工程
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
Qt读写XML文件(含源码+注释)
Solution to Chinese garbled code after reg file is imported into the registry
随机推荐
Gst-launch-1.0 usage notes
Selenium + phantom JS crack sliding verification 2
Robocode tutorial 8 - advanced robot
【ACM】509. 斐波那契数(dp五部曲)
硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
JD freefuck Jingdong HaoMao control panel background Command Execution Vulnerability
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
positioner
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)
Batch export ArcGIS attribute table
Jeecg boot microservice architecture
MATLAB从入门到精通(二)
Multifunctional toolbox wechat applet source code
【ACM】376. 摆动序列
Serial port debugging tools cutecom and minicom
Scikit learn sklearn 0.18 official document Chinese version
Installation du docker redis
Queue solving Joseph problem
Box pointer of rust
Dynamically add default fusing rules to feign client based on sentinel + Nacos