2023-07-10 12:51 AM
Hello,
I try to connect a popular Arduino board PCM5102a with my board which is base on STM32MP135.
I read some documentation from the link
but pcm, i2s and sound topics are something I have only a base knowledge of, so please give some advice and hints.
My dts looks like
/ {
sound {
compatible = "audio-graph-card";
label = "STM32MP1-audio-test-card";
routing =
"Playback" , "MCLK",
"Capture" , "MCLK",
"MICL" , "Mic Bias";
dais = <&i2s1_port>;
status = "okay";
};
codec: pcm5102a-codec {
compatible = "ti,pcm5102a";
#sound-dai-cells = <0>;
clocks = <&i2s1>; /* The codec is a consumer of I2S2 master clock */
clock-names = "MCLK"; /* Feed MCLK codec clock with I2S2 master clock provider */
codec_port: port {
codec_endpoint: endpoint {
remote-endpoint = <&i2s1_endpoint>;
frame-master; /* Set codec as master of SAI1A for FS clock. */
bitclock-master; /* Set codec as master of SAI1A for SCK clock. */
};
};
};
};
sai1a_pins_mx: sai1a_mx-0 {
pins {
pinmux = <STM32_PINMUX('C', 0, AF2)>, /* SAI1_SCK_A */
<STM32_PINMUX('C', 3, AF10)>, /* SAI1_MCLK_A */
<STM32_PINMUX('E', 11, AF6)>, /* SAI1_FS_A */
<STM32_PINMUX('F', 12, AF6)>; /* SAI1_SD_A */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
};
sai1a_sleep_pins_mx: sai1a_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('C', 0, ANALOG)>, /* SAI1_SCK_A */
<STM32_PINMUX('C', 3, ANALOG)>, /* SAI1_MCLK_A */
<STM32_PINMUX('E', 11, ANALOG)>, /* SAI1_FS_A */
<STM32_PINMUX('F', 12, ANALOG)>; /* SAI1_SD_A */
};
};
&sai1{
pinctrl-names = "default", "sleep";
pinctrl-0 = <&sai1a_pins_mx>;
pinctrl-1 = <&sai1a_sleep_pins_mx>;
status = "okay";
/* USER CODE BEGIN sai1 */
#clock-cells = <0>;
clocks = <&rcc SAI1>, <&scmi_clk CK_SCMI_PLL3_Q>, <&scmi_clk CK_SCMI_PLL3_R>;
clock-names = "pclk", "x8k", "x11k";
#sound-dai-cells = <1>;
/* USER CODE END sai1 */
sai1a:audio-controller@4400a004{
status = "okay";
/* USER CODE BEGIN sai1a */
compatible = "st,stm32-sai-sub-a";
reg = <0x4 0x1C>;
clocks = <&rcc SAI1>;
clock-names = "sai_ck";
#clock-cells = <0>;
dma-names = "tx";
/*dmas = <&dmamux1 1 87 0x400 0x0>;*/
/*dma-names = "tx";*/
i2s1_port: port {
i2s1_endpoint: endpoint {
remote-endpoint = <&codec_endpoint>;
format = "i2s";
mclk-fs = <256>;
};
};
/* USER CODE END sai1a */
};
};
I get an error like
root@mp1-sagittarius:~# dmesg | grep audio
[ 0.057703] OF: /pcm5102a-codec: could not get #clock-cells for /soc/audio-controller@44004000
[ 35.535330] platform 4400a004.audio-controller: Fixing up cyclic dependency with pcm5102a-codec
[ 39.684607] OF: /pcm5102a-codec: could not get #clock-cells for /soc/audio-controller@44004000
[ 39.692414] st,stm32-sai-sub 4400a004.audio-controller: Missing dma channel for stream: 0
[ 39.836205] st,stm32-sai-sub 4400a004.audio-controller: ASoC: error at snd_soc_pcm_component_new on 4400a004.audio-controller: -22
[ 39.923241] asoc-audio-graph-card sound: ASoC: can't create pcm 4400a004.audio-controller-pcm5102a-hifi :-22
[ 39.932041] asoc-audio-graph-card sound: parse error -22
[ 40.049044] asoc-audio-graph-card: probe of sound failed with error -22
root@mp1-sagittarius:~#
in optte dts I use CLK_SAI1_PLL4Q for SAI1a.
BR Michal
2023-07-17 11:54 PM
I think I found a links with information, I try and give feedback
https://wiki.st.com/stm32mpu/wiki/How_to_play_audio
https://wiki.st.com/stm32mpu/wiki/ALSA_overview
Regards
Michal
2023-07-18 12:59 PM - edited 2023-07-18 01:14 PM
Hmmm,
the test and the result
root@mp1-sagittarius:~# speaker-test -D hw:0,0
speaker-test 1.2.6
Playback device is hw:0,0
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 1024 to 16384
Period size range from 512 to 2048
Using max buffer size 16384
Periods = 4
was set period_size = 2048
was set buffer_size = 16384
0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error
additionally, nothing happens on any transmission lines.
I think there is still something to do with the codec driver as Erwan suggest in the patch
"Please not that you have to get inspired by cs42l51 codecs driver to complete it"
BR Michal