All of lore.kernel.org
 help / color / mirror / Atom feed
* Is snd_pcm_hw_constraint_mask64 really needed ?
@ 2017-03-09 16:23 Chemsi Mehdi
  2017-03-12  1:24 ` Takashi Sakamoto
  0 siblings, 1 reply; 3+ messages in thread
From: Chemsi Mehdi @ 2017-03-09 16:23 UTC (permalink / raw)
  To: Vinod Koul, alsa-devel

Dear ALSA expert ,


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 ?

Please explain to me Takashi.

Thanks a lot in advance.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is snd_pcm_hw_constraint_mask64 really needed ?
  2017-03-09 16:23 Is snd_pcm_hw_constraint_mask64 really needed ? Chemsi Mehdi
@ 2017-03-12  1:24 ` Takashi Sakamoto
  2017-03-13  9:06   ` Chemsi Mehdi
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sakamoto @ 2017-03-12  1:24 UTC (permalink / raw)
  To: Chemsi Mehdi, Vinod Koul, alsa-devel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is snd_pcm_hw_constraint_mask64 really needed ?
  2017-03-12  1:24 ` Takashi Sakamoto
@ 2017-03-13  9:06   ` Chemsi Mehdi
  0 siblings, 0 replies; 3+ messages in thread
From: Chemsi Mehdi @ 2017-03-13  9:06 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: Vinod Koul, alsa-devel

Thanks a lot dear Takashi, helpful as the habit

2017-03-12 2:24 GMT+01:00 Takashi Sakamoto <o-takashi@sakamocchi.jp>:

> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-13  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-09 16:23 Is snd_pcm_hw_constraint_mask64 really needed ? Chemsi Mehdi
2017-03-12  1:24 ` Takashi Sakamoto
2017-03-13  9:06   ` Chemsi Mehdi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.