10 #include <linux/module.h>
13 #include <linux/slab.h>
24 #define ALCHEMY_PCM_FMTS \
25 (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \
26 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
27 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE | \
28 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | \
29 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE | \
50 static void au1000_release_dma_link(
struct audio_stream *stream)
61 pointer_next = pointer->
next;
63 pointer = pointer_next;
64 }
while (pointer != stream->
buffer);
68 static int au1000_setup_dma_link(
struct audio_stream *stream,
69 unsigned int period_bytes,
84 au1000_release_dma_link(stream);
93 for (i = 0; i < periods; i++) {
94 pointer->
start = (
u32)(dma_start + (i * period_bytes));
96 if (i < periods - 1) {
100 au1000_release_dma_link(stream);
103 pointer = pointer->
next;
110 static void au1000_dma_stop(
struct audio_stream *stream)
116 static void au1000_dma_start(
struct audio_stream *stream)
121 init_dma(stream->
dma);
122 if (get_dma_active_buffer(stream->
dma) == 0) {
123 clear_dma_done0(stream->
dma);
124 set_dma_addr0(stream->
dma, stream->
buffer->start);
126 set_dma_addr1(stream->
dma, stream->
buffer->next->start);
129 clear_dma_done1(stream->
dma);
130 set_dma_addr1(stream->
dma, stream->
buffer->start);
132 set_dma_addr0(stream->
dma, stream->
buffer->next->start);
135 enable_dma_buffers(stream->
dma);
136 start_dma(stream->
dma);
144 switch (get_dma_buffer_done(stream->
dma)) {
147 clear_dma_done0(stream->
dma);
148 set_dma_addr0(stream->
dma, stream->
buffer->next->start);
150 enable_dma_buffer0(stream->
dma);
154 clear_dma_done1(stream->
dma);
155 set_dma_addr1(stream->
dma, stream->
buffer->next->start);
157 enable_dma_buffer1(stream->
dma);
160 pr_debug(
"DMA %d missed interrupt.\n", stream->
dma);
161 au1000_dma_stop(stream);
162 au1000_dma_start(stream);
180 .period_bytes_min = 1024,
181 .period_bytes_max = 16 * 1024 - 1,
184 .buffer_bytes_max = 128 * 1024,
191 return snd_soc_platform_get_drvdata(rtd->
platform);
204 int *dmaids,
s = substream->
stream;
207 dmaids = snd_soc_dai_get_dma_data(rtd->
cpu_dai, substream);
214 au1000_dma_interrupt, 0,
219 ctx->
stream[
s].substream = substream;
229 int stype = substream->
stream;
247 err = au1000_setup_dma_link(stream,
248 params_period_bytes(hw_params),
259 au1000_release_dma_link(stream);
270 au1000_dma_start(stream);
273 au1000_dma_stop(stream);
291 return bytes_to_frames(ss->
runtime, location);
295 .open = alchemy_pcm_open,
296 .close = alchemy_pcm_close,
298 .hw_params = alchemy_pcm_hw_params,
299 .hw_free = alchemy_pcm_hw_free,
300 .trigger = alchemy_pcm_trigger,
301 .pointer = alchemy_pcm_pointer,
304 static void alchemy_pcm_free_dma_buffers(
struct snd_pcm *pcm)
320 .ops = &alchemy_pcm_ops,
321 .pcm_new = alchemy_pcm_new,
322 .pcm_free = alchemy_pcm_free_dma_buffers,
333 platform_set_drvdata(pdev, ctx);
347 .name =
"alchemy-pcm-dma",
350 .probe = alchemy_pcm_drvprobe,