]> err.no Git - linux-2.6/blobdiff - sound/soc/s3c24xx/s3c24xx-pcm.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / sound / soc / s3c24xx / s3c24xx-pcm.c
index 4107a87d4de3cb39fdcf7f8d51432e5a37361c93..6c70a81c730cdbf8aea253a4240cd7007c7cfd68 100644 (file)
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
 
-#include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 
 #include <asm/dma.h>
-#include <asm/io.h>
 #include <asm/hardware.h>
 #include <asm/arch/dma.h>
 #include <asm/arch/audio.h>
@@ -40,7 +39,7 @@
 
 #define S3C24XX_PCM_DEBUG 0
 #if S3C24XX_PCM_DEBUG
-#define DBG(x...) printk(KERN_DEBUG x)
+#define DBG(x...) printk(KERN_DEBUG "s3c24xx-pcm: " x)
 #else
 #define DBG(x...)
 #endif
@@ -49,7 +48,9 @@ static const struct snd_pcm_hardware s3c24xx_pcm_hardware = {
        .info                   = SNDRV_PCM_INFO_INTERLEAVED |
                                    SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                    SNDRV_PCM_INFO_MMAP |
-                                   SNDRV_PCM_INFO_MMAP_VALID,
+                                   SNDRV_PCM_INFO_MMAP_VALID |
+                                   SNDRV_PCM_INFO_PAUSE |
+                                   SNDRV_PCM_INFO_RESUME,
        .formats                = SNDRV_PCM_FMTBIT_S16_LE |
                                    SNDRV_PCM_FMTBIT_U16_LE |
                                    SNDRV_PCM_FMTBIT_U8 |
@@ -87,20 +88,20 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
        dma_addr_t pos = prtd->dma_pos;
        int ret;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        while (prtd->dma_loaded < prtd->dma_limit) {
                unsigned long len = prtd->dma_period;
 
-               DBG("dma_loaded: %d\n",prtd->dma_loaded);
+               DBG("dma_loaded: %d\n", prtd->dma_loaded);
 
                if ((pos + len) > prtd->dma_end) {
                        len  = prtd->dma_end - pos;
                        DBG(KERN_DEBUG "%s: corrected dma len %ld\n",
-                              __FUNCTION__, len);
+                              __func__, len);
                }
 
-               ret = s3c2410_dma_enqueue(prtd->params->channel, 
+               ret = s3c2410_dma_enqueue(prtd->params->channel,
                        substream, pos, len);
 
                if (ret == 0) {
@@ -122,13 +123,13 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
        struct snd_pcm_substream *substream = dev_id;
        struct s3c24xx_runtime_data *prtd;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
                return;
 
        prtd = substream->runtime->private_data;
-       
+
        if (substream)
                snd_pcm_period_elapsed(substream);
 
@@ -149,9 +150,9 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct s3c24xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data;
        unsigned long totbytes = params_buffer_bytes(params);
-       int ret=0;
+       int ret = 0;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        /* return if this is a bufferless transfer e.g.
         * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -176,28 +177,6 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
                }
        }
 
-       /* channel needs configuring for mem=>device, increment memory addr,
-        * sync to pclk, half-word transfers to the IIS-FIFO. */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               s3c2410_dma_devconfig(prtd->params->channel,
-                               S3C2410_DMASRC_MEM, S3C2410_DISRCC_INC |
-                               S3C2410_DISRCC_APB, prtd->params->dma_addr);
-
-               s3c2410_dma_config(prtd->params->channel,
-                               prtd->params->dma_size,
-                               S3C2410_DCON_SYNC_PCLK | 
-                               S3C2410_DCON_HANDSHAKE);
-       } else {
-               s3c2410_dma_config(prtd->params->channel,
-                               prtd->params->dma_size,
-                               S3C2410_DCON_HANDSHAKE | 
-                               S3C2410_DCON_SYNC_PCLK);
-
-               s3c2410_dma_devconfig(prtd->params->channel,
-                                       S3C2410_DMASRC_HW, 0x3,
-                                       prtd->params->dma_addr);
-       }
-
        s3c2410_dma_set_buffdone_fn(prtd->params->channel,
                                    s3c24xx_audio_buffdone);
 
@@ -221,7 +200,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
 {
        struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        /* TODO - do we need to ensure DMA flushed */
        snd_pcm_set_runtime_buffer(substream, NULL);
@@ -239,12 +218,34 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
        struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
        int ret = 0;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        /* return if this is a bufferless transfer e.g.
         * codec <--> BT codec or GSM modem -- lg FIXME */
        if (!prtd->params)
-               return 0;
+               return 0;
+
+       /* channel needs configuring for mem=>device, increment memory addr,
+        * sync to pclk, half-word transfers to the IIS-FIFO. */
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               s3c2410_dma_devconfig(prtd->params->channel,
+                               S3C2410_DMASRC_MEM, S3C2410_DISRCC_INC |
+                               S3C2410_DISRCC_APB, prtd->params->dma_addr);
+
+               s3c2410_dma_config(prtd->params->channel,
+                               prtd->params->dma_size,
+                               S3C2410_DCON_SYNC_PCLK |
+                               S3C2410_DCON_HANDSHAKE);
+       } else {
+               s3c2410_dma_config(prtd->params->channel,
+                               prtd->params->dma_size,
+                               S3C2410_DCON_HANDSHAKE |
+                               S3C2410_DCON_SYNC_PCLK);
+
+               s3c2410_dma_devconfig(prtd->params->channel,
+                                       S3C2410_DMASRC_HW, 0x3,
+                                       prtd->params->dma_addr);
+       }
 
        /* flush the DMA channel */
        s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_FLUSH);
@@ -262,7 +263,7 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
        int ret = 0;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        spin_lock(&prtd->lock);
 
@@ -292,15 +293,15 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        return ret;
 }
 
-static snd_pcm_uframes_t 
-       s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
+static snd_pcm_uframes_t
+s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct s3c24xx_runtime_data *prtd = runtime->private_data;
        unsigned long res;
        dma_addr_t src, dst;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        spin_lock(&prtd->lock);
        s3c2410_dma_getposition(prtd->params->channel, &src, &dst);
@@ -312,7 +313,7 @@ static snd_pcm_uframes_t
 
        spin_unlock(&prtd->lock);
 
-       DBG("Pointer %x %x\n",src,dst);
+       DBG("Pointer %x %x\n", src, dst);
 
        /* we seem to be getting the odd error from the pcm library due
         * to out-of-bounds pointers. this is maybe due to the dma engine
@@ -333,7 +334,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct s3c24xx_runtime_data *prtd;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
 
@@ -352,13 +353,13 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct s3c24xx_runtime_data *prtd = runtime->private_data;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
-       if (prtd)
-               kfree(prtd);
-       else
+       if (!prtd)
                DBG("s3c24xx_pcm_close called with prtd == NULL\n");
 
+       kfree(prtd);
+
        return 0;
 }
 
@@ -367,12 +368,12 @@ static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream,
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        return dma_mmap_writecombine(substream->pcm->card->dev, vma,
-                                     runtime->dma_area,
-                                     runtime->dma_addr,
-                                     runtime->dma_bytes);
+                                    runtime->dma_area,
+                                    runtime->dma_addr,
+                                    runtime->dma_bytes);
 }
 
 static struct snd_pcm_ops s3c24xx_pcm_ops = {
@@ -393,7 +394,7 @@ static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
        struct snd_dma_buffer *buf = &substream->dma_buffer;
        size_t size = s3c24xx_pcm_hardware.buffer_bytes_max;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        buf->dev.type = SNDRV_DMA_TYPE_DEV;
        buf->dev.dev = pcm->card->dev;
@@ -412,7 +413,7 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
        struct snd_dma_buffer *buf;
        int stream;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        for (stream = 0; stream < 2; stream++) {
                substream = pcm->streams[stream].substream;
@@ -431,12 +432,12 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
 
 static u64 s3c24xx_pcm_dmamask = DMA_32BIT_MASK;
 
-static int s3c24xx_pcm_new(struct snd_card *card, 
+static int s3c24xx_pcm_new(struct snd_card *card,
        struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
 {
        int ret = 0;
 
-       DBG("Entered %s\n", __FUNCTION__);
+       DBG("Entered %s\n", __func__);
 
        if (!card->dev->dma_mask)
                card->dev->dma_mask = &s3c24xx_pcm_dmamask;
@@ -466,7 +467,6 @@ struct snd_soc_platform s3c24xx_soc_platform = {
        .pcm_new        = s3c24xx_pcm_new,
        .pcm_free       = s3c24xx_pcm_free_dma_buffers,
 };
-
 EXPORT_SYMBOL_GPL(s3c24xx_soc_platform);
 
 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");