From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: Re: How to handle stream rates if CPU supports many channels ? Date: Tue, 6 Jun 2017 07:04:02 +0000 Message-ID: <874lvtzjo5.wl%kuninori.morimoto.gx@renesas.com> References: <87tw3uymhu.wl%kuninori.morimoto.gx@renesas.com> <6d1e2ca9-2a3f-ff12-28c4-c96224760913@sakamocchi.jp> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id 6DB9F2668E2 for ; Tue, 6 Jun 2017 09:04:08 +0200 (CEST) In-Reply-To: <6d1e2ca9-2a3f-ff12-28c4-c96224760913@sakamocchi.jp> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Sakamoto Cc: Linux-ALSA , Mark Brown , Hiroyuki Yokoyama List-Id: alsa-devel@alsa-project.org 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