Commit 312bb4f6 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: imx-pcm: Embed the imx_dma_data struct in the dma_params struct

Currently the imx_dma_data struct, which gets passed to the dmaengine driver, is
allocated and constructed in the pcm driver from the data stored in the
dma_params struct. The dma_params struct gets passed to the pcm driver from the
dai driver. Instead of going this route of indirection embed the dma_data struct
directly into the dma_params struct and let the dai driver fill it in. This
allows us to simplify the imx-pcm-dma driver quite a bit, since it doesn't have
care about memory managing the imx_dma_data struct anymore.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Tested-by: default avatarShawn Guo <shawn.guo@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent ac581e60
...@@ -649,6 +649,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) ...@@ -649,6 +649,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
const uint32_t *iprop; const uint32_t *iprop;
struct resource res; struct resource res;
char name[64]; char name[64];
bool shared;
/* SSIs that are not connected on the board should have a /* SSIs that are not connected on the board should have a
* status = "disabled" * status = "disabled"
...@@ -755,14 +756,14 @@ static int fsl_ssi_probe(struct platform_device *pdev) ...@@ -755,14 +756,14 @@ static int fsl_ssi_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "could not get dma events\n"); dev_err(&pdev->dev, "could not get dma events\n");
goto error_clk; goto error_clk;
} }
ssi_private->dma_params_tx.dma = dma_events[0];
ssi_private->dma_params_rx.dma = dma_events[1]; shared = of_device_is_compatible(of_get_parent(np),
"fsl,spba-bus");
ssi_private->dma_params_tx.shared_peripheral =
of_device_is_compatible(of_get_parent(np), imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx,
"fsl,spba-bus"); dma_events[0], shared);
ssi_private->dma_params_rx.shared_peripheral = imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx,
ssi_private->dma_params_tx.shared_peripheral; dma_events[1], shared);
} }
/* Initialize the the device_attribute structure */ /* Initialize the the device_attribute structure */
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/dmaengine_pcm.h> #include <sound/dmaengine_pcm.h>
#include <linux/platform_data/dma-imx.h>
#include "imx-pcm.h" #include "imx-pcm.h"
static bool filter(struct dma_chan *chan, void *param) static bool filter(struct dma_chan *chan, void *param)
...@@ -101,46 +99,17 @@ static int snd_imx_open(struct snd_pcm_substream *substream) ...@@ -101,46 +99,17 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct imx_pcm_dma_params *dma_params; struct imx_pcm_dma_params *dma_params;
struct imx_dma_data *dma_data;
int ret;
snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); return snd_dmaengine_pcm_open(substream, filter, &dma_params->dma_data);
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;
} }
static struct snd_pcm_ops imx_pcm_ops = { static struct snd_pcm_ops imx_pcm_ops = {
.open = snd_imx_open, .open = snd_imx_open,
.close = snd_imx_close, .close = snd_dmaengine_pcm_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_imx_pcm_hw_params, .hw_params = snd_imx_pcm_hw_params,
.trigger = snd_dmaengine_pcm_trigger, .trigger = snd_dmaengine_pcm_trigger,
......
...@@ -13,18 +13,31 @@ ...@@ -13,18 +13,31 @@
#ifndef _IMX_PCM_H #ifndef _IMX_PCM_H
#define _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 * Do not change this as the FIQ handler depends on this size
*/ */
#define IMX_SSI_DMABUF_SIZE (64 * 1024) #define IMX_SSI_DMABUF_SIZE (64 * 1024)
struct imx_pcm_dma_params { struct imx_pcm_dma_params {
int dma;
unsigned long dma_addr; unsigned long dma_addr;
int burstsize; int burstsize;
bool shared_peripheral; /* The peripheral is on SPBA bus */ struct imx_dma_data dma_data;
}; };
static inline void
imx_pcm_dma_params_init_data(struct imx_pcm_dma_params *params,
int dma, bool shared)
{
params->dma_data.dma_request = dma;
params->dma_data.priority = DMA_PRIO_HIGH;
if (shared)
params->dma_data.peripheral_type = IMX_DMATYPE_SSI_SP;
else
params->dma_data.peripheral_type = IMX_DMATYPE_SSI;
}
int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma); struct vm_area_struct *vma);
int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); int imx_pcm_new(struct snd_soc_pcm_runtime *rtd);
......
...@@ -577,12 +577,16 @@ static int imx_ssi_probe(struct platform_device *pdev) ...@@ -577,12 +577,16 @@ static int imx_ssi_probe(struct platform_device *pdev)
ssi->dma_params_rx.burstsize = 4; ssi->dma_params_rx.burstsize = 4;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0");
if (res) if (res) {
ssi->dma_params_tx.dma = res->start; imx_pcm_dma_params_init_data(&ssi->dma_params_tx, res->start,
false);
}
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0");
if (res) if (res) {
ssi->dma_params_rx.dma = res->start; imx_pcm_dma_params_init_data(&ssi->dma_params_rx, res->start,
false);
}
platform_set_drvdata(pdev, ssi); platform_set_drvdata(pdev, ssi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment