audiolinux-device-driveralsai2s

Alsa records double speed


Disclaimer : I posted for the same issue (with a different point of view) here

I use a SPH0645 I2S microphone with a custom driver.

It seams properly recognized by alsa :

arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: imxaudiosph0645 [imx-audio-sph0645], device 0: imx-sph0645 snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

When recording with arecord the sound is speed up by 2

When recording with arecord -d (duration):

I used an oscilloscope to check the BCLK clock and the frame (WS) clock :

time arecord -D hw:0,0 -r 48000 -f S32_LE -c 1 -d 5 -t wav -v 48000_32_1.wav
fsl_sai logs : clk_rate = 3072000, ratio = 1, ret = 0, freq = 3072000
Record time : 10s
File duration : 5s
Osciloscope BCLK clock 3.072 MHz, frame (WS) clock 48kHz
When opening the file in audacity, the configuration is correct but its length is 5 sec but it is speed up.

An example of sound : here

As I understand it the clocks are correct. The datasheet indicate "The Over Sampling Rate is fixed at 64 therefore the WS signal must be BCLK/64 and synchronized to the BCLK."

Maybe there is a configuration somewhere in alsa that I am not aware off ?

Let me know if I can add more informations.


Solution

  • I found the solution and posted it on my initial post on the nxp forum.

    The error was in the driver :

    - snd_soc_dai_set_sysclk(cpu_dai, 1, bclk, SND_SOC_CLOCK_OUT);
    + snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
    

    The updated driver patch can be found here