Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[sfrench/cifs-2.6.git] / sound / soc / s3c24xx / s3c24xx-pcm.c
index bfbdc3cbd43b5e936c0614c9429d1414e4a4bb56..29a6c82f873ac7c5f50def0470ef4d44e6fb5222 100644 (file)
@@ -24,7 +24,6 @@
 #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>
@@ -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 |
@@ -158,40 +159,22 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
        if (!dma)
                return 0;
 
-       /* prepare DMA */
-       prtd->params = dma;
+       /* this may get called several times by oss emulation
+        * with different params -HW */
+       if (prtd->params == NULL) {
+               /* prepare DMA */
+               prtd->params = dma;
 
-       DBG("params %p, client %p, channel %d\n", prtd->params,
-               prtd->params->client, prtd->params->channel);
+               DBG("params %p, client %p, channel %d\n", prtd->params,
+                       prtd->params->client, prtd->params->channel);
 
-       ret = s3c2410_dma_request(prtd->params->channel,
-                                 prtd->params->client, NULL);
+               ret = s3c2410_dma_request(prtd->params->channel,
+                                         prtd->params->client, NULL);
 
-       if (ret) {
-               DBG(KERN_ERR "failed to get dma channel\n");
-               return ret;
-       }
-
-       /* 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);
+               if (ret) {
+                       DBG(KERN_ERR "failed to get dma channel\n");
+                       return ret;
+               }
        }
 
        s3c2410_dma_set_buffdone_fn(prtd->params->channel,
@@ -242,6 +225,28 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
        if (!prtd->params)
                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);
        prtd->dma_loaded = 0;