[alsa-devel] About the buffer_time and period_time
Hi all, I met a problem about period_time/buffer_time on PXA with ASOC enabled. The kernel version is 2.6.21.
The Audio stream is 32k which is not supported by PXA ASOC driver. Please refer following RATES definition for PXA2xx.
#define PXA2XX_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000)
So I set plughw as default ALSA device enable auto samplerate conversion.
The code to set the period_time/buffer_time is as following:
err = snd_pcm_hw_params_set_rate_near(hPCM, params, &rate, 0); if (err < 0) { error("Rate not available: %d\n", rate); return err; }
err = snd_pcm_hw_params_get_buffer_time_max(params, &buffer_time, 0); if (buffer_time > 500000) buffer_time = 500000;
buffer_time = 400000; period_time = buffer_time/4;
err = snd_pcm_hw_params_set_buffer_time_near(hPCM, params, &buffer_time, 0); if (err < 0) { error("Buffer time not available: %d, error number: %d\n", buffer_time, err); return err; }
err = snd_pcm_hw_params_set_period_time_near(hPCM, params, &period_time, 0); if (err < 0) { error("Period time not available: %d\n", period_time); return err; }
If I set buffer_time to 400000, I will get: " Buffer time not available: 400000, error number: -22
Cannot init audio driver. Floating point exception " If I set buffer time to 500000, buffer_time can be set correctly. But audio playback failed.
If I set period_time before setting buffer_time, Everything is OK.
Any thought about this problem. Thanks.
Regards Yin, Fengwei
On Tue, 2007-10-16 at 16:27 +0800, Fengwei Yin wrote:
Hi all, I met a problem about period_time/buffer_time on PXA with ASOC enabled. The kernel version is 2.6.21.
The Audio stream is 32k which is not supported by PXA ASOC driver. Please refer following RATES definition for PXA2xx.
#define PXA2XX_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000)
This may be a bug in the pxa AC97 driver as most AC97 codecs can run at 32k and hence drive the AC97 link at 32k. I assume your using the WM9713 and this will request from the pxa AC97 controller when it needs PCM audio data in VRA mode. i.e. it will mark every 2 out of 3 AC97 frames (slot 3 & 4) as valid.
Can you set SNDRV_PCM_RATE_32000 and give it a try, hopefully it should work and wont require any sample rate conversion.
Liam
On 10/17/07, Liam Girdwood lg@opensource.wolfsonmicro.com wrote:
On Tue, 2007-10-16 at 16:27 +0800, Fengwei Yin wrote:
Hi all, I met a problem about period_time/buffer_time on PXA with ASOC enabled. The kernel version is 2.6.21.
The Audio stream is 32k which is not supported by PXA ASOC driver.
Please
refer following RATES definition for PXA2xx.
#define PXA2XX_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000)
This may be a bug in the pxa AC97 driver as most AC97 codecs can run at 32k and hence drive the AC97 link at 32k. I assume your using the WM9713 and this will request from the pxa AC97 controller when it needs PCM audio data in VRA mode. i.e. it will mark every 2 out of 3 AC97 frames (slot 3 & 4) as valid.
Can you set SNDRV_PCM_RATE_32000 and give it a try, hopefully it should work and wont require any sample rate conversion.
Liam
I tried set SNDRV_PCM_RATE_32000, the audio playback works OK. And SNDRV_PCM_RATE_32000 should be added because the drivers instead of ASOC have this bit.
But my understand is the default samplerate conversion will convert the sample rate to one supported by hardware if I remove 32k support in driver.
My test show that there are some issues in samplerate conversion. And why buffer_time can be change to 400000 successfully if I set period_time first?
Regards Yin, Fengwei
participants (2)
-
Fengwei Yin
-
Liam Girdwood