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
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()
136 prtd->pos += snd_pcm_lib_period_bytes(substream); in dmaengine_pcm_dma_complete()
137 if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream)) in dmaengine_pcm_dma_complete()
138 prtd->pos = 0; in dmaengine_pcm_dma_complete()
146 struct dma_chan *chan = prtd->dma_chan; in dmaengine_pcm_prepare_and_submit()
153 if (!substream->runtime->no_period_wakeup) in dmaengine_pcm_prepare_and_submit()
156 prtd->pos = 0; in dmaengine_pcm_prepare_and_submit()
158 substream->runtime->dma_addr, in dmaengine_pcm_prepare_and_submit()
163 return -ENOMEM; in dmaengine_pcm_prepare_and_submit()
165 desc->callback = dmaengine_pcm_dma_complete; in dmaengine_pcm_prepare_and_submit()
166 desc->callback_param = substream; in dmaengine_pcm_prepare_and_submit()
167 prtd->cookie = dmaengine_submit(desc); in dmaengine_pcm_prepare_and_submit()
173 * snd_dmaengine_pcm_trigger - dmaengine based PCM trigger implementation
185 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_trigger()
193 dma_async_issue_pending(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
197 dmaengine_resume(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
200 if (runtime->info & SNDRV_PCM_INFO_PAUSE) in snd_dmaengine_pcm_trigger()
201 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
203 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
206 dmaengine_pause(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
209 dmaengine_terminate_async(prtd->dma_chan); in snd_dmaengine_pcm_trigger()
212 return -EINVAL; in snd_dmaengine_pcm_trigger()
220 * snd_dmaengine_pcm_pointer_no_residue - dmaengine based PCM pointer implementation
229 return bytes_to_frames(substream->runtime, prtd->pos); in snd_dmaengine_pcm_pointer_no_residue()
234 * snd_dmaengine_pcm_pointer - dmaengine based PCM pointer implementation
243 struct snd_pcm_runtime *runtime = substream->runtime; in snd_dmaengine_pcm_pointer()
249 status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state); in snd_dmaengine_pcm_pointer()
253 pos = buf_size - state.residue; in snd_dmaengine_pcm_pointer()
255 runtime->delay = bytes_to_frames(runtime, in snd_dmaengine_pcm_pointer()
264 * snd_dmaengine_pcm_request_channel - Request channel for the dmaengine PCM
265 * @filter_fn: Filter function used to request the DMA channel
266 * @filter_data: Data passed to the DMA filter function
268 * Returns NULL or the requested DMA channel.
270 * This function request a DMA channel for usage with dmaengine PCM.
275 dma_cap_mask_t mask; in snd_dmaengine_pcm_request_channel() local
277 dma_cap_zero(mask); in snd_dmaengine_pcm_request_channel()
278 dma_cap_set(DMA_SLAVE, mask); in snd_dmaengine_pcm_request_channel()
279 dma_cap_set(DMA_CYCLIC, mask); in snd_dmaengine_pcm_request_channel()
281 return dma_request_channel(mask, filter_fn, filter_data); in snd_dmaengine_pcm_request_channel()
286 * snd_dmaengine_pcm_open - Open a dmaengine based PCM substream
288 * @chan: DMA channel to use for data transfers
303 return -ENXIO; in snd_dmaengine_pcm_open()
305 ret = snd_pcm_hw_constraint_integer(substream->runtime, in snd_dmaengine_pcm_open()
312 return -ENOMEM; in snd_dmaengine_pcm_open()
314 prtd->dma_chan = chan; in snd_dmaengine_pcm_open()
316 substream->runtime->private_data = prtd; in snd_dmaengine_pcm_open()
323 * snd_dmaengine_pcm_open_request_chan - Open a dmaengine based PCM substream and request channel
325 * @filter_fn: Filter function used to request the DMA channel
326 * @filter_data: Data passed to the DMA filter function
330 * This function will request a DMA channel using the passed filter function and
344 * snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
351 dmaengine_synchronize(prtd->dma_chan); in snd_dmaengine_pcm_close()
359 * snd_dmaengine_pcm_close_release_chan - Close a dmaengine based PCM
360 * substream and release channel
363 * Releases the DMA channel associated with the PCM substream.
369 dmaengine_synchronize(prtd->dma_chan); in snd_dmaengine_pcm_close_release_chan()
370 dma_release_channel(prtd->dma_chan); in snd_dmaengine_pcm_close_release_chan()
378 * snd_dmaengine_pcm_refine_runtime_hwparams - Refine runtime hw params
380 * @dma_data: DAI DMA data
382 * @chan: DMA channel to use for data transfers
386 * This function will query DMA capability, then refine the pcm hardware
403 return -EINVAL; in snd_dmaengine_pcm_refine_runtime_hwparams()
408 hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; in snd_dmaengine_pcm_refine_runtime_hwparams()
410 hw->info |= SNDRV_PCM_INFO_BATCH; in snd_dmaengine_pcm_refine_runtime_hwparams()
412 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_dmaengine_pcm_refine_runtime_hwparams()
424 if (!(dma_data->flags & SND_DMAENGINE_PCM_DAI_FLAG_PACK)) in snd_dmaengine_pcm_refine_runtime_hwparams()
426 * Prepare formats mask for valid/allowed sample types. If the in snd_dmaengine_pcm_refine_runtime_hwparams()
427 * dma does not have support for the given physical word size, in snd_dmaengine_pcm_refine_runtime_hwparams()
430 * In case the dma driver does not implement the slave_caps the in snd_dmaengine_pcm_refine_runtime_hwparams()
438 * Enable only samples with DMA supported physical in snd_dmaengine_pcm_refine_runtime_hwparams()
448 hw->formats |= pcm_format_to_bits(i); in snd_dmaengine_pcm_refine_runtime_hwparams()