[alsa-devel] How to handle stream rates if CPU supports many channels ?
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Tue Jun 6 09:04:02 CEST 2017
Hi Sakamoto-san
Thank you for detail explanation.
> static int hw_rule_rate()
> {
> unsigned int list[2]
> /* when the range of channels include 2, then 192000 is available. */
> /* when the range of channels include 8, then 48000 is available. */
> snd_interval_list(list)
> }
>
> static int hw_rule_channels()
> {
> unsigned int list[2]
> /* when the range of rates include 48000, then 8ch is available. */
> /* when the range of rates include 192000, then 2ch is available. */
> snd_interval_list(list)
> }
>
> static int startup()
> {
> ...
> snd_pcm_hw_rule_add(SNDRV_PCM_HW_PARAM_RATE, hw_rule_rate,
> SNDRV_PCM_HW_PARAM_CHANNELS)
> snd_pcm_hw_rule_add(SNDRV_PCM_HW_PARAM_CHANNELS, hw_rule_channels,
> SNDRV_PCM_HW_PARAM_RATE)
> ...
> }
>
> struct snd_soc_dai.startup = startup;
I didn't know about this.
Thanks. I will implement it.
> 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).
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 ?
Thank you for your help
Best regards
---
Kuninori Morimoto
More information about the Alsa-devel
mailing list