Hi,
I am using pico-imx7 platform, and trying to add a new sound card to ALSA through sai3 port to use the sound card as an external Mic. I have added the sound card successfully.
But when I try to record the voice in pico-imx7 using "arecord -Dhw:1 -c2 -r48000 -fS32_LE -twav -d10 -Vstereo test.wav" command, its giving the following error log:
[ 93.085619] fsl-sai 308c0000.sai: failed to derive required Rx rate: 2822400
[ 93.091371] fsl-sai 308c0000.sai: ASoC: can't set 308c0000.sai hw params: -22
[ 93.097607] fsl-sai 308c0000.sai: failed to derive required Rx rate: 2822400
[ 93.103435] fsl-sai 308c0000.sai: ASoC: can't set 308c0000.sai hw params: -22
[ 93.109701] fsl-sai 308c0000.sai: failed to derive required Rx rate: 2822400
[ 93.115610] fsl-sai 308c0000.sai: ASoC: can't set 308c0000.sai hw params: -22
Configuration in baseboard_pico_pi.dtsi file is
sound-ics52000{
compatible = "fsl,imx-ics52000",
"fsl,imx-audio-ics52000";
model = "audio-ics52000";
ssi-controller = <&sai3>;
audio-codec = <&codec_card>;
audio-routing = "Mic Jack", "MIC_OUT";
};
codec_card: ics52000@a{
status = "okay";
compatible = "fsl,ics52000";
system-clock-direction = "in";
system-clock-frequency = <12288000>;
};
&sai3
{
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>
assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>,
<&clks IMX7D_SAI3_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <36864000>;
status = "okay";
};
So please help me regarding this clock configuration of custom sound card.
Thanks in advance..
Regards,
Ganapathirao.P
Hi Ganapathirao
for sai3 example one can look at linux/arch/arm/boot/dts/imx7d-sdb.dts
linux-imx.git - i.MX Linux Kernel
Linux clock configuration is described in presentation:
http://elinux.org/images/b/b8/Elc2013_Clement.pdf
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Igor,
Thank you for your inputs. I have gone through the links you provided and did some modifications in baseboard_pico_pi.dtsi file. So the configuration is like below:
sound-ics52000{
compatible = "fsl,imx-ics52000",
"fsl,imx-audio-ics52000";
model = "audio-ics52000";
ssi-controller = <&sai3>;
audio-codec = <&codec_card>;
clock-frequency = <12288000>;
audio-routing = "Mic Jack", "MIC_OUT";
assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>,
<&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <12288000>;
};
codec_card: ics52000@a{
status = "okay";
compatible = "fsl,ics52000";
system-clock-direction = "out";
system-clock-frequency = <12288000>;
};
&sai3
{
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3 &pinctrl_sai3_mclk>;
assigned-clocks = <&clks IMX7D_SAI3_ROOT_SRC>,
<&clks IMX7D_SAI3_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <36864000>;
status = "okay";
};
After this configuration, if I try to record the voice using arecord -Dhw:0 -fS24_LE test.wav command I am getting the following log:
root@pico-imx7:~# arecord -Dhw:0 -fS24_LE test.wav
Recording WAVE 'test.wav' : <Log> Control is in fsl_sai_hw_params()
Signed 24 bit Little Endian, Ratefsl-sai 308c0000.sai: failed to derive required Rx rate: 512000
8000 Hz, Mono
fsl-sai 308c0000.sai: ASoC: can't set 308c0000.sai hw params: -22
arecord: set_params:1305: Unable to install hw params:
ACCESS: RW_INTERLEAVED
FORMAT: S24_LE
SUBFORMAT: STD
SAMPLE_BITS: 32
FRAME_BITS: 32
CHANNELS: 1
RATE: 8000
PERIOD_TIME: 128000
PERIOD_SIZE: 1024
PERIOD_BYTES: 4096
PERIODS: (3 4)
BUFFER_TIME: 500000
BUFFER_SIZE: 4000
BUFFER_BYTES: 16000
TICK_TIME: 0
Kindly provide your inputs..
Regards,
Ganapathirao.P
Hi Igor,
Now I am able to configure mclk, bitclk and lrclk properly.
But when I am Trying to record the voice using "arecord -Dhw:1 -c2 -r48000 -fS32_LE -twav -d10 -Vstereo test.wav" commnd, it is giving pcm_read error.
rooot@pico-imx7:~# arecord -Dhw:0 -c2 -r16000 -fS24_LE -twav -d10 -Vstereo test.w
Recording WAVE 'test.wav' :
<Log> Savediv in fsl_sai.c:1Signed 24 bit Little Endian, Rate
<Log> Clock rate in fsl_sai.c is:24000000 16000 Hz, Stereo
<Log> Freq in fsl_sai.c is:8192000
<Log> set RCR2 register is successful
arecord: pcm_read:2039: read error: Invalid argument
So was it related to the iomux configuration of sai3 port? the iomux configuration for sai3 port is below:
pinctrl_sai3: sai3grp {
fsl,pins = <
MX7D_PAD_SD1_DATA0__SAI3_RX_DATA0 0x30
MX7D_PAD_SD1_DATA1__SAI3_TX_BCLK 0x1f
MX7D_PAD_SD1_DATA2__SAI3_TX_SYNC 0x1f
>;
};
Kindly provide your inputs....
Thanks in advance.
Regards,
Ganapathirao.P
Hi Ganapathirao
had you checked sect.28.2.1 Stereo CODEC Features suggested Linux Manual for
supported rates, seems 16000 rate is not supported.
Best regards
igor
Hi Igor,
I have gone through the Linux Manual and I changed the rate to 48000 but still getting the same error.
So please provide some info regarding this clock configuration from device tree. Bcz I followed the Linux reference manual and some other dtsi files in kernel source but nothing helped me in this.
My clock requirement is SAI as master.
Is there any test script available to validate SAI master functionality instead of building kernel for every modification.
So please help to get out of this issue.
Thanks in advance....
Regards,
Ganapathirao.P