Date:2013-04-03 11:06:05 (9 years 5 months ago)
Author:Lars C.
Commit:f82953d88f4d343247624593226af59819a7ee14
Message:ASoC: omap: Use common DAI DMA data

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

For omap-dmic and omap-mcpdm also move the DMA data from a global variable to
the driver state struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Files: sound/soc/omap/am3517evm.c (1 diff)
sound/soc/omap/ams-delta.c (1 diff)
sound/soc/omap/mcbsp.c (2 diffs)
sound/soc/omap/mcbsp.h (2 diffs)
sound/soc/omap/n810.c (1 diff)
sound/soc/omap/omap-abe-twl6040.c (1 diff)
sound/soc/omap/omap-dmic.c (7 diffs)
sound/soc/omap/omap-hdmi.c (5 diffs)
sound/soc/omap/omap-mcbsp.c (3 diffs)
sound/soc/omap/omap-mcpdm.c (6 diffs)
sound/soc/omap/omap-pcm.c (4 diffs)
sound/soc/omap/omap-pcm.h (1 diff)
sound/soc/omap/omap-twl4030.c (1 diff)
sound/soc/omap/omap3pandora.c (1 diff)
sound/soc/omap/osk5912.c (1 diff)
sound/soc/omap/rx51.c (1 diff)

Change Details

sound/soc/omap/am3517evm.c
2828#include <linux/platform_data/asoc-ti-mcbsp.h>
2929
3030#include "omap-mcbsp.h"
31#include "omap-pcm.h"
3231
3332#include "../codecs/tlv320aic23.h"
3433
sound/soc/omap/ams-delta.c
3636#include <linux/platform_data/asoc-ti-mcbsp.h>
3737
3838#include "omap-mcbsp.h"
39#include "omap-pcm.h"
4039#include "../codecs/cx20442.h"
4140
4241
sound/soc/omap/mcbsp.c
10181018        return -ENODEV;
10191019    }
10201020    /* RX DMA request number, and port address configuration */
1021    mcbsp->dma_data[1].name = "Audio Capture";
1022    mcbsp->dma_data[1].dma_req = res->start;
1023    mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
1021    mcbsp->dma_req[1] = res->start;
1022    mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1];
1023    mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
1024    mcbsp->dma_data[1].maxburst = 4;
10241025
10251026    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
10261027    if (!res) {
...... 
10281029        return -ENODEV;
10291030    }
10301031    /* TX DMA request number, and port address configuration */
1031    mcbsp->dma_data[0].name = "Audio Playback";
1032    mcbsp->dma_data[0].dma_req = res->start;
1033    mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
1032    mcbsp->dma_req[0] = res->start;
1033    mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
1034    mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
1035    mcbsp->dma_data[0].maxburst = 4;
10341036
10351037    mcbsp->fclk = clk_get(&pdev->dev, "fck");
10361038    if (IS_ERR(mcbsp->fclk)) {
sound/soc/omap/mcbsp.h
2424#ifndef __ASOC_MCBSP_H
2525#define __ASOC_MCBSP_H
2626
27#include "omap-pcm.h"
28
2927#ifdef CONFIG_ARCH_OMAP1
3028#define mcbsp_omap1() 1
3129#else
3230#define mcbsp_omap1() 0
3331#endif
3432
33#include <sound/dmaengine_pcm.h>
34
3535/* McBSP register numbers. Register address offset = num * reg_step */
3636enum {
3737    /* Common registers */
...... 
312312    struct omap_mcbsp_platform_data *pdata;
313313    struct omap_mcbsp_st_data *st_data;
314314    struct omap_mcbsp_reg_cfg cfg_regs;
315    struct omap_pcm_dma_data dma_data[2];
315    struct snd_dmaengine_dai_dma_data dma_data[2];
316    unsigned int dma_req[2];
316317    int dma_op_mode;
317318    u16 max_tx_thres;
318319    u16 max_rx_thres;
sound/soc/omap/n810.c
3434#include <linux/platform_data/asoc-ti-mcbsp.h>
3535
3636#include "omap-mcbsp.h"
37#include "omap-pcm.h"
3837
3938#define N810_HEADSET_AMP_GPIO 10
4039#define N810_SPEAKER_AMP_GPIO 101
sound/soc/omap/omap-abe-twl6040.c
3434
3535#include "omap-dmic.h"
3636#include "omap-mcpdm.h"
37#include "omap-pcm.h"
3837#include "../codecs/twl6040.h"
3938
4039struct abe_twl6040 {
sound/soc/omap/omap-dmic.c
3939#include <sound/pcm_params.h>
4040#include <sound/initval.h>
4141#include <sound/soc.h>
42#include <sound/dmaengine_pcm.h>
4243
43#include "omap-pcm.h"
4444#include "omap-dmic.h"
4545
4646struct omap_dmic {
...... 
5555    u32 ch_enabled;
5656    bool active;
5757    struct mutex mutex;
58};
5958
60/*
61 * Stream DMA parameters
62 */
63static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
64    .name = "DMIC capture",
59    struct snd_dmaengine_dai_dma_data dma_data;
60    unsigned int dma_req;
6561};
6662
6763static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
...... 
118114
119115    mutex_unlock(&dmic->mutex);
120116
121    snd_soc_dai_set_dma_data(dai, substream, &omap_dmic_dai_dma_params);
117    snd_soc_dai_set_dma_data(dai, substream, &dmic->dma_data);
122118    return ret;
123119}
124120
...... 
203199                    struct snd_soc_dai *dai)
204200{
205201    struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
206    struct omap_pcm_dma_data *dma_data;
202    struct snd_dmaengine_dai_dma_data *dma_data;
207203    int channels;
208204
209205    dmic->clk_div = omap_dmic_select_divider(dmic, params_rate(params));
...... 
230226
231227    /* packet size is threshold * channels */
232228    dma_data = snd_soc_dai_get_dma_data(dai, substream);
233    dma_data->packet_size = dmic->threshold * channels;
229    dma_data->maxburst = dmic->threshold * channels;
234230
235231    return 0;
236232}
...... 
476472        ret = -ENODEV;
477473        goto err_put_clk;
478474    }
479    omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG;
475    dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
480476
481477    res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
482478    if (!res) {
...... 
484480        ret = -ENODEV;
485481        goto err_put_clk;
486482    }
487    omap_dmic_dai_dma_params.dma_req = res->start;
483
484    dmic->dma_req = res->start;
485    dmic->dma_data.filter_data = &dmic->dma_req;
488486
489487    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
490488    if (!res) {
sound/soc/omap/omap-hdmi.c
3232#include <sound/soc.h>
3333#include <sound/asound.h>
3434#include <sound/asoundef.h>
35#include <sound/dmaengine_pcm.h>
3536#include <video/omapdss.h>
3637
37#include "omap-pcm.h"
3838#include "omap-hdmi.h"
3939
4040#define DRV_NAME "omap-hdmi-audio-dai"
4141
4242struct hdmi_priv {
43    struct omap_pcm_dma_data dma_params;
43    struct snd_dmaengine_dai_dma_data dma_data;
44    unsigned int dma_req;
4445    struct omap_dss_audio dss_audio;
4546    struct snd_aes_iec958 iec;
4647    struct snd_cea_861_aud_if cea;
...... 
6869        return -ENODEV;
6970    }
7071
71    snd_soc_dai_set_dma_data(dai, substream, &priv->dma_params);
72    snd_soc_dai_set_dma_data(dai, substream, &priv->dma_data);
7273
7374    return 0;
7475}
...... 
8889    struct hdmi_priv *priv = snd_soc_dai_get_drvdata(dai);
8990    struct snd_aes_iec958 *iec = &priv->iec;
9091    struct snd_cea_861_aud_if *cea = &priv->cea;
91    struct omap_pcm_dma_data *dma_data;
9292    int err = 0;
9393
94    dma_data = snd_soc_dai_get_dma_data(dai, substream);
95
9694    switch (params_format(params)) {
9795    case SNDRV_PCM_FORMAT_S16_LE:
98        dma_data->packet_size = 16;
96        priv->dma_data.maxburst = 16;
9997        break;
10098    case SNDRV_PCM_FORMAT_S24_LE:
101        dma_data->packet_size = 32;
99        priv->dma_data.maxburst = 32;
102100        break;
103101    default:
104102        dev_err(dai->dev, "format not supported!\n");
105103        return -EINVAL;
106104    }
107105
108    dma_data->data_type = 32;
109
110106    /*
111107     * fill the IEC-60958 channel status word
112108     */
...... 
283279        return -ENODEV;
284280    }
285281
286    hdmi_data->dma_params.port_addr = hdmi_rsrc->start
287        + OMAP_HDMI_AUDIO_DMA_PORT;
282    hdmi_data->dma_data.addr = hdmi_rsrc->start + OMAP_HDMI_AUDIO_DMA_PORT;
288283
289284    hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0);
290285    if (!hdmi_rsrc) {
...... 
292287        return -ENODEV;
293288    }
294289
295    hdmi_data->dma_params.dma_req = hdmi_rsrc->start;
296    hdmi_data->dma_params.name = "HDMI playback";
290    hdmi_data->dma_req = hdmi_rsrc->start;
291    hdmi_data->dma_data.filter_data = &hdmi_data->dma_req;
292    hdmi_data->dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
297293
298294    /*
299295     * TODO: We assume that there is only one DSS HDMI device. Future
sound/soc/omap/omap-mcbsp.c
3333#include <sound/pcm_params.h>
3434#include <sound/initval.h>
3535#include <sound/soc.h>
36#include <sound/dmaengine_pcm.h>
3637
3738#include <linux/platform_data/asoc-ti-mcbsp.h>
3839#include "mcbsp.h"
3940#include "omap-mcbsp.h"
40#include "omap-pcm.h"
4141
4242#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000)
4343
...... 
224224{
225225    struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
226226    struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
227    struct omap_pcm_dma_data *dma_data;
227    struct snd_dmaengine_dai_dma_data *dma_data;
228228    int wlen, channels, wpf;
229229    int pkt_size = 0;
230230    unsigned int format, div, framesize, master;
...... 
276276        omap_mcbsp_set_threshold(substream, pkt_size);
277277    }
278278
279    dma_data->packet_size = pkt_size;
279    dma_data->maxburst = pkt_size;
280280
281281    if (mcbsp->configured) {
282282        /* McBSP already configured by another stream */
sound/soc/omap/omap-mcpdm.c
3939#include <sound/pcm.h>
4040#include <sound/pcm_params.h>
4141#include <sound/soc.h>
42#include <sound/dmaengine_pcm.h>
4243
4344#include "omap-mcpdm.h"
44#include "omap-pcm.h"
4545
4646struct mcpdm_link_config {
4747    u32 link_mask; /* channel mask for the direction */
...... 
6464
6565    /* McPDM needs to be restarted due to runtime reconfiguration */
6666    bool restart;
67
68    struct snd_dmaengine_dai_dma_data dma_data[2];
69    unsigned int dma_req[2];
6770};
6871
6972/*
7073 * Stream DMA parameters
7174 */
72static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
73    {
74        .name = "Audio playback",
75    },
76    {
77        .name = "Audio capture",
78    },
79};
8075
8176static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val)
8277{
...... 
272267    mutex_unlock(&mcpdm->mutex);
273268
274269    snd_soc_dai_set_dma_data(dai, substream,
275                 &omap_mcpdm_dai_dma_params[substream->stream]);
270                 &mcpdm->dma_data[substream->stream]);
276271
277272    return 0;
278273}
...... 
302297{
303298    struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
304299    int stream = substream->stream;
305    struct omap_pcm_dma_data *dma_data;
300    struct snd_dmaengine_dai_dma_data *dma_data;
306301    u32 threshold;
307302    int channels;
308303    int link_mask = 0;
...... 
342337        if (!mcpdm->config[!stream].link_mask)
343338            mcpdm->config[!stream].link_mask = 0x3;
344339
345        dma_data->packet_size =
340        dma_data->maxburst =
346341                (MCPDM_DN_THRES_MAX - threshold) * channels;
347342    } else {
348343        /* If playback is not running assume a stereo stream to come */
349344        if (!mcpdm->config[!stream].link_mask)
350345            mcpdm->config[!stream].link_mask = (0x3 << 3);
351346
352        dma_data->packet_size = threshold * channels;
347        dma_data->maxburst = threshold * channels;
353348    }
354349
355350    /* Check if we need to restart McPDM with this stream */
...... 
475470    if (res == NULL)
476471        return -ENOMEM;
477472
478    omap_mcpdm_dai_dma_params[0].port_addr = res->start + MCPDM_REG_DN_DATA;
479    omap_mcpdm_dai_dma_params[1].port_addr = res->start + MCPDM_REG_UP_DATA;
473    mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA;
474    mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
480475
481476    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link");
482477    if (!res)
483478        return -ENODEV;
484479
485    omap_mcpdm_dai_dma_params[0].dma_req = res->start;
480    mcpdm->dma_req[0] = res->start;
481    mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0];
486482
487483    res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
488484    if (!res)
489485        return -ENODEV;
490486
491    omap_mcpdm_dai_dma_params[1].dma_req = res->start;
487    mcpdm->dma_req[1] = res->start;
488    mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1];
492489
493490    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
494491    if (res == NULL)
sound/soc/omap/omap-pcm.c
3232#include <sound/dmaengine_pcm.h>
3333#include <sound/soc.h>
3434
35#include "omap-pcm.h"
36
3735#ifdef CONFIG_ARCH_OMAP1
3836#define pcm_omap1510() cpu_is_omap1510()
3937#else
...... 
5654    .buffer_bytes_max = 128 * 1024,
5755};
5856
59static int omap_pcm_get_dma_buswidth(int num_bits)
60{
61    int buswidth;
62
63    switch (num_bits) {
64    case 16:
65        buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
66        break;
67    case 32:
68        buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
69        break;
70    default:
71        buswidth = -EINVAL;
72        break;
73    }
74    return buswidth;
75}
76
77
7857/* this may get called several times by oss emulation */
7958static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
8059                  struct snd_pcm_hw_params *params)
...... 
10584    if (err)
10685        return err;
10786
108    /* Override the *_dma addr_width if requested by the DAI driver */
109    if (dma_data->data_type) {
110        int buswidth = omap_pcm_get_dma_buswidth(dma_data->data_type);
111
112        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
113            config.dst_addr_width = buswidth;
114        else
115            config.src_addr_width = buswidth;
116    }
117
118    config.src_addr = dma_data->port_addr;
119    config.dst_addr = dma_data->port_addr;
120    config.src_maxburst = dma_data->packet_size;
121    config.dst_maxburst = dma_data->packet_size;
87    snd_dmaengine_pcm_set_config_from_dai_data(substream,
88            snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
89            &config);
12290
12391    return dmaengine_slave_config(chan, &config);
12492}
...... 
144112static int omap_pcm_open(struct snd_pcm_substream *substream)
145113{
146114    struct snd_soc_pcm_runtime *rtd = substream->private_data;
147    struct omap_pcm_dma_data *dma_data;
115    struct snd_dmaengine_dai_dma_data *dma_data;
148116
149117    snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
150118
151119    dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
152120
153121    return snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
154                      &dma_data->dma_req);
122                      dma_data->filter_data);
155123}
156124
157125static int omap_pcm_mmap(struct snd_pcm_substream *substream,
sound/soc/omap/omap-pcm.h
1/*
2 * omap-pcm.h
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
7 * Peter Ujfalusi <peter.ujfalusi@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __OMAP_PCM_H__
26#define __OMAP_PCM_H__
27
28struct snd_pcm_substream;
29
30struct omap_pcm_dma_data {
31    char *name; /* stream identifier */
32    int dma_req; /* DMA request line */
33    unsigned long port_addr; /* transmit/receive register */
34    int data_type; /* 8, 16, 32 (bits) or 0 to let omap-pcm
35                     * to decide the sDMA data type */
36    int packet_size; /* packet size only in PACKET mode */
37};
38
39#endif
sound/soc/omap/omap-twl4030.c
4343#include <sound/jack.h>
4444
4545#include "omap-mcbsp.h"
46#include "omap-pcm.h"
4746
4847struct omap_twl4030 {
4948    int jack_detect; /* board can detect jack events */
sound/soc/omap/omap3pandora.c
3434#include <linux/platform_data/asoc-ti-mcbsp.h>
3535
3636#include "omap-mcbsp.h"
37#include "omap-pcm.h"
3837
3938#define OMAP3_PANDORA_DAC_POWER_GPIO 118
4039#define OMAP3_PANDORA_AMP_POWER_GPIO 14
sound/soc/omap/osk5912.c
3333#include <linux/platform_data/asoc-ti-mcbsp.h>
3434
3535#include "omap-mcbsp.h"
36#include "omap-pcm.h"
3736#include "../codecs/tlv320aic23.h"
3837
3938#define CODEC_CLOCK 12000000
sound/soc/omap/rx51.c
3737#include <asm/mach-types.h>
3838
3939#include "omap-mcbsp.h"
40#include "omap-pcm.h"
4140
4241#define RX51_TVOUT_SEL_GPIO 40
4342#define RX51_JACK_DETECT_GPIO 177

Archive Download the corresponding diff file



interactive