Lines Matching +full:dma +full:- +full:maxburst
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Author: Lars-Peter Clausen <lars@metafoo.de>
7 * imx-pcm-dma-mx2.c, Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
8 * mxs-pcm.c, Copyright (C) 2011 Freescale Semiconductor, Inc.
9 * ep93xx-pcm.c, Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
32 return substream->runtime->private_data; in substream_to_prtd()
39 return prtd->dma_chan; in snd_dmaengine_pcm_get_chan()
44 * snd_hwparams_to_dma_slave_config - Convert hw_params to dma_slave_config
47 * @slave_config: DMA slave config
61 return -EINVAL; in snd_hwparams_to_dma_slave_config()
73 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hwparams_to_dma_slave_config()
74 slave_config->direction = DMA_MEM_TO_DEV; in snd_hwparams_to_dma_slave_config()
75 slave_config->dst_addr_width = buswidth; in snd_hwparams_to_dma_slave_config()
77 slave_config->direction = DMA_DEV_TO_MEM; in snd_hwparams_to_dma_slave_config()
78 slave_config->src_addr_width = buswidth; in snd_hwparams_to_dma_slave_config()
81 slave_config->device_fc = false; in snd_hwparams_to_dma_slave_config()
88 * snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
89 * using DAI DMA data.
91 * @dma_data: DAI DMA data
92 * @slave_config: DMA slave configuration
95 * slave_id fields of the DMA slave config from the same fields of the DAI DMA
101 * the DAI DMA data struct is not equal to DMA_SLAVE_BUSWIDTH_UNDEFINED. If
109 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_dmaengine_pcm_set_config_from_dai_data()
110 slave_config->dst_addr = dma_data->addr; in snd_dmaengine_pcm_set_config_from_dai_data()
111 slave_config->dst_maxburst = dma_data->maxburst; in snd_dmaengine_pcm_set_config_from_dai_data()
112 if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK) in snd_dmaengine_pcm_set_config_from_dai_data()
113 slave_config->dst_addr_width = in snd_dmaengine_pcm_set_config_from_dai_data()
115 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) in snd_dmaengine_pcm_set_config_from_dai_data()
116 slave_config->dst_addr_width = dma_data->addr_width; in snd_dmaengine_pcm_set_config_from_dai_data()
118 slave_config->src_addr = dma_data->addr; in snd_dmaengine_pcm_set_config_from_dai_data()
119 slave_config->src_maxburst = dma_data->maxburst; in snd_dmaengine_pcm_set_config_from_dai_data()
120 if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK) in snd_dmaengine_pcm_set_config_from_dai_data()
121 slave_config->src_addr_width = in snd_dmaengine_pcm_set_config_from_dai_data()
123 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) in snd_dmaengine_pcm_set_config_from_dai_data()
124 slave_config->src_addr_width = dma_data->addr_width; in snd_dmaengine_pcm_set_config_from_dai_data()
127 slave_config->slave_id = dma_data->slave_id; in snd_dmaengine_pcm_set_config_from_dai_data()
128 slave_config->peripheral_config = dma_data->peripheral_config; in snd_dmaengine_pcm_set_config_from_dai_data()
129 slave_config->peripheral_size = dma_data->peripheral_size; in snd_dmaengine_pcm_set_config_from_dai_data()
138 prtd->pos += snd_pcm_lib_period_bytes(substream); in dmaengine_pcm_dma_complete()
139 if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream)) in dmaengine_pcm_dma_complete()
140 prtd->pos = 0; in dmaengine_pcm_dma_complete()
148 struct dma_chan *chan = prtd->dma_chan; in dmaengine_pcm_prepare_and_submit()
155 if (!substream->runtime->no_period_wakeup) in dmaengine_pcm_prepare_and_submit()
158 prtd->pos = 0; in dmaengine_pcm_prepare_and_submit()
160 substream->runtime->dma_addr, in dmaengine_pcm_prepare_and_submit()
165 return -ENOMEM; in dmaengine_pcm_prepare_and_submit()
167 desc->callback = dmaengine_pcm_dma_complete; in dmaengine_pcm_prepare_and_submit()
168 desc->callback_param = substream; in dmaengine_pcm_prepare_and_submit()
169 prtd->cookie = dmaengine_submit(desc); in dmaengine_pcm_prepare_and_submit()
175 * snd_dmaengine_pcm_trigger - dmaengine based PCM trigger implementation
187 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_trigger()
195 dma_async_issue_pending(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
199 dmaengine_resume(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
202 if (runtime->info & SNDRV_PCM_INFO_PAUSE) in snd_dmaengine_pcm_trigger()
203 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
205 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
208 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
211 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
214 return -EINVAL; in snd_dmaengine_pcm_trigger()
222 * snd_dmaengine_pcm_pointer_no_residue - dmaengine based PCM pointer implementation
231 return bytes_to_frames(substream->runtime, prtd->pos); in snd_dmaengine_pcm_pointer_no_residue()
236 * snd_dmaengine_pcm_pointer - dmaengine based PCM pointer implementation
245 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_pointer()
251 status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); in snd_dmaengine_pcm_pointer()
255 pos = buf_size - state.residue; in snd_dmaengine_pcm_pointer()
257 runtime->delay = bytes_to_frames(runtime, in snd_dmaengine_pcm_pointer()
266 * snd_dmaengine_pcm_request_channel - Request channel for the dmaengine PCM
267 * @filter_fn: Filter function used to request the DMA channel
268 * @filter_data: Data passed to the DMA filter function
270 * Returns NULL or the requested DMA channel.
272 * This function request a DMA channel for usage with dmaengine PCM.
288 * snd_dmaengine_pcm_open - Open a dmaengine based PCM substream
290 * @chan: DMA channel to use for data transfers
305 return -ENXIO; in snd_dmaengine_pcm_open()
307 ret = snd_pcm_hw_constraint_integer(substream->runtime, in snd_dmaengine_pcm_open()
314 return -ENOMEM; in snd_dmaengine_pcm_open()
316 prtd->dma_chan = chan; in snd_dmaengine_pcm_open()
318 substream->runtime->private_data = prtd; in snd_dmaengine_pcm_open()
325 * snd_dmaengine_pcm_open_request_chan - Open a dmaengine based PCM substream and request channel
327 * @filter_fn: Filter function used to request the DMA channel
328 * @filter_data: Data passed to the DMA filter function
332 * This function will request a DMA channel using the passed filter function and
346 * snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
353 dmaengine_synchronize(prtd->dma_chan); in snd_dmaengine_pcm_close()
361 * snd_dmaengine_pcm_close_release_chan - Close a dmaengine based PCM
365 * Releases the DMA channel associated with the PCM substream.
371 dmaengine_synchronize(prtd->dma_chan); in snd_dmaengine_pcm_close_release_chan()
372 dma_release_channel(prtd->dma_chan); in snd_dmaengine_pcm_close_release_chan()
380 * snd_dmaengine_pcm_refine_runtime_hwparams - Refine runtime hw params
382 * @dma_data: DAI DMA data
384 * @chan: DMA channel to use for data transfers
388 * This function will query DMA capability, then refine the pcm hardware
405 return -EINVAL; in snd_dmaengine_pcm_refine_runtime_hwparams()
410 hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; in snd_dmaengine_pcm_refine_runtime_hwparams()
412 hw->info |= SNDRV_PCM_INFO_BATCH; in snd_dmaengine_pcm_refine_runtime_hwparams()
414 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_dmaengine_pcm_refine_runtime_hwparams()
426 if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)) in snd_dmaengine_pcm_refine_runtime_hwparams()
429 * dma does not have support for the given physical word size, in snd_dmaengine_pcm_refine_runtime_hwparams()
432 * In case the dma driver does not implement the slave_caps the in snd_dmaengine_pcm_refine_runtime_hwparams()
440 * Enable only samples with DMA supported physical in snd_dmaengine_pcm_refine_runtime_hwparams()
450 hw->formats |= pcm_format_to_bits(i); in snd_dmaengine_pcm_refine_runtime_hwparams()