]> err.no Git - linux-2.6/commitdiff
[ALSA] ASoC Samsung S3c24xx updates - audio DMA cleanup
authorGraeme Gregory <gg@opensource.wolfsonmicro.com>
Tue, 17 Apr 2007 10:35:18 +0000 (12:35 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 11 May 2007 14:56:03 +0000 (16:56 +0200)
This patch cleans up the audio DMA for the Samsung S3C24xx platform.

Signed-off-by: Graeme Gregory <gg@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/soc/s3c24xx/s3c24xx-pcm.c
sound/soc/s3c24xx/s3c24xx-pcm.h

index f1c0b9fa179c2159ef34fd6218dd16a5df927fed..21dc6974d6a3922c3d6a94baf5f232e4bf5e8c44 100644 (file)
@@ -89,7 +89,7 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
 
        DBG("Entered %s\n", __FUNCTION__);
 
-       while ( prtd->dma_loaded < prtd->dma_limit) {
+       while (prtd->dma_loaded < prtd->dma_limit) {
                unsigned long len = prtd->dma_period;
 
                DBG("dma_loaded: %d\n",prtd->dma_loaded);
@@ -100,7 +100,8 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
                               __FUNCTION__, len);
                }
 
-               ret = s3c2410_dma_enqueue(prtd->params->channel, substream, pos, len);
+               ret = s3c2410_dma_enqueue(prtd->params->channel, 
+                       substream, pos, len);
 
                if (ret == 0) {
                        prtd->dma_loaded++;
@@ -115,17 +116,19 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
 }
 
 static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
-                                                       void *dev_id, int size,
-                                                       enum s3c2410_dma_buffresult result)
+                               void *dev_id, int size,
+                               enum s3c2410_dma_buffresult result)
 {
        struct snd_pcm_substream *substream = dev_id;
-       struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
+       struct s3c24xx_runtime_data *prtd;
 
        DBG("Entered %s\n", __FUNCTION__);
 
        if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
                return;
 
+       prtd = substream->runtime->private_data;
+       
        if (substream)
                snd_pcm_period_elapsed(substream);
 
@@ -173,18 +176,22 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
         * 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_DMASRC_MEM, S3C2410_DISRCC_INC |
+                               S3C2410_DISRCC_APB, prtd->params->dma_addr);
 
                s3c2410_dma_config(prtd->params->channel,
-                                               2, S3C2410_DCON_SYNC_PCLK | S3C2410_DCON_HANDSHAKE);
+                               prtd->params->dma_size,
+                               S3C2410_DCON_SYNC_PCLK | 
+                               S3C2410_DCON_HANDSHAKE);
        } else {
                s3c2410_dma_config(prtd->params->channel,
-                                               2, S3C2410_DCON_HANDSHAKE | S3C2410_DCON_SYNC_PCLK);
+                               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_DMASRC_HW, 0x3,
+                                       prtd->params->dma_addr);
        }
 
        s3c2410_dma_set_buffdone_fn(prtd->params->channel,
@@ -215,7 +222,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
        /* TODO - do we need to ensure DMA flushed */
        snd_pcm_set_runtime_buffer(substream, NULL);
 
-       if(prtd->params) {
+       if (prtd->params) {
                s3c2410_dma_free(prtd->params->channel, prtd->params->client);
                prtd->params = NULL;
        }
@@ -281,7 +288,8 @@ 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;
@@ -321,8 +329,6 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct s3c24xx_runtime_data *prtd;
 
-       int ret;
-
        DBG("Entered %s\n", __FUNCTION__);
 
        snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
@@ -342,7 +348,7 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
 
        DBG("Entered %s\n", __FUNCTION__);
 
-       if(prtd)
+       if (prtd)
                kfree(prtd);
        else
                DBG("s3c24xx_pcm_close called with prtd == NULL\n");
@@ -419,8 +425,8 @@ 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, struct snd_soc_codec_dai *dai,
-       struct snd_pcm *pcm)
+static int s3c24xx_pcm_new(struct snd_card *card, 
+       struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
 {
        int ret = 0;
 
index 5dced4ab193257df3abce9bfe2d403f2481baab1..0088c79822ead0b409aec38ea4729fb1c2758a34 100644 (file)
 #define ST_OPENED              (1<<1)
 
 struct s3c24xx_pcm_dma_params {
-       struct s3c2410_dma_client *client;                      /* stream identifier */
-       int channel;                                            /* Channel ID */
+       struct s3c2410_dma_client *client;      /* stream identifier */
+       int channel;                            /* Channel ID */
        dma_addr_t dma_addr;
+       int dma_size;                   /* Size of the DMA transfer */
 };
 
 #define S3C24XX_DAI_I2S                        0
 
-extern struct snd_soc_cpu_dai s3c24xx_i2s_dai;
-
 /* platform data */
 extern struct snd_soc_platform s3c24xx_soc_platform;
 extern struct snd_ac97_bus_ops s3c24xx_ac97_ops;