diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-12 16:57:04 +0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-12 16:57:04 +0400 |
commit | 38e8c895d33b0642dc341f83cce0adde4cffbc82 (patch) | |
tree | 3657c043986d5c944f971c9685ae4a68f5a5b035 /sound/soc/fsl | |
parent | d66e065c5b8b64b03a9d9b8a7c5d674c7dfa2e3d (diff) | |
parent | 69b6f19622ce0aef41df884b75e3f789c64b89c0 (diff) | |
download | linux-38e8c895d33b0642dc341f83cce0adde4cffbc82.tar.xz |
Merge remote-tracking branch 'asoc/topic/dma' into asoc-next
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/fsl_ssi.c | 36 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm-dma.c | 58 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm-fiq.c | 4 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm.h | 19 | ||||
-rw-r--r-- | sound/soc/fsl/imx-ssi.c | 29 | ||||
-rw-r--r-- | sound/soc/fsl/imx-ssi.h | 7 |
6 files changed, 69 insertions, 84 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index fe04c67f8fb8..42366d776f62 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -27,6 +27,7 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h> #include "fsl_ssi.h" #include "imx-pcm.h" @@ -122,8 +123,10 @@ struct fsl_ssi_private { bool ssi_on_imx; struct clk *clk; struct platform_device *imx_pcm_pdev; - struct imx_pcm_dma_params dma_params_tx; - struct imx_pcm_dma_params dma_params_rx; + struct snd_dmaengine_dai_dma_data dma_params_tx; + struct snd_dmaengine_dai_dma_data dma_params_rx; + struct imx_dma_data filter_data_tx; + struct imx_dma_data filter_data_rx; struct { unsigned int rfrc; @@ -653,6 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) const uint32_t *iprop; struct resource res; char name[64]; + bool shared; /* SSIs that are not connected on the board should have a * status = "disabled" @@ -741,14 +745,18 @@ static int fsl_ssi_probe(struct platform_device *pdev) * We have burstsize be "fifo_depth - 2" to match the SSI * watermark setting in fsl_ssi_startup(). */ - ssi_private->dma_params_tx.burstsize = + ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2; - ssi_private->dma_params_rx.burstsize = + ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2; - ssi_private->dma_params_tx.dma_addr = + ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0); - ssi_private->dma_params_rx.dma_addr = + ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0); + ssi_private->dma_params_tx.filter_data = + &ssi_private->filter_data_tx; + ssi_private->dma_params_rx.filter_data = + &ssi_private->filter_data_rx; /* * TODO: This is a temporary solution and should be changed * to use generic DMA binding later when the helplers get in. @@ -759,14 +767,14 @@ static int fsl_ssi_probe(struct platform_device *pdev) dev_err(&pdev->dev, "could not get dma events\n"); goto error_clk; } - ssi_private->dma_params_tx.dma = dma_events[0]; - ssi_private->dma_params_rx.dma = dma_events[1]; - - ssi_private->dma_params_tx.shared_peripheral = - of_device_is_compatible(of_get_parent(np), - "fsl,spba-bus"); - ssi_private->dma_params_rx.shared_peripheral = - ssi_private->dma_params_tx.shared_peripheral; + + shared = of_device_is_compatible(of_get_parent(np), + "fsl,spba-bus"); + + imx_pcm_dma_params_init_data(&ssi_private->filter_data_tx, + dma_events[0], shared); + imx_pcm_dma_params_init_data(&ssi_private->filter_data_rx, + dma_events[1], shared); } /* Initialize the the device_attribute structure */ diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 500f8ce55d78..ee838c8a3b11 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -30,16 +30,16 @@ #include <sound/soc.h> #include <sound/dmaengine_pcm.h> -#include <linux/platform_data/dma-imx.h> - #include "imx-pcm.h" static bool filter(struct dma_chan *chan, void *param) { + struct snd_dmaengine_dai_dma_data *dma_data = param; + if (!imx_dma_is_general_purpose(chan)) return false; - chan->private = param; + chan->private = dma_data->filter_data; return true; } @@ -49,25 +49,16 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); - struct imx_pcm_dma_params *dma_params; struct dma_slave_config slave_config; int ret; - dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config); if (ret) return ret; - slave_config.device_fc = false; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - slave_config.dst_addr = dma_params->dma_addr; - slave_config.dst_maxburst = dma_params->burstsize; - } else { - slave_config.src_addr = dma_params->dma_addr; - slave_config.src_maxburst = dma_params->burstsize; - } + snd_dmaengine_pcm_set_config_from_dai_data(substream, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream), + &slave_config); ret = dmaengine_slave_config(chan, &slave_config); if (ret) @@ -100,47 +91,16 @@ static struct snd_pcm_hardware snd_imx_hardware = { static int snd_imx_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct imx_pcm_dma_params *dma_params; - struct imx_dma_data *dma_data; - int ret; snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); - dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); - if (!dma_data) - return -ENOMEM; - - dma_data->peripheral_type = dma_params->shared_peripheral ? - IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI; - dma_data->priority = DMA_PRIO_HIGH; - dma_data->dma_request = dma_params->dma; - - ret = snd_dmaengine_pcm_open(substream, filter, dma_data); - if (ret) { - kfree(dma_data); - return ret; - } - - snd_dmaengine_pcm_set_data(substream, dma_data); - - return 0; -} - -static int snd_imx_close(struct snd_pcm_substream *substream) -{ - struct imx_dma_data *dma_data = snd_dmaengine_pcm_get_data(substream); - - snd_dmaengine_pcm_close(substream); - kfree(dma_data); - - return 0; + return snd_dmaengine_pcm_open(substream, filter, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream)); } static struct snd_pcm_ops imx_pcm_ops = { .open = snd_imx_open, - .close = snd_imx_close, + .close = snd_dmaengine_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_imx_pcm_hw_params, .trigger = snd_dmaengine_pcm_trigger, diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 920f945cb2f4..025d0d9494f4 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -299,8 +299,8 @@ int imx_pcm_fiq_init(struct platform_device *pdev) imx_ssi_fiq_base = (unsigned long)ssi->base; - ssi->dma_params_tx.burstsize = 4; - ssi->dma_params_rx.burstsize = 6; + ssi->dma_params_tx.maxburst = 4; + ssi->dma_params_rx.maxburst = 6; ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); if (ret) diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 5ae13a13a353..be9cc64a208b 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -13,17 +13,24 @@ #ifndef _IMX_PCM_H #define _IMX_PCM_H +#include <linux/platform_data/dma-imx.h> + /* * Do not change this as the FIQ handler depends on this size */ #define IMX_SSI_DMABUF_SIZE (64 * 1024) -struct imx_pcm_dma_params { - int dma; - unsigned long dma_addr; - int burstsize; - bool shared_peripheral; /* The peripheral is on SPBA bus */ -}; +static inline void +imx_pcm_dma_params_init_data(struct imx_dma_data *dma_data, + int dma, bool shared) +{ + dma_data->dma_request = dma; + dma_data->priority = DMA_PRIO_HIGH; + if (shared) + dma_data->peripheral_type = IMX_DMATYPE_SSI_SP; + else + dma_data->peripheral_type = IMX_DMATYPE_SSI; +} int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma); diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 4a26d88d7236..77300d163b96 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -236,7 +236,7 @@ static int imx_ssi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); - struct imx_pcm_dma_params *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data; /* Tx/Rx config */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -369,8 +369,8 @@ static int imx_ssi_dai_probe(struct snd_soc_dai *dai) snd_soc_dai_set_drvdata(dai, ssi); - val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) | - SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize); + val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.maxburst) | + SSI_SFCSR_RFWM0(ssi->dma_params_rx.maxburst); writel(val, ssi->base + SSI_SFCSR); return 0; @@ -579,19 +579,26 @@ static int imx_ssi_probe(struct platform_device *pdev) writel(0x0, ssi->base + SSI_SIER); - ssi->dma_params_rx.dma_addr = res->start + SSI_SRX0; - ssi->dma_params_tx.dma_addr = res->start + SSI_STX0; + ssi->dma_params_rx.addr = res->start + SSI_SRX0; + ssi->dma_params_tx.addr = res->start + SSI_STX0; - ssi->dma_params_tx.burstsize = 6; - ssi->dma_params_rx.burstsize = 4; + ssi->dma_params_tx.maxburst = 6; + ssi->dma_params_rx.maxburst = 4; + + ssi->dma_params_tx.filter_data = &ssi->filter_data_tx; + ssi->dma_params_rx.filter_data = &ssi->filter_data_rx; res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); - if (res) - ssi->dma_params_tx.dma = res->start; + if (res) { + imx_pcm_dma_params_init_data(&ssi->filter_data_tx, res->start, + false); + } res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); - if (res) - ssi->dma_params_rx.dma = res->start; + if (res) { + imx_pcm_dma_params_init_data(&ssi->filter_data_rx, res->start, + false); + } platform_set_drvdata(pdev, ssi); diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index dc114bdedce5..bb6b3dbb13fd 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h @@ -187,6 +187,7 @@ #include <linux/dmaengine.h> #include <linux/platform_data/dma-imx.h> +#include <sound/dmaengine_pcm.h> #include "imx-pcm.h" struct imx_ssi { @@ -204,8 +205,10 @@ struct imx_ssi { void (*ac97_reset) (struct snd_ac97 *ac97); void (*ac97_warm_reset)(struct snd_ac97 *ac97); - struct imx_pcm_dma_params dma_params_rx; - struct imx_pcm_dma_params dma_params_tx; + struct snd_dmaengine_dai_dma_data dma_params_rx; + struct snd_dmaengine_dai_dma_data dma_params_tx; + struct imx_dma_data filter_data_tx; + struct imx_dma_data filter_data_rx; int enabled; |