ASoC: fsi: use SNDRV_DMA_TYPE_DEV for sound buffer
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 23 Jun 2014 00:55:18 +0000 (17:55 -0700)
committerMark Brown <broonie@linaro.org>
Sat, 28 Jun 2014 13:41:18 +0000 (14:41 +0100)
Current fsi driver is using SNDRV_DMA_TYPE_CONTINUOUS
for snd_pcm_lib_preallocate_pages_for_all().
But, it came from original dma-sh7760.c,
and no longer needed.
This patch exchange its parameter, and removed
original dma mapping and un-needed
dma_sync_single_xxx() from driver.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/arm/mach-shmobile/board-armadillo800eva.c
arch/arm/mach-shmobile/board-kzm9g.c
arch/arm/mach-shmobile/board-mackerel.c
arch/sh/boards/mach-ecovec24/setup.c
sound/soc/sh/fsi.c

index 30fcac73a540f84b8a47e00ac3fa2abc755b4d90..689c121157ec3a2722f0c3c4c7540a6085fbec51 100644 (file)
@@ -998,6 +998,8 @@ static struct platform_device fsi_wm8978_device = {
        .id     = 0,
        .dev    = {
                .platform_data  = &fsi_wm8978_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_wm8978_device.dev.coherent_dma_mask,
        },
 };
 
@@ -1021,6 +1023,8 @@ static struct platform_device fsi_hdmi_device = {
        .id     = 1,
        .dev    = {
                .platform_data  = &fsi2_hdmi_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
        },
 };
 
index f94ec8ca42c1eb81bf913e8c22600dc90b925d46..01e0d1386db75477e22cb5d39fc4c6ca95fdce36 100644 (file)
@@ -603,6 +603,8 @@ static struct platform_device fsi_ak4648_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi2_ak4648_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_ak4648_device.dev.coherent_dma_mask,
        },
 };
 
index 0ff4d8e45cf7d9a2a7dc5974756b43d14256b1c8..112553f0f9bfab6558b73326d59885079aef5456 100644 (file)
@@ -523,6 +523,8 @@ static struct platform_device fsi_hdmi_device = {
        .id     = 1,
        .dev    = {
                .platform_data  = &fsi2_hdmi_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
        },
 };
 
@@ -919,6 +921,8 @@ static struct platform_device fsi_ak4643_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi2_ak4643_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask,
        },
 };
 
index 85d5255d259f690247494072635d35f29f9c5c8d..0d3049244cd3ad048a93a452ffd9583d48163531 100644 (file)
@@ -874,6 +874,8 @@ static struct platform_device fsi_da7210_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi_da7210_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
        },
 };
 
index 710a079a7377db8f9cf55422648242496fd97d07..7a6b632c3db88ee8fdca7737a84792caf2ad7b3e 100644 (file)
@@ -233,7 +233,6 @@ struct fsi_stream {
         */
        struct dma_chan         *chan;
        struct work_struct      work;
-       dma_addr_t              dma;
        int                     dma_id;
        int                     loop_cnt;
        int                     additional_pos;
@@ -1279,11 +1278,6 @@ static irqreturn_t fsi_interrupt(int irq, void *data)
  */
 static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
 {
-       struct snd_pcm_runtime *runtime = io->substream->runtime;
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-                               DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
        /*
         * 24bit data : 24bit bus / package in back
         * 16bit data : 16bit bus / stream mode
@@ -1293,19 +1287,7 @@ static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
 
        io->loop_cnt = 2; /* push 1st, 2nd period first, then 3rd, 4th... */
        io->additional_pos = 0;
-       io->dma = dma_map_single(dai->dev, runtime->dma_area,
-                                snd_pcm_lib_buffer_bytes(io->substream), dir);
-       return 0;
-}
-
-static int fsi_dma_quit(struct fsi_priv *fsi, struct fsi_stream *io)
-{
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-               DMA_TO_DEVICE : DMA_FROM_DEVICE;
 
-       dma_unmap_single(dai->dev, io->dma,
-                        snd_pcm_lib_buffer_bytes(io->substream), dir);
        return 0;
 }
 
@@ -1317,7 +1299,8 @@ static dma_addr_t fsi_dma_get_area(struct fsi_stream *io, int additional)
        if (period >= runtime->periods)
                period = 0;
 
-       return io->dma + samples_to_bytes(runtime, period * io->period_samples);
+       return runtime->dma_addr +
+               samples_to_bytes(runtime, period * io->period_samples);
 }
 
 static void fsi_dma_complete(void *data)
@@ -1325,12 +1308,6 @@ static void fsi_dma_complete(void *data)
        struct fsi_stream *io = (struct fsi_stream *)data;
        struct fsi_priv *fsi = fsi_stream_to_priv(io);
        struct snd_pcm_runtime *runtime = io->substream->runtime;
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-               DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
-       dma_sync_single_for_cpu(dai->dev, fsi_dma_get_area(io, 0),
-                       samples_to_bytes(runtime, io->period_samples), dir);
 
        io->buff_sample_pos += io->period_samples;
        io->period_pos++;
@@ -1369,8 +1346,6 @@ static void fsi_dma_do_work(struct work_struct *work)
        for (i = 0; i < io->loop_cnt; i++) {
                buf     = fsi_dma_get_area(io, io->additional_pos);
 
-               dma_sync_single_for_device(dai->dev, buf, len, dir);
-
                desc = dmaengine_prep_slave_single(io->chan, buf, len, dir,
                                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
                if (!desc) {
@@ -1495,7 +1470,6 @@ static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
 
 static struct fsi_stream_handler fsi_dma_push_handler = {
        .init           = fsi_dma_init,
-       .quit           = fsi_dma_quit,
        .probe          = fsi_dma_probe,
        .transfer       = fsi_dma_transfer,
        .remove         = fsi_dma_remove,
@@ -1850,16 +1824,10 @@ static void fsi_pcm_free(struct snd_pcm *pcm)
 
 static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
 {
-       struct snd_pcm *pcm = rtd->pcm;
-
-       /*
-        * dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel
-        * in MMAP mode (i.e. aplay -M)
-        */
        return snd_pcm_lib_preallocate_pages_for_all(
-               pcm,
-               SNDRV_DMA_TYPE_CONTINUOUS,
-               snd_dma_continuous_data(GFP_KERNEL),
+               rtd->pcm,
+               SNDRV_DMA_TYPE_DEV,
+               rtd->card->snd_card->dev,
                PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
 }