[alsa-devel] How to handle stream rates if CPU supports many channels ?

Takashi Sakamoto o-takashi at sakamocchi.jp
Tue Jun 6 17:22:01 CEST 2017


On 2017年06月06日 16:04, Kuninori Morimoto wrote:
>> Furthermore, PCM runtime require constraints for channels and
>> rates. In ALSA SoC part, this is done by 'soc_pcm_init_runtime_hw()'
>> in 'sound/soc/soc-pcm.c'. Your driver should have proper values in
>> data of 'struct snd_soc_pcm_stream' as the constraints.
>>
>> ```
>> (struct snd_soc_dai_driver.playback or capture?)
>> struct snd_soc_pcm_stream.channels_min = 2
>> struct snd_soc_pcm_stream.channels_max = 8
>> struct snd_soc_pcm_stream.rate_min = 48000
>> struct snd_soc_pcm_stream.rate_max = 192000
>> struct snd_soc_pcm_stream.rates =
>>      SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_192000
> 
> Here, I'm not yet 100% understanding about these value.
> I think, above are constraints of whole driver (= it supports both 2ch, 8ch).

It's not my intension. I don't know exactly where you implement 'struct 
snd_soc_pcm_stream' data in your driver. Perhaps as a part of 'struct 
snd_soc_dai_driver' data.

> About rate_min/max and rates.
> is this "rate_min" 48000 (= maximum rate of min case = 8ch) ?? not 8000 ?
> (For example, if 2ch supports 8000-192000, 8ch supports 8000-48000)
> 
> And is .rates "SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_192000" ?
> not SNDRV_PCM_RATE_8000_192000 ?

In my code snippets, I assumed that the hardware supports just two 
modes; 8ch/48.0kHz and 2ch/192.0kHz. You can expand the snippets as your 
case. Even if using SNDRV_PCM_RATE_8000_192000, role of the 
'hw_rule_rate()' and the 'hw_rule_channels()' is invariant. The former 
checks channels parameters and constrains rate parameter with valid 
interval. The latter checks and constraints vice versa with valid list.


Regards

Takashi Sakamoto


More information about the Alsa-devel mailing list