34 #include <linux/module.h>
37 #include <linux/slab.h>
62 .period_bytes_min = 32,
63 .period_bytes_max = 8192,
66 .buffer_bytes_max = 32 * 1024,
92 static int atmel_pcm_preallocate_dma_buffer(
struct snd_pcm *pcm,
105 "preallocate_dma_buffer: area=%p, addr=%p, size=%d\n",
119 static void atmel_pcm_dma_irq(
u32 ssc_sr,
128 if (ssc_sr & params->
mask->ssc_endbuf) {
130 " (SSC_SR=%#x, count=%d)\n",
132 ?
"underrun" :
"overrun",
133 params->
name, ssc_sr, count);
137 params->
mask->pdc_disable);
147 params->
mask->pdc_enable);
150 if (ssc_sr & params->
mask->ssc_endx) {
179 snd_pcm_set_runtime_buffer(substream, &substream->
dma_buffer);
182 prtd->
params = snd_soc_dai_get_dma_data(rtd->
cpu_dai, substream);
183 prtd->
params->dma_intr_handler = atmel_pcm_dma_irq;
190 "hw_params: DMA for %s initialized "
191 "(dma_bytes=%u, period_size=%u)\n",
203 if (params !=
NULL) {
205 params->
mask->pdc_disable);
218 params->
mask->ssc_endx | params->
mask->ssc_endbuf);
220 params->
mask->pdc_disable);
232 pr_debug(
"atmel-pcm:buffer_size = %ld,"
233 "dma_area = %p, dma_bytes = %u\n",
252 "period_ptr=%lx, xpr=%u, "
253 "xcr=%u, xnpr=%u, xncr=%u\n",
261 params->
mask->ssc_endx | params->
mask->ssc_endbuf);
263 params->
mask->pdc_enable);
274 params->
mask->pdc_disable);
280 params->
mask->pdc_enable);
300 x = bytes_to_frames(runtime, ptr - prtd->
dma_buffer);
350 .open = atmel_pcm_open,
351 .close = atmel_pcm_close,
353 .hw_params = atmel_pcm_hw_params,
354 .hw_free = atmel_pcm_hw_free,
355 .prepare = atmel_pcm_prepare,
356 .trigger = atmel_pcm_trigger,
357 .pointer = atmel_pcm_pointer,
358 .mmap = atmel_pcm_mmap,
373 if (!card->
dev->dma_mask)
374 card->
dev->dma_mask = &atmel_pcm_dmamask;
375 if (!card->
dev->coherent_dma_mask)
379 ret = atmel_pcm_preallocate_dma_buffer(pcm,
387 "Allocating PCM capture DMA buffer\n");
388 ret = atmel_pcm_preallocate_dma_buffer(pcm,
397 static void atmel_pcm_free_dma_buffers(
struct snd_pcm *pcm)
403 for (stream = 0; stream < 2; stream++) {
404 substream = pcm->
streams[stream].substream;
464 #define atmel_pcm_suspend NULL
465 #define atmel_pcm_resume NULL
469 .ops = &atmel_pcm_ops,
470 .pcm_new = atmel_pcm_new,
471 .pcm_free = atmel_pcm_free_dma_buffers,
489 .name =
"atmel-pcm-audio",
493 .probe = atmel_soc_platform_probe,