Date:2013-04-03 11:06:04 (9 years 5 months ago)
Author:Lars C.
Commit:559dd5b62032c7874ac477bf116a21a6771d2d87
Message:ASoC: fsl: Use common DAI DMA data struct

Use the common DAI DMA data struct for fsl/imx, this allows us to use the common
helper function to configure the DMA slave config based on the DAI DMA data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Files: sound/soc/fsl/fsl_ssi.c (4 diffs)
sound/soc/fsl/imx-pcm-dma.c (3 diffs)
sound/soc/fsl/imx-pcm-fiq.c (1 diff)
sound/soc/fsl/imx-pcm.h (1 diff)
sound/soc/fsl/imx-ssi.c (3 diffs)
sound/soc/fsl/imx-ssi.h (2 diffs)

Change Details

sound/soc/fsl/fsl_ssi.c
2727#include <sound/pcm_params.h>
2828#include <sound/initval.h>
2929#include <sound/soc.h>
30#include <sound/dmaengine_pcm.h>
3031
3132#include "fsl_ssi.h"
3233#include "imx-pcm.h"
...... 
122123    bool ssi_on_imx;
123124    struct clk *clk;
124125    struct platform_device *imx_pcm_pdev;
125    struct imx_pcm_dma_params dma_params_tx;
126    struct imx_pcm_dma_params dma_params_rx;
126    struct snd_dmaengine_dai_dma_data dma_params_tx;
127    struct snd_dmaengine_dai_dma_data dma_params_rx;
128    struct imx_dma_data filter_data_tx;
129    struct imx_dma_data filter_data_rx;
127130
128131    struct {
129132        unsigned int rfrc;
...... 
738741         * We have burstsize be "fifo_depth - 2" to match the SSI
739742         * watermark setting in fsl_ssi_startup().
740743         */
741        ssi_private->dma_params_tx.burstsize =
744        ssi_private->dma_params_tx.maxburst =
742745            ssi_private->fifo_depth - 2;
743        ssi_private->dma_params_rx.burstsize =
746        ssi_private->dma_params_rx.maxburst =
744747            ssi_private->fifo_depth - 2;
745        ssi_private->dma_params_tx.dma_addr =
748        ssi_private->dma_params_tx.addr =
746749            ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0);
747        ssi_private->dma_params_rx.dma_addr =
750        ssi_private->dma_params_rx.addr =
748751            ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0);
752        ssi_private->dma_params_tx.filter_data =
753            &ssi_private->filter_data_tx;
754        ssi_private->dma_params_rx.filter_data =
755            &ssi_private->filter_data_rx;
749756        /*
750757         * TODO: This is a temporary solution and should be changed
751758         * to use generic DMA binding later when the helplers get in.
...... 
760767        shared = of_device_is_compatible(of_get_parent(np),
761768                "fsl,spba-bus");
762769
763        imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx,
770        imx_pcm_dma_params_init_data(&ssi_private->filter_data_tx,
764771            dma_events[0], shared);
765        imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx,
772        imx_pcm_dma_params_init_data(&ssi_private->filter_data_rx,
766773            dma_events[1], shared);
767774    }
768775
sound/soc/fsl/imx-pcm-dma.c
3434
3535static bool filter(struct dma_chan *chan, void *param)
3636{
37    struct snd_dmaengine_dai_dma_data *dma_data = param;
38
3739    if (!imx_dma_is_general_purpose(chan))
3840        return false;
3941
40    chan->private = param;
42    chan->private = dma_data->filter_data;
4143
4244    return true;
4345}
...... 
4749{
4850    struct snd_soc_pcm_runtime *rtd = substream->private_data;
4951    struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
50    struct imx_pcm_dma_params *dma_params;
5152    struct dma_slave_config slave_config;
5253    int ret;
5354
54    dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
55
5655    ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config);
5756    if (ret)
5857        return ret;
5958
60    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
61        slave_config.dst_addr = dma_params->dma_addr;
62        slave_config.dst_maxburst = dma_params->burstsize;
63    } else {
64        slave_config.src_addr = dma_params->dma_addr;
65        slave_config.src_maxburst = dma_params->burstsize;
66    }
59    snd_dmaengine_pcm_set_config_from_dai_data(substream,
60            snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
61            &slave_config);
6762
6863    ret = dmaengine_slave_config(chan, &slave_config);
6964    if (ret)
...... 
9691static int snd_imx_open(struct snd_pcm_substream *substream)
9792{
9893    struct snd_soc_pcm_runtime *rtd = substream->private_data;
99    struct imx_pcm_dma_params *dma_params;
10094
10195    snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
10296
103    dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
104
105    return snd_dmaengine_pcm_open(substream, filter, &dma_params->dma_data);
97    return snd_dmaengine_pcm_open(substream, filter,
98        snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
10699}
107100
108101static struct snd_pcm_ops imx_pcm_ops = {
sound/soc/fsl/imx-pcm-fiq.c
299299
300300    imx_ssi_fiq_base = (unsigned long)ssi->base;
301301
302    ssi->dma_params_tx.burstsize = 4;
303    ssi->dma_params_rx.burstsize = 6;
302    ssi->dma_params_tx.maxburst = 4;
303    ssi->dma_params_rx.maxburst = 6;
304304
305305    ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq);
306306    if (ret)
sound/soc/fsl/imx-pcm.h
2020 */
2121#define IMX_SSI_DMABUF_SIZE (64 * 1024)
2222
23struct imx_pcm_dma_params {
24    unsigned long dma_addr;
25    int burstsize;
26    struct imx_dma_data dma_data;
27};
28
2923static inline void
30imx_pcm_dma_params_init_data(struct imx_pcm_dma_params *params,
24imx_pcm_dma_params_init_data(struct imx_dma_data *dma_data,
3125    int dma, bool shared)
3226{
33    params->dma_data.dma_request = dma;
34    params->dma_data.priority = DMA_PRIO_HIGH;
27    dma_data->dma_request = dma;
28    dma_data->priority = DMA_PRIO_HIGH;
3529    if (shared)
36        params->dma_data.peripheral_type = IMX_DMATYPE_SSI_SP;
30        dma_data->peripheral_type = IMX_DMATYPE_SSI_SP;
3731    else
38        params->dma_data.peripheral_type = IMX_DMATYPE_SSI;
32        dma_data->peripheral_type = IMX_DMATYPE_SSI;
3933}
4034
4135int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,
sound/soc/fsl/imx-ssi.c
236236               struct snd_soc_dai *cpu_dai)
237237{
238238    struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
239    struct imx_pcm_dma_params *dma_data;
239    struct snd_dmaengine_dai_dma_data *dma_data;
240240
241241    /* Tx/Rx config */
242242    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
...... 
369369
370370    snd_soc_dai_set_drvdata(dai, ssi);
371371
372    val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) |
373        SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize);
372    val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.maxburst) |
373        SSI_SFCSR_RFWM0(ssi->dma_params_rx.maxburst);
374374    writel(val, ssi->base + SSI_SFCSR);
375375
376376    return 0;
...... 
575575
576576    writel(0x0, ssi->base + SSI_SIER);
577577
578    ssi->dma_params_rx.dma_addr = res->start + SSI_SRX0;
579    ssi->dma_params_tx.dma_addr = res->start + SSI_STX0;
578    ssi->dma_params_rx.addr = res->start + SSI_SRX0;
579    ssi->dma_params_tx.addr = res->start + SSI_STX0;
580580
581    ssi->dma_params_tx.burstsize = 6;
582    ssi->dma_params_rx.burstsize = 4;
581    ssi->dma_params_tx.maxburst = 6;
582    ssi->dma_params_rx.maxburst = 4;
583
584    ssi->dma_params_tx.filter_data = &ssi->filter_data_tx;
585    ssi->dma_params_rx.filter_data = &ssi->filter_data_rx;
583586
584587    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0");
585588    if (res) {
586        imx_pcm_dma_params_init_data(&ssi->dma_params_tx, res->start,
589        imx_pcm_dma_params_init_data(&ssi->filter_data_tx, res->start,
587590            false);
588591    }
589592
590593    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0");
591594    if (res) {
592        imx_pcm_dma_params_init_data(&ssi->dma_params_rx, res->start,
595        imx_pcm_dma_params_init_data(&ssi->filter_data_rx, res->start,
593596            false);
594597    }
595598
sound/soc/fsl/imx-ssi.h
187187
188188#include <linux/dmaengine.h>
189189#include <linux/platform_data/dma-imx.h>
190#include <sound/dmaengine_pcm.h>
190191#include "imx-pcm.h"
191192
192193struct imx_ssi {
...... 
204205    void (*ac97_reset) (struct snd_ac97 *ac97);
205206    void (*ac97_warm_reset)(struct snd_ac97 *ac97);
206207
207    struct imx_pcm_dma_params dma_params_rx;
208    struct imx_pcm_dma_params dma_params_tx;
208    struct snd_dmaengine_dai_dma_data dma_params_rx;
209    struct snd_dmaengine_dai_dma_data dma_params_tx;
210    struct imx_dma_data filter_data_tx;
211    struct imx_dma_data filter_data_rx;
209212
210213    int enabled;
211214

Archive Download the corresponding diff file



interactive