[alsa-devel] ALSA SoC driver playback twice as fast as desired
I've been developing an ALSA SoC driver for the past 3 weeks.
The codec is a wolfsom WM8973 on a Freescale i.MX27 development platform. I've added SPI support to the existing (using i.MX27 platform SPI API -- not exactly portable) codec in the GIT repository. In addition I wrote up the DAI (I2S over SSI bus) and the PCM portion of the driver which handles DMA transfers. I written the driver to reduce the number of factors to reduce the number of factors that would be causing any problems. The files being played are all encoded for 48kHz. The PLLs, MCLK and BCLK settings are all set to assume a sample rate of 48KHz. Even the file is a mono file. However, when attempting to play the file back using SoX or aplay a self generated sine file made to play for 5 seconds always plays twice as fast. The windows chimes file for instance (which is a 2 x 16 bit audio file) when played as a single channel file -- essentially doubling the play time (0.6 to 1.2 seconds) -- will end up playing properly. The timer displayed by SoX is correct for that file. However, when the file is played back it is obviously being pumped through too fast. I'm out of ideas as to where to look. The DAI interface is set as a I2S slave. The clock is mastered by the Codec (WM8974). I've set up min_channels and max_channels to be 1 whereever possible. On a scope the clocking seems to be at the right speed. Why is it sound is playing twice as fast? Any ideas? Any help is appreciated. WM8974 is a mono codec. The SSI bus on the i.MX27 is set to I2S slave mode with a 16 bit word length. The word length on the codec is set to 16 bits. The audio interface on the codec is set to I2S, sample rate coded to do only 48kHz. THANK YOU _________________________________________________________________ We are your photos. Share us now with Windows Live Photos. http://go.microsoft.com/?linkid=9666047
On Thu, Jul 02, 2009 at 04:24:17PM -0600, Louis Lee wrote:
I'm out of ideas as to where to look. The DAI interface is set as a I2S slave. The clock is mastered by the Codec (WM8974). I've set up min_channels and max_channels to be 1 whereever possible. On a scope the clocking seems to be at the right speed. Why is it sound is playing twice as fast? Any ideas? Any help is appreciated. WM8974 is a mono codec. The SSI bus on the i.MX27 is set to I2S slave mode with a 16 bit word length. The word length on the codec is set to 16 bits. The audio interface on the codec is set to I2S, sample rate coded to do only 48kHz.
If you're running in I2S mode try playing back a stereo file instead - you'll need to adjust the capabilities of all the DAIs to say they support stereo. I suspect that the CPU side is trying to play back stereo data and so plays back two samples for every frame (one in the left channel and one in the right channel) which would give double speed playback.
For mono data it's easier to use one of the DSP modes.
Date: Sat, 4 Jul 2009 10:49:43 +0100 From: broonie@opensource.wolfsonmicro.com To: lwhlee@hotmail.com CC: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] ALSA SoC driver playback twice as fast as desired
On Thu, Jul 02, 2009 at 04:24:17PM -0600, Louis Lee wrote:
I'm out of ideas as to where to look. The DAI interface is set as a I2S slave. The clock is mastered by the Codec (WM8974). I've set up min_channels and max_channels to be 1 whereever possible. On a scope the clocking seems to be at the right speed. Why is it sound is playing twice as fast? Any ideas? Any help is appreciated. WM8974 is a mono codec. The SSI bus on the i.MX27 is set to I2S slave mode with a 16 bit word length. The word length on the codec is set to 16 bits. The audio interface on the codec is set to I2S, sample rate coded to do only 48kHz.
If you're running in I2S mode try playing back a stereo file instead - you'll need to adjust the capabilities of all the DAIs to say they support stereo. I suspect that the CPU side is trying to play back stereo data and so plays back two samples for every frame (one in the left channel and one in the right channel) which would give double speed playback.
For mono data it's easier to use one of the DSP modes.
Hi Mark,
I set the DAI to support Stereo and magically it plays the files properly with the correct timing!!
I took your recommendation as well. I setup the SSI and code in DSP mode instead of I2S mode and everything plays back fine as expected.
Thanks for your help, I'd have never figured that out!
Regards, Louis
_________________________________________________________________ We are your photos. Share us now with Windows Live Photos. http://go.microsoft.com/?linkid=9666047
Date: Sat, 4 Jul 2009 10:49:43 +0100 From: broonie@opensource.wolfsonmicro.com To: lwhlee@hotmail.com CC: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] ALSA SoC driver playback twice as fast as desired
On Thu, Jul 02, 2009 at 04:24:17PM -0600, Louis Lee wrote:
I'm out of ideas as to where to look. The DAI interface is set as a I2S slave. The clock is mastered by the Codec (WM8974). I've set up min_channels and max_channels to be 1 whereever possible. On a scope the clocking seems to be at the right speed. Why is it sound is playing twice as fast? Any ideas? Any help is appreciated. WM8974 is a mono codec. The SSI bus on the i.MX27 is set to I2S slave mode with a 16 bit word length. The word length on the codec is set to 16 bits. The audio interface on the codec is set to I2S, sample rate coded to do only 48kHz.
If you're running in I2S mode try playing back a stereo file instead - you'll need to adjust the capabilities of all the DAIs to say they support stereo. I suspect that the CPU side is trying to play back stereo data and so plays back two samples for every frame (one in the left channel and one in the right channel) which would give double speed playback.
For mono data it's easier to use one of the DSP modes.
Hi Mark, I did get the playback working with your recommendations. Thanks again. What's really strange is that this behavior is still present on the capturing of audio. I try to capture audio and the captured audio file turns out to be twice as long as the actual audio file. A 5 second audio file becomes a 10 second audio file. My voice in the file is stretched. I tried the experiment of setting the capabilities of the DAI to support stereo and recorded a file and it played at the normal speed. The volume of the audio is a bit low but the overall result audio quality was okay (not sure if that is relevant). SSI is set to DSP mode. Control bus is SPI. SSI and codec word lengths are coded as 16 bits. The clock is mastered by the codec. All the registers for DMA, SSI and SPI access seem to be setup correctly. Once again, the WM8974 is a mono codec. What could I start looking for? Any help is appreciated. Thanks,Louis _________________________________________________________________ Windows Live helps you keep up with all your friends, in one place. http://go.microsoft.com/?linkid=9660826
participants (2)
-
Louis Lee
-
Mark Brown