29 #include <linux/module.h>
46 #define PCM_BUFFER_MAX 0x8000
47 #define FRAGMENT_SIZE_MIN (4*1024)
48 #define FRAGMENTS_MIN 2
49 #define FRAGMENTS_MAX 32
51 static void bf5xx_dma_irq(
void *
data)
91 int fragsize_bytes = frames_to_bytes(runtime, runtime->
period_size);
100 runtime->
periods, fragsize_bytes);
104 runtime->
periods, fragsize_bytes);
147 frames = diff / (8*4);
150 frames = diff / (8*4);
159 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
172 if (sport_handle !=
NULL) {
180 pr_err(
"sport_handle is NULL\n");
199 dst = (
unsigned int *)substream->
runtime->dma_area;
203 for (i = 0; i < substream->
runtime->channels; i++)
204 *(dst + tdm_port->
tx_map[i]) = *src++;
208 src = (
unsigned int *)substream->
runtime->dma_area;
213 for (i = 0; i < substream->
runtime->channels; i++)
214 *dst++ = *(src + tdm_port->
rx_map[i]);
225 unsigned char *buf = substream->
runtime->dma_area;
227 memset(buf,
'\0', count * 8 * 4);
234 .open = bf5xx_pcm_open,
236 .hw_params = bf5xx_pcm_hw_params,
237 .hw_free = bf5xx_pcm_hw_free,
238 .prepare = bf5xx_pcm_prepare,
239 .trigger = bf5xx_pcm_trigger,
240 .pointer = bf5xx_pcm_pointer,
241 .copy = bf5xx_pcm_copy,
242 .silence = bf5xx_pcm_silence,
245 static int bf5xx_pcm_preallocate_dma_buffer(
struct snd_pcm *pcm,
int stream)
257 pr_err(
"Failed to allocate dma memory - Please increase uncached DMA memory region\n");
265 static void bf5xx_pcm_free_dma_buffers(
struct snd_pcm *pcm)
271 for (stream = 0; stream < 2; stream++) {
272 substream = pcm->
streams[stream].substream;
292 if (!card->
dev->dma_mask)
293 card->
dev->dma_mask = &bf5xx_pcm_dmamask;
294 if (!card->
dev->coherent_dma_mask)
298 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
305 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
316 .pcm_new = bf5xx_pcm_tdm_new,
317 .pcm_free = bf5xx_pcm_free_dma_buffers,
333 .name =
"bfin-tdm-pcm-audio",
337 .probe = bf5xx_soc_platform_probe,