[alsa-devel] [PATCH 0/8] More dmaengine PCM cleanups
Hi,
The first few patches in this series are a few unrelated cleanups to different dmaengine PCM drivers and one fix for a small compile error I introduced in the last dmaengine PCM cleanup series.
The last four patches introduce a common DAI DMA data struct, which will be used by tegra, omap and fsl/imx. Having a common DAI DMA data struct allows us to factor out some redundant code from these drivers into a common helper function in the dmaengine PCM library.
This should hopefully be the last set of cleanups before the generic dmaengine PCM driver.
- Lars
Lars-Peter Clausen (8): ASoC: ep93xx_pcm: Fix compile error ASoC: tegra: Don't claim to support PCM pause and resume ASoC: ux500_pcm: Use the same snd_pcm_hardware for playback and capture ASoC: dmaengine_pcm: Setup device_fc in snd_hwparams_to_dma_slave_config ASoC: dmaengine-pcm: Add a common DAI DMA data struct ASoC: tegra: Use common DAI DMA data struct ASoC: fsl: Use common DAI DMA data struct ASoC: omap: Use common DAI DMA data
include/sound/dmaengine_pcm.h | 24 ++++++++++++++++++ sound/soc/atmel/atmel-pcm-dma.c | 2 -- sound/soc/cirrus/ep93xx-i2s.c | 4 +-- sound/soc/fsl/fsl_ssi.c | 23 ++++++++++++------ sound/soc/fsl/imx-pcm-dma.c | 25 ++++++------------- sound/soc/fsl/imx-pcm-fiq.c | 4 +-- sound/soc/fsl/imx-pcm.h | 16 ++++-------- sound/soc/fsl/imx-ssi.c | 21 +++++++++------- sound/soc/fsl/imx-ssi.h | 7 ++++-- sound/soc/omap/am3517evm.c | 1 - sound/soc/omap/ams-delta.c | 1 - sound/soc/omap/mcbsp.c | 14 ++++++----- sound/soc/omap/mcbsp.h | 7 +++--- sound/soc/omap/n810.c | 1 - sound/soc/omap/omap-abe-twl6040.c | 1 - sound/soc/omap/omap-dmic.c | 22 ++++++++--------- sound/soc/omap/omap-hdmi.c | 24 ++++++++---------- sound/soc/omap/omap-mcbsp.c | 6 ++--- sound/soc/omap/omap-mcpdm.c | 31 +++++++++++------------- sound/soc/omap/omap-pcm.c | 42 ++++---------------------------- sound/soc/omap/omap-pcm.h | 39 ------------------------------ sound/soc/omap/omap-twl4030.c | 1 - sound/soc/omap/omap3pandora.c | 1 - sound/soc/omap/osk5912.c | 1 - sound/soc/omap/rx51.c | 1 - sound/soc/soc-dmaengine-pcm.c | 39 ++++++++++++++++++++++++++++++ sound/soc/tegra/tegra20_ac97.c | 13 +++++----- sound/soc/tegra/tegra20_ac97.h | 4 +-- sound/soc/tegra/tegra20_i2s.c | 13 +++++----- sound/soc/tegra/tegra20_i2s.h | 4 +-- sound/soc/tegra/tegra20_spdif.c | 7 +++--- sound/soc/tegra/tegra20_spdif.h | 4 +-- sound/soc/tegra/tegra30_ahub.c | 8 +++--- sound/soc/tegra/tegra30_ahub.h | 8 +++--- sound/soc/tegra/tegra30_i2s.c | 13 +++++----- sound/soc/tegra/tegra30_i2s.h | 4 +-- sound/soc/tegra/tegra_pcm.c | 40 +++--------------------------- sound/soc/tegra/tegra_pcm.h | 7 ------ sound/soc/ux500/ux500_pcm.c | 51 ++++++++++++--------------------------- sound/soc/ux500/ux500_pcm.h | 14 ----------- 40 files changed, 226 insertions(+), 322 deletions(-) delete mode 100644 sound/soc/omap/omap-pcm.h
Commit 453807f3 ("ASoC: ep93xx: Use ep93xx_dma_params instead of ep93xx_pcm_dma_params") introduced a small compile error by not updating the name of the 'dma_port' field to 'port'. This patch fixes it.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/cirrus/ep93xx-i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c index 3f2ad9c..5c1102e 100644 --- a/sound/soc/cirrus/ep93xx-i2s.c +++ b/sound/soc/cirrus/ep93xx-i2s.c @@ -67,12 +67,12 @@ struct ep93xx_i2s_info { struct ep93xx_dma_data ep93xx_i2s_dma_data[] = { [SNDRV_PCM_STREAM_PLAYBACK] = { .name = "i2s-pcm-out", - .dma_port = EP93XX_DMA_I2S1, + .port = EP93XX_DMA_I2S1, .direction = DMA_MEM_TO_DEV, }, [SNDRV_PCM_STREAM_CAPTURE] = { .name = "i2s-pcm-in", - .dma_port = EP93XX_DMA_I2S1, + .port = EP93XX_DMA_I2S1, .direction = DMA_DEV_TO_MEM, }, };
On Wed, Apr 03, 2013 at 11:00:00AM +0200, Lars-Peter Clausen wrote:
Commit 453807f3 ("ASoC: ep93xx: Use ep93xx_dma_params instead of ep93xx_pcm_dma_params") introduced a small compile error by not updating the name of the 'dma_port' field to 'port'. This patch fixes it.
Applied, thanks.
The tegra dmaengine driver does not support pausing and resuming a DMA stream. The tegra PCM driver still claims to support pause and resume though and implements them by stopping and restarting the stream. This is not what an application using pause/resume would expect. Usually applications have support for working around PCMs which do not support suspend and resume, so don't set the SNDRV_PCM_INFO_PAUSE and SNDRV_PCM_INFO_RESUME flags for the tegra PCM and use the default snd_dmaengine_pcm_trigger callback.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/tegra/tegra_pcm.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index e67af0b..117cccc 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -43,8 +43,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_INTERLEAVED, .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels_min = 2, @@ -121,26 +119,6 @@ static int tegra_pcm_hw_free(struct snd_pcm_substream *substream) return 0; }
-static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - return snd_dmaengine_pcm_trigger(substream, - SNDRV_PCM_TRIGGER_START); - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - return snd_dmaengine_pcm_trigger(substream, - SNDRV_PCM_TRIGGER_STOP); - default: - return -EINVAL; - } - return 0; -} - static int tegra_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { @@ -158,7 +136,7 @@ static struct snd_pcm_ops tegra_pcm_ops = { .ioctl = snd_pcm_lib_ioctl, .hw_params = tegra_pcm_hw_params, .hw_free = tegra_pcm_hw_free, - .trigger = tegra_pcm_trigger, + .trigger = snd_dmaengine_pcm_trigger, .pointer = snd_dmaengine_pcm_pointer, .mmap = tegra_pcm_mmap, };
On 04/03/2013 03:00 AM, Lars-Peter Clausen wrote:
The tegra dmaengine driver does not support pausing and resuming a DMA stream. The tegra PCM driver still claims to support pause and resume though and
Tegra really should be capitalized in free-form text, since it's a name, but I suppose that's a nit.
implements them by stopping and restarting the stream. This is not what an application using pause/resume would expect. Usually applications have support for working around PCMs which do not support suspend and resume, so don't set the SNDRV_PCM_INFO_PAUSE and SNDRV_PCM_INFO_RESUME flags for the tegra PCM and use the default snd_dmaengine_pcm_trigger callback.
Since Laxman posted the same patch, Acked-by: Stephen Warren swarren@nvidia.com
The snd_pcm_hardware structs for playback and capture in the ux500 PCM are identical, so remove one of them and use the same snd_pcm_hardware struct for both playback and capture. Also move the defines used to initialize the snd_pcm_hardware fields from ux500_pcm.h to ux500_pcm.c since that's the only place where they are used.
Also drop the assignment of the snd_pcm_hardware struct to runtime->hw since that is what the call to snd_soc_set_runtime_hwparams() right above it already does, so the second assignment is redundant.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/ux500/ux500_pcm.c | 51 +++++++++++++-------------------------------- sound/soc/ux500/ux500_pcm.h | 14 ------------- 2 files changed, 15 insertions(+), 50 deletions(-)
diff --git a/sound/soc/ux500/ux500_pcm.c b/sound/soc/ux500/ux500_pcm.c index 1ab36fa..09b5364 100644 --- a/sound/soc/ux500/ux500_pcm.c +++ b/sound/soc/ux500/ux500_pcm.c @@ -28,28 +28,19 @@ #include "ux500_msp_i2s.h" #include "ux500_pcm.h"
-static struct snd_pcm_hardware ux500_pcm_hw_playback = { - .info = SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_RESUME | - SNDRV_PCM_INFO_PAUSE, - .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_U16_LE | - SNDRV_PCM_FMTBIT_S16_BE | - SNDRV_PCM_FMTBIT_U16_BE, - .rates = SNDRV_PCM_RATE_KNOT, - .rate_min = UX500_PLATFORM_MIN_RATE_PLAYBACK, - .rate_max = UX500_PLATFORM_MAX_RATE_PLAYBACK, - .channels_min = UX500_PLATFORM_MIN_CHANNELS, - .channels_max = UX500_PLATFORM_MAX_CHANNELS, - .buffer_bytes_max = UX500_PLATFORM_BUFFER_BYTES_MAX, - .period_bytes_min = UX500_PLATFORM_PERIODS_BYTES_MIN, - .period_bytes_max = UX500_PLATFORM_PERIODS_BYTES_MAX, - .periods_min = UX500_PLATFORM_PERIODS_MIN, - .periods_max = UX500_PLATFORM_PERIODS_MAX, -}; +#define UX500_PLATFORM_MIN_RATE 8000 +#define UX500_PLATFORM_MAX_RATE 48000 + +#define UX500_PLATFORM_MIN_CHANNELS 1 +#define UX500_PLATFORM_MAX_CHANNELS 8 + +#define UX500_PLATFORM_PERIODS_BYTES_MIN 128 +#define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE) +#define UX500_PLATFORM_PERIODS_MIN 2 +#define UX500_PLATFORM_PERIODS_MAX 48 +#define UX500_PLATFORM_BUFFER_BYTES_MAX (2048 * PAGE_SIZE)
-static struct snd_pcm_hardware ux500_pcm_hw_capture = { +static struct snd_pcm_hardware ux500_pcm_hw = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_RESUME | @@ -59,8 +50,8 @@ static struct snd_pcm_hardware ux500_pcm_hw_capture = { SNDRV_PCM_FMTBIT_S16_BE | SNDRV_PCM_FMTBIT_U16_BE, .rates = SNDRV_PCM_RATE_KNOT, - .rate_min = UX500_PLATFORM_MIN_RATE_CAPTURE, - .rate_max = UX500_PLATFORM_MAX_RATE_CAPTURE, + .rate_min = UX500_PLATFORM_MIN_RATE, + .rate_max = UX500_PLATFORM_MAX_RATE, .channels_min = UX500_PLATFORM_MIN_CHANNELS, .channels_max = UX500_PLATFORM_MAX_CHANNELS, .buffer_bytes_max = UX500_PLATFORM_BUFFER_BYTES_MAX, @@ -90,8 +81,6 @@ static void ux500_pcm_dma_hw_free(struct device *dev,
static int ux500_pcm_open(struct snd_pcm_substream *substream) { - int stream_id = substream->pstr->stream; - struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *dai = rtd->cpu_dai; struct device *dev = dai->dev; @@ -104,17 +93,7 @@ static int ux500_pcm_open(struct snd_pcm_substream *substream) snd_pcm_stream_str(substream));
dev_dbg(dev, "%s: Set runtime hwparams.\n", __func__); - if (stream_id == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_set_runtime_hwparams(substream, - &ux500_pcm_hw_playback); - else - snd_soc_set_runtime_hwparams(substream, - &ux500_pcm_hw_capture); - - dev_dbg(dev, "%s: Set hw-struct for %s.\n", __func__, - snd_pcm_stream_str(substream)); - runtime->hw = (stream_id == SNDRV_PCM_STREAM_PLAYBACK) ? - ux500_pcm_hw_playback : ux500_pcm_hw_capture; + snd_soc_set_runtime_hwparams(substream, &ux500_pcm_hw);
mem_data_width = STEDMA40_HALFWORD_WIDTH;
diff --git a/sound/soc/ux500/ux500_pcm.h b/sound/soc/ux500/ux500_pcm.h index 76d3444..d76e1af 100644 --- a/sound/soc/ux500/ux500_pcm.h +++ b/sound/soc/ux500/ux500_pcm.h @@ -18,20 +18,6 @@
#include <linux/workqueue.h>
-#define UX500_PLATFORM_MIN_RATE_PLAYBACK 8000 -#define UX500_PLATFORM_MAX_RATE_PLAYBACK 48000 -#define UX500_PLATFORM_MIN_RATE_CAPTURE 8000 -#define UX500_PLATFORM_MAX_RATE_CAPTURE 48000 - -#define UX500_PLATFORM_MIN_CHANNELS 1 -#define UX500_PLATFORM_MAX_CHANNELS 8 - -#define UX500_PLATFORM_PERIODS_BYTES_MIN 128 -#define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE) -#define UX500_PLATFORM_PERIODS_MIN 2 -#define UX500_PLATFORM_PERIODS_MAX 48 -#define UX500_PLATFORM_BUFFER_BYTES_MAX (2048 * PAGE_SIZE) - int ux500_pcm_register_platform(struct platform_device *pdev); int ux500_pcm_unregister_platform(struct platform_device *pdev);
Usually device_fc should be set to false for audio DMAs. Initialize it in a common place so drivers don't have to do this manually.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/atmel/atmel-pcm-dma.c | 2 -- sound/soc/fsl/imx-pcm-dma.c | 2 -- sound/soc/soc-dmaengine-pcm.c | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index b8570e3..bb07989 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -129,8 +129,6 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, slave_config.src_maxburst = 1; }
- slave_config.device_fc = false; - dma_chan = snd_dmaengine_pcm_get_chan(substream); if (dmaengine_slave_config(dma_chan, &slave_config)) { pr_err("atmel-pcm: failed to configure dma channel\n"); diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 6832c49..64af573 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -57,8 +57,6 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) return ret;
- slave_config.device_fc = false; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { slave_config.dst_addr = dma_params->dma_addr; slave_config.dst_maxburst = dma_params->burstsize; diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index e8b1215..7c24ded 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -89,6 +89,8 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, slave_config->src_addr_width = buswidth; }
+ slave_config->device_fc = false; + return 0; } EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
On 04/03/2013 11:02 AM, Lars-Peter Clausen :
Usually device_fc should be set to false for audio DMAs. Initialize it in a common place so drivers don't have to do this manually.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
Seems okay:
Acked-by: Nicolas Ferre nicolas.ferre@atmel.com
sound/soc/atmel/atmel-pcm-dma.c | 2 -- sound/soc/fsl/imx-pcm-dma.c | 2 -- sound/soc/soc-dmaengine-pcm.c | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index b8570e3..bb07989 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -129,8 +129,6 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, slave_config.src_maxburst = 1; }
- slave_config.device_fc = false;
- dma_chan = snd_dmaengine_pcm_get_chan(substream); if (dmaengine_slave_config(dma_chan, &slave_config)) { pr_err("atmel-pcm: failed to configure dma channel\n");
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 6832c49..64af573 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -57,8 +57,6 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) return ret;
- slave_config.device_fc = false;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { slave_config.dst_addr = dma_params->dma_addr; slave_config.dst_maxburst = dma_params->burstsize;
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index e8b1215..7c24ded 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -89,6 +89,8 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, slave_config->src_addr_width = buswidth; }
- slave_config->device_fc = false;
- return 0;
} EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
On 04/03/2013 11:02 AM, Lars-Peter Clausen wrote:
Usually device_fc should be set to false for audio DMAs. Initialize it in a common place so drivers don't have to do this manually.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
Tested-by: Peter Ujfalusi peter.ujfalusi@ti.com
sound/soc/atmel/atmel-pcm-dma.c | 2 -- sound/soc/fsl/imx-pcm-dma.c | 2 -- sound/soc/soc-dmaengine-pcm.c | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index b8570e3..bb07989 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -129,8 +129,6 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, slave_config.src_maxburst = 1; }
- slave_config.device_fc = false;
- dma_chan = snd_dmaengine_pcm_get_chan(substream); if (dmaengine_slave_config(dma_chan, &slave_config)) { pr_err("atmel-pcm: failed to configure dma channel\n");
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 6832c49..64af573 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -57,8 +57,6 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) return ret;
- slave_config.device_fc = false;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { slave_config.dst_addr = dma_params->dma_addr; slave_config.dst_maxburst = dma_params->burstsize;
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index e8b1215..7c24ded 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -89,6 +89,8 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, slave_config->src_addr_width = buswidth; }
- slave_config->device_fc = false;
- return 0;
} EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
On Wed, Apr 03, 2013 at 11:02:56AM +0200, Lars-Peter Clausen wrote:
Usually device_fc should be set to false for audio DMAs. Initialize it in a common place so drivers don't have to do this manually.
Applied, thanks.
On Wed, Apr 03, 2013 at 11:02:55AM +0200, Lars-Peter Clausen wrote:
The snd_pcm_hardware structs for playback and capture in the ux500 PCM are identical, so remove one of them and use the same snd_pcm_hardware struct for both playback and capture. Also move the defines used to initialize the snd_pcm_hardware fields from ux500_pcm.h to ux500_pcm.c since that's the only place where they are used.
Applied, thanks.
This patch adds a common DMA data struct which can be used by DAI drivers to communicate their DMA configuration requirements to the DMA pcm driver. Having a common data structure for this allows us to implement common functions on top of them, which can be used by multiple platforms.
This patch also introduces a new function to initialize certain fields of a dma_slave_config struct from the common DAI DMA data struct.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- include/sound/dmaengine_pcm.h | 24 ++++++++++++++++++++++++ sound/soc/soc-dmaengine-pcm.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index f8a7031..9562042 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -44,4 +44,28 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
+/** + * struct snd_dmaengine_dai_dma_data - DAI DMA configuration data + * @addr: Address of the DAI data source or destination register. + * @addr_width: Width of the DAI data source or destination register. + * @maxburst: Maximum number of words(note: words, as in units of the + * src_addr_width member, not bytes) that can be send to or received from the + * DAI in one burst. + * @slave_id: Slave requester id for the DMA channel. + * @filter_data: Custom DMA channel filter data, this will usually be used when + * requesting the DMA channel. + */ +struct snd_dmaengine_dai_dma_data { + dma_addr_t addr; + enum dma_slave_buswidth addr_width; + u32 maxburst; + unsigned int slave_id; + void *filter_data; +}; + +void snd_dmaengine_pcm_set_config_from_dai_data( + const struct snd_pcm_substream *substream, + const struct snd_dmaengine_dai_dma_data *dma_data, + struct dma_slave_config *config); + #endif diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index 7c24ded..a9a300a 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -95,6 +95,43 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
+/** + * snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config + * using DAI DMA data. + * @substream: PCM substream + * @dma_data: DAI DMA data + * @slave_config: DMA slave configuration + * + * Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and + * slave_id fields of the DMA slave config from the same fields of the DAI DMA + * data struct. The src and dst fields will be initialized depending on the + * direction of the substream. If the substream is a playback stream the dst + * fields will be initialized, if it is a capture stream the src fields will be + * initialized. The {dst,src}_addr_width field will only be initialized if the + * addr_width field of the DAI DMA data struct is not equal to + * DMA_SLAVE_BUSWIDTH_UNDEFINED. + */ +void snd_dmaengine_pcm_set_config_from_dai_data( + const struct snd_pcm_substream *substream, + const struct snd_dmaengine_dai_dma_data *dma_data, + struct dma_slave_config *slave_config) +{ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + slave_config->dst_addr = dma_data->addr; + slave_config->dst_maxburst = dma_data->maxburst; + if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) + slave_config->dst_addr_width = dma_data->addr_width; + } else { + slave_config->src_addr = dma_data->addr; + slave_config->src_maxburst = dma_data->maxburst; + if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED) + slave_config->src_addr_width = dma_data->addr_width; + } + + slave_config->slave_id = dma_data->slave_id; +} +EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data); + static void dmaengine_pcm_dma_complete(void *arg) { struct snd_pcm_substream *substream = arg;
Use the common DAI DMA data struct for tegra, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/tegra/tegra20_ac97.c | 13 +++++++------ sound/soc/tegra/tegra20_ac97.h | 4 ++-- sound/soc/tegra/tegra20_i2s.c | 13 +++++++------ sound/soc/tegra/tegra20_i2s.h | 4 ++-- sound/soc/tegra/tegra20_spdif.c | 7 ++++--- sound/soc/tegra/tegra20_spdif.h | 4 ++-- sound/soc/tegra/tegra30_ahub.c | 8 ++++---- sound/soc/tegra/tegra30_ahub.h | 8 ++++---- sound/soc/tegra/tegra30_i2s.c | 13 +++++++------ sound/soc/tegra/tegra30_i2s.h | 4 ++-- sound/soc/tegra/tegra_pcm.c | 16 +++------------- sound/soc/tegra/tegra_pcm.h | 7 ------- 12 files changed, 44 insertions(+), 57 deletions(-)
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c index b5cee92..2f70ea7 100644 --- a/sound/soc/tegra/tegra20_ac97.c +++ b/sound/soc/tegra/tegra20_ac97.c @@ -35,6 +35,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "tegra_asoc_utils.h" #include "tegra20_ac97.h" @@ -393,14 +394,14 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev) }
ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1; - ac97->capture_dma_data.wrap = 4; - ac97->capture_dma_data.width = 32; - ac97->capture_dma_data.req_sel = of_dma[1]; + ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + ac97->capture_dma_data.maxburst = 4; + ac97->capture_dma_data.slave_id = of_dma[1];
ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1; - ac97->playback_dma_data.wrap = 4; - ac97->playback_dma_data.width = 32; - ac97->playback_dma_data.req_sel = of_dma[1]; + ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + ac97->capture_dma_data.maxburst = 4; + ac97->capture_dma_data.slave_id = of_dma[0];
ret = snd_soc_register_component(&pdev->dev, &tegra20_ac97_component, &tegra20_ac97_dai, 1); diff --git a/sound/soc/tegra/tegra20_ac97.h b/sound/soc/tegra/tegra20_ac97.h index dddc682..4acb3aa 100644 --- a/sound/soc/tegra/tegra20_ac97.h +++ b/sound/soc/tegra/tegra20_ac97.h @@ -85,8 +85,8 @@
struct tegra20_ac97 { struct clk *clk_ac97; - struct tegra_pcm_dma_params capture_dma_data; - struct tegra_pcm_dma_params playback_dma_data; + struct snd_dmaengine_dai_dma_data capture_dma_data; + struct snd_dmaengine_dai_dma_data playback_dma_data; struct regmap *regmap; int reset_gpio; int sync_gpio; diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c index 8b1ceb8..52af7f6 100644 --- a/sound/soc/tegra/tegra20_i2s.c +++ b/sound/soc/tegra/tegra20_i2s.c @@ -41,6 +41,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "tegra20_i2s.h"
@@ -407,14 +408,14 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev) }
i2s->capture_dma_data.addr = mem->start + TEGRA20_I2S_FIFO2; - i2s->capture_dma_data.wrap = 4; - i2s->capture_dma_data.width = 32; - i2s->capture_dma_data.req_sel = dma_ch; + i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + i2s->capture_dma_data.maxburst = 4; + i2s->capture_dma_data.slave_id = dma_ch;
i2s->playback_dma_data.addr = mem->start + TEGRA20_I2S_FIFO1; - i2s->playback_dma_data.wrap = 4; - i2s->playback_dma_data.width = 32; - i2s->playback_dma_data.req_sel = dma_ch; + i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + i2s->playback_dma_data.maxburst = 4; + i2s->playback_dma_data.slave_id = dma_ch;
pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { diff --git a/sound/soc/tegra/tegra20_i2s.h b/sound/soc/tegra/tegra20_i2s.h index 7299587..fa6c29c 100644 --- a/sound/soc/tegra/tegra20_i2s.h +++ b/sound/soc/tegra/tegra20_i2s.h @@ -155,8 +155,8 @@ struct tegra20_i2s { struct snd_soc_dai_driver dai; struct clk *clk_i2s; - struct tegra_pcm_dma_params capture_dma_data; - struct tegra_pcm_dma_params playback_dma_data; + struct snd_dmaengine_dai_dma_data capture_dma_data; + struct snd_dmaengine_dai_dma_data playback_dma_data; struct regmap *regmap; };
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c index 6fce0be..5eaa12c 100644 --- a/sound/soc/tegra/tegra20_spdif.c +++ b/sound/soc/tegra/tegra20_spdif.c @@ -32,6 +32,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "tegra20_spdif.h"
@@ -322,9 +323,9 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev) }
spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; - spdif->playback_dma_data.wrap = 4; - spdif->playback_dma_data.width = 32; - spdif->playback_dma_data.req_sel = dmareq->start; + spdif->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + spdif->capture_dma_data.maxburst = 4; + spdif->playback_dma_data.slave_id = dmareq->start;
pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { diff --git a/sound/soc/tegra/tegra20_spdif.h b/sound/soc/tegra/tegra20_spdif.h index b48d699..85a9aef 100644 --- a/sound/soc/tegra/tegra20_spdif.h +++ b/sound/soc/tegra/tegra20_spdif.h @@ -462,8 +462,8 @@
struct tegra20_spdif { struct clk *clk_spdif_out; - struct tegra_pcm_dma_params capture_dma_data; - struct tegra_pcm_dma_params playback_dma_data; + struct snd_dmaengine_dai_dma_data capture_dma_data; + struct snd_dmaengine_dai_dma_data playback_dma_data; struct regmap *regmap; };
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 4405c3a..23e592f 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -95,8 +95,8 @@ static int tegra30_ahub_runtime_resume(struct device *dev) }
int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, - unsigned long *fiforeg, - unsigned long *reqsel) + dma_addr_t *fiforeg, + unsigned int *reqsel) { int channel; u32 reg, val; @@ -178,8 +178,8 @@ int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif) EXPORT_SYMBOL_GPL(tegra30_ahub_free_rx_fifo);
int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, - unsigned long *fiforeg, - unsigned long *reqsel) + dma_addr_t *fiforeg, + unsigned int *reqsel) { int channel; u32 reg, val; diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index 7189be9..09766cd 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h @@ -451,15 +451,15 @@ enum tegra30_ahub_rxcif { };
extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, - unsigned long *fiforeg, - unsigned long *reqsel); + dma_addr_t *fiforeg, + unsigned int *reqsel); extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif); extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif); extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif);
extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, - unsigned long *fiforeg, - unsigned long *reqsel); + dma_addr_t *fiforeg, + unsigned int *reqsel); extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif); extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif); extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif); diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index f138d8f..31d092d 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -38,6 +38,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "tegra30_ahub.h" #include "tegra30_i2s.h" @@ -80,17 +81,17 @@ static int tegra30_i2s_startup(struct snd_pcm_substream *substream, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif, &i2s->playback_dma_data.addr, - &i2s->playback_dma_data.req_sel); - i2s->playback_dma_data.wrap = 4; - i2s->playback_dma_data.width = 32; + &i2s->playback_dma_data.slave_id); + i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + i2s->playback_dma_data.maxburst = 4; tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif, i2s->playback_fifo_cif); } else { ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif, &i2s->capture_dma_data.addr, - &i2s->capture_dma_data.req_sel); - i2s->capture_dma_data.wrap = 4; - i2s->capture_dma_data.width = 32; + &i2s->capture_dma_data.slave_id); + i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + i2s->capture_dma_data.maxburst = 4; tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif, i2s->capture_i2s_cif); } diff --git a/sound/soc/tegra/tegra30_i2s.h b/sound/soc/tegra/tegra30_i2s.h index a294d94..bea23af 100644 --- a/sound/soc/tegra/tegra30_i2s.h +++ b/sound/soc/tegra/tegra30_i2s.h @@ -231,10 +231,10 @@ struct tegra30_i2s { struct clk *clk_i2s; enum tegra30_ahub_txcif capture_i2s_cif; enum tegra30_ahub_rxcif capture_fifo_cif; - struct tegra_pcm_dma_params capture_dma_data; + struct snd_dmaengine_dai_dma_data capture_dma_data; enum tegra30_ahub_rxcif playback_i2s_cif; enum tegra30_ahub_txcif playback_fifo_cif; - struct tegra_pcm_dma_params playback_dma_data; + struct snd_dmaengine_dai_dma_data playback_dma_data; struct regmap *regmap; };
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index 117cccc..6d1c70c 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -79,12 +79,9 @@ static int tegra_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct device *dev = rtd->platform->dev; struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); - struct tegra_pcm_dma_params *dmap; struct dma_slave_config slave_config; int ret;
- dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config); if (ret) { @@ -92,16 +89,9 @@ static int tegra_pcm_hw_params(struct snd_pcm_substream *substream, return ret; }
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - slave_config.dst_addr = dmap->addr; - slave_config.dst_maxburst = 4; - } else { - slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - slave_config.src_addr = dmap->addr; - slave_config.src_maxburst = 4; - } - slave_config.slave_id = dmap->req_sel; + snd_dmaengine_pcm_set_config_from_dai_data(substream, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream), + &slave_config);
ret = dmaengine_slave_config(chan, &slave_config); if (ret < 0) { diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h index bc8b46a..68ad901 100644 --- a/sound/soc/tegra/tegra_pcm.h +++ b/sound/soc/tegra/tegra_pcm.h @@ -31,13 +31,6 @@ #ifndef __TEGRA_PCM_H__ #define __TEGRA_PCM_H__
-struct tegra_pcm_dma_params { - unsigned long addr; - unsigned long wrap; - unsigned long width; - unsigned long req_sel; -}; - int tegra_pcm_platform_register(struct device *dev); void tegra_pcm_platform_unregister(struct device *dev);
On 04/03/2013 03:06 AM, Lars-Peter Clausen wrote:
Use the common DAI DMA data struct for tegra, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Nice. Patches 2, 5, 6, Reviewed-by: Stephen Warren swarren@nvidia.com Tested-by: Stephen Warren swarren@nvidia.com
But one minor question below:
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
@@ -92,16 +89,9 @@ static int tegra_pcm_hw_params(struct snd_pcm_substream *substream,
- snd_dmaengine_pcm_set_config_from_dai_data(substream,
snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
&slave_config);
Would it make sense to have snd_dmaengine_pcm_set_config_from_dai_data() call snd_soc_dai_get_dma_data() internally, to avoid all call-sites from having to do it?
On 04/03/2013 07:08 PM, Stephen Warren wrote:
On 04/03/2013 03:06 AM, Lars-Peter Clausen wrote:
Use the common DAI DMA data struct for tegra, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Nice. Patches 2, 5, 6, Reviewed-by: Stephen Warren swarren@nvidia.com Tested-by: Stephen Warren swarren@nvidia.com
But one minor question below:
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
@@ -92,16 +89,9 @@ static int tegra_pcm_hw_params(struct snd_pcm_substream *substream,
- snd_dmaengine_pcm_set_config_from_dai_data(substream,
snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
&slave_config);
Would it make sense to have snd_dmaengine_pcm_set_config_from_dai_data() call snd_soc_dai_get_dma_data() internally, to avoid all call-sites from having to do it?
Yes, I thought about that as well, but there are some platforms like mmp which we can't switch to using the generic DAI DMA data yet, but may find it useful to be able to use this function. So they'd initialize the dma data struct on the stack and pass it to the function.
- Lars
On Wed, Apr 03, 2013 at 11:06:03AM +0200, Lars-Peter Clausen wrote:
Use the common DAI DMA data struct for tegra, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Applied, thanks.
Use the common DAI DMA data struct for fsl/imx, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/fsl/fsl_ssi.c | 23 +++++++++++++++-------- sound/soc/fsl/imx-pcm-dma.c | 23 ++++++++--------------- sound/soc/fsl/imx-pcm-fiq.c | 4 ++-- sound/soc/fsl/imx-pcm.h | 16 +++++----------- sound/soc/fsl/imx-ssi.c | 21 ++++++++++++--------- sound/soc/fsl/imx-ssi.h | 7 +++++-- 6 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index d02450e..42366d7 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -27,6 +27,7 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "fsl_ssi.h" #include "imx-pcm.h" @@ -122,8 +123,10 @@ struct fsl_ssi_private { bool ssi_on_imx; struct clk *clk; struct platform_device *imx_pcm_pdev; - struct imx_pcm_dma_params dma_params_tx; - struct imx_pcm_dma_params dma_params_rx; + struct snd_dmaengine_dai_dma_data dma_params_tx; + struct snd_dmaengine_dai_dma_data dma_params_rx; + struct imx_dma_data filter_data_tx; + struct imx_dma_data filter_data_rx;
struct { unsigned int rfrc; @@ -742,14 +745,18 @@ static int fsl_ssi_probe(struct platform_device *pdev) * We have burstsize be "fifo_depth - 2" to match the SSI * watermark setting in fsl_ssi_startup(). */ - ssi_private->dma_params_tx.burstsize = + ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2; - ssi_private->dma_params_rx.burstsize = + ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2; - ssi_private->dma_params_tx.dma_addr = + ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0); - ssi_private->dma_params_rx.dma_addr = + ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0); + ssi_private->dma_params_tx.filter_data = + &ssi_private->filter_data_tx; + ssi_private->dma_params_rx.filter_data = + &ssi_private->filter_data_rx; /* * TODO: This is a temporary solution and should be changed * to use generic DMA binding later when the helplers get in. @@ -764,9 +771,9 @@ static int fsl_ssi_probe(struct platform_device *pdev) shared = of_device_is_compatible(of_get_parent(np), "fsl,spba-bus");
- imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx, + imx_pcm_dma_params_init_data(&ssi_private->filter_data_tx, dma_events[0], shared); - imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx, + imx_pcm_dma_params_init_data(&ssi_private->filter_data_rx, dma_events[1], shared); }
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 64af573..ee838c8 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -34,10 +34,12 @@
static bool filter(struct dma_chan *chan, void *param) { + struct snd_dmaengine_dai_dma_data *dma_data = param; + if (!imx_dma_is_general_purpose(chan)) return false;
- chan->private = param; + chan->private = dma_data->filter_data;
return true; } @@ -47,23 +49,16 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); - struct imx_pcm_dma_params *dma_params; struct dma_slave_config slave_config; int ret;
- dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config); if (ret) return ret;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - slave_config.dst_addr = dma_params->dma_addr; - slave_config.dst_maxburst = dma_params->burstsize; - } else { - slave_config.src_addr = dma_params->dma_addr; - slave_config.src_maxburst = dma_params->burstsize; - } + snd_dmaengine_pcm_set_config_from_dai_data(substream, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream), + &slave_config);
ret = dmaengine_slave_config(chan, &slave_config); if (ret) @@ -96,13 +91,11 @@ static struct snd_pcm_hardware snd_imx_hardware = { static int snd_imx_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct imx_pcm_dma_params *dma_params;
snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
- dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - return snd_dmaengine_pcm_open(substream, filter, &dma_params->dma_data); + return snd_dmaengine_pcm_open(substream, filter, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream)); }
static struct snd_pcm_ops imx_pcm_ops = { diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 47228c0..670b96b 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -299,8 +299,8 @@ int imx_pcm_fiq_init(struct platform_device *pdev)
imx_ssi_fiq_base = (unsigned long)ssi->base;
- ssi->dma_params_tx.burstsize = 4; - ssi->dma_params_rx.burstsize = 6; + ssi->dma_params_tx.maxburst = 4; + ssi->dma_params_rx.maxburst = 6;
ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); if (ret) diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 16eaf5a..be9cc64 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h @@ -20,22 +20,16 @@ */ #define IMX_SSI_DMABUF_SIZE (64 * 1024)
-struct imx_pcm_dma_params { - unsigned long dma_addr; - int burstsize; - struct imx_dma_data dma_data; -}; - static inline void -imx_pcm_dma_params_init_data(struct imx_pcm_dma_params *params, +imx_pcm_dma_params_init_data(struct imx_dma_data *dma_data, int dma, bool shared) { - params->dma_data.dma_request = dma; - params->dma_data.priority = DMA_PRIO_HIGH; + dma_data->dma_request = dma; + dma_data->priority = DMA_PRIO_HIGH; if (shared) - params->dma_data.peripheral_type = IMX_DMATYPE_SSI_SP; + dma_data->peripheral_type = IMX_DMATYPE_SSI_SP; else - params->dma_data.peripheral_type = IMX_DMATYPE_SSI; + dma_data->peripheral_type = IMX_DMATYPE_SSI; }
int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 706097f..4ce2d60 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -236,7 +236,7 @@ static int imx_ssi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); - struct imx_pcm_dma_params *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data;
/* Tx/Rx config */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -369,8 +369,8 @@ static int imx_ssi_dai_probe(struct snd_soc_dai *dai)
snd_soc_dai_set_drvdata(dai, ssi);
- val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) | - SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize); + val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.maxburst) | + SSI_SFCSR_RFWM0(ssi->dma_params_rx.maxburst); writel(val, ssi->base + SSI_SFCSR);
return 0; @@ -579,21 +579,24 @@ static int imx_ssi_probe(struct platform_device *pdev)
writel(0x0, ssi->base + SSI_SIER);
- ssi->dma_params_rx.dma_addr = res->start + SSI_SRX0; - ssi->dma_params_tx.dma_addr = res->start + SSI_STX0; + ssi->dma_params_rx.addr = res->start + SSI_SRX0; + ssi->dma_params_tx.addr = res->start + SSI_STX0;
- ssi->dma_params_tx.burstsize = 6; - ssi->dma_params_rx.burstsize = 4; + ssi->dma_params_tx.maxburst = 6; + ssi->dma_params_rx.maxburst = 4; + + ssi->dma_params_tx.filter_data = &ssi->filter_data_tx; + ssi->dma_params_rx.filter_data = &ssi->filter_data_rx;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); if (res) { - imx_pcm_dma_params_init_data(&ssi->dma_params_tx, res->start, + imx_pcm_dma_params_init_data(&ssi->filter_data_tx, res->start, false); }
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); if (res) { - imx_pcm_dma_params_init_data(&ssi->dma_params_rx, res->start, + imx_pcm_dma_params_init_data(&ssi->filter_data_rx, res->start, false); }
diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index dc114bd..bb6b3db 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h @@ -187,6 +187,7 @@
#include <linux/dmaengine.h> #include <linux/platform_data/dma-imx.h> +#include <sound/dmaengine_pcm.h> #include "imx-pcm.h"
struct imx_ssi { @@ -204,8 +205,10 @@ struct imx_ssi { void (*ac97_reset) (struct snd_ac97 *ac97); void (*ac97_warm_reset)(struct snd_ac97 *ac97);
- struct imx_pcm_dma_params dma_params_rx; - struct imx_pcm_dma_params dma_params_tx; + struct snd_dmaengine_dai_dma_data dma_params_rx; + struct snd_dmaengine_dai_dma_data dma_params_tx; + struct imx_dma_data filter_data_tx; + struct imx_dma_data filter_data_rx;
int enabled;
On Wed, Apr 03, 2013 at 11:06:04AM +0200, Lars-Peter Clausen wrote:
Use the common DAI DMA data struct for fsl/imx, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
Sorry for the delay. On imx6q,
Tested-by: Shawn Guo shawn.guo@linaro.org
On Wed, Apr 03, 2013 at 11:06:04AM +0200, Lars-Peter Clausen wrote:
Use the common DAI DMA data struct for fsl/imx, this allows us to use the common helper function to configure the DMA slave config based on the DAI DMA data.
Applied, thanks.
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 --- sound/soc/omap/am3517evm.c | 1 - sound/soc/omap/ams-delta.c | 1 - sound/soc/omap/mcbsp.c | 14 +++++++------ sound/soc/omap/mcbsp.h | 7 ++++--- sound/soc/omap/n810.c | 1 - sound/soc/omap/omap-abe-twl6040.c | 1 - sound/soc/omap/omap-dmic.c | 22 ++++++++++---------- sound/soc/omap/omap-hdmi.c | 24 ++++++++++------------ sound/soc/omap/omap-mcbsp.c | 6 +++--- sound/soc/omap/omap-mcpdm.c | 31 +++++++++++++---------------- sound/soc/omap/omap-pcm.c | 42 +++++---------------------------------- sound/soc/omap/omap-pcm.h | 39 ------------------------------------ sound/soc/omap/omap-twl4030.c | 1 - sound/soc/omap/omap3pandora.c | 1 - sound/soc/omap/osk5912.c | 1 - sound/soc/omap/rx51.c | 1 - 16 files changed, 54 insertions(+), 139 deletions(-) delete mode 100644 sound/soc/omap/omap-pcm.h
diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c index c1900b2..994dcf3 100644 --- a/sound/soc/omap/am3517evm.c +++ b/sound/soc/omap/am3517evm.c @@ -28,7 +28,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#include "../codecs/tlv320aic23.h"
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 2600447..6294464 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -36,7 +36,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h" #include "../codecs/cx20442.h"
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 285c836..eb68c7d 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -1018,9 +1018,10 @@ int omap_mcbsp_init(struct platform_device *pdev) return -ENODEV; } /* RX DMA request number, and port address configuration */ - mcbsp->dma_data[1].name = "Audio Capture"; - mcbsp->dma_data[1].dma_req = res->start; - mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1); + mcbsp->dma_req[1] = res->start; + mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1]; + mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1); + mcbsp->dma_data[1].maxburst = 4;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); if (!res) { @@ -1028,9 +1029,10 @@ int omap_mcbsp_init(struct platform_device *pdev) return -ENODEV; } /* TX DMA request number, and port address configuration */ - mcbsp->dma_data[0].name = "Audio Playback"; - mcbsp->dma_data[0].dma_req = res->start; - mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0); + mcbsp->dma_req[0] = res->start; + mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0]; + mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0); + mcbsp->dma_data[0].maxburst = 4;
mcbsp->fclk = clk_get(&pdev->dev, "fck"); if (IS_ERR(mcbsp->fclk)) { diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index f93e0b0..96d1b08 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -24,14 +24,14 @@ #ifndef __ASOC_MCBSP_H #define __ASOC_MCBSP_H
-#include "omap-pcm.h" - #ifdef CONFIG_ARCH_OMAP1 #define mcbsp_omap1() 1 #else #define mcbsp_omap1() 0 #endif
+#include <sound/dmaengine_pcm.h> + /* McBSP register numbers. Register address offset = num * reg_step */ enum { /* Common registers */ @@ -312,7 +312,8 @@ struct omap_mcbsp { struct omap_mcbsp_platform_data *pdata; struct omap_mcbsp_st_data *st_data; struct omap_mcbsp_reg_cfg cfg_regs; - struct omap_pcm_dma_data dma_data[2]; + struct snd_dmaengine_dai_dma_data dma_data[2]; + unsigned int dma_req[2]; int dma_op_mode; u16 max_tx_thres; u16 max_rx_thres; diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index ee7cd53..5e8d640 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -34,7 +34,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define N810_HEADSET_AMP_GPIO 10 #define N810_SPEAKER_AMP_GPIO 101 diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index e7d93fa..70cd5c7 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -34,7 +34,6 @@
#include "omap-dmic.h" #include "omap-mcpdm.h" -#include "omap-pcm.h" #include "../codecs/twl6040.h"
struct abe_twl6040 { diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 37f4539..2ad0370 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -39,8 +39,8 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
-#include "omap-pcm.h" #include "omap-dmic.h"
struct omap_dmic { @@ -55,13 +55,9 @@ struct omap_dmic { u32 ch_enabled; bool active; struct mutex mutex; -};
-/* - * Stream DMA parameters - */ -static struct omap_pcm_dma_data omap_dmic_dai_dma_params = { - .name = "DMIC capture", + struct snd_dmaengine_dai_dma_data dma_data; + unsigned int dma_req; };
static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) @@ -118,7 +114,7 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream,
mutex_unlock(&dmic->mutex);
- snd_soc_dai_set_dma_data(dai, substream, &omap_dmic_dai_dma_params); + snd_soc_dai_set_dma_data(dai, substream, &dmic->dma_data); return ret; }
@@ -203,7 +199,7 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); - struct omap_pcm_dma_data *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data; int channels;
dmic->clk_div = omap_dmic_select_divider(dmic, params_rate(params)); @@ -230,7 +226,7 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream,
/* packet size is threshold * channels */ dma_data = snd_soc_dai_get_dma_data(dai, substream); - dma_data->packet_size = dmic->threshold * channels; + dma_data->maxburst = dmic->threshold * channels;
return 0; } @@ -480,7 +476,7 @@ static int asoc_dmic_probe(struct platform_device *pdev) ret = -ENODEV; goto err_put_clk; } - omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG; + dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { @@ -488,7 +484,9 @@ static int asoc_dmic_probe(struct platform_device *pdev) ret = -ENODEV; goto err_put_clk; } - omap_dmic_dai_dma_params.dma_req = res->start; + + dmic->dma_req = res->start; + dmic->dma_data.filter_data = &dmic->dma_req;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (!res) { diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c index 7e120cc..ced3b88 100644 --- a/sound/soc/omap/omap-hdmi.c +++ b/sound/soc/omap/omap-hdmi.c @@ -32,15 +32,16 @@ #include <sound/soc.h> #include <sound/asound.h> #include <sound/asoundef.h> +#include <sound/dmaengine_pcm.h> #include <video/omapdss.h>
-#include "omap-pcm.h" #include "omap-hdmi.h"
#define DRV_NAME "omap-hdmi-audio-dai"
struct hdmi_priv { - struct omap_pcm_dma_data dma_params; + struct snd_dmaengine_dai_dma_data dma_data; + unsigned int dma_req; struct omap_dss_audio dss_audio; struct snd_aes_iec958 iec; struct snd_cea_861_aud_if cea; @@ -68,7 +69,7 @@ static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream, return -ENODEV; }
- snd_soc_dai_set_dma_data(dai, substream, &priv->dma_params); + snd_soc_dai_set_dma_data(dai, substream, &priv->dma_data);
return 0; } @@ -88,25 +89,20 @@ static int omap_hdmi_dai_hw_params(struct snd_pcm_substream *substream, struct hdmi_priv *priv = snd_soc_dai_get_drvdata(dai); struct snd_aes_iec958 *iec = &priv->iec; struct snd_cea_861_aud_if *cea = &priv->cea; - struct omap_pcm_dma_data *dma_data; int err = 0;
- dma_data = snd_soc_dai_get_dma_data(dai, substream); - switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: - dma_data->packet_size = 16; + priv->dma_data.maxburst = 16; break; case SNDRV_PCM_FORMAT_S24_LE: - dma_data->packet_size = 32; + priv->dma_data.maxburst = 32; break; default: dev_err(dai->dev, "format not supported!\n"); return -EINVAL; }
- dma_data->data_type = 32; - /* * fill the IEC-60958 channel status word */ @@ -287,8 +283,7 @@ static int omap_hdmi_probe(struct platform_device *pdev) return -ENODEV; }
- hdmi_data->dma_params.port_addr = hdmi_rsrc->start - + OMAP_HDMI_AUDIO_DMA_PORT; + hdmi_data->dma_data.addr = hdmi_rsrc->start + OMAP_HDMI_AUDIO_DMA_PORT;
hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!hdmi_rsrc) { @@ -296,8 +291,9 @@ static int omap_hdmi_probe(struct platform_device *pdev) return -ENODEV; }
- hdmi_data->dma_params.dma_req = hdmi_rsrc->start; - hdmi_data->dma_params.name = "HDMI playback"; + hdmi_data->dma_req = hdmi_rsrc->start; + hdmi_data->dma_data.filter_data = &hdmi_data->dma_req; + hdmi_data->dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
/* * TODO: We assume that there is only one DSS HDMI device. Future diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 1de4213..eadbfb6 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -33,11 +33,11 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include <linux/platform_data/asoc-ti-mcbsp.h> #include "mcbsp.h" #include "omap-mcbsp.h" -#include "omap-pcm.h"
#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000)
@@ -224,7 +224,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; - struct omap_pcm_dma_data *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data; int wlen, channels, wpf; int pkt_size = 0; unsigned int format, div, framesize, master; @@ -276,7 +276,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, omap_mcbsp_set_threshold(substream, pkt_size); }
- dma_data->packet_size = pkt_size; + dma_data->maxburst = pkt_size;
if (mcbsp->configured) { /* McBSP already configured by another stream */ diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 06ab334..eb05c7e 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -39,9 +39,9 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "omap-mcpdm.h" -#include "omap-pcm.h"
struct mcpdm_link_config { u32 link_mask; /* channel mask for the direction */ @@ -64,19 +64,14 @@ struct omap_mcpdm {
/* McPDM needs to be restarted due to runtime reconfiguration */ bool restart; + + struct snd_dmaengine_dai_dma_data dma_data[2]; + unsigned int dma_req[2]; };
/* * Stream DMA parameters */ -static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = { - { - .name = "Audio playback", - }, - { - .name = "Audio capture", - }, -};
static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) { @@ -272,7 +267,7 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, mutex_unlock(&mcpdm->mutex);
snd_soc_dai_set_dma_data(dai, substream, - &omap_mcpdm_dai_dma_params[substream->stream]); + &mcpdm->dma_data[substream->stream]);
return 0; } @@ -302,7 +297,7 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); int stream = substream->stream; - struct omap_pcm_dma_data *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data; u32 threshold; int channels; int link_mask = 0; @@ -342,14 +337,14 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = 0x3;
- dma_data->packet_size = + dma_data->maxburst = (MCPDM_DN_THRES_MAX - threshold) * channels; } else { /* If playback is not running assume a stereo stream to come */ if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = (0x3 << 3);
- dma_data->packet_size = threshold * channels; + dma_data->maxburst = threshold * channels; }
/* Check if we need to restart McPDM with this stream */ @@ -479,20 +474,22 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) if (res == NULL) return -ENOMEM;
- omap_mcpdm_dai_dma_params[0].port_addr = res->start + MCPDM_REG_DN_DATA; - omap_mcpdm_dai_dma_params[1].port_addr = res->start + MCPDM_REG_UP_DATA; + mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; + mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link"); if (!res) return -ENODEV;
- omap_mcpdm_dai_dma_params[0].dma_req = res->start; + mcpdm->dma_req[0] = res->start; + mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0];
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link"); if (!res) return -ENODEV;
- omap_mcpdm_dai_dma_params[1].dma_req = res->start; + mcpdm->dma_req[1] = res->start; + mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1];
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (res == NULL) diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 6c842c7..c8e272f 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -32,8 +32,6 @@ #include <sound/dmaengine_pcm.h> #include <sound/soc.h>
-#include "omap-pcm.h" - #ifdef CONFIG_ARCH_OMAP1 #define pcm_omap1510() cpu_is_omap1510() #else @@ -56,25 +54,6 @@ static const struct snd_pcm_hardware omap_pcm_hardware = { .buffer_bytes_max = 128 * 1024, };
-static int omap_pcm_get_dma_buswidth(int num_bits) -{ - int buswidth; - - switch (num_bits) { - case 16: - buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; - break; - case 32: - buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; - break; - default: - buswidth = -EINVAL; - break; - } - return buswidth; -} - - /* this may get called several times by oss emulation */ static int omap_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -105,20 +84,9 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream, if (err) return err;
- /* Override the *_dma addr_width if requested by the DAI driver */ - if (dma_data->data_type) { - int buswidth = omap_pcm_get_dma_buswidth(dma_data->data_type); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - config.dst_addr_width = buswidth; - else - config.src_addr_width = buswidth; - } - - config.src_addr = dma_data->port_addr; - config.dst_addr = dma_data->port_addr; - config.src_maxburst = dma_data->packet_size; - config.dst_maxburst = dma_data->packet_size; + snd_dmaengine_pcm_set_config_from_dai_data(substream, + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream), + &config);
return dmaengine_slave_config(chan, &config); } @@ -144,14 +112,14 @@ static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream) static int omap_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct omap_pcm_dma_data *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data;
snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
return snd_dmaengine_pcm_open(substream, omap_dma_filter_fn, - &dma_data->dma_req); + dma_data->filter_data); }
static int omap_pcm_mmap(struct snd_pcm_substream *substream, diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h deleted file mode 100644 index 39e6e45..0000000 --- a/sound/soc/omap/omap-pcm.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * omap-pcm.h - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula jarkko.nikula@bitmer.com - * Peter Ujfalusi peter.ujfalusi@ti.com - * - * 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. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef __OMAP_PCM_H__ -#define __OMAP_PCM_H__ - -struct snd_pcm_substream; - -struct omap_pcm_dma_data { - char *name; /* stream identifier */ - int dma_req; /* DMA request line */ - unsigned long port_addr; /* transmit/receive register */ - int data_type; /* 8, 16, 32 (bits) or 0 to let omap-pcm - * to decide the sDMA data type */ - int packet_size; /* packet size only in PACKET mode */ -}; - -#endif diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index fd98509..2a9324f 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -43,7 +43,6 @@ #include <sound/jack.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
struct omap_twl4030 { int jack_detect; /* board can detect jack events */ diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 9e46e1d..cf604a2 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -34,7 +34,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define OMAP3_PANDORA_DAC_POWER_GPIO 118 #define OMAP3_PANDORA_AMP_POWER_GPIO 14 diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index 06ef8d6..d03e57d 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c @@ -33,7 +33,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h" #include "../codecs/tlv320aic23.h"
#define CODEC_CLOCK 12000000 diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 3cd5257..249cd23 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -37,7 +37,6 @@ #include <asm/mach-types.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define RX51_TVOUT_SEL_GPIO 40 #define RX51_JACK_DETECT_GPIO 177
On 04/03/2013 11:06 AM, Lars-Peter Clausen wrote:
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
Looks good, works fine.
Acked-by: Peter Ujfalusi peter.ujfalusi@ti.com
sound/soc/omap/am3517evm.c | 1 - sound/soc/omap/ams-delta.c | 1 - sound/soc/omap/mcbsp.c | 14 +++++++------ sound/soc/omap/mcbsp.h | 7 ++++--- sound/soc/omap/n810.c | 1 - sound/soc/omap/omap-abe-twl6040.c | 1 - sound/soc/omap/omap-dmic.c | 22 ++++++++++---------- sound/soc/omap/omap-hdmi.c | 24 ++++++++++------------ sound/soc/omap/omap-mcbsp.c | 6 +++--- sound/soc/omap/omap-mcpdm.c | 31 +++++++++++++---------------- sound/soc/omap/omap-pcm.c | 42 +++++---------------------------------- sound/soc/omap/omap-pcm.h | 39 ------------------------------------ sound/soc/omap/omap-twl4030.c | 1 - sound/soc/omap/omap3pandora.c | 1 - sound/soc/omap/osk5912.c | 1 - sound/soc/omap/rx51.c | 1 - 16 files changed, 54 insertions(+), 139 deletions(-) delete mode 100644 sound/soc/omap/omap-pcm.h
diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c index c1900b2..994dcf3 100644 --- a/sound/soc/omap/am3517evm.c +++ b/sound/soc/omap/am3517evm.c @@ -28,7 +28,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#include "../codecs/tlv320aic23.h"
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 2600447..6294464 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -36,7 +36,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h" #include "../codecs/cx20442.h"
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 285c836..eb68c7d 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -1018,9 +1018,10 @@ int omap_mcbsp_init(struct platform_device *pdev) return -ENODEV; } /* RX DMA request number, and port address configuration */
- mcbsp->dma_data[1].name = "Audio Capture";
- mcbsp->dma_data[1].dma_req = res->start;
- mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
mcbsp->dma_req[1] = res->start;
mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1];
mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
mcbsp->dma_data[1].maxburst = 4;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); if (!res) {
@@ -1028,9 +1029,10 @@ int omap_mcbsp_init(struct platform_device *pdev) return -ENODEV; } /* TX DMA request number, and port address configuration */
- mcbsp->dma_data[0].name = "Audio Playback";
- mcbsp->dma_data[0].dma_req = res->start;
- mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
mcbsp->dma_req[0] = res->start;
mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
mcbsp->dma_data[0].maxburst = 4;
mcbsp->fclk = clk_get(&pdev->dev, "fck"); if (IS_ERR(mcbsp->fclk)) {
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index f93e0b0..96d1b08 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -24,14 +24,14 @@ #ifndef __ASOC_MCBSP_H #define __ASOC_MCBSP_H
-#include "omap-pcm.h"
#ifdef CONFIG_ARCH_OMAP1 #define mcbsp_omap1() 1 #else #define mcbsp_omap1() 0 #endif
+#include <sound/dmaengine_pcm.h>
/* McBSP register numbers. Register address offset = num * reg_step */ enum { /* Common registers */ @@ -312,7 +312,8 @@ struct omap_mcbsp { struct omap_mcbsp_platform_data *pdata; struct omap_mcbsp_st_data *st_data; struct omap_mcbsp_reg_cfg cfg_regs;
- struct omap_pcm_dma_data dma_data[2];
- struct snd_dmaengine_dai_dma_data dma_data[2];
- unsigned int dma_req[2]; int dma_op_mode; u16 max_tx_thres; u16 max_rx_thres;
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index ee7cd53..5e8d640 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -34,7 +34,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define N810_HEADSET_AMP_GPIO 10 #define N810_SPEAKER_AMP_GPIO 101 diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index e7d93fa..70cd5c7 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -34,7 +34,6 @@
#include "omap-dmic.h" #include "omap-mcpdm.h" -#include "omap-pcm.h" #include "../codecs/twl6040.h"
struct abe_twl6040 { diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 37f4539..2ad0370 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -39,8 +39,8 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
-#include "omap-pcm.h" #include "omap-dmic.h"
struct omap_dmic { @@ -55,13 +55,9 @@ struct omap_dmic { u32 ch_enabled; bool active; struct mutex mutex; -};
-/*
- Stream DMA parameters
- */
-static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
- .name = "DMIC capture",
- struct snd_dmaengine_dai_dma_data dma_data;
- unsigned int dma_req;
};
static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) @@ -118,7 +114,7 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream,
mutex_unlock(&dmic->mutex);
- snd_soc_dai_set_dma_data(dai, substream, &omap_dmic_dai_dma_params);
- snd_soc_dai_set_dma_data(dai, substream, &dmic->dma_data); return ret;
}
@@ -203,7 +199,7 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
- struct omap_pcm_dma_data *dma_data;
struct snd_dmaengine_dai_dma_data *dma_data; int channels;
dmic->clk_div = omap_dmic_select_divider(dmic, params_rate(params));
@@ -230,7 +226,7 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream,
/* packet size is threshold * channels */ dma_data = snd_soc_dai_get_dma_data(dai, substream);
- dma_data->packet_size = dmic->threshold * channels;
dma_data->maxburst = dmic->threshold * channels;
return 0;
} @@ -480,7 +476,7 @@ static int asoc_dmic_probe(struct platform_device *pdev) ret = -ENODEV; goto err_put_clk; }
- omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG;
dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) {
@@ -488,7 +484,9 @@ static int asoc_dmic_probe(struct platform_device *pdev) ret = -ENODEV; goto err_put_clk; }
- omap_dmic_dai_dma_params.dma_req = res->start;
dmic->dma_req = res->start;
dmic->dma_data.filter_data = &dmic->dma_req;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (!res) {
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c index 7e120cc..ced3b88 100644 --- a/sound/soc/omap/omap-hdmi.c +++ b/sound/soc/omap/omap-hdmi.c @@ -32,15 +32,16 @@ #include <sound/soc.h> #include <sound/asound.h> #include <sound/asoundef.h> +#include <sound/dmaengine_pcm.h> #include <video/omapdss.h>
-#include "omap-pcm.h" #include "omap-hdmi.h"
#define DRV_NAME "omap-hdmi-audio-dai"
struct hdmi_priv {
- struct omap_pcm_dma_data dma_params;
- struct snd_dmaengine_dai_dma_data dma_data;
- unsigned int dma_req; struct omap_dss_audio dss_audio; struct snd_aes_iec958 iec; struct snd_cea_861_aud_if cea;
@@ -68,7 +69,7 @@ static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream, return -ENODEV; }
- snd_soc_dai_set_dma_data(dai, substream, &priv->dma_params);
snd_soc_dai_set_dma_data(dai, substream, &priv->dma_data);
return 0;
} @@ -88,25 +89,20 @@ static int omap_hdmi_dai_hw_params(struct snd_pcm_substream *substream, struct hdmi_priv *priv = snd_soc_dai_get_drvdata(dai); struct snd_aes_iec958 *iec = &priv->iec; struct snd_cea_861_aud_if *cea = &priv->cea;
struct omap_pcm_dma_data *dma_data; int err = 0;
dma_data = snd_soc_dai_get_dma_data(dai, substream);
switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE:
dma_data->packet_size = 16;
break; case SNDRV_PCM_FORMAT_S24_LE:priv->dma_data.maxburst = 16;
dma_data->packet_size = 32;
break; default: dev_err(dai->dev, "format not supported!\n"); return -EINVAL; }priv->dma_data.maxburst = 32;
- dma_data->data_type = 32;
- /*
*/
- fill the IEC-60958 channel status word
@@ -287,8 +283,7 @@ static int omap_hdmi_probe(struct platform_device *pdev) return -ENODEV; }
- hdmi_data->dma_params.port_addr = hdmi_rsrc->start
+ OMAP_HDMI_AUDIO_DMA_PORT;
hdmi_data->dma_data.addr = hdmi_rsrc->start + OMAP_HDMI_AUDIO_DMA_PORT;
hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!hdmi_rsrc) {
@@ -296,8 +291,9 @@ static int omap_hdmi_probe(struct platform_device *pdev) return -ENODEV; }
- hdmi_data->dma_params.dma_req = hdmi_rsrc->start;
- hdmi_data->dma_params.name = "HDMI playback";
hdmi_data->dma_req = hdmi_rsrc->start;
hdmi_data->dma_data.filter_data = &hdmi_data->dma_req;
hdmi_data->dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
/*
- TODO: We assume that there is only one DSS HDMI device. Future
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 1de4213..eadbfb6 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -33,11 +33,11 @@ #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include <linux/platform_data/asoc-ti-mcbsp.h> #include "mcbsp.h" #include "omap-mcbsp.h" -#include "omap-pcm.h"
#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000)
@@ -224,7 +224,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
- struct omap_pcm_dma_data *dma_data;
- struct snd_dmaengine_dai_dma_data *dma_data; int wlen, channels, wpf; int pkt_size = 0; unsigned int format, div, framesize, master;
@@ -276,7 +276,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, omap_mcbsp_set_threshold(substream, pkt_size); }
- dma_data->packet_size = pkt_size;
dma_data->maxburst = pkt_size;
if (mcbsp->configured) { /* McBSP already configured by another stream */
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 06ab334..eb05c7e 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -39,9 +39,9 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/dmaengine_pcm.h>
#include "omap-mcpdm.h" -#include "omap-pcm.h"
struct mcpdm_link_config { u32 link_mask; /* channel mask for the direction */ @@ -64,19 +64,14 @@ struct omap_mcpdm {
/* McPDM needs to be restarted due to runtime reconfiguration */ bool restart;
- struct snd_dmaengine_dai_dma_data dma_data[2];
- unsigned int dma_req[2];
};
/*
- Stream DMA parameters
*/ -static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
- {
.name = "Audio playback",
- },
- {
.name = "Audio capture",
- },
-};
static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) { @@ -272,7 +267,7 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, mutex_unlock(&mcpdm->mutex);
snd_soc_dai_set_dma_data(dai, substream,
&omap_mcpdm_dai_dma_params[substream->stream]);
&mcpdm->dma_data[substream->stream]);
return 0;
} @@ -302,7 +297,7 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); int stream = substream->stream;
- struct omap_pcm_dma_data *dma_data;
- struct snd_dmaengine_dai_dma_data *dma_data; u32 threshold; int channels; int link_mask = 0;
@@ -342,14 +337,14 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = 0x3;
dma_data->packet_size =
} else { /* If playback is not running assume a stereo stream to come */ if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = (0x3 << 3);dma_data->maxburst = (MCPDM_DN_THRES_MAX - threshold) * channels;
dma_data->packet_size = threshold * channels;
dma_data->maxburst = threshold * channels;
}
/* Check if we need to restart McPDM with this stream */
@@ -479,20 +474,22 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) if (res == NULL) return -ENOMEM;
- omap_mcpdm_dai_dma_params[0].port_addr = res->start + MCPDM_REG_DN_DATA;
- omap_mcpdm_dai_dma_params[1].port_addr = res->start + MCPDM_REG_UP_DATA;
mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA;
mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link"); if (!res) return -ENODEV;
- omap_mcpdm_dai_dma_params[0].dma_req = res->start;
mcpdm->dma_req[0] = res->start;
mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0];
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link"); if (!res) return -ENODEV;
- omap_mcpdm_dai_dma_params[1].dma_req = res->start;
mcpdm->dma_req[1] = res->start;
mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1];
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (res == NULL)
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 6c842c7..c8e272f 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -32,8 +32,6 @@ #include <sound/dmaengine_pcm.h> #include <sound/soc.h>
-#include "omap-pcm.h"
#ifdef CONFIG_ARCH_OMAP1 #define pcm_omap1510() cpu_is_omap1510() #else @@ -56,25 +54,6 @@ static const struct snd_pcm_hardware omap_pcm_hardware = { .buffer_bytes_max = 128 * 1024, };
-static int omap_pcm_get_dma_buswidth(int num_bits) -{
- int buswidth;
- switch (num_bits) {
- case 16:
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
break;
- case 32:
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
break;
- default:
buswidth = -EINVAL;
break;
- }
- return buswidth;
-}
/* this may get called several times by oss emulation */ static int omap_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -105,20 +84,9 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream, if (err) return err;
- /* Override the *_dma addr_width if requested by the DAI driver */
- if (dma_data->data_type) {
int buswidth = omap_pcm_get_dma_buswidth(dma_data->data_type);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
config.dst_addr_width = buswidth;
else
config.src_addr_width = buswidth;
- }
- config.src_addr = dma_data->port_addr;
- config.dst_addr = dma_data->port_addr;
- config.src_maxburst = dma_data->packet_size;
- config.dst_maxburst = dma_data->packet_size;
snd_dmaengine_pcm_set_config_from_dai_data(substream,
snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
&config);
return dmaengine_slave_config(chan, &config);
} @@ -144,14 +112,14 @@ static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream) static int omap_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct omap_pcm_dma_data *dma_data;
struct snd_dmaengine_dai_dma_data *dma_data;
snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
return snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
&dma_data->dma_req);
dma_data->filter_data);
}
static int omap_pcm_mmap(struct snd_pcm_substream *substream, diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h deleted file mode 100644 index 39e6e45..0000000 --- a/sound/soc/omap/omap-pcm.h +++ /dev/null @@ -1,39 +0,0 @@ -/*
- omap-pcm.h
- Copyright (C) 2008 Nokia Corporation
- Contact: Jarkko Nikula jarkko.nikula@bitmer.com
Peter Ujfalusi <peter.ujfalusi@ti.com>
- 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.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA
- */
-#ifndef __OMAP_PCM_H__ -#define __OMAP_PCM_H__
-struct snd_pcm_substream;
-struct omap_pcm_dma_data {
- char *name; /* stream identifier */
- int dma_req; /* DMA request line */
- unsigned long port_addr; /* transmit/receive register */
- int data_type; /* 8, 16, 32 (bits) or 0 to let omap-pcm
* to decide the sDMA data type */
- int packet_size; /* packet size only in PACKET mode */
-};
-#endif diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index fd98509..2a9324f 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -43,7 +43,6 @@ #include <sound/jack.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
struct omap_twl4030 { int jack_detect; /* board can detect jack events */ diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 9e46e1d..cf604a2 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -34,7 +34,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define OMAP3_PANDORA_DAC_POWER_GPIO 118 #define OMAP3_PANDORA_AMP_POWER_GPIO 14 diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index 06ef8d6..d03e57d 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c @@ -33,7 +33,6 @@ #include <linux/platform_data/asoc-ti-mcbsp.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h" #include "../codecs/tlv320aic23.h"
#define CODEC_CLOCK 12000000 diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 3cd5257..249cd23 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -37,7 +37,6 @@ #include <asm/mach-types.h>
#include "omap-mcbsp.h" -#include "omap-pcm.h"
#define RX51_TVOUT_SEL_GPIO 40 #define RX51_JACK_DETECT_GPIO 177
On Wed, 3 Apr 2013 12:06:43 +0200 Peter Ujfalusi peter.ujfalusi@ti.com wrote:
On 04/03/2013 11:06 AM, Lars-Peter Clausen wrote:
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
Looks good, works fine.
Acked-by: Peter Ujfalusi peter.ujfalusi@ti.com
Acked-by: Jarkko Nikula jarkko.nikula@bitmer.com
On Wed, Apr 03, 2013 at 11:06:05AM +0200, Lars-Peter Clausen wrote:
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.
Applied, thanks.
On 04/03/2013 11:06 AM, Lars-Peter Clausen wrote:
This patch adds a common DMA data struct which can be used by DAI drivers to communicate their DMA configuration requirements to the DMA pcm driver. Having a common data structure for this allows us to implement common functions on top of them, which can be used by multiple platforms.
This patch also introduces a new function to initialize certain fields of a dma_slave_config struct from the common DAI DMA data struct.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
Tested-by: Peter Ujfalusi peter.ujfalusi@ti.com
include/sound/dmaengine_pcm.h | 24 ++++++++++++++++++++++++ sound/soc/soc-dmaengine-pcm.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index f8a7031..9562042 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -44,4 +44,28 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
+/**
- struct snd_dmaengine_dai_dma_data - DAI DMA configuration data
- @addr: Address of the DAI data source or destination register.
- @addr_width: Width of the DAI data source or destination register.
- @maxburst: Maximum number of words(note: words, as in units of the
- src_addr_width member, not bytes) that can be send to or received from the
- DAI in one burst.
- @slave_id: Slave requester id for the DMA channel.
- @filter_data: Custom DMA channel filter data, this will usually be used when
- requesting the DMA channel.
- */
+struct snd_dmaengine_dai_dma_data {
- dma_addr_t addr;
- enum dma_slave_buswidth addr_width;
- u32 maxburst;
- unsigned int slave_id;
- void *filter_data;
+};
+void snd_dmaengine_pcm_set_config_from_dai_data(
- const struct snd_pcm_substream *substream,
- const struct snd_dmaengine_dai_dma_data *dma_data,
- struct dma_slave_config *config);
#endif diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index 7c24ded..a9a300a 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -95,6 +95,43 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
+/**
- snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
- using DAI DMA data.
- @substream: PCM substream
- @dma_data: DAI DMA data
- @slave_config: DMA slave configuration
- Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and
- slave_id fields of the DMA slave config from the same fields of the DAI DMA
- data struct. The src and dst fields will be initialized depending on the
- direction of the substream. If the substream is a playback stream the dst
- fields will be initialized, if it is a capture stream the src fields will be
- initialized. The {dst,src}_addr_width field will only be initialized if the
- addr_width field of the DAI DMA data struct is not equal to
- DMA_SLAVE_BUSWIDTH_UNDEFINED.
- */
+void snd_dmaengine_pcm_set_config_from_dai_data(
- const struct snd_pcm_substream *substream,
- const struct snd_dmaengine_dai_dma_data *dma_data,
- struct dma_slave_config *slave_config)
+{
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
slave_config->dst_addr = dma_data->addr;
slave_config->dst_maxburst = dma_data->maxburst;
if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
slave_config->dst_addr_width = dma_data->addr_width;
- } else {
slave_config->src_addr = dma_data->addr;
slave_config->src_maxburst = dma_data->maxburst;
if (dma_data->addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED)
slave_config->src_addr_width = dma_data->addr_width;
- }
- slave_config->slave_id = dma_data->slave_id;
+} +EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data);
static void dmaengine_pcm_dma_complete(void *arg) { struct snd_pcm_substream *substream = arg;
On Wed, Apr 03, 2013 at 11:06:02AM +0200, Lars-Peter Clausen wrote:
This patch adds a common DMA data struct which can be used by DAI drivers to communicate their DMA configuration requirements to the DMA pcm driver. Having a common data structure for this allows us to implement common functions on top of them, which can be used by multiple platforms.
Applied, thanks.
participants (7)
-
Jarkko Nikula
-
Lars-Peter Clausen
-
Mark Brown
-
Nicolas Ferre
-
Peter Ujfalusi
-
Shawn Guo
-
Stephen Warren