Date:2013-03-22 14:12:12 (9 years 6 months ago)
Author:Lars C.
Commit:b095949cbfd4e0163b7834701737dbbcbd4c8cd2
Message: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>
Files: sound/soc/fsl/fsl_ssi.c (2 diffs)
sound/soc/fsl/imx-pcm-dma.c (2 diffs)
sound/soc/fsl/imx-pcm.h (1 diff)
sound/soc/fsl/imx-ssi.c (1 diff)

Change Details

sound/soc/fsl/fsl_ssi.c
649649    const uint32_t *iprop;
650650    struct resource res;
651651    char name[64];
652    bool shared;
652653
653654    /* SSIs that are not connected on the board should have a
654655     * status = "disabled"
...... 
755756            dev_err(&pdev->dev, "could not get dma events\n");
756757            goto error_clk;
757758        }
758        ssi_private->dma_params_tx.dma = dma_events[0];
759        ssi_private->dma_params_rx.dma = dma_events[1];
760
761        ssi_private->dma_params_tx.shared_peripheral =
762                of_device_is_compatible(of_get_parent(np),
763                            "fsl,spba-bus");
764        ssi_private->dma_params_rx.shared_peripheral =
765                ssi_private->dma_params_tx.shared_peripheral;
759
760        shared = of_device_is_compatible(of_get_parent(np),
761                "fsl,spba-bus");
762
763        imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx,
764            dma_events[0], shared);
765        imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx,
766            dma_events[1], shared);
766767    }
767768
768769    /* Initialize the the device_attribute structure */
sound/soc/fsl/imx-pcm-dma.c
3030#include <sound/soc.h>
3131#include <sound/dmaengine_pcm.h>
3232
33#include <linux/platform_data/dma-imx.h>
34
3533#include "imx-pcm.h"
3634
3735static bool filter(struct dma_chan *chan, void *param)
...... 
10199{
102100    struct snd_soc_pcm_runtime *rtd = substream->private_data;
103101    struct imx_pcm_dma_params *dma_params;
104    struct imx_dma_data *dma_data;
105    int ret;
106102
107103    snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
108104
109105    dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
110106
111    dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL);
112    if (!dma_data)
113        return -ENOMEM;
114
115    dma_data->peripheral_type = dma_params->shared_peripheral ?
116                    IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI;
117    dma_data->priority = DMA_PRIO_HIGH;
118    dma_data->dma_request = dma_params->dma;
119
120    ret = snd_dmaengine_pcm_open(substream, filter, dma_data);
121    if (ret) {
122        kfree(dma_data);
123        return ret;
124    }
125
126    snd_dmaengine_pcm_set_data(substream, dma_data);
127
128    return 0;
129}
130
131static int snd_imx_close(struct snd_pcm_substream *substream)
132{
133    struct imx_dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
134
135    snd_dmaengine_pcm_close(substream);
136    kfree(dma_data);
137
138    return 0;
107    return snd_dmaengine_pcm_open(substream, filter, &dma_params->dma_data);
139108}
140109
141110static struct snd_pcm_ops imx_pcm_ops = {
142111    .open = snd_imx_open,
143    .close = snd_imx_close,
112    .close = snd_dmaengine_pcm_close,
144113    .ioctl = snd_pcm_lib_ioctl,
145114    .hw_params = snd_imx_pcm_hw_params,
146115    .trigger = snd_dmaengine_pcm_trigger,
sound/soc/fsl/imx-pcm.h
1313#ifndef _IMX_PCM_H
1414#define _IMX_PCM_H
1515
16#include <linux/platform_data/dma-imx.h>
17
1618/*
1719 * Do not change this as the FIQ handler depends on this size
1820 */
1921#define IMX_SSI_DMABUF_SIZE (64 * 1024)
2022
2123struct imx_pcm_dma_params {
22    int dma;
2324    unsigned long dma_addr;
2425    int burstsize;
25    bool shared_peripheral; /* The peripheral is on SPBA bus */
26    struct imx_dma_data dma_data;
2627};
2728
29static inline void
30imx_pcm_dma_params_init_data(struct imx_pcm_dma_params *params,
31    int dma, bool shared)
32{
33    params->dma_data.dma_request = dma;
34    params->dma_data.priority = DMA_PRIO_HIGH;
35    if (shared)
36        params->dma_data.peripheral_type = IMX_DMATYPE_SSI_SP;
37    else
38        params->dma_data.peripheral_type = IMX_DMATYPE_SSI;
39}
40
2841int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,
2942             struct vm_area_struct *vma);
3043int imx_pcm_new(struct snd_soc_pcm_runtime *rtd);
sound/soc/fsl/imx-ssi.c
582582    ssi->dma_params_rx.burstsize = 4;
583583
584584    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0");
585    if (res)
586        ssi->dma_params_tx.dma = res->start;
585    if (res) {
586        imx_pcm_dma_params_init_data(&ssi->dma_params_tx, res->start,
587            false);
588    }
587589
588590    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0");
589    if (res)
590        ssi->dma_params_rx.dma = res->start;
591    if (res) {
592        imx_pcm_dma_params_init_data(&ssi->dma_params_rx, res->start,
593            false);
594    }
591595
592596    platform_set_drvdata(pdev, ssi);
593597

Archive Download the corresponding diff file



interactive