Lines Matching +full:dma +full:- +full:channel +full:- +full:mask

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
63 return -EINVAL; in snd_hwparams_to_dma_slave_config()
75 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hwparams_to_dma_slave_config()
76 slave_config->direction = DMA_MEM_TO_DEV; in snd_hwparams_to_dma_slave_config()
77 slave_config->dst_addr_width = buswidth; in snd_hwparams_to_dma_slave_config()
79 slave_config->direction = DMA_DEV_TO_MEM; in snd_hwparams_to_dma_slave_config()
80 slave_config->src_addr_width = buswidth; in snd_hwparams_to_dma_slave_config()
83 slave_config->device_fc = false; in snd_hwparams_to_dma_slave_config()
90 * snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
91 * using DAI DMA data.
93 * @dma_data: DAI DMA data
94 * @slave_config: DMA slave configuration
97 * fields of the DMA slave config from the same fields of the DAI DMA
103 * the DAI DMA data struct is not equal to DMA_SLAVE_BUSWIDTH_UNDEFINED. If
111 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_dmaengine_pcm_set_config_from_dai_data()
112 slave_config->dst_addr = dma_data->addr; in snd_dmaengine_pcm_set_config_from_dai_data()
113 slave_config->dst_maxburst = dma_data->maxburst; in snd_dmaengine_pcm_set_config_from_dai_data()
114 if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK) in snd_dmaengine_pcm_set_config_from_dai_data()
115 slave_config->dst_addr_width = in snd_dmaengine_pcm_set_config_from_dai_data()
117 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) in snd_dmaengine_pcm_set_config_from_dai_data()
118 slave_config->dst_addr_width = dma_data->addr_width; in snd_dmaengine_pcm_set_config_from_dai_data()
120 slave_config->src_addr = dma_data->addr; in snd_dmaengine_pcm_set_config_from_dai_data()
121 slave_config->src_maxburst = dma_data->maxburst; in snd_dmaengine_pcm_set_config_from_dai_data()
122 if (dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK) in snd_dmaengine_pcm_set_config_from_dai_data()
123 slave_config->src_addr_width = in snd_dmaengine_pcm_set_config_from_dai_data()
125 if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) in snd_dmaengine_pcm_set_config_from_dai_data()
126 slave_config->src_addr_width = dma_data->addr_width; in snd_dmaengine_pcm_set_config_from_dai_data()
129 slave_config->peripheral_config = dma_data->peripheral_config; in snd_dmaengine_pcm_set_config_from_dai_data()
130 slave_config->peripheral_size = dma_data->peripheral_size; in snd_dmaengine_pcm_set_config_from_dai_data()
140 new_pos = prtd->pos + snd_pcm_lib_period_bytes(substream); in dmaengine_pcm_dma_complete()
143 prtd->pos = new_pos; in dmaengine_pcm_dma_complete()
151 struct dma_chan *chan = prtd->dma_chan; in dmaengine_pcm_prepare_and_submit()
158 if (!substream->runtime->no_period_wakeup) in dmaengine_pcm_prepare_and_submit()
161 prtd->pos = 0; in dmaengine_pcm_prepare_and_submit()
163 substream->runtime->dma_addr, in dmaengine_pcm_prepare_and_submit()
168 return -ENOMEM; in dmaengine_pcm_prepare_and_submit()
170 desc->callback = dmaengine_pcm_dma_complete; in dmaengine_pcm_prepare_and_submit()
171 desc->callback_param = substream; in dmaengine_pcm_prepare_and_submit()
172 prtd->cookie = dmaengine_submit(desc); in dmaengine_pcm_prepare_and_submit()
178 * snd_dmaengine_pcm_trigger - dmaengine based PCM trigger implementation
190 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_trigger()
198 dma_async_issue_pending(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
202 dmaengine_resume(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
205 if (runtime->info & SNDRV_PCM_INFO_PAUSE) in snd_dmaengine_pcm_trigger()
206 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
208 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
211 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
214 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
217 return -EINVAL; in snd_dmaengine_pcm_trigger()
225 * snd_dmaengine_pcm_pointer_no_residue - dmaengine based PCM pointer implementation
236 return bytes_to_frames(substream->runtime, prtd->pos); in snd_dmaengine_pcm_pointer_no_residue()
241 * snd_dmaengine_pcm_pointer - dmaengine based PCM pointer implementation
252 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_pointer()
258 status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); in snd_dmaengine_pcm_pointer()
262 pos = buf_size - state.residue; in snd_dmaengine_pcm_pointer()
264 runtime->delay = bytes_to_frames(runtime, in snd_dmaengine_pcm_pointer()
273 * snd_dmaengine_pcm_request_channel - Request channel for the dmaengine PCM
274 * @filter_fn: Filter function used to request the DMA channel
275 * @filter_data: Data passed to the DMA filter function
277 * This function request a DMA channel for usage with dmaengine PCM.
279 * Return: NULL or the requested DMA channel
284 dma_cap_mask_t mask; in snd_dmaengine_pcm_request_channel() local
286 dma_cap_zero(mask); in snd_dmaengine_pcm_request_channel()
287 dma_cap_set(DMA_SLAVE, mask); in snd_dmaengine_pcm_request_channel()
288 dma_cap_set(DMA_CYCLIC, mask); in snd_dmaengine_pcm_request_channel()
290 return dma_request_channel(mask, filter_fn, filter_data); in snd_dmaengine_pcm_request_channel()
295 * snd_dmaengine_pcm_open - Open a dmaengine based PCM substream
297 * @chan: DMA channel to use for data transfers
312 return -ENXIO; in snd_dmaengine_pcm_open()
314 ret = snd_pcm_hw_constraint_integer(substream->runtime, in snd_dmaengine_pcm_open()
321 return -ENOMEM; in snd_dmaengine_pcm_open()
323 prtd->dma_chan = chan; in snd_dmaengine_pcm_open()
325 substream->runtime->private_data = prtd; in snd_dmaengine_pcm_open()
332 * snd_dmaengine_pcm_open_request_chan - Open a dmaengine based PCM substream and request channel
334 * @filter_fn: Filter function used to request the DMA channel
335 * @filter_data: Data passed to the DMA filter function
337 * This function will request a DMA channel using the passed filter function and
358 status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); in snd_dmaengine_pcm_sync_stop()
360 dmaengine_synchronize(prtd->dma_chan); in snd_dmaengine_pcm_sync_stop()
373 status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); in __snd_dmaengine_pcm_close()
375 dmaengine_terminate_async(prtd->dma_chan); in __snd_dmaengine_pcm_close()
377 dmaengine_synchronize(prtd->dma_chan); in __snd_dmaengine_pcm_close()
379 dma_release_channel(prtd->dma_chan); in __snd_dmaengine_pcm_close()
384 * snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
397 * snd_dmaengine_pcm_close_release_chan - Close a dmaengine based PCM
398 * substream and release channel
401 * Releases the DMA channel associated with the PCM substream.
413 * snd_dmaengine_pcm_refine_runtime_hwparams - Refine runtime hw params
415 * @dma_data: DAI DMA data
417 * @chan: DMA channel to use for data transfers
419 * This function will query DMA capability, then refine the pcm hardware
438 return -EINVAL; in snd_dmaengine_pcm_refine_runtime_hwparams()
443 hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; in snd_dmaengine_pcm_refine_runtime_hwparams()
445 hw->info |= SNDRV_PCM_INFO_BATCH; in snd_dmaengine_pcm_refine_runtime_hwparams()
447 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_dmaengine_pcm_refine_runtime_hwparams()
459 if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)) in snd_dmaengine_pcm_refine_runtime_hwparams()
461 * Prepare formats mask for valid/allowed sample types. If the in snd_dmaengine_pcm_refine_runtime_hwparams()
462 * dma does not have support for the given physical word size, in snd_dmaengine_pcm_refine_runtime_hwparams()
465 * In case the dma driver does not implement the slave_caps the in snd_dmaengine_pcm_refine_runtime_hwparams()
473 * Enable only samples with DMA supported physical in snd_dmaengine_pcm_refine_runtime_hwparams()
483 hw->formats |= pcm_format_to_bits(i); in snd_dmaengine_pcm_refine_runtime_hwparams()