Hi,
On Mar 10 2017 01:23, Chemsi Mehdi wrote:
I am working with an alsa codec driver where the driver is calling err = snd_pcm_hw_constraint_mask64(substream->runtime, SNDRV_PCM_HW_PARAM_FORMAT, formats); my driver is already setting format before that so I wonder why this function is called? Looks like it is needed to add audio constraints to substreams at open/startup time, but why ? what can be the issue if I do not call it ?
It's for user space applications.
In protocol of ALSA PCM interface between kernel/userspace, parameters of PCM substream are decided via interaction between drivers and applications. Typically, applications keep memory object in user space for 'struct snd_pcm_hw_params' and set their preferable parameters to it, then call ioctl(2) system call for it with SNDRV_PCM_IOCTL_HW_PARAMS or SNDRV_PCM_IOCTL_HW_REFINE. In kernel mode, the memory object is copied to kernel space and handled by ALSA PCM core. The constrains and rules registered by drivers are applied to it, then the result is copied to user space. Finally, applications can get available parameters of PCM substream.
Without this interaction, even if your driver can handle your devices correctly, applications cannot use them with proper parameters of PCM substream; e.g. wrong PCM samples per frame, wrong sampling rate, and so on.
Regards
# I'm another Takashi.
Takashi Sakamoto