Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ALSA PCM interface for the TI DAVINCI processor |
| 3 | * |
Vladimir Barinov | d6b5203 | 2008-09-29 23:14:11 +0400 | [diff] [blame] | 4 | * Author: Vladimir Barinov, <vbarinov@embeddedalley.com> |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 5 | * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/slab.h> |
| 16 | #include <linux/dma-mapping.h> |
Alexander Beregalov | 9cd28ab | 2008-12-13 16:25:27 +0300 | [diff] [blame] | 17 | #include <linux/kernel.h> |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 18 | |
| 19 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> |
| 21 | #include <sound/pcm_params.h> |
| 22 | #include <sound/soc.h> |
| 23 | |
| 24 | #include <asm/dma.h> |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 25 | #include <mach/edma.h> |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 26 | |
| 27 | #include "davinci-pcm.h" |
| 28 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 29 | static struct snd_pcm_hardware davinci_pcm_hardware = { |
| 30 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
| 31 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
| 32 | SNDRV_PCM_INFO_PAUSE), |
| 33 | .formats = (SNDRV_PCM_FMTBIT_S16_LE), |
| 34 | .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | |
| 35 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | |
| 36 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | |
| 37 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | |
| 38 | SNDRV_PCM_RATE_KNOT), |
| 39 | .rate_min = 8000, |
| 40 | .rate_max = 96000, |
| 41 | .channels_min = 2, |
| 42 | .channels_max = 2, |
| 43 | .buffer_bytes_max = 128 * 1024, |
| 44 | .period_bytes_min = 32, |
| 45 | .period_bytes_max = 8 * 1024, |
| 46 | .periods_min = 16, |
| 47 | .periods_max = 255, |
| 48 | .fifo_size = 0, |
| 49 | }; |
| 50 | |
| 51 | struct davinci_runtime_data { |
| 52 | spinlock_t lock; |
| 53 | int period; /* current DMA period */ |
| 54 | int master_lch; /* Master DMA channel */ |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 55 | int slave_lch; /* linked parameter RAM reload slot */ |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 56 | struct davinci_pcm_dma_params *params; /* DMA params */ |
| 57 | }; |
| 58 | |
| 59 | static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream) |
| 60 | { |
| 61 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
| 62 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 63 | int lch = prtd->slave_lch; |
| 64 | unsigned int period_size; |
| 65 | unsigned int dma_offset; |
| 66 | dma_addr_t dma_pos; |
| 67 | dma_addr_t src, dst; |
| 68 | unsigned short src_bidx, dst_bidx; |
| 69 | unsigned int data_type; |
Chaithrika U S | 6a99fb5 | 2009-08-11 16:58:52 -0400 | [diff] [blame] | 70 | unsigned short acnt; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 71 | unsigned int count; |
| 72 | |
| 73 | period_size = snd_pcm_lib_period_bytes(substream); |
| 74 | dma_offset = prtd->period * period_size; |
| 75 | dma_pos = runtime->dma_addr + dma_offset; |
| 76 | |
Alexander Beregalov | 9cd28ab | 2008-12-13 16:25:27 +0300 | [diff] [blame] | 77 | pr_debug("davinci_pcm: audio_set_dma_params_play channel = %d " |
| 78 | "dma_ptr = %x period_size=%x\n", lch, dma_pos, period_size); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 79 | |
| 80 | data_type = prtd->params->data_type; |
| 81 | count = period_size / data_type; |
| 82 | |
| 83 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 84 | src = dma_pos; |
| 85 | dst = prtd->params->dma_addr; |
| 86 | src_bidx = data_type; |
| 87 | dst_bidx = 0; |
| 88 | } else { |
| 89 | src = prtd->params->dma_addr; |
| 90 | dst = dma_pos; |
| 91 | src_bidx = 0; |
| 92 | dst_bidx = data_type; |
| 93 | } |
| 94 | |
Chaithrika U S | 6a99fb5 | 2009-08-11 16:58:52 -0400 | [diff] [blame] | 95 | acnt = prtd->params->acnt; |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 96 | edma_set_src(lch, src, INCR, W8BIT); |
| 97 | edma_set_dest(lch, dst, INCR, W8BIT); |
| 98 | edma_set_src_index(lch, src_bidx, 0); |
| 99 | edma_set_dest_index(lch, dst_bidx, 0); |
Chaithrika U S | 6a99fb5 | 2009-08-11 16:58:52 -0400 | [diff] [blame] | 100 | edma_set_transfer_params(lch, acnt, count, 1, 0, ASYNC); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 101 | |
| 102 | prtd->period++; |
| 103 | if (unlikely(prtd->period >= runtime->periods)) |
| 104 | prtd->period = 0; |
| 105 | } |
| 106 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 107 | static void davinci_pcm_dma_irq(unsigned lch, u16 ch_status, void *data) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 108 | { |
| 109 | struct snd_pcm_substream *substream = data; |
| 110 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
| 111 | |
Alexander Beregalov | 9cd28ab | 2008-12-13 16:25:27 +0300 | [diff] [blame] | 112 | pr_debug("davinci_pcm: lch=%d, status=0x%x\n", lch, ch_status); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 113 | |
| 114 | if (unlikely(ch_status != DMA_COMPLETE)) |
| 115 | return; |
| 116 | |
| 117 | if (snd_pcm_running(substream)) { |
| 118 | snd_pcm_period_elapsed(substream); |
| 119 | |
| 120 | spin_lock(&prtd->lock); |
| 121 | davinci_pcm_enqueue_dma(substream); |
| 122 | spin_unlock(&prtd->lock); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) |
| 127 | { |
| 128 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 129 | struct edmacc_param p_ram; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 130 | int ret; |
| 131 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 132 | /* Request master DMA channel */ |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 133 | ret = edma_alloc_channel(prtd->params->channel, |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 134 | davinci_pcm_dma_irq, substream, |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 135 | EVENTQ_0); |
| 136 | if (ret < 0) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 137 | return ret; |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 138 | prtd->master_lch = ret; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 139 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 140 | /* Request parameter RAM reload slot */ |
| 141 | ret = edma_alloc_slot(EDMA_SLOT_ANY); |
| 142 | if (ret < 0) { |
| 143 | edma_free_channel(prtd->master_lch); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 144 | return ret; |
| 145 | } |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 146 | prtd->slave_lch = ret; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 147 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 148 | /* Issue transfer completion IRQ when the channel completes a |
| 149 | * transfer, then always reload from the same slot (by a kind |
| 150 | * of loopback link). The completion IRQ handler will update |
| 151 | * the reload slot with a new buffer. |
| 152 | * |
| 153 | * REVISIT save p_ram here after setting up everything except |
| 154 | * the buffer and its length (ccnt) ... use it as a template |
| 155 | * so davinci_pcm_enqueue_dma() takes less time in IRQ. |
| 156 | */ |
| 157 | edma_read_slot(prtd->slave_lch, &p_ram); |
| 158 | p_ram.opt |= TCINTEN | EDMA_TCC(prtd->master_lch); |
| 159 | p_ram.link_bcntrld = prtd->slave_lch << 5; |
| 160 | edma_write_slot(prtd->slave_lch, &p_ram); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
| 166 | { |
| 167 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
| 168 | int ret = 0; |
| 169 | |
| 170 | spin_lock(&prtd->lock); |
| 171 | |
| 172 | switch (cmd) { |
| 173 | case SNDRV_PCM_TRIGGER_START: |
| 174 | case SNDRV_PCM_TRIGGER_RESUME: |
| 175 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 176 | edma_start(prtd->master_lch); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 177 | break; |
| 178 | case SNDRV_PCM_TRIGGER_STOP: |
| 179 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 180 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 181 | edma_stop(prtd->master_lch); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 182 | break; |
| 183 | default: |
| 184 | ret = -EINVAL; |
| 185 | break; |
| 186 | } |
| 187 | |
| 188 | spin_unlock(&prtd->lock); |
| 189 | |
| 190 | return ret; |
| 191 | } |
| 192 | |
| 193 | static int davinci_pcm_prepare(struct snd_pcm_substream *substream) |
| 194 | { |
| 195 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 196 | struct edmacc_param temp; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 197 | |
| 198 | prtd->period = 0; |
| 199 | davinci_pcm_enqueue_dma(substream); |
| 200 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 201 | /* Copy self-linked parameter RAM entry into master channel */ |
| 202 | edma_read_slot(prtd->slave_lch, &temp); |
| 203 | edma_write_slot(prtd->master_lch, &temp); |
Troy Kisky | 6e54147 | 2009-07-07 17:36:06 -0700 | [diff] [blame] | 204 | davinci_pcm_enqueue_dma(substream); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static snd_pcm_uframes_t |
| 210 | davinci_pcm_pointer(struct snd_pcm_substream *substream) |
| 211 | { |
| 212 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 213 | struct davinci_runtime_data *prtd = runtime->private_data; |
| 214 | unsigned int offset; |
| 215 | dma_addr_t count; |
| 216 | dma_addr_t src, dst; |
| 217 | |
| 218 | spin_lock(&prtd->lock); |
| 219 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 220 | edma_get_position(prtd->master_lch, &src, &dst); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 221 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 222 | count = src - runtime->dma_addr; |
| 223 | else |
Fernando Carrijo | c19a28e | 2009-01-07 18:09:08 -0800 | [diff] [blame] | 224 | count = dst - runtime->dma_addr; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 225 | |
| 226 | spin_unlock(&prtd->lock); |
| 227 | |
| 228 | offset = bytes_to_frames(runtime, count); |
| 229 | if (offset >= runtime->buffer_size) |
| 230 | offset = 0; |
| 231 | |
| 232 | return offset; |
| 233 | } |
| 234 | |
| 235 | static int davinci_pcm_open(struct snd_pcm_substream *substream) |
| 236 | { |
| 237 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 238 | struct davinci_runtime_data *prtd; |
| 239 | int ret = 0; |
Troy Kisky | 81ac55a | 2009-09-11 14:29:02 -0700 | [diff] [blame] | 240 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Troy Kisky | 92e2a6f | 2009-09-11 14:29:03 -0700 | [diff] [blame] | 241 | struct davinci_pcm_dma_params *pa = rtd->dai->cpu_dai->private_data; |
| 242 | struct davinci_pcm_dma_params *params = &pa[substream->stream]; |
Troy Kisky | 81ac55a | 2009-09-11 14:29:02 -0700 | [diff] [blame] | 243 | if (!params) |
| 244 | return -ENODEV; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 245 | |
| 246 | snd_soc_set_runtime_hwparams(substream, &davinci_pcm_hardware); |
Troy Kisky | 6a90d53 | 2009-08-06 16:55:32 -0700 | [diff] [blame] | 247 | /* ensure that buffer size is a multiple of period size */ |
| 248 | ret = snd_pcm_hw_constraint_integer(runtime, |
| 249 | SNDRV_PCM_HW_PARAM_PERIODS); |
| 250 | if (ret < 0) |
| 251 | return ret; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 252 | |
| 253 | prtd = kzalloc(sizeof(struct davinci_runtime_data), GFP_KERNEL); |
| 254 | if (prtd == NULL) |
| 255 | return -ENOMEM; |
| 256 | |
| 257 | spin_lock_init(&prtd->lock); |
Troy Kisky | 81ac55a | 2009-09-11 14:29:02 -0700 | [diff] [blame] | 258 | prtd->params = params; |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 259 | |
| 260 | runtime->private_data = prtd; |
| 261 | |
| 262 | ret = davinci_pcm_dma_request(substream); |
| 263 | if (ret) { |
| 264 | printk(KERN_ERR "davinci_pcm: Failed to get dma channels\n"); |
| 265 | kfree(prtd); |
| 266 | } |
| 267 | |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | static int davinci_pcm_close(struct snd_pcm_substream *substream) |
| 272 | { |
| 273 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 274 | struct davinci_runtime_data *prtd = runtime->private_data; |
| 275 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 276 | edma_unlink(prtd->slave_lch); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 277 | |
David Brownell | 82075af | 2009-05-14 12:41:22 -0700 | [diff] [blame] | 278 | edma_free_slot(prtd->slave_lch); |
| 279 | edma_free_channel(prtd->master_lch); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 280 | |
| 281 | kfree(prtd); |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | static int davinci_pcm_hw_params(struct snd_pcm_substream *substream, |
| 287 | struct snd_pcm_hw_params *hw_params) |
| 288 | { |
| 289 | return snd_pcm_lib_malloc_pages(substream, |
| 290 | params_buffer_bytes(hw_params)); |
| 291 | } |
| 292 | |
| 293 | static int davinci_pcm_hw_free(struct snd_pcm_substream *substream) |
| 294 | { |
| 295 | return snd_pcm_lib_free_pages(substream); |
| 296 | } |
| 297 | |
| 298 | static int davinci_pcm_mmap(struct snd_pcm_substream *substream, |
| 299 | struct vm_area_struct *vma) |
| 300 | { |
| 301 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 302 | |
| 303 | return dma_mmap_writecombine(substream->pcm->card->dev, vma, |
| 304 | runtime->dma_area, |
| 305 | runtime->dma_addr, |
| 306 | runtime->dma_bytes); |
| 307 | } |
| 308 | |
Mark Brown | b2a19d0 | 2009-01-17 19:14:26 +0000 | [diff] [blame] | 309 | static struct snd_pcm_ops davinci_pcm_ops = { |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 310 | .open = davinci_pcm_open, |
| 311 | .close = davinci_pcm_close, |
| 312 | .ioctl = snd_pcm_lib_ioctl, |
| 313 | .hw_params = davinci_pcm_hw_params, |
| 314 | .hw_free = davinci_pcm_hw_free, |
| 315 | .prepare = davinci_pcm_prepare, |
| 316 | .trigger = davinci_pcm_trigger, |
| 317 | .pointer = davinci_pcm_pointer, |
| 318 | .mmap = davinci_pcm_mmap, |
| 319 | }; |
| 320 | |
| 321 | static int davinci_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) |
| 322 | { |
| 323 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; |
| 324 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
| 325 | size_t size = davinci_pcm_hardware.buffer_bytes_max; |
| 326 | |
| 327 | buf->dev.type = SNDRV_DMA_TYPE_DEV; |
| 328 | buf->dev.dev = pcm->card->dev; |
| 329 | buf->private_data = NULL; |
| 330 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, |
| 331 | &buf->addr, GFP_KERNEL); |
| 332 | |
Alexander Beregalov | 9cd28ab | 2008-12-13 16:25:27 +0300 | [diff] [blame] | 333 | pr_debug("davinci_pcm: preallocate_dma_buffer: area=%p, addr=%p, " |
| 334 | "size=%d\n", (void *) buf->area, (void *) buf->addr, size); |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 335 | |
| 336 | if (!buf->area) |
| 337 | return -ENOMEM; |
| 338 | |
| 339 | buf->bytes = size; |
| 340 | return 0; |
| 341 | } |
| 342 | |
| 343 | static void davinci_pcm_free(struct snd_pcm *pcm) |
| 344 | { |
| 345 | struct snd_pcm_substream *substream; |
| 346 | struct snd_dma_buffer *buf; |
| 347 | int stream; |
| 348 | |
| 349 | for (stream = 0; stream < 2; stream++) { |
| 350 | substream = pcm->streams[stream].substream; |
| 351 | if (!substream) |
| 352 | continue; |
| 353 | |
| 354 | buf = &substream->dma_buffer; |
| 355 | if (!buf->area) |
| 356 | continue; |
| 357 | |
| 358 | dma_free_writecombine(pcm->card->dev, buf->bytes, |
| 359 | buf->area, buf->addr); |
| 360 | buf->area = NULL; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | static u64 davinci_pcm_dmamask = 0xffffffff; |
| 365 | |
| 366 | static int davinci_pcm_new(struct snd_card *card, |
Liam Girdwood | 9cb132d | 2008-07-07 16:07:42 +0100 | [diff] [blame] | 367 | struct snd_soc_dai *dai, struct snd_pcm *pcm) |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 368 | { |
| 369 | int ret; |
| 370 | |
| 371 | if (!card->dev->dma_mask) |
| 372 | card->dev->dma_mask = &davinci_pcm_dmamask; |
| 373 | if (!card->dev->coherent_dma_mask) |
| 374 | card->dev->coherent_dma_mask = 0xffffffff; |
| 375 | |
| 376 | if (dai->playback.channels_min) { |
| 377 | ret = davinci_pcm_preallocate_dma_buffer(pcm, |
| 378 | SNDRV_PCM_STREAM_PLAYBACK); |
| 379 | if (ret) |
| 380 | return ret; |
| 381 | } |
| 382 | |
| 383 | if (dai->capture.channels_min) { |
| 384 | ret = davinci_pcm_preallocate_dma_buffer(pcm, |
| 385 | SNDRV_PCM_STREAM_CAPTURE); |
| 386 | if (ret) |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | struct snd_soc_platform davinci_soc_platform = { |
| 394 | .name = "davinci-audio", |
| 395 | .pcm_ops = &davinci_pcm_ops, |
| 396 | .pcm_new = davinci_pcm_new, |
| 397 | .pcm_free = davinci_pcm_free, |
| 398 | }; |
| 399 | EXPORT_SYMBOL_GPL(davinci_soc_platform); |
| 400 | |
Takashi Iwai | c9b3a40 | 2008-12-10 07:47:22 +0100 | [diff] [blame] | 401 | static int __init davinci_soc_platform_init(void) |
Mark Brown | 958e792 | 2008-12-03 19:58:17 +0000 | [diff] [blame] | 402 | { |
| 403 | return snd_soc_register_platform(&davinci_soc_platform); |
| 404 | } |
| 405 | module_init(davinci_soc_platform_init); |
| 406 | |
| 407 | static void __exit davinci_soc_platform_exit(void) |
| 408 | { |
| 409 | snd_soc_unregister_platform(&davinci_soc_platform); |
| 410 | } |
| 411 | module_exit(davinci_soc_platform_exit); |
| 412 | |
Vladimir Barinov | 310355c | 2008-02-18 11:40:22 +0100 | [diff] [blame] | 413 | MODULE_AUTHOR("Vladimir Barinov"); |
| 414 | MODULE_DESCRIPTION("TI DAVINCI PCM DMA module"); |
| 415 | MODULE_LICENSE("GPL"); |