[alsa-devel] ALSA queries

Takashi Iwai tiwai at suse.de
Fri Aug 3 09:35:07 CEST 2018


On Thu, 02 Aug 2018 16:31:13 +0200,
Chakravarthi Pradeep wrote:
> 
> I'm working on ALSA driver for PCIe card. My ALSA driver and it's
> initializing struct snd_pcm_hardware with below parameter.
> 
> /************************ code  start
> ************************************************/
> static struct snd_pcm_hardware audio_pcm_hardware = {
> .info = (SNDRV_PCM_INFO_INTERLEAVED  | SNDRV_PCM_INFO_MMAP |
> SNDRV_PCM_INFO_MMAP_VALID |
> SNDRV_PCM_INFO_BLOCK_TRANSFER |
> SNDRV_PCM_INFO_RESUME ),
> .formats  =       (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S24_LE),
> .rates  = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
> SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000),
> .rate_min  = 44100,
> .rate_max  = 192000,
> .channels_min  = 2,
> .channels_max  = 8,
> .buffer_bytes_max  = 76800, /*75 kbytes */
> .period_bytes_min  = 512,//4410, /* (channel (2) * sample_rate (44100)
> * bit width (24)) / (60 * 8)  */
> .period_bytes_max  = 16*1024,
> .periods_min  = 10,
> .periods_max  = 255,
> 
> };
> /************************ code  end
> ************************************************/
> 
> 1) I did not understand what is significance of periods_min ,
> period_bytes_min ,  period_bytes_max and periods_max. Can you please
> tell me what is importance of these parameter and what value should be
> mentioned according into ALSA.

These three defines the values your hardware may accept:
 periods_min = the minimal number of periods
 period_bytes_min = the minimal size of bytes for one period
 period_bytes_max = the maximal size of bytes for one period

> 2) snd_pcm_ops trigger callback is getting called in the driver when
> application sends "start" command. But ALSA driver is stopping by
> itself after one frame is copied to ALSA framework, without waiting
> for "stop" command.
> 
> For instance:
> In trigger callback , I'm getting these logs after one frame is copied.
> Trigger:Start (When Play button is selected/clicked in application,
> Start command is sent to ALSA driver)
> Dma transfer is completed.
> Trigger:Stop. (When Stop button is selected/clicked in application,
> Stop command is sent to ALSA driver. But stop button is not clicked in
> this case)

It's most likely the ALSA PCM core's safety stop; your driver seem to
have missed snd_pcm_period_elapsed() calls, so the hwptr isn't
updated, resulting in XRUN.  ALSA PCM core checks such XRUN condition
with the own timer.


Takashi


More information about the Alsa-devel mailing list