16 #include <linux/module.h>
19 #include <linux/slab.h>
35 #define MSG(x...) printk(KERN_INFO "au1xpsc_pcm: " x)
39 #define DBG(x...) do {} while (0)
65 #define AU1XPSC_PERIOD_MIN_BYTES 1024
66 #define AU1XPSC_BUFFER_MIN_BYTES 65536
68 #define AU1XPSC_PCM_FMTS \
69 (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \
70 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
71 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE | \
72 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | \
73 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE | \
82 .period_bytes_max = 4096 * 1024 - 1,
85 .buffer_bytes_max = 4096 * 1024 - 1,
117 static void au1x_pcm_dmatx_cb(
int irq,
void *
dev_id)
127 au1x_pcm_queue_tx(cd);
130 static void au1x_pcm_dmarx_cb(
int irq,
void *dev_id)
140 au1x_pcm_queue_rx(cd);
170 au1x_pcm_dbdma_free(pcd);
175 au1x_pcm_dmarx_cb, (
void *)pcd);
179 au1x_pcm_dmatx_cb, (
void *)pcd);
200 snd_soc_platform_get_drvdata(rtd->
platform);
215 stype = substream->
stream;
216 pcd = to_dmadata(substream);
218 DBG(
"runtime->dma_area = 0x%08lx dma_addr_t = 0x%08lx dma_size = %d "
219 "runtime->min_align %d\n",
224 DBG(
"bits %d frags %d frag_bytes %d is_rx %d\n", params->
msbits,
227 ret = au1x_pcm_dbdma_realloc(pcd, stype, params->
msbits);
229 MSG(
"DDMA channel (re)alloc failed!\n");
259 au1x_pcm_queue_rx(pcd);
260 au1x_pcm_queue_rx(pcd);
262 au1x_pcm_queue_tx(pcd);
263 au1x_pcm_queue_tx(pcd);
271 u32 c = to_dmadata(substream)->ddma_chan;
291 return bytes_to_frames(substream->
runtime, to_dmadata(substream)->
pos);
298 int stype = substream->
stream, *dmaids;
300 dmaids = snd_soc_dai_get_dma_data(rtd->
cpu_dai, substream);
312 au1x_pcm_dbdma_free(to_dmadata(substream));
317 .open = au1xpsc_pcm_open,
318 .close = au1xpsc_pcm_close,
320 .hw_params = au1xpsc_pcm_hw_params,
321 .hw_free = au1xpsc_pcm_hw_free,
322 .prepare = au1xpsc_pcm_prepare,
323 .trigger = au1xpsc_pcm_trigger,
324 .pointer = au1xpsc_pcm_pointer,
327 static void au1xpsc_pcm_free_dma_buffers(
struct snd_pcm *pcm)
345 .ops = &au1xpsc_pcm_ops,
346 .pcm_new = au1xpsc_pcm_new,
347 .pcm_free = au1xpsc_pcm_free_dma_buffers,
360 platform_set_drvdata(pdev, dmadata);
374 .name =
"au1xpsc-pcm",
377 .probe = au1xpsc_pcm_drvprobe,