Date:2013-03-22 14:12:10 (11 years 6 days ago)
Author:Lars C.
Commit:cb7b9da5ec137ac9c4b0c5c569d09dddec980209
Message:ASoC: ep93xx: Use ep93xx_dma_params instead of ep93xx_pcm_dma_params

Currently the ep93xx_dma_params struct which is passed to the dmaengine driver
is constructed at runtime from the ep93xx_pcm_dma_params that gets passed to the
ep93xx PCM driver from one of the ep93xx DAI drivers. The ep93xx_pcm_dma_params
struct is almost identical to the ep93xx_dma_params struct. The only missing
field is the 'direction' field, which is computed at runtime in the PCM driver
based on the current substream. Since we know in advance which
ep93xx_pcm_dma_params struct is being used for which substream at compile time,
we also already know which direction to use at compile time. So we can easily
replace all instances of ep93xx_pcm_dma_params with their ep93xx_dma_params
counterpart. This allows us to simplify the code in the ep93xx pcm driver quite
a bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Files: sound/soc/cirrus/edb93xx.c (1 diff)
sound/soc/cirrus/ep93xx-ac97.c (3 diffs)
sound/soc/cirrus/ep93xx-i2s.c (4 diffs)
sound/soc/cirrus/ep93xx-pcm.c (3 diffs)
sound/soc/cirrus/ep93xx-pcm.h (1 diff)
sound/soc/cirrus/simone.c (1 diff)
sound/soc/cirrus/snappercl15.c (1 diff)

Change Details

sound/soc/cirrus/edb93xx.c
2727#include <sound/soc.h>
2828#include <asm/mach-types.h>
2929#include <mach/hardware.h>
30#include "ep93xx-pcm.h"
3130
3231static int edb93xx_hw_params(struct snd_pcm_substream *substream,
3332                 struct snd_pcm_hw_params *params)
sound/soc/cirrus/ep93xx-ac97.c
2323#include <sound/soc.h>
2424
2525#include <linux/platform_data/dma-ep93xx.h>
26#include "ep93xx-pcm.h"
2726
2827/*
2928 * Per channel (1-4) registers.
...... 
101100/* currently ALSA only supports a single AC97 device */
102101static struct ep93xx_ac97_info *ep93xx_ac97_info;
103102
104static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_out = {
103static struct ep93xx_dma_data ep93xx_ac97_pcm_out = {
105104    .name = "ac97-pcm-out",
106105    .dma_port = EP93XX_DMA_AAC1,
106    .direction = DMA_MEM_TO_DEV,
107107};
108108
109static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_in = {
109static struct ep93xx_dma_data ep93xx_ac97_pcm_in = {
110110    .name = "ac97-pcm-in",
111111    .dma_port = EP93XX_DMA_AAC1,
112    .direction = DMA_DEV_TO_MEM,
112113};
113114
114115static inline unsigned ep93xx_ac97_read_reg(struct ep93xx_ac97_info *info,
...... 
316317static int ep93xx_ac97_startup(struct snd_pcm_substream *substream,
317318                   struct snd_soc_dai *dai)
318319{
319    struct ep93xx_pcm_dma_params *dma_data;
320    struct ep93xx_dma_data *dma_data;
320321
321322    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
322323        dma_data = &ep93xx_ac97_pcm_out;
sound/soc/cirrus/ep93xx-i2s.c
3030#include <mach/ep93xx-regs.h>
3131#include <linux/platform_data/dma-ep93xx.h>
3232
33#include "ep93xx-pcm.h"
34
3533#define EP93XX_I2S_TXCLKCFG 0x00
3634#define EP93XX_I2S_RXCLKCFG 0x04
3735#define EP93XX_I2S_GLCTRL 0x0C
...... 
6260    struct clk *mclk;
6361    struct clk *sclk;
6462    struct clk *lrclk;
65    struct ep93xx_pcm_dma_params *dma_params;
63    struct ep93xx_dma_data *dma_data;
6664    void __iomem *regs;
6765};
6866
69struct ep93xx_pcm_dma_params ep93xx_i2s_dma_params[] = {
67struct ep93xx_dma_data ep93xx_i2s_dma_data[] = {
7068    [SNDRV_PCM_STREAM_PLAYBACK] = {
7169        .name = "i2s-pcm-out",
7270        .dma_port = EP93XX_DMA_I2S1,
71        .direction = DMA_MEM_TO_DEV,
7372    },
7473    [SNDRV_PCM_STREAM_CAPTURE] = {
7574        .name = "i2s-pcm-in",
7675        .dma_port = EP93XX_DMA_I2S1,
76        .direction = DMA_DEV_TO_MEM,
7777    },
7878};
7979
...... 
147147    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
148148
149149    snd_soc_dai_set_dma_data(cpu_dai, substream,
150                 &info->dma_params[substream->stream]);
150                 &info->dma_data[substream->stream]);
151151    return 0;
152152}
153153
...... 
403403    }
404404
405405    dev_set_drvdata(&pdev->dev, info);
406    info->dma_params = ep93xx_i2s_dma_params;
406    info->dma_data = ep93xx_i2s_dma_data;
407407
408408    err = snd_soc_register_dai(&pdev->dev, &ep93xx_i2s_dai);
409409    if (err)
sound/soc/cirrus/ep93xx-pcm.c
2929#include <mach/hardware.h>
3030#include <mach/ep93xx-regs.h>
3131
32#include "ep93xx-pcm.h"
33
3432static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
3533    .info = (SNDRV_PCM_INFO_MMAP |
3634                   SNDRV_PCM_INFO_MMAP_VALID |
...... 
6866static int ep93xx_pcm_open(struct snd_pcm_substream *substream)
6967{
7068    struct snd_soc_pcm_runtime *rtd = substream->private_data;
71    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
72    struct ep93xx_pcm_dma_params *dma_params;
73    struct ep93xx_dma_data *dma_data;
74    int ret;
7569
7670    snd_soc_set_runtime_hwparams(substream, &ep93xx_pcm_hardware);
7771
78    dma_data = kmalloc(sizeof(*dma_data), GFP_KERNEL);
79    if (!dma_data)
80        return -ENOMEM;
81
82    dma_params = snd_soc_dai_get_dma_data(cpu_dai, substream);
83    dma_data->port = dma_params->dma_port;
84    dma_data->name = dma_params->name;
85    dma_data->direction = snd_pcm_substream_to_dma_direction(substream);
86
87    ret = snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter, dma_data);
88    if (ret) {
89        kfree(dma_data);
90        return ret;
91    }
92
93    snd_dmaengine_pcm_set_data(substream, dma_data);
94
95    return 0;
96}
97
98static int ep93xx_pcm_close(struct snd_pcm_substream *substream)
99{
100    struct dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
101
102    snd_dmaengine_pcm_close(substream);
103    kfree(dma_data);
104    return 0;
72    return snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter,
73            snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
10574}
10675
10776static int ep93xx_pcm_hw_params(struct snd_pcm_substream *substream,
...... 
131100
132101static struct snd_pcm_ops ep93xx_pcm_ops = {
133102    .open = ep93xx_pcm_open,
134    .close = ep93xx_pcm_close,
103    .close = snd_dmaengine_pcm_close,
135104    .ioctl = snd_pcm_lib_ioctl,
136105    .hw_params = ep93xx_pcm_hw_params,
137106    .hw_free = ep93xx_pcm_hw_free,
sound/soc/cirrus/ep93xx-pcm.h
1/*
2 * sound/soc/ep93xx/ep93xx-pcm.h - EP93xx ALSA PCM interface
3 *
4 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
5 * Copyright (C) 2006 Applied Data Systems
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _EP93XX_SND_SOC_PCM_H
13#define _EP93XX_SND_SOC_PCM_H
14
15struct ep93xx_pcm_dma_params {
16    char *name;
17    int dma_port;
18};
19
20#endif /* _EP93XX_SND_SOC_PCM_H */
sound/soc/cirrus/simone.c
2121#include <asm/mach-types.h>
2222#include <mach/hardware.h>
2323
24#include "ep93xx-pcm.h"
25
2624static struct snd_soc_dai_link simone_dai = {
2725    .name = "AC97",
2826    .stream_name = "AC97 HiFi",
sound/soc/cirrus/snappercl15.c
2121#include <mach/hardware.h>
2222
2323#include "../codecs/tlv320aic23.h"
24#include "ep93xx-pcm.h"
2524
2625#define CODEC_CLOCK 5644800
2726

Archive Download the corresponding diff file



interactive