aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/s3c24xx/s3c24xx-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/s3c24xx/s3c24xx-pcm.c')
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index 7c64d31d067e..a9d68fa2b34a 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -4,7 +4,7 @@
4 * (c) 2006 Wolfson Microelectronics PLC. 4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com 5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 * 6 *
7 * (c) 2004-2005 Simtec Electronics 7 * Copyright 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/ 8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk> 9 * Ben Dooks <ben@simtec.co.uk>
10 * 10 *
@@ -29,17 +29,10 @@
29#include <asm/dma.h> 29#include <asm/dma.h>
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <mach/dma.h> 31#include <mach/dma.h>
32#include <mach/audio.h> 32#include <plat/audio.h>
33 33
34#include "s3c24xx-pcm.h" 34#include "s3c24xx-pcm.h"
35 35
36#define S3C24XX_PCM_DEBUG 0
37#if S3C24XX_PCM_DEBUG
38#define DBG(x...) printk(KERN_DEBUG "s3c24xx-pcm: " x)
39#else
40#define DBG(x...)
41#endif
42
43static const struct snd_pcm_hardware s3c24xx_pcm_hardware = { 36static const struct snd_pcm_hardware s3c24xx_pcm_hardware = {
44 .info = SNDRV_PCM_INFO_INTERLEAVED | 37 .info = SNDRV_PCM_INFO_INTERLEAVED |
45 SNDRV_PCM_INFO_BLOCK_TRANSFER | 38 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -84,16 +77,16 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
84 dma_addr_t pos = prtd->dma_pos; 77 dma_addr_t pos = prtd->dma_pos;
85 int ret; 78 int ret;
86 79
87 DBG("Entered %s\n", __func__); 80 pr_debug("Entered %s\n", __func__);
88 81
89 while (prtd->dma_loaded < prtd->dma_limit) { 82 while (prtd->dma_loaded < prtd->dma_limit) {
90 unsigned long len = prtd->dma_period; 83 unsigned long len = prtd->dma_period;
91 84
92 DBG("dma_loaded: %d\n", prtd->dma_loaded); 85 pr_debug("dma_loaded: %d\n", prtd->dma_loaded);
93 86
94 if ((pos + len) > prtd->dma_end) { 87 if ((pos + len) > prtd->dma_end) {
95 len = prtd->dma_end - pos; 88 len = prtd->dma_end - pos;
96 DBG(KERN_DEBUG "%s: corrected dma len %ld\n", 89 pr_debug(KERN_DEBUG "%s: corrected dma len %ld\n",
97 __func__, len); 90 __func__, len);
98 } 91 }
99 92
@@ -119,7 +112,7 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
119 struct snd_pcm_substream *substream = dev_id; 112 struct snd_pcm_substream *substream = dev_id;
120 struct s3c24xx_runtime_data *prtd; 113 struct s3c24xx_runtime_data *prtd;
121 114
122 DBG("Entered %s\n", __func__); 115 pr_debug("Entered %s\n", __func__);
123 116
124 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR) 117 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
125 return; 118 return;
@@ -148,7 +141,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
148 unsigned long totbytes = params_buffer_bytes(params); 141 unsigned long totbytes = params_buffer_bytes(params);
149 int ret = 0; 142 int ret = 0;
150 143
151 DBG("Entered %s\n", __func__); 144 pr_debug("Entered %s\n", __func__);
152 145
153 /* return if this is a bufferless transfer e.g. 146 /* return if this is a bufferless transfer e.g.
154 * codec <--> BT codec or GSM modem -- lg FIXME */ 147 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -161,14 +154,14 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
161 /* prepare DMA */ 154 /* prepare DMA */
162 prtd->params = dma; 155 prtd->params = dma;
163 156
164 DBG("params %p, client %p, channel %d\n", prtd->params, 157 pr_debug("params %p, client %p, channel %d\n", prtd->params,
165 prtd->params->client, prtd->params->channel); 158 prtd->params->client, prtd->params->channel);
166 159
167 ret = s3c2410_dma_request(prtd->params->channel, 160 ret = s3c2410_dma_request(prtd->params->channel,
168 prtd->params->client, NULL); 161 prtd->params->client, NULL);
169 162
170 if (ret < 0) { 163 if (ret < 0) {
171 DBG(KERN_ERR "failed to get dma channel\n"); 164 printk(KERN_ERR "failed to get dma channel\n");
172 return ret; 165 return ret;
173 } 166 }
174 } 167 }
@@ -196,7 +189,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
196{ 189{
197 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 190 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
198 191
199 DBG("Entered %s\n", __func__); 192 pr_debug("Entered %s\n", __func__);
200 193
201 /* TODO - do we need to ensure DMA flushed */ 194 /* TODO - do we need to ensure DMA flushed */
202 snd_pcm_set_runtime_buffer(substream, NULL); 195 snd_pcm_set_runtime_buffer(substream, NULL);
@@ -214,7 +207,7 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
214 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 207 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
215 int ret = 0; 208 int ret = 0;
216 209
217 DBG("Entered %s\n", __func__); 210 pr_debug("Entered %s\n", __func__);
218 211
219 /* return if this is a bufferless transfer e.g. 212 /* return if this is a bufferless transfer e.g.
220 * codec <--> BT codec or GSM modem -- lg FIXME */ 213 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -259,7 +252,7 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
259 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 252 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
260 int ret = 0; 253 int ret = 0;
261 254
262 DBG("Entered %s\n", __func__); 255 pr_debug("Entered %s\n", __func__);
263 256
264 spin_lock(&prtd->lock); 257 spin_lock(&prtd->lock);
265 258
@@ -297,7 +290,7 @@ s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
297 unsigned long res; 290 unsigned long res;
298 dma_addr_t src, dst; 291 dma_addr_t src, dst;
299 292
300 DBG("Entered %s\n", __func__); 293 pr_debug("Entered %s\n", __func__);
301 294
302 spin_lock(&prtd->lock); 295 spin_lock(&prtd->lock);
303 s3c2410_dma_getposition(prtd->params->channel, &src, &dst); 296 s3c2410_dma_getposition(prtd->params->channel, &src, &dst);
@@ -309,7 +302,7 @@ s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
309 302
310 spin_unlock(&prtd->lock); 303 spin_unlock(&prtd->lock);
311 304
312 DBG("Pointer %x %x\n", src, dst); 305 pr_debug("Pointer %x %x\n", src, dst);
313 306
314 /* we seem to be getting the odd error from the pcm library due 307 /* we seem to be getting the odd error from the pcm library due
315 * to out-of-bounds pointers. this is maybe due to the dma engine 308 * to out-of-bounds pointers. this is maybe due to the dma engine
@@ -330,7 +323,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
330 struct snd_pcm_runtime *runtime = substream->runtime; 323 struct snd_pcm_runtime *runtime = substream->runtime;
331 struct s3c24xx_runtime_data *prtd; 324 struct s3c24xx_runtime_data *prtd;
332 325
333 DBG("Entered %s\n", __func__); 326 pr_debug("Entered %s\n", __func__);
334 327
335 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware); 328 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
336 329
@@ -349,10 +342,10 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
349 struct snd_pcm_runtime *runtime = substream->runtime; 342 struct snd_pcm_runtime *runtime = substream->runtime;
350 struct s3c24xx_runtime_data *prtd = runtime->private_data; 343 struct s3c24xx_runtime_data *prtd = runtime->private_data;
351 344
352 DBG("Entered %s\n", __func__); 345 pr_debug("Entered %s\n", __func__);
353 346
354 if (!prtd) 347 if (!prtd)
355 DBG("s3c24xx_pcm_close called with prtd == NULL\n"); 348 pr_debug("s3c24xx_pcm_close called with prtd == NULL\n");
356 349
357 kfree(prtd); 350 kfree(prtd);
358 351
@@ -364,7 +357,7 @@ static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream,
364{ 357{
365 struct snd_pcm_runtime *runtime = substream->runtime; 358 struct snd_pcm_runtime *runtime = substream->runtime;
366 359
367 DBG("Entered %s\n", __func__); 360 pr_debug("Entered %s\n", __func__);
368 361
369 return dma_mmap_writecombine(substream->pcm->card->dev, vma, 362 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
370 runtime->dma_area, 363 runtime->dma_area,
@@ -390,7 +383,7 @@ static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
390 struct snd_dma_buffer *buf = &substream->dma_buffer; 383 struct snd_dma_buffer *buf = &substream->dma_buffer;
391 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max; 384 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max;
392 385
393 DBG("Entered %s\n", __func__); 386 pr_debug("Entered %s\n", __func__);
394 387
395 buf->dev.type = SNDRV_DMA_TYPE_DEV; 388 buf->dev.type = SNDRV_DMA_TYPE_DEV;
396 buf->dev.dev = pcm->card->dev; 389 buf->dev.dev = pcm->card->dev;
@@ -409,7 +402,7 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
409 struct snd_dma_buffer *buf; 402 struct snd_dma_buffer *buf;
410 int stream; 403 int stream;
411 404
412 DBG("Entered %s\n", __func__); 405 pr_debug("Entered %s\n", __func__);
413 406
414 for (stream = 0; stream < 2; stream++) { 407 for (stream = 0; stream < 2; stream++) {
415 substream = pcm->streams[stream].substream; 408 substream = pcm->streams[stream].substream;
@@ -433,7 +426,7 @@ static int s3c24xx_pcm_new(struct snd_card *card,
433{ 426{
434 int ret = 0; 427 int ret = 0;
435 428
436 DBG("Entered %s\n", __func__); 429 pr_debug("Entered %s\n", __func__);
437 430
438 if (!card->dev->dma_mask) 431 if (!card->dev->dma_mask)
439 card->dev->dma_mask = &s3c24xx_pcm_dmamask; 432 card->dev->dma_mask = &s3c24xx_pcm_dmamask;