12 #include <linux/module.h>
15 #include <linux/slab.h>
29 #define S6_PCM_PREALLOCATE_SIZE (96 * 1024)
30 #define S6_PCM_PREALLOCATE_MAX (2048 * 1024)
38 SNDRV_PCM_RATE_8000_192000),
63 unsigned int period_size;
64 unsigned int dma_offset;
68 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
70 period_size = snd_pcm_lib_period_bytes(substream);
71 dma_offset = prtd->
period * period_size;
72 dma_pos = runtime->
dma_addr + dma_offset;
95 src, dst, period_size);
107 unsigned int has_xrun;
110 for (i = 0; i < 2; ++
i) {
113 snd_soc_dai_get_dma_data(runtime->
cpu_dai, substream);
115 unsigned int pending;
127 if (
unlikely(has_xrun & (1 << i)) &&
129 snd_pcm_running(substream)) {
141 snd_pcm_running(substream))) {
148 prtd = substream->
runtime->private_data;
149 spin_lock(&prtd->
lock);
150 s6000_pcm_enqueue_dma(substream);
151 spin_unlock(&prtd->
lock);
156 if (pending & (1 << 3))
158 "s6000-pcm: DMA %x Underflow\n",
160 if (pending & (1 << 4))
162 "s6000-pcm: DMA %x Overflow\n",
166 "s6000-pcm: DMA %x Master Error "
168 channel, pending >> 5);
185 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
210 s6000_pcm_enqueue_dma(substream);
211 s6000_pcm_enqueue_dma(substream);
213 spin_unlock_irqrestore(&prtd->
lock, flags);
226 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
240 spin_unlock_irqrestore(&prtd->
lock, flags);
251 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
253 ret = par->
trigger(substream, cmd, 0);
261 ret = s6000_pcm_start(substream);
266 ret = s6000_pcm_stop(substream);
274 return par->
trigger(substream, cmd, 1);
296 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
309 spin_unlock_irqrestore(&prtd->
lock, flags);
311 offset = bytes_to_frames(runtime, count);
326 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
344 spin_lock(&par->
lock);
346 spin_unlock(&par->
lock);
390 par = snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
393 spin_lock(&par->
lock);
394 if (par->
rate == -1 ||
403 spin_unlock(&par->
lock);
412 snd_soc_dai_get_dma_data(soc_runtime->
cpu_dai, substream);
414 spin_lock(&par->
lock);
418 spin_unlock(&par->
lock);
424 .open = s6000_pcm_open,
425 .close = s6000_pcm_close,
427 .hw_params = s6000_pcm_hw_params,
428 .hw_free = s6000_pcm_hw_free,
429 .trigger = s6000_pcm_trigger,
430 .prepare = s6000_pcm_prepare,
431 .pointer = s6000_pcm_pointer,
434 static void s6000_pcm_free(
struct snd_pcm *pcm)
438 snd_soc_dai_get_dma_data(runtime->
cpu_dai,
454 params = snd_soc_dai_get_dma_data(runtime->
cpu_dai,
457 if (!card->
dev->dma_mask)
458 card->
dev->dma_mask = &s6000_pcm_dmamask;
459 if (!card->
dev->coherent_dma_mask)
498 .ops = &s6000_pcm_ops,
499 .pcm_new = s6000_pcm_new,
500 .pcm_free = s6000_pcm_free,
516 .name =
"s6000-pcm-audio",
520 .probe = s6000_soc_platform_probe,