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: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Lars-Peter Clausen 2013-03-22 14:12:12 +01:00 коммит произвёл Mark Brown
Родитель ac581e60df
Коммит 312bb4f626
4 изменённых файлов: 33 добавлений и 46 удалений

Просмотреть файл

@ -649,6 +649,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"
@ -755,14 +756,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),
shared = 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;
imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx,
dma_events[0], shared);
imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx,
dma_events[1], shared);
}
/* Initialize the the device_attribute structure */

Просмотреть файл

@ -30,8 +30,6 @@
#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)
@ -101,46 +99,17 @@ 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, &dma_params->dma_data);
}
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,

Просмотреть файл

@ -13,18 +13,31 @@
#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 */
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,
struct vm_area_struct *vma);
int imx_pcm_new(struct snd_soc_pcm_runtime *rtd);

Просмотреть файл

@ -577,12 +577,16 @@ static int imx_ssi_probe(struct platform_device *pdev)
ssi->dma_params_rx.burstsize = 4;
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->dma_params_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->dma_params_rx, res->start,
false);
}
platform_set_drvdata(pdev, ssi);