mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
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>
This commit is contained in:
parent
5fe668a1d2
commit
453807f300
@ -27,7 +27,6 @@
|
||||
#include <sound/soc.h>
|
||||
#include <asm/mach-types.h>
|
||||
#include <mach/hardware.h>
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
static int edb93xx_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <sound/soc.h>
|
||||
|
||||
#include <linux/platform_data/dma-ep93xx.h>
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
/*
|
||||
* Per channel (1-4) registers.
|
||||
@ -101,14 +100,16 @@ struct ep93xx_ac97_info {
|
||||
/* currently ALSA only supports a single AC97 device */
|
||||
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",
|
||||
.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",
|
||||
.dma_port = EP93XX_DMA_AAC1,
|
||||
.direction = DMA_DEV_TO_MEM,
|
||||
};
|
||||
|
||||
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,
|
||||
static int ep93xx_ac97_startup(struct snd_pcm_substream *substream,
|
||||
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)
|
||||
dma_data = &ep93xx_ac97_pcm_out;
|
||||
|
@ -30,8 +30,6 @@
|
||||
#include <mach/ep93xx-regs.h>
|
||||
#include <linux/platform_data/dma-ep93xx.h>
|
||||
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
#define EP93XX_I2S_TXCLKCFG 0x00
|
||||
#define EP93XX_I2S_RXCLKCFG 0x04
|
||||
#define EP93XX_I2S_GLCTRL 0x0C
|
||||
@ -62,18 +60,20 @@ struct ep93xx_i2s_info {
|
||||
struct clk *mclk;
|
||||
struct clk *sclk;
|
||||
struct clk *lrclk;
|
||||
struct ep93xx_pcm_dma_params *dma_params;
|
||||
struct ep93xx_dma_data *dma_data;
|
||||
void __iomem *regs;
|
||||
};
|
||||
|
||||
struct ep93xx_pcm_dma_params ep93xx_i2s_dma_params[] = {
|
||||
struct ep93xx_dma_data ep93xx_i2s_dma_data[] = {
|
||||
[SNDRV_PCM_STREAM_PLAYBACK] = {
|
||||
.name = "i2s-pcm-out",
|
||||
.dma_port = EP93XX_DMA_I2S1,
|
||||
.direction = DMA_MEM_TO_DEV,
|
||||
},
|
||||
[SNDRV_PCM_STREAM_CAPTURE] = {
|
||||
.name = "i2s-pcm-in",
|
||||
.dma_port = EP93XX_DMA_I2S1,
|
||||
.direction = DMA_DEV_TO_MEM,
|
||||
},
|
||||
};
|
||||
|
||||
@ -147,7 +147,7 @@ static int ep93xx_i2s_startup(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
|
||||
snd_soc_dai_set_dma_data(cpu_dai, substream,
|
||||
&info->dma_params[substream->stream]);
|
||||
&info->dma_data[substream->stream]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ static int ep93xx_i2s_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
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);
|
||||
if (err)
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include <mach/hardware.h>
|
||||
#include <mach/ep93xx-regs.h>
|
||||
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
|
||||
.info = (SNDRV_PCM_INFO_MMAP |
|
||||
SNDRV_PCM_INFO_MMAP_VALID |
|
||||
@ -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)
|
||||
{
|
||||
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);
|
||||
|
||||
dma_data = kmalloc(sizeof(*dma_data), GFP_KERNEL);
|
||||
if (!dma_data)
|
||||
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;
|
||||
return snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter,
|
||||
snd_soc_dai_get_dma_data(rtd->cpu_dai, 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,
|
||||
|
||||
static struct snd_pcm_ops ep93xx_pcm_ops = {
|
||||
.open = ep93xx_pcm_open,
|
||||
.close = ep93xx_pcm_close,
|
||||
.close = snd_dmaengine_pcm_close,
|
||||
.ioctl = snd_pcm_lib_ioctl,
|
||||
.hw_params = ep93xx_pcm_hw_params,
|
||||
.hw_free = ep93xx_pcm_hw_free,
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* 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 @@
|
||||
#include <asm/mach-types.h>
|
||||
#include <mach/hardware.h>
|
||||
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
static struct snd_soc_dai_link simone_dai = {
|
||||
.name = "AC97",
|
||||
.stream_name = "AC97 HiFi",
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <mach/hardware.h>
|
||||
|
||||
#include "../codecs/tlv320aic23.h"
|
||||
#include "ep93xx-pcm.h"
|
||||
|
||||
#define CODEC_CLOCK 5644800
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user