14 #include <linux/module.h>
18 #include <linux/slab.h>
25 static struct txx9aclc_soc_device {
27 } txx9aclc_soc_device;
32 static int txx9aclc_dma_init(
struct txx9aclc_soc_device *
dev,
48 .period_bytes_min = 1024,
49 .period_bytes_max = 8 * 1024,
52 .buffer_bytes_max = 32 * 1024,
68 "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd "
69 "runtime->min_align %ld\n",
74 "periods %d period_bytes %d stream %d\n",
94 dmadata->
buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
95 dmadata->
period_bytes = snd_pcm_lib_period_bytes(substream);
109 static void txx9aclc_dma_complete(
void *
arg)
119 tasklet_schedule(&dmadata->
tasklet);
121 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
135 desc = dmaengine_prep_slave_sg(chan, &
sg, 1,
140 dev_err(&chan->
dev->device,
"cannot prepare slave dma\n");
143 desc->
callback = txx9aclc_dma_complete;
149 #define NR_DMA_CHAIN 2
151 static void txx9aclc_dma_tasklet(
unsigned long data)
167 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
171 desc = txx9aclc_dma_submit(dmadata,
177 chan->
device->device_issue_pending(chan);
181 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
187 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
188 desc = txx9aclc_dma_submit(dmadata,
193 chan->
device->device_issue_pending(chan);
204 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
221 tasklet_schedule(&dmadata->
tasklet);
235 spin_unlock_irqrestore(&dmadata->
dma_lock, flags);
244 return bytes_to_frames(substream->
runtime, dmadata->
pos);
249 struct txx9aclc_soc_device *
dev = &txx9aclc_soc_device;
261 substream->
runtime->private_data = dmadata;
276 .open = txx9aclc_pcm_open,
277 .close = txx9aclc_pcm_close,
279 .hw_params = txx9aclc_pcm_hw_params,
280 .hw_free = txx9aclc_pcm_hw_free,
281 .prepare = txx9aclc_pcm_prepare,
282 .trigger = txx9aclc_pcm_trigger,
283 .pointer = txx9aclc_pcm_pointer,
286 static void txx9aclc_pcm_free_dma_buffers(
struct snd_pcm *pcm)
297 struct txx9aclc_soc_device *
dev;
303 dev = snd_soc_dai_get_drvdata(dai);
307 for (i = 0; i < 2; i++) {
313 dev->dmadata[
i].dma_res =
r;
314 ret = txx9aclc_dma_init(dev, &dev->dmadata[i]);
319 card->
dev, 64 * 1024, 4 * 1024 * 1024);
322 for (i = 0; i < 2; i++) {
323 if (dev->dmadata[i].dma_chan)
325 dev->dmadata[
i].dma_chan =
NULL;
338 if (
strcmp(dev_name(chan->
device->dev), devname) == 0) {
346 static int txx9aclc_dma_init(
struct txx9aclc_soc_device *dev,
370 "DMA channel for %s is not available\n",
372 "playback" :
"capture");
376 (
unsigned long)dmadata);
382 snd_soc_platform_set_drvdata(platform, &txx9aclc_soc_device);
388 struct txx9aclc_soc_device *dev = snd_soc_platform_get_drvdata(platform);
398 for (i = 0; i < 2; i++) {
403 chan->
device->device_control(chan,
407 dev->dmadata[
i].dma_chan =
NULL;
413 .probe = txx9aclc_pcm_probe,
414 .remove = txx9aclc_pcm_remove,
415 .ops = &txx9aclc_pcm_ops,
416 .pcm_new = txx9aclc_pcm_new,
417 .pcm_free = txx9aclc_pcm_free_dma_buffers,
433 .name =
"txx9aclc-pcm-audio",
437 .probe = txx9aclc_soc_platform_probe,
438 .remove =
__devexit_p(txx9aclc_soc_platform_remove),