From: Lars-Peter Clausen <lars@metafoo.de> To: Barry Song <21cnbao@gmail.com> Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, Workgroup.Linux@csr.com, Rongjun Ying <Rongjun.Ying@csr.com>, broonie@kernel.org, Barry Song <Baohua.Song@csr.com>, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/6] ASoC: sirf: add sirf platform driver which provides DMA Date: Fri, 19 Jul 2013 17:08:12 +0200 [thread overview] Message-ID: <51E9565C.8020308@metafoo.de> (raw) In-Reply-To: <1374232042-26088-2-git-send-email-Baohua.Song@csr.com> On 07/19/2013 01:07 PM, Barry Song wrote: > From: Rongjun Ying <Rongjun.Ying@csr.com> > > this driver uses dmaengine APIs and provides DMA to the CPU DAIs > of I2S, USP and SiRF-soc-inner. > SiRFSoC has 3 audio DAIs: I2S, USP(Universal Serial Ports) and DAI > connected to soc-inner-codec, all of them will use the same DMA > driver here. > I think the bulk of the code here can be replaced by using the generic dmaengine PCM driver. Have a look at e.g. mxs to see how that is done. [...] > + > +static int sirf_pcm_open(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct sirf_pcm_dma_data *dma_data; > + substream->runtime->hw = sirf_pcm_hardware; > + snd_soc_set_runtime_hwparams(substream, &sirf_pcm_hardware); > + > + dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); > + > + return snd_dmaengine_pcm_open_request_chan(substream, > + (dma_filter_fn)sirfsoc_dma_filter_id, > + (void *)(dma_data->dma_req)); Since you are using devicetree on this platform use the devicetree to get a handle to the DMA channel. > +} > + > +static int sirf_pcm_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct sirf_pcm_dma_data *dma_data; > + struct dma_slave_config config; > + struct dma_chan *chan; > + int err = 0; > + > + dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); > + > + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); > + runtime->dma_bytes = params_buffer_bytes(params); > + > + chan = snd_dmaengine_pcm_get_chan(substream); > + if (!chan) > + return -EINVAL; > + > + /* fills in addr_width and direction */ > + err = snd_hwparams_to_dma_slave_config(substream, params, &config); > + if (err) > + return err; > + > + config.dst_addr_width = DMA_SLAVE_BUSWIDTH_8_BYTES; > + config.src_addr_width = DMA_SLAVE_BUSWIDTH_8_BYTES; > + > + config.src_addr = runtime->dma_addr; > + config.dst_addr = runtime->dma_addr; > + config.src_maxburst = DMA_SLAVE_BUSWIDTH_8_BYTES; > + config.dst_maxburst = DMA_SLAVE_BUSWIDTH_8_BYTES; > + > + return dmaengine_slave_config(chan, &config); Nothing special in here, just use the generic snd_dmaengine_pcm_prepare_slave_config(). > +} > + [...] static const struct of_device_id sirf_pcm_of_match[] = { > + { .compatible = "sirf,pcm-audio", }, > + {} > +}; Since this is not a separate piece of hardware, but just the glue logic between the DMA controller and the audio DAI it should not have it's own devicetree node. Usually the the PCM device is registered by the DAI driver. Again take at other platforms using the generic dmaengine PCM driver for examples. > +MODULE_DEVICE_TABLE(of, sirf_pcm_of_match); > + > +static struct platform_driver sirf_pcm_driver = { > + .driver = { > + .name = "sirf-pcm-audio", > + .owner = THIS_MODULE, > + .of_match_table = sirf_pcm_of_match, > + }, > + .probe = sirf_pcm_probe, > + .remove = sirf_pcm_remove, > +}; > +module_platform_driver(sirf_pcm_driver); [...]
WARNING: multiple messages have this Message-ID (diff)
From: lars@metafoo.de (Lars-Peter Clausen) To: linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH 1/6] ASoC: sirf: add sirf platform driver which provides DMA Date: Fri, 19 Jul 2013 17:08:12 +0200 [thread overview] Message-ID: <51E9565C.8020308@metafoo.de> (raw) In-Reply-To: <1374232042-26088-2-git-send-email-Baohua.Song@csr.com> On 07/19/2013 01:07 PM, Barry Song wrote: > From: Rongjun Ying <Rongjun.Ying@csr.com> > > this driver uses dmaengine APIs and provides DMA to the CPU DAIs > of I2S, USP and SiRF-soc-inner. > SiRFSoC has 3 audio DAIs: I2S, USP(Universal Serial Ports) and DAI > connected to soc-inner-codec, all of them will use the same DMA > driver here. > I think the bulk of the code here can be replaced by using the generic dmaengine PCM driver. Have a look at e.g. mxs to see how that is done. [...] > + > +static int sirf_pcm_open(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct sirf_pcm_dma_data *dma_data; > + substream->runtime->hw = sirf_pcm_hardware; > + snd_soc_set_runtime_hwparams(substream, &sirf_pcm_hardware); > + > + dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); > + > + return snd_dmaengine_pcm_open_request_chan(substream, > + (dma_filter_fn)sirfsoc_dma_filter_id, > + (void *)(dma_data->dma_req)); Since you are using devicetree on this platform use the devicetree to get a handle to the DMA channel. > +} > + > +static int sirf_pcm_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct sirf_pcm_dma_data *dma_data; > + struct dma_slave_config config; > + struct dma_chan *chan; > + int err = 0; > + > + dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); > + > + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); > + runtime->dma_bytes = params_buffer_bytes(params); > + > + chan = snd_dmaengine_pcm_get_chan(substream); > + if (!chan) > + return -EINVAL; > + > + /* fills in addr_width and direction */ > + err = snd_hwparams_to_dma_slave_config(substream, params, &config); > + if (err) > + return err; > + > + config.dst_addr_width = DMA_SLAVE_BUSWIDTH_8_BYTES; > + config.src_addr_width = DMA_SLAVE_BUSWIDTH_8_BYTES; > + > + config.src_addr = runtime->dma_addr; > + config.dst_addr = runtime->dma_addr; > + config.src_maxburst = DMA_SLAVE_BUSWIDTH_8_BYTES; > + config.dst_maxburst = DMA_SLAVE_BUSWIDTH_8_BYTES; > + > + return dmaengine_slave_config(chan, &config); Nothing special in here, just use the generic snd_dmaengine_pcm_prepare_slave_config(). > +} > + [...] static const struct of_device_id sirf_pcm_of_match[] = { > + { .compatible = "sirf,pcm-audio", }, > + {} > +}; Since this is not a separate piece of hardware, but just the glue logic between the DMA controller and the audio DAI it should not have it's own devicetree node. Usually the the PCM device is registered by the DAI driver. Again take at other platforms using the generic dmaengine PCM driver for examples. > +MODULE_DEVICE_TABLE(of, sirf_pcm_of_match); > + > +static struct platform_driver sirf_pcm_driver = { > + .driver = { > + .name = "sirf-pcm-audio", > + .owner = THIS_MODULE, > + .of_match_table = sirf_pcm_of_match, > + }, > + .probe = sirf_pcm_probe, > + .remove = sirf_pcm_remove, > +}; > +module_platform_driver(sirf_pcm_driver); [...]
next prev parent reply other threads:[~2013-07-19 15:07 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-19 11:07 [PATCH 0/6] ASoC: add CSR SiRFSoC sound drivers Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 11:07 ` [PATCH 1/6] ASoC: sirf: add sirf platform driver which provides DMA Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 15:08 ` Lars-Peter Clausen [this message] 2013-07-19 15:08 ` [alsa-devel] " Lars-Peter Clausen 2013-07-19 16:12 ` Mark Brown 2013-07-19 16:12 ` Mark Brown 2013-07-22 0:06 ` Barry Song 2013-07-22 0:06 ` Barry Song 2013-07-19 11:07 ` [PATCH 2/6] ASoC: sirf: add I2S CPU DAI driver Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 16:52 ` Mark Brown 2013-07-19 16:52 ` Mark Brown 2013-07-22 9:07 ` Barry Song 2013-07-22 9:07 ` Barry Song 2013-07-19 11:07 ` [PATCH 3/6] ASoC: usp-pcm: add CPU DAI driver for PCM simulated from USP Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 18:13 ` Mark Brown 2013-07-19 18:13 ` Mark Brown 2013-07-25 9:32 ` Barry Song 2013-07-25 9:32 ` Barry Song 2013-07-25 10:24 ` Mark Brown 2013-07-25 10:24 ` Mark Brown 2013-07-19 11:07 ` [PATCH 4/6] ASoC: sirf-soc-inner: add drivers for both CPU and Codec DAIs Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 18:35 ` Mark Brown 2013-07-19 18:35 ` Mark Brown 2013-07-25 9:11 ` Barry Song 2013-07-25 9:11 ` Barry Song 2013-07-19 11:07 ` [PATCH 5/6] ASoC: sirf-inner: add mach driver for SiRFSoC internal codec Barry Song 2013-07-19 11:07 ` Barry Song 2013-07-19 18:51 ` Mark Brown 2013-07-19 18:51 ` Mark Brown 2013-07-25 8:57 ` Barry Song 2013-07-25 8:57 ` Barry Song 2013-07-19 11:07 ` [PATCH 6/6] arm: prima2: defconfig: enable sound components Barry Song 2013-07-19 11:07 ` Barry Song
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=51E9565C.8020308@metafoo.de \ --to=lars@metafoo.de \ --cc=21cnbao@gmail.com \ --cc=Baohua.Song@csr.com \ --cc=Rongjun.Ying@csr.com \ --cc=Workgroup.Linux@csr.com \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=lgirdwood@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.