29 #include <linux/module.h>
46 static unsigned int ac97_chan_mask[] = {
55 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
61 unsigned int chan_mask = ac97_chan_mask[runtime->
channels - 1];
65 runtime->
channels, count, chan_mask);
69 sport->tx_delay_pos = sport->tx_pos;
81 static void bf5xx_dma_irq(
void *
data)
84 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
89 if (sport->once == 0) {
105 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
112 .period_bytes_min = 32,
113 .period_bytes_max = 0x10000,
116 .buffer_bytes_max = 0x20000,
133 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
159 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
193 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
195 sport->tx_delay_pos = 0;
205 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
210 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
228 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
230 curr = sport->tx_delay_pos;
232 curr = sport->rx_pos;
248 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
260 if (sport_handle !=
NULL)
263 pr_err(
"sport_handle is NULL\n");
272 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
289 unsigned int chan_mask = ac97_chan_mask[runtime->
channels - 1];
290 pr_debug(
"%s copy pos:0x%lx count:0x%lx\n",
291 substream->
stream ?
"Capture" :
"Playback", pos, count);
295 (
__u16 *)buf, count, chan_mask);
298 (
__u16 *)buf, count);
304 .open = bf5xx_pcm_open,
306 .hw_params = bf5xx_pcm_hw_params,
307 .hw_free = bf5xx_pcm_hw_free,
308 .prepare = bf5xx_pcm_prepare,
309 .trigger = bf5xx_pcm_trigger,
310 .pointer = bf5xx_pcm_pointer,
311 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
312 .mmap = bf5xx_pcm_mmap,
314 .copy = bf5xx_pcm_copy,
318 static int bf5xx_pcm_preallocate_dma_buffer(
struct snd_pcm *pcm,
int stream)
322 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
334 pr_err(
"Failed to allocate dma memory\n");
335 pr_err(
"Please increase uncached DMA memory region\n");
340 pr_debug(
"%s, area:%p, size:0x%08lx\n", __func__,
352 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
358 pr_err(
"Failed to allocate memory for tx dma buf - Please increase uncached DMA memory region\n");
369 pr_err(
"Failed to allocate memory for rx dma buf - Please increase uncached DMA memory region\n");
380 static void bf5xx_pcm_free_dma_buffers(
struct snd_pcm *pcm)
385 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
388 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
392 for (stream = 0; stream < 2; stream++) {
393 substream = pcm->
streams[stream].substream;
402 #if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
428 if (!card->
dev->dma_mask)
429 card->
dev->dma_mask = &bf5xx_pcm_dmamask;
430 if (!card->
dev->coherent_dma_mask)
434 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
441 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
451 .ops = &bf5xx_pcm_ac97_ops,
452 .pcm_new = bf5xx_pcm_ac97_new,
453 .pcm_free = bf5xx_pcm_free_dma_buffers,
469 .name =
"bfin-ac97-pcm-audio",
473 .probe = bf5xx_soc_platform_probe,