Commit 453807f3 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Reviewed-by: default avatarRyan Mallon <rmallon@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 5fe668a1
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include "ep93xx-pcm.h"
static int edb93xx_hw_params(struct snd_pcm_substream *substream, static int edb93xx_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <linux/platform_data/dma-ep93xx.h> #include <linux/platform_data/dma-ep93xx.h>
#include "ep93xx-pcm.h"
/* /*
* Per channel (1-4) registers. * Per channel (1-4) registers.
...@@ -101,14 +100,16 @@ struct ep93xx_ac97_info { ...@@ -101,14 +100,16 @@ struct ep93xx_ac97_info {
/* currently ALSA only supports a single AC97 device */ /* currently ALSA only supports a single AC97 device */
static struct ep93xx_ac97_info *ep93xx_ac97_info; static struct ep93xx_ac97_info *ep93xx_ac97_info;
static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_out = { static struct ep93xx_dma_data ep93xx_ac97_pcm_out = {
.name = "ac97-pcm-out", .name = "ac97-pcm-out",
.dma_port = EP93XX_DMA_AAC1, .dma_port = EP93XX_DMA_AAC1,
.direction = DMA_MEM_TO_DEV,
}; };
static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_in = { static struct ep93xx_dma_data ep93xx_ac97_pcm_in = {
.name = "ac97-pcm-in", .name = "ac97-pcm-in",
.dma_port = EP93XX_DMA_AAC1, .dma_port = EP93XX_DMA_AAC1,
.direction = DMA_DEV_TO_MEM,
}; };
static inline unsigned ep93xx_ac97_read_reg(struct ep93xx_ac97_info *info, static inline unsigned ep93xx_ac97_read_reg(struct ep93xx_ac97_info *info,
...@@ -316,7 +317,7 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream, ...@@ -316,7 +317,7 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream,
static int ep93xx_ac97_startup(struct snd_pcm_substream *substream, static int ep93xx_ac97_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct ep93xx_pcm_dma_params *dma_data; struct ep93xx_dma_data *dma_data;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
dma_data = &ep93xx_ac97_pcm_out; dma_data = &ep93xx_ac97_pcm_out;
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <mach/ep93xx-regs.h> #include <mach/ep93xx-regs.h>
#include <linux/platform_data/dma-ep93xx.h> #include <linux/platform_data/dma-ep93xx.h>
#include "ep93xx-pcm.h"
#define EP93XX_I2S_TXCLKCFG 0x00 #define EP93XX_I2S_TXCLKCFG 0x00
#define EP93XX_I2S_RXCLKCFG 0x04 #define EP93XX_I2S_RXCLKCFG 0x04
#define EP93XX_I2S_GLCTRL 0x0C #define EP93XX_I2S_GLCTRL 0x0C
...@@ -62,18 +60,20 @@ struct ep93xx_i2s_info { ...@@ -62,18 +60,20 @@ struct ep93xx_i2s_info {
struct clk *mclk; struct clk *mclk;
struct clk *sclk; struct clk *sclk;
struct clk *lrclk; struct clk *lrclk;
struct ep93xx_pcm_dma_params *dma_params; struct ep93xx_dma_data *dma_data;
void __iomem *regs; void __iomem *regs;
}; };
struct ep93xx_pcm_dma_params ep93xx_i2s_dma_params[] = { struct ep93xx_dma_data ep93xx_i2s_dma_data[] = {
[SNDRV_PCM_STREAM_PLAYBACK] = { [SNDRV_PCM_STREAM_PLAYBACK] = {
.name = "i2s-pcm-out", .name = "i2s-pcm-out",
.dma_port = EP93XX_DMA_I2S1, .dma_port = EP93XX_DMA_I2S1,
.direction = DMA_MEM_TO_DEV,
}, },
[SNDRV_PCM_STREAM_CAPTURE] = { [SNDRV_PCM_STREAM_CAPTURE] = {
.name = "i2s-pcm-in", .name = "i2s-pcm-in",
.dma_port = EP93XX_DMA_I2S1, .dma_port = EP93XX_DMA_I2S1,
.direction = DMA_DEV_TO_MEM,
}, },
}; };
...@@ -147,7 +147,7 @@ static int ep93xx_i2s_startup(struct snd_pcm_substream *substream, ...@@ -147,7 +147,7 @@ static int ep93xx_i2s_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
snd_soc_dai_set_dma_data(cpu_dai, substream, snd_soc_dai_set_dma_data(cpu_dai, substream,
&info->dma_params[substream->stream]); &info->dma_data[substream->stream]);
return 0; return 0;
} }
...@@ -403,7 +403,7 @@ static int ep93xx_i2s_probe(struct platform_device *pdev) ...@@ -403,7 +403,7 @@ static int ep93xx_i2s_probe(struct platform_device *pdev)
} }
dev_set_drvdata(&pdev->dev, info); dev_set_drvdata(&pdev->dev, info);
info->dma_params = ep93xx_i2s_dma_params; info->dma_data = ep93xx_i2s_dma_data;
err = snd_soc_register_dai(&pdev->dev, &ep93xx_i2s_dai); err = snd_soc_register_dai(&pdev->dev, &ep93xx_i2s_dai);
if (err) if (err)
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <mach/hardware.h> #include <mach/hardware.h>
#include <mach/ep93xx-regs.h> #include <mach/ep93xx-regs.h>
#include "ep93xx-pcm.h"
static const struct snd_pcm_hardware ep93xx_pcm_hardware = { static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
.info = (SNDRV_PCM_INFO_MMAP | .info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_MMAP_VALID |
...@@ -68,40 +66,11 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) ...@@ -68,40 +66,11 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
static int ep93xx_pcm_open(struct snd_pcm_substream *substream) static int ep93xx_pcm_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 snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct ep93xx_pcm_dma_params *dma_params;
struct ep93xx_dma_data *dma_data;
int ret;
snd_soc_set_runtime_hwparams(substream, &ep93xx_pcm_hardware); snd_soc_set_runtime_hwparams(substream, &ep93xx_pcm_hardware);
dma_data = kmalloc(sizeof(*dma_data), GFP_KERNEL); return snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter,
if (!dma_data) snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
return -ENOMEM;
dma_params = snd_soc_dai_get_dma_data(cpu_dai, substream);
dma_data->port = dma_params->dma_port;
dma_data->name = dma_params->name;
dma_data->direction = snd_pcm_substream_to_dma_direction(substream);
ret = snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter, dma_data);
if (ret) {
kfree(dma_data);
return ret;
}
snd_dmaengine_pcm_set_data(substream, dma_data);
return 0;
}
static int ep93xx_pcm_close(struct snd_pcm_substream *substream)
{
struct dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
snd_dmaengine_pcm_close(substream);
kfree(dma_data);
return 0;
} }
static int ep93xx_pcm_hw_params(struct snd_pcm_substream *substream, static int ep93xx_pcm_hw_params(struct snd_pcm_substream *substream,
...@@ -131,7 +100,7 @@ static int ep93xx_pcm_mmap(struct snd_pcm_substream *substream, ...@@ -131,7 +100,7 @@ static int ep93xx_pcm_mmap(struct snd_pcm_substream *substream,
static struct snd_pcm_ops ep93xx_pcm_ops = { static struct snd_pcm_ops ep93xx_pcm_ops = {
.open = ep93xx_pcm_open, .open = ep93xx_pcm_open,
.close = ep93xx_pcm_close, .close = snd_dmaengine_pcm_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = ep93xx_pcm_hw_params, .hw_params = ep93xx_pcm_hw_params,
.hw_free = ep93xx_pcm_hw_free, .hw_free = ep93xx_pcm_hw_free,
......
/*
* sound/soc/ep93xx/ep93xx-pcm.h - EP93xx ALSA PCM interface
*
* Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
* Copyright (C) 2006 Applied Data Systems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _EP93XX_SND_SOC_PCM_H
#define _EP93XX_SND_SOC_PCM_H
struct ep93xx_pcm_dma_params {
char *name;
int dma_port;
};
#endif /* _EP93XX_SND_SOC_PCM_H */
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include "ep93xx-pcm.h"
static struct snd_soc_dai_link simone_dai = { static struct snd_soc_dai_link simone_dai = {
.name = "AC97", .name = "AC97",
.stream_name = "AC97 HiFi", .stream_name = "AC97 HiFi",
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <mach/hardware.h> #include <mach/hardware.h>
#include "../codecs/tlv320aic23.h" #include "../codecs/tlv320aic23.h"
#include "ep93xx-pcm.h"
#define CODEC_CLOCK 5644800 #define CODEC_CLOCK 5644800
......
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