1f11a96d5SLiam Girdwood /* 2f11a96d5SLiam Girdwood * linux/sound/arm/pxa2xx-pcm.c -- ALSA PCM interface for the Intel PXA2xx chip 3f11a96d5SLiam Girdwood * 4f11a96d5SLiam Girdwood * Author: Nicolas Pitre 5f11a96d5SLiam Girdwood * Created: Nov 30, 2004 6f11a96d5SLiam Girdwood * Copyright: (C) 2004 MontaVista Software, Inc. 7f11a96d5SLiam Girdwood * 8f11a96d5SLiam Girdwood * This program is free software; you can redistribute it and/or modify 9f11a96d5SLiam Girdwood * it under the terms of the GNU General Public License version 2 as 10f11a96d5SLiam Girdwood * published by the Free Software Foundation. 11f11a96d5SLiam Girdwood */ 12f11a96d5SLiam Girdwood 13f11a96d5SLiam Girdwood #include <linux/module.h> 14f11a96d5SLiam Girdwood #include <linux/init.h> 15f11a96d5SLiam Girdwood #include <linux/platform_device.h> 16f11a96d5SLiam Girdwood #include <linux/slab.h> 17f11a96d5SLiam Girdwood #include <linux/dma-mapping.h> 18f11a96d5SLiam Girdwood 19f11a96d5SLiam Girdwood #include <sound/driver.h> 20f11a96d5SLiam Girdwood #include <sound/core.h> 21f11a96d5SLiam Girdwood #include <sound/pcm.h> 22f11a96d5SLiam Girdwood #include <sound/pcm_params.h> 23f11a96d5SLiam Girdwood #include <sound/soc.h> 24f11a96d5SLiam Girdwood 25f11a96d5SLiam Girdwood #include <asm/dma.h> 26f11a96d5SLiam Girdwood #include <asm/hardware.h> 27f11a96d5SLiam Girdwood #include <asm/arch/pxa-regs.h> 28f11a96d5SLiam Girdwood #include <asm/arch/audio.h> 29f11a96d5SLiam Girdwood 30f11a96d5SLiam Girdwood #include "pxa2xx-pcm.h" 31f11a96d5SLiam Girdwood 32f11a96d5SLiam Girdwood static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { 33f11a96d5SLiam Girdwood .info = SNDRV_PCM_INFO_MMAP | 34f11a96d5SLiam Girdwood SNDRV_PCM_INFO_MMAP_VALID | 35f11a96d5SLiam Girdwood SNDRV_PCM_INFO_INTERLEAVED | 36f11a96d5SLiam Girdwood SNDRV_PCM_INFO_PAUSE | 37f11a96d5SLiam Girdwood SNDRV_PCM_INFO_RESUME, 38f11a96d5SLiam Girdwood .formats = SNDRV_PCM_FMTBIT_S16_LE | 39f11a96d5SLiam Girdwood SNDRV_PCM_FMTBIT_S24_LE | 40f11a96d5SLiam Girdwood SNDRV_PCM_FMTBIT_S32_LE, 41f11a96d5SLiam Girdwood .period_bytes_min = 32, 42f11a96d5SLiam Girdwood .period_bytes_max = 8192 - 32, 43f11a96d5SLiam Girdwood .periods_min = 1, 44f11a96d5SLiam Girdwood .periods_max = PAGE_SIZE/sizeof(pxa_dma_desc), 45f11a96d5SLiam Girdwood .buffer_bytes_max = 128 * 1024, 46f11a96d5SLiam Girdwood .fifo_size = 32, 47f11a96d5SLiam Girdwood }; 48f11a96d5SLiam Girdwood 49f11a96d5SLiam Girdwood struct pxa2xx_runtime_data { 50f11a96d5SLiam Girdwood int dma_ch; 51f11a96d5SLiam Girdwood struct pxa2xx_pcm_dma_params *params; 52f11a96d5SLiam Girdwood pxa_dma_desc *dma_desc_array; 53f11a96d5SLiam Girdwood dma_addr_t dma_desc_array_phys; 54f11a96d5SLiam Girdwood }; 55f11a96d5SLiam Girdwood 56f11a96d5SLiam Girdwood static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id) 57f11a96d5SLiam Girdwood { 58f11a96d5SLiam Girdwood struct snd_pcm_substream *substream = dev_id; 59f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; 60f11a96d5SLiam Girdwood int dcsr; 61f11a96d5SLiam Girdwood 62f11a96d5SLiam Girdwood dcsr = DCSR(dma_ch); 63f11a96d5SLiam Girdwood DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN; 64f11a96d5SLiam Girdwood 65f11a96d5SLiam Girdwood if (dcsr & DCSR_ENDINTR) { 66f11a96d5SLiam Girdwood snd_pcm_period_elapsed(substream); 67f11a96d5SLiam Girdwood } else { 68f11a96d5SLiam Girdwood printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n", 69f11a96d5SLiam Girdwood prtd->params->name, dma_ch, dcsr ); 70f11a96d5SLiam Girdwood } 71f11a96d5SLiam Girdwood } 72f11a96d5SLiam Girdwood 73f11a96d5SLiam Girdwood static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, 74f11a96d5SLiam Girdwood struct snd_pcm_hw_params *params) 75f11a96d5SLiam Girdwood { 76f11a96d5SLiam Girdwood struct snd_pcm_runtime *runtime = substream->runtime; 77f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = runtime->private_data; 78f11a96d5SLiam Girdwood struct snd_soc_pcm_runtime *rtd = substream->private_data; 79f11a96d5SLiam Girdwood struct pxa2xx_pcm_dma_params *dma = rtd->cpu_dai->dma_data; 80f11a96d5SLiam Girdwood size_t totsize = params_buffer_bytes(params); 81f11a96d5SLiam Girdwood size_t period = params_period_bytes(params); 82f11a96d5SLiam Girdwood pxa_dma_desc *dma_desc; 83f11a96d5SLiam Girdwood dma_addr_t dma_buff_phys, next_desc_phys; 84f11a96d5SLiam Girdwood int ret; 85f11a96d5SLiam Girdwood 86f11a96d5SLiam Girdwood /* this may get called several times by oss emulation 87f11a96d5SLiam Girdwood * with different params */ 88f11a96d5SLiam Girdwood if (prtd->params == NULL) { 89f11a96d5SLiam Girdwood prtd->params = dma; 90f11a96d5SLiam Girdwood ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW, 91f11a96d5SLiam Girdwood pxa2xx_pcm_dma_irq, substream); 92f11a96d5SLiam Girdwood if (ret < 0) 93f11a96d5SLiam Girdwood return ret; 94f11a96d5SLiam Girdwood prtd->dma_ch = ret; 95f11a96d5SLiam Girdwood } else if (prtd->params != dma) { 96f11a96d5SLiam Girdwood pxa_free_dma(prtd->dma_ch); 97f11a96d5SLiam Girdwood prtd->params = dma; 98f11a96d5SLiam Girdwood ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW, 99f11a96d5SLiam Girdwood pxa2xx_pcm_dma_irq, substream); 100f11a96d5SLiam Girdwood if (ret < 0) 101f11a96d5SLiam Girdwood return ret; 102f11a96d5SLiam Girdwood prtd->dma_ch = ret; 103f11a96d5SLiam Girdwood } 104f11a96d5SLiam Girdwood 105f11a96d5SLiam Girdwood snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 106f11a96d5SLiam Girdwood runtime->dma_bytes = totsize; 107f11a96d5SLiam Girdwood 108f11a96d5SLiam Girdwood dma_desc = prtd->dma_desc_array; 109f11a96d5SLiam Girdwood next_desc_phys = prtd->dma_desc_array_phys; 110f11a96d5SLiam Girdwood dma_buff_phys = runtime->dma_addr; 111f11a96d5SLiam Girdwood do { 112f11a96d5SLiam Girdwood next_desc_phys += sizeof(pxa_dma_desc); 113f11a96d5SLiam Girdwood dma_desc->ddadr = next_desc_phys; 114f11a96d5SLiam Girdwood if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 115f11a96d5SLiam Girdwood dma_desc->dsadr = dma_buff_phys; 116f11a96d5SLiam Girdwood dma_desc->dtadr = prtd->params->dev_addr; 117f11a96d5SLiam Girdwood } else { 118f11a96d5SLiam Girdwood dma_desc->dsadr = prtd->params->dev_addr; 119f11a96d5SLiam Girdwood dma_desc->dtadr = dma_buff_phys; 120f11a96d5SLiam Girdwood } 121f11a96d5SLiam Girdwood if (period > totsize) 122f11a96d5SLiam Girdwood period = totsize; 123f11a96d5SLiam Girdwood dma_desc->dcmd = prtd->params->dcmd | period | DCMD_ENDIRQEN; 124f11a96d5SLiam Girdwood dma_desc++; 125f11a96d5SLiam Girdwood dma_buff_phys += period; 126f11a96d5SLiam Girdwood } while (totsize -= period); 127f11a96d5SLiam Girdwood dma_desc[-1].ddadr = prtd->dma_desc_array_phys; 128f11a96d5SLiam Girdwood 129f11a96d5SLiam Girdwood return 0; 130f11a96d5SLiam Girdwood } 131f11a96d5SLiam Girdwood 132f11a96d5SLiam Girdwood static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) 133f11a96d5SLiam Girdwood { 134f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; 135f11a96d5SLiam Girdwood 136f11a96d5SLiam Girdwood if (prtd && prtd->params) 137f11a96d5SLiam Girdwood *prtd->params->drcmr = 0; 138f11a96d5SLiam Girdwood 139f11a96d5SLiam Girdwood if (prtd->dma_ch) { 140f11a96d5SLiam Girdwood snd_pcm_set_runtime_buffer(substream, NULL); 141f11a96d5SLiam Girdwood pxa_free_dma(prtd->dma_ch); 142f11a96d5SLiam Girdwood prtd->dma_ch = 0; 143f11a96d5SLiam Girdwood } 144f11a96d5SLiam Girdwood 145f11a96d5SLiam Girdwood return 0; 146f11a96d5SLiam Girdwood } 147f11a96d5SLiam Girdwood 148f11a96d5SLiam Girdwood static int pxa2xx_pcm_prepare(struct snd_pcm_substream *substream) 149f11a96d5SLiam Girdwood { 150f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; 151f11a96d5SLiam Girdwood 152f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) &= ~DCSR_RUN; 153f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) = 0; 154f11a96d5SLiam Girdwood DCMD(prtd->dma_ch) = 0; 155f11a96d5SLiam Girdwood *prtd->params->drcmr = prtd->dma_ch | DRCMR_MAPVLD; 156f11a96d5SLiam Girdwood 157f11a96d5SLiam Girdwood return 0; 158f11a96d5SLiam Girdwood } 159f11a96d5SLiam Girdwood 160f11a96d5SLiam Girdwood static int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 161f11a96d5SLiam Girdwood { 162f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; 163f11a96d5SLiam Girdwood int ret = 0; 164f11a96d5SLiam Girdwood 165f11a96d5SLiam Girdwood switch (cmd) { 166f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_START: 167f11a96d5SLiam Girdwood DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; 168f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) = DCSR_RUN; 169f11a96d5SLiam Girdwood break; 170f11a96d5SLiam Girdwood 171f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_STOP: 172f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_SUSPEND: 173f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 174f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) &= ~DCSR_RUN; 175f11a96d5SLiam Girdwood break; 176f11a96d5SLiam Girdwood 177f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_RESUME: 178f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) |= DCSR_RUN; 179f11a96d5SLiam Girdwood break; 180f11a96d5SLiam Girdwood case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 181f11a96d5SLiam Girdwood DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; 182f11a96d5SLiam Girdwood DCSR(prtd->dma_ch) |= DCSR_RUN; 183f11a96d5SLiam Girdwood break; 184f11a96d5SLiam Girdwood 185f11a96d5SLiam Girdwood default: 186f11a96d5SLiam Girdwood ret = -EINVAL; 187f11a96d5SLiam Girdwood } 188f11a96d5SLiam Girdwood 189f11a96d5SLiam Girdwood return ret; 190f11a96d5SLiam Girdwood } 191f11a96d5SLiam Girdwood 192f11a96d5SLiam Girdwood static snd_pcm_uframes_t 193f11a96d5SLiam Girdwood pxa2xx_pcm_pointer(struct snd_pcm_substream *substream) 194f11a96d5SLiam Girdwood { 195f11a96d5SLiam Girdwood struct snd_pcm_runtime *runtime = substream->runtime; 196f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = runtime->private_data; 197f11a96d5SLiam Girdwood 198f11a96d5SLiam Girdwood dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 199f11a96d5SLiam Girdwood DSADR(prtd->dma_ch) : DTADR(prtd->dma_ch); 200f11a96d5SLiam Girdwood snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr); 201f11a96d5SLiam Girdwood 202f11a96d5SLiam Girdwood if (x == runtime->buffer_size) 203f11a96d5SLiam Girdwood x = 0; 204f11a96d5SLiam Girdwood return x; 205f11a96d5SLiam Girdwood } 206f11a96d5SLiam Girdwood 207f11a96d5SLiam Girdwood static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) 208f11a96d5SLiam Girdwood { 209f11a96d5SLiam Girdwood struct snd_pcm_runtime *runtime = substream->runtime; 210f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd; 211f11a96d5SLiam Girdwood int ret; 212f11a96d5SLiam Girdwood 213f11a96d5SLiam Girdwood snd_soc_set_runtime_hwparams(substream, &pxa2xx_pcm_hardware); 214f11a96d5SLiam Girdwood 215f11a96d5SLiam Girdwood /* 216f11a96d5SLiam Girdwood * For mysterious reasons (and despite what the manual says) 217f11a96d5SLiam Girdwood * playback samples are lost if the DMA count is not a multiple 218f11a96d5SLiam Girdwood * of the DMA burst size. Let's add a rule to enforce that. 219f11a96d5SLiam Girdwood */ 220f11a96d5SLiam Girdwood ret = snd_pcm_hw_constraint_step(runtime, 0, 221f11a96d5SLiam Girdwood SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); 222f11a96d5SLiam Girdwood if (ret) 223f11a96d5SLiam Girdwood goto out; 224f11a96d5SLiam Girdwood 225f11a96d5SLiam Girdwood ret = snd_pcm_hw_constraint_step(runtime, 0, 226f11a96d5SLiam Girdwood SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); 227f11a96d5SLiam Girdwood if (ret) 228f11a96d5SLiam Girdwood goto out; 229f11a96d5SLiam Girdwood 230f11a96d5SLiam Girdwood prtd = kzalloc(sizeof(struct pxa2xx_runtime_data), GFP_KERNEL); 231f11a96d5SLiam Girdwood if (prtd == NULL) { 232f11a96d5SLiam Girdwood ret = -ENOMEM; 233f11a96d5SLiam Girdwood goto out; 234f11a96d5SLiam Girdwood } 235f11a96d5SLiam Girdwood 236f11a96d5SLiam Girdwood prtd->dma_desc_array = 237f11a96d5SLiam Girdwood dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE, 238f11a96d5SLiam Girdwood &prtd->dma_desc_array_phys, GFP_KERNEL); 239f11a96d5SLiam Girdwood if (!prtd->dma_desc_array) { 240f11a96d5SLiam Girdwood ret = -ENOMEM; 241f11a96d5SLiam Girdwood goto err1; 242f11a96d5SLiam Girdwood } 243f11a96d5SLiam Girdwood 244f11a96d5SLiam Girdwood runtime->private_data = prtd; 245f11a96d5SLiam Girdwood return 0; 246f11a96d5SLiam Girdwood 247f11a96d5SLiam Girdwood err1: 248f11a96d5SLiam Girdwood kfree(prtd); 249f11a96d5SLiam Girdwood out: 250f11a96d5SLiam Girdwood return ret; 251f11a96d5SLiam Girdwood } 252f11a96d5SLiam Girdwood 253f11a96d5SLiam Girdwood static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) 254f11a96d5SLiam Girdwood { 255f11a96d5SLiam Girdwood struct snd_pcm_runtime *runtime = substream->runtime; 256f11a96d5SLiam Girdwood struct pxa2xx_runtime_data *prtd = runtime->private_data; 257f11a96d5SLiam Girdwood 258f11a96d5SLiam Girdwood dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE, 259f11a96d5SLiam Girdwood prtd->dma_desc_array, prtd->dma_desc_array_phys); 260f11a96d5SLiam Girdwood kfree(prtd); 261f11a96d5SLiam Girdwood return 0; 262f11a96d5SLiam Girdwood } 263f11a96d5SLiam Girdwood 264f11a96d5SLiam Girdwood static int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, 265f11a96d5SLiam Girdwood struct vm_area_struct *vma) 266f11a96d5SLiam Girdwood { 267f11a96d5SLiam Girdwood struct snd_pcm_runtime *runtime = substream->runtime; 268f11a96d5SLiam Girdwood return dma_mmap_writecombine(substream->pcm->card->dev, vma, 269f11a96d5SLiam Girdwood runtime->dma_area, 270f11a96d5SLiam Girdwood runtime->dma_addr, 271f11a96d5SLiam Girdwood runtime->dma_bytes); 272f11a96d5SLiam Girdwood } 273f11a96d5SLiam Girdwood 274f11a96d5SLiam Girdwood struct snd_pcm_ops pxa2xx_pcm_ops = { 275f11a96d5SLiam Girdwood .open = pxa2xx_pcm_open, 276f11a96d5SLiam Girdwood .close = pxa2xx_pcm_close, 277f11a96d5SLiam Girdwood .ioctl = snd_pcm_lib_ioctl, 278f11a96d5SLiam Girdwood .hw_params = pxa2xx_pcm_hw_params, 279f11a96d5SLiam Girdwood .hw_free = pxa2xx_pcm_hw_free, 280f11a96d5SLiam Girdwood .prepare = pxa2xx_pcm_prepare, 281f11a96d5SLiam Girdwood .trigger = pxa2xx_pcm_trigger, 282f11a96d5SLiam Girdwood .pointer = pxa2xx_pcm_pointer, 283f11a96d5SLiam Girdwood .mmap = pxa2xx_pcm_mmap, 284f11a96d5SLiam Girdwood }; 285f11a96d5SLiam Girdwood 286f11a96d5SLiam Girdwood static int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) 287f11a96d5SLiam Girdwood { 288f11a96d5SLiam Girdwood struct snd_pcm_substream *substream = pcm->streams[stream].substream; 289f11a96d5SLiam Girdwood struct snd_dma_buffer *buf = &substream->dma_buffer; 290f11a96d5SLiam Girdwood size_t size = pxa2xx_pcm_hardware.buffer_bytes_max; 291f11a96d5SLiam Girdwood buf->dev.type = SNDRV_DMA_TYPE_DEV; 292f11a96d5SLiam Girdwood buf->dev.dev = pcm->card->dev; 293f11a96d5SLiam Girdwood buf->private_data = NULL; 294f11a96d5SLiam Girdwood buf->area = dma_alloc_writecombine(pcm->card->dev, size, 295f11a96d5SLiam Girdwood &buf->addr, GFP_KERNEL); 296f11a96d5SLiam Girdwood if (!buf->area) 297f11a96d5SLiam Girdwood return -ENOMEM; 298f11a96d5SLiam Girdwood buf->bytes = size; 299f11a96d5SLiam Girdwood return 0; 300f11a96d5SLiam Girdwood } 301f11a96d5SLiam Girdwood 302f11a96d5SLiam Girdwood static void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm) 303f11a96d5SLiam Girdwood { 304f11a96d5SLiam Girdwood struct snd_pcm_substream *substream; 305f11a96d5SLiam Girdwood struct snd_dma_buffer *buf; 306f11a96d5SLiam Girdwood int stream; 307f11a96d5SLiam Girdwood 308f11a96d5SLiam Girdwood for (stream = 0; stream < 2; stream++) { 309f11a96d5SLiam Girdwood substream = pcm->streams[stream].substream; 310f11a96d5SLiam Girdwood if (!substream) 311f11a96d5SLiam Girdwood continue; 312f11a96d5SLiam Girdwood 313f11a96d5SLiam Girdwood buf = &substream->dma_buffer; 314f11a96d5SLiam Girdwood if (!buf->area) 315f11a96d5SLiam Girdwood continue; 316f11a96d5SLiam Girdwood 317f11a96d5SLiam Girdwood dma_free_writecombine(pcm->card->dev, buf->bytes, 318f11a96d5SLiam Girdwood buf->area, buf->addr); 319f11a96d5SLiam Girdwood buf->area = NULL; 320f11a96d5SLiam Girdwood } 321f11a96d5SLiam Girdwood } 322f11a96d5SLiam Girdwood 323f11a96d5SLiam Girdwood static u64 pxa2xx_pcm_dmamask = DMA_32BIT_MASK; 324f11a96d5SLiam Girdwood 325f11a96d5SLiam Girdwood int pxa2xx_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai, 326f11a96d5SLiam Girdwood struct snd_pcm *pcm) 327f11a96d5SLiam Girdwood { 328f11a96d5SLiam Girdwood int ret = 0; 329f11a96d5SLiam Girdwood 330f11a96d5SLiam Girdwood if (!card->dev->dma_mask) 331f11a96d5SLiam Girdwood card->dev->dma_mask = &pxa2xx_pcm_dmamask; 332f11a96d5SLiam Girdwood if (!card->dev->coherent_dma_mask) 333f11a96d5SLiam Girdwood card->dev->coherent_dma_mask = DMA_32BIT_MASK; 334f11a96d5SLiam Girdwood 335f11a96d5SLiam Girdwood if (dai->playback.channels_min) { 336f11a96d5SLiam Girdwood ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 337f11a96d5SLiam Girdwood SNDRV_PCM_STREAM_PLAYBACK); 338f11a96d5SLiam Girdwood if (ret) 339f11a96d5SLiam Girdwood goto out; 340f11a96d5SLiam Girdwood } 341f11a96d5SLiam Girdwood 342f11a96d5SLiam Girdwood if (dai->capture.channels_min) { 343f11a96d5SLiam Girdwood ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 344f11a96d5SLiam Girdwood SNDRV_PCM_STREAM_CAPTURE); 345f11a96d5SLiam Girdwood if (ret) 346f11a96d5SLiam Girdwood goto out; 347f11a96d5SLiam Girdwood } 348f11a96d5SLiam Girdwood out: 349f11a96d5SLiam Girdwood return ret; 350f11a96d5SLiam Girdwood } 351f11a96d5SLiam Girdwood 352f11a96d5SLiam Girdwood struct snd_soc_platform pxa2xx_soc_platform = { 353f11a96d5SLiam Girdwood .name = "pxa2xx-audio", 354f11a96d5SLiam Girdwood .pcm_ops = &pxa2xx_pcm_ops, 355f11a96d5SLiam Girdwood .pcm_new = pxa2xx_pcm_new, 356f11a96d5SLiam Girdwood .pcm_free = pxa2xx_pcm_free_dma_buffers, 357f11a96d5SLiam Girdwood }; 358f11a96d5SLiam Girdwood 359f11a96d5SLiam Girdwood EXPORT_SYMBOL_GPL(pxa2xx_soc_platform); 360f11a96d5SLiam Girdwood 361f11a96d5SLiam Girdwood MODULE_AUTHOR("Nicolas Pitre"); 362f11a96d5SLiam Girdwood MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module"); 363f11a96d5SLiam Girdwood MODULE_LICENSE("GPL"); 364