Lines Matching +full:chan +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0+
4 // Author: Lars-Peter Clausen <lars@metafoo.de>
13 #include <linux/dma-mapping.h>
31 if (!pcm->chan[substream->stream]) in dmaengine_dma_dev()
34 return pcm->chan[substream->stream]->device->dev; in dmaengine_dma_dev()
38 * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback
57 if (rtd->dai_link->num_cpus > 1) { in snd_dmaengine_pcm_prepare_slave_config()
58 dev_err(rtd->dev, in snd_dmaengine_pcm_prepare_slave_config()
60 return -EINVAL; in snd_dmaengine_pcm_prepare_slave_config()
81 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); in dmaengine_pcm_hw_params() local
85 if (!pcm->config->prepare_slave_config) in dmaengine_pcm_hw_params()
90 ret = pcm->config->prepare_slave_config(substream, params, &slave_config); in dmaengine_pcm_hw_params()
94 return dmaengine_slave_config(chan, &slave_config); in dmaengine_pcm_hw_params()
104 struct dma_chan *chan = pcm->chan[substream->stream]; in dmaengine_pcm_set_runtime_hwparams() local
108 if (rtd->dai_link->num_cpus > 1) { in dmaengine_pcm_set_runtime_hwparams()
109 dev_err(rtd->dev, in dmaengine_pcm_set_runtime_hwparams()
111 return -EINVAL; in dmaengine_pcm_set_runtime_hwparams()
114 if (pcm->config->pcm_hardware) in dmaengine_pcm_set_runtime_hwparams()
116 pcm->config->pcm_hardware); in dmaengine_pcm_set_runtime_hwparams()
125 hw.period_bytes_min = dma_data->maxburst * DMA_SLAVE_BUSWIDTH_8_BYTES; in dmaengine_pcm_set_runtime_hwparams()
130 hw.fifo_size = dma_data->fifo_size; in dmaengine_pcm_set_runtime_hwparams()
132 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) in dmaengine_pcm_set_runtime_hwparams()
143 chan); in dmaengine_pcm_set_runtime_hwparams()
152 struct dma_chan *chan = pcm->chan[substream->stream]; in dmaengine_pcm_open() local
159 return snd_dmaengine_pcm_open(substream, chan); in dmaengine_pcm_open()
182 if (rtd->dai_link->num_cpus > 1) { in dmaengine_pcm_compat_request_channel()
183 dev_err(rtd->dev, in dmaengine_pcm_compat_request_channel()
190 if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0]) in dmaengine_pcm_compat_request_channel()
191 return pcm->chan[0]; in dmaengine_pcm_compat_request_channel()
193 if (pcm->config->compat_request_channel) in dmaengine_pcm_compat_request_channel()
194 return pcm->config->compat_request_channel(rtd, substream); in dmaengine_pcm_compat_request_channel()
196 return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn, in dmaengine_pcm_compat_request_channel()
197 dma_data->filter_data); in dmaengine_pcm_compat_request_channel()
201 struct dma_chan *chan) in dmaengine_pcm_can_report_residue() argument
206 ret = dma_get_slave_caps(chan, &dma_caps); in dmaengine_pcm_can_report_residue()
223 const struct snd_dmaengine_pcm_config *config = pcm->config; in dmaengine_pcm_new()
224 struct device *dev = component->dev; in dmaengine_pcm_new()
229 if (config->prealloc_buffer_size) in dmaengine_pcm_new()
230 prealloc_buffer_size = config->prealloc_buffer_size; in dmaengine_pcm_new()
234 if (config->pcm_hardware && config->pcm_hardware->buffer_bytes_max) in dmaengine_pcm_new()
235 max_buffer_size = config->pcm_hardware->buffer_bytes_max; in dmaengine_pcm_new()
240 struct snd_pcm_substream *substream = rtd->pcm->streams[i].substream; in dmaengine_pcm_new()
244 if (!pcm->chan[i] && config->chan_names[i]) in dmaengine_pcm_new()
245 pcm->chan[i] = dma_request_slave_channel(dev, in dmaengine_pcm_new()
246 config->chan_names[i]); in dmaengine_pcm_new()
248 if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) { in dmaengine_pcm_new()
249 pcm->chan[i] = dmaengine_pcm_compat_request_channel( in dmaengine_pcm_new()
253 if (!pcm->chan[i]) { in dmaengine_pcm_new()
254 dev_err(component->dev, in dmaengine_pcm_new()
256 return -EINVAL; in dmaengine_pcm_new()
265 if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) in dmaengine_pcm_new()
266 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; in dmaengine_pcm_new()
268 if (rtd->pcm->streams[i].pcm->name[0] == '\0') { in dmaengine_pcm_new()
269 strscpy_pad(rtd->pcm->streams[i].pcm->name, in dmaengine_pcm_new()
270 rtd->pcm->streams[i].pcm->id, in dmaengine_pcm_new()
271 sizeof(rtd->pcm->streams[i].pcm->name)); in dmaengine_pcm_new()
284 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) in dmaengine_pcm_pointer()
295 struct snd_pcm_runtime *runtime = substream->runtime; in dmaengine_copy_user()
299 void *buf, unsigned long bytes) = pcm->config->process; in dmaengine_copy_user()
300 bool is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in dmaengine_copy_user()
301 void *dma_ptr = runtime->dma_area + hwoff + in dmaengine_copy_user()
302 channel * (runtime->dma_bytes / runtime->channels); in dmaengine_copy_user()
306 return -EFAULT; in dmaengine_copy_user()
316 return -EFAULT; in dmaengine_copy_user()
322 .name = SND_DMAENGINE_PCM_DRV_NAME,
333 .name = SND_DMAENGINE_PCM_DRV_NAME,
353 const char *name; in dmaengine_pcm_request_chan_of() local
354 struct dma_chan *chan; in dmaengine_pcm_request_chan_of() local
356 if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_DT) || (!dev->of_node && in dmaengine_pcm_request_chan_of()
357 !(config->dma_dev && config->dma_dev->of_node))) in dmaengine_pcm_request_chan_of()
360 if (config->dma_dev) { in dmaengine_pcm_request_chan_of()
368 dev_name(config->dma_dev)); in dmaengine_pcm_request_chan_of()
369 dev = config->dma_dev; in dmaengine_pcm_request_chan_of()
373 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) in dmaengine_pcm_request_chan_of()
374 name = "rx-tx"; in dmaengine_pcm_request_chan_of()
376 name = dmaengine_pcm_dma_channel_names[i]; in dmaengine_pcm_request_chan_of()
377 if (config->chan_names[i]) in dmaengine_pcm_request_chan_of()
378 name = config->chan_names[i]; in dmaengine_pcm_request_chan_of()
379 chan = dma_request_chan(dev, name); in dmaengine_pcm_request_chan_of()
380 if (IS_ERR(chan)) { in dmaengine_pcm_request_chan_of()
386 if (PTR_ERR(chan) == -EPROBE_DEFER) in dmaengine_pcm_request_chan_of()
387 return -EPROBE_DEFER; in dmaengine_pcm_request_chan_of()
388 pcm->chan[i] = NULL; in dmaengine_pcm_request_chan_of()
390 pcm->chan[i] = chan; in dmaengine_pcm_request_chan_of()
392 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) in dmaengine_pcm_request_chan_of()
396 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) in dmaengine_pcm_request_chan_of()
397 pcm->chan[1] = pcm->chan[0]; in dmaengine_pcm_request_chan_of()
407 if (!pcm->chan[i]) in dmaengine_pcm_release_chan()
409 dma_release_channel(pcm->chan[i]); in dmaengine_pcm_release_chan()
410 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) in dmaengine_pcm_release_chan()
420 * snd_dmaengine_pcm_register - Register a dmaengine based PCM device
434 return -ENOMEM; in snd_dmaengine_pcm_register()
437 pcm->component.debugfs_prefix = "dma"; in snd_dmaengine_pcm_register()
441 pcm->config = config; in snd_dmaengine_pcm_register()
442 pcm->flags = flags; in snd_dmaengine_pcm_register()
448 if (config->process) in snd_dmaengine_pcm_register()
453 ret = snd_soc_component_initialize(&pcm->component, driver, dev); in snd_dmaengine_pcm_register()
457 ret = snd_soc_add_component(&pcm->component, NULL, 0); in snd_dmaengine_pcm_register()
471 * snd_dmaengine_pcm_unregister - Removes a dmaengine based PCM device
488 snd_soc_unregister_component_by_driver(dev, component->driver); in snd_dmaengine_pcm_unregister()