Jaroslav,
Thank you for the quick reply.
On Thu, Oct 21, 2010 at 10:50 AM, Jaroslav Kysela perex@perex.cz wrote:
On Thu, 21 Oct 2010, Adam Rosenberg wrote:
I would like to make sure that all programs that use the sound driver
I wrote are required to use 512 frames per period. Is there a snd_pcm_hw_constraint function that will allow me to do this?
Just use periods_min and period_max = 512 in the hw structure. But why this constraint? It's better to use different ways in the driver (timers, etc) to leave reasonable range of the configuration space.
I am trying to constrain the number of frames per period (not the number of periods). The DMA transfer creates an interrupt every 512 frames (1 frame = 16 channels with 32bits per channel) . I am having a difficult time understanding how to properly write the ALSA driver so that it will work with many different formats and between 1 and 2 channels. It seems as though I have to call snd_pcm_period_elapsed everytime I get a DMA interrupt to let the underlying code know that 512 frames have finished transferring. If the application does not select 512 frames per period, the audio plays too fast or too slow. Here is my best guess at what the hardware settings should be:
static struct snd_pcm_hardware ourCS42448PcmHw = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER ),
// Note: the CS42448 does not support 8 bit audio .formats = (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_BE | SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S16_BE),
// Sample rates supported // Note: this board has an ICS661 chip // that is being configured in init // so these values must match that setting #if CONFIG_CS42448_SAMPLE_RATE == 44100 .rates = SNDRV_PCM_RATE_44100, .rate_min = 44100, .rate_max = 44100, #else // default to 48000 .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, .rate_max = 48000, #endif
// the max number of bytes in one PCM stream // must allow for a minimum of 4 periods with // 512 frames per period and up to 2 channels of // 32 bit data per frame .buffer_bytes_max = 32768, // this value allows 8 periods of the max frame size
// the number of channels in one PCM stream .channels_min = 1, .channels_max = 2,
.period_bytes_max = 4096, .periods_min = 4, .period_bytes_min = 512, .periods_max = 64, };
Is there some way that I can impose a constraint on the number of frames in a period or is this the wrong solution to my problem?
Thanks, Adam
Adam Rosenberg Software Engineer
Alcorn McBride Inc. 3300 South Hiawassee Building 105 Orlando, FL 32835
(407) 296 - 5800 ext. 5490