2 * linux/sound/arm/pxa2xx-pcm.c -- ALSA PCM interface for the Intel PXA2xx chip
4 * Author: Nicolas Pitre
5 * Created: Nov 30, 2004
6 * Copyright: (C) 2004 MontaVista Software, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/dmaengine.h>
19 #include <sound/core.h>
20 #include <sound/pxa2xx-lib.h>
21 #include <sound/dmaengine_pcm.h>
23 #include "pxa2xx-pcm.h"
25 static int pxa2xx_pcm_prepare(struct snd_pcm_substream *substream)
27 struct pxa2xx_pcm_client *client = substream->private_data;
29 __pxa2xx_pcm_prepare(substream);
31 return client->prepare(substream);
34 static int pxa2xx_pcm_open(struct snd_pcm_substream *substream)
36 struct pxa2xx_pcm_client *client = substream->private_data;
37 struct snd_pcm_runtime *runtime = substream->runtime;
38 struct pxa2xx_runtime_data *rtd;
41 ret = __pxa2xx_pcm_open(substream);
45 rtd = runtime->private_data;
47 rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
48 client->playback_params : client->capture_params;
50 ret = client->startup(substream);
57 __pxa2xx_pcm_close(substream);
62 static int pxa2xx_pcm_close(struct snd_pcm_substream *substream)
64 struct pxa2xx_pcm_client *client = substream->private_data;
66 client->shutdown(substream);
68 return __pxa2xx_pcm_close(substream);
71 static struct snd_pcm_ops pxa2xx_pcm_ops = {
72 .open = pxa2xx_pcm_open,
73 .close = pxa2xx_pcm_close,
74 .ioctl = snd_pcm_lib_ioctl,
75 .hw_params = __pxa2xx_pcm_hw_params,
76 .hw_free = __pxa2xx_pcm_hw_free,
77 .prepare = pxa2xx_pcm_prepare,
78 .trigger = pxa2xx_pcm_trigger,
79 .pointer = pxa2xx_pcm_pointer,
80 .mmap = pxa2xx_pcm_mmap,
83 int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client,
84 struct snd_pcm **rpcm)
87 int play = client->playback_params ? 1 : 0;
88 int capt = client->capture_params ? 1 : 0;
91 ret = snd_pcm_new(card, "PXA2xx-PCM", 0, play, capt, &pcm);
95 pcm->private_data = client;
96 pcm->private_free = pxa2xx_pcm_free_dma_buffers;
98 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
103 int stream = SNDRV_PCM_STREAM_PLAYBACK;
104 snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);
105 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);
110 int stream = SNDRV_PCM_STREAM_CAPTURE;
111 snd_pcm_set_ops(pcm, stream, &pxa2xx_pcm_ops);
112 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, stream);
125 EXPORT_SYMBOL(pxa2xx_pcm_new);
127 MODULE_AUTHOR("Nicolas Pitre");
128 MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module");
129 MODULE_LICENSE("GPL");