From: padma.kvr@gmail.com (Padma Venkat)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 18/23] ASoC: samsung: convert to dmaengine API
Date: Wed, 6 Mar 2013 14:28:42 +0530 [thread overview]
Message-ID: <CAAgF-Bd=b721r_hiJKGDhw1AqRKC8bNkLh6f9ipcGdFtkM62vQ@mail.gmail.com> (raw)
In-Reply-To: <1362505353-8873-19-git-send-email-arnd@arndb.de>
Hi Arnd,
On Tue, Mar 5, 2013 at 11:12 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> In order to build the exynos kernel with CONFIG_ARCH_MULTIPLATFORM,
> we must convert all users of the Samsung private DMA interface to
> the generic dmaengine API. This converts the sound/soc drivers,
> breaking the older s3c platforms in the process, since they do not
> support the dmaengine interface yet.
>
> This patch must not get mainlined until mach-s3c* is also converted,
> but can be used for testing in the meantime.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> sound/soc/samsung/ac97.c | 15 ------
> sound/soc/samsung/dma.c | 104 +++++++++++++++++++++-------------------
> sound/soc/samsung/dma.h | 4 +-
> sound/soc/samsung/i2s.c | 9 +---
> sound/soc/samsung/pcm.c | 13 -----
> sound/soc/samsung/s3c2412-i2s.c | 10 ----
> sound/soc/samsung/s3c24xx-i2s.c | 10 ----
> sound/soc/samsung/spdif.c | 6 ---
> 8 files changed, 57 insertions(+), 114 deletions(-)
>
> diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c
> index c76abdf..214f454 100644
> --- a/sound/soc/samsung/ac97.c
> +++ b/sound/soc/samsung/ac97.c
> @@ -39,30 +39,15 @@ struct s3c_ac97_info {
> };
> static struct s3c_ac97_info s3c_ac97;
>
> -static struct s3c2410_dma_client s3c_dma_client_out = {
> - .name = "AC97 PCMOut"
> -};
> -
> -static struct s3c2410_dma_client s3c_dma_client_in = {
> - .name = "AC97 PCMIn"
> -};
> -
> -static struct s3c2410_dma_client s3c_dma_client_micin = {
> - .name = "AC97 MicIn"
> -};
> -
> static struct s3c_dma_params s3c_ac97_pcm_out = {
> - .client = &s3c_dma_client_out,
> .dma_size = 4,
> };
>
> static struct s3c_dma_params s3c_ac97_pcm_in = {
> - .client = &s3c_dma_client_in,
> .dma_size = 4,
> };
>
> static struct s3c_dma_params s3c_ac97_mic_in = {
> - .client = &s3c_dma_client_micin,
> .dma_size = 4,
> };
>
> diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
> index 21b7926..67b8dcc 100644
> --- a/sound/soc/samsung/dma.c
> +++ b/sound/soc/samsung/dma.c
> @@ -16,14 +16,14 @@
>
> #include <linux/slab.h>
> #include <linux/dma-mapping.h>
> +#include <linux/dmaengine.h>
> #include <linux/module.h>
> +#include <linux/amba/pl330.h>
>
> #include <sound/soc.h>
> #include <sound/pcm_params.h>
>
> #include <asm/dma.h>
> -#include <mach/hardware.h>
> -#include <mach/dma.h>
>
> #include "dma.h"
>
> @@ -67,12 +67,16 @@ static void audio_buffdone(void *data);
> * place a dma buffer onto the queue for the dma system
> * to handle.
> */
> +
> static void dma_enqueue(struct snd_pcm_substream *substream)
> {
> struct runtime_data *prtd = substream->runtime->private_data;
> dma_addr_t pos = prtd->dma_pos;
> + unsigned long period = prtd->dma_period;
> unsigned int limit;
> - struct samsung_dma_prep dma_info;
> + enum dma_transfer_direction direction;
> + struct dma_chan *chan = prtd->params->ch;
> + struct dma_async_tx_descriptor *desc;
>
> pr_debug("Entered %s\n", __func__);
>
> @@ -81,29 +85,30 @@ static void dma_enqueue(struct snd_pcm_substream *substream)
> pr_debug("%s: loaded %d, limit %d\n",
> __func__, prtd->dma_loaded, limit);
>
> - dma_info.cap = (samsung_dma_has_circular() ? DMA_CYCLIC : DMA_SLAVE);
> - dma_info.direction =
> - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK
> - ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM);
> - dma_info.fp = audio_buffdone;
> - dma_info.fp_param = substream;
> - dma_info.period = prtd->dma_period;
> - dma_info.len = prtd->dma_period*limit;
> + direction = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK
> + ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM);
>
> while (prtd->dma_loaded < limit) {
> pr_debug("dma_loaded: %d\n", prtd->dma_loaded);
>
> - if ((pos + dma_info.period) > prtd->dma_end) {
> - dma_info.period = prtd->dma_end - pos;
> + if ((pos + period) > prtd->dma_end) {
> + period = prtd->dma_end - pos;
> pr_debug("%s: corrected dma len %ld\n",
> - __func__, dma_info.period);
> + __func__, period);
> }
>
> - dma_info.buf = pos;
> - prtd->params->ops->prepare(prtd->params->ch, &dma_info);
> + desc = dmaengine_prep_dma_cyclic(chan, pos,
> + prtd->dma_period*limit, period, direction,
> + DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> +
> + if (desc) {
> + desc->callback = audio_buffdone;
> + desc->callback_param = substream;
> + dmaengine_submit(desc);
> + }
>
> prtd->dma_loaded++;
> - pos += prtd->dma_period;
> + pos += period;
> if (pos >= prtd->dma_end)
> pos = prtd->dma_start;
> }
> @@ -125,13 +130,6 @@ static void audio_buffdone(void *data)
>
> if (substream)
> snd_pcm_period_elapsed(substream);
> -
> - spin_lock(&prtd->lock);
> - if (!samsung_dma_has_circular()) {
> - prtd->dma_loaded--;
> - dma_enqueue(substream);
> - }
> - spin_unlock(&prtd->lock);
> }
> }
>
> @@ -144,8 +142,6 @@ static int dma_hw_params(struct snd_pcm_substream *substream,
> unsigned long totbytes = params_buffer_bytes(params);
> struct s3c_dma_params *dma =
> snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
> - struct samsung_dma_req req;
> - struct samsung_dma_config config;
>
> pr_debug("Entered %s\n", __func__);
>
> @@ -157,26 +153,37 @@ static int dma_hw_params(struct snd_pcm_substream *substream,
> /* this may get called several times by oss emulation
> * with different params -HW */
> if (prtd->params == NULL) {
> + struct dma_slave_config config;
> + dma_cap_mask_t mask;
> +
> /* prepare DMA */
> prtd->params = dma;
>
> - pr_debug("params %p, client %p, channel %d\n", prtd->params,
> - prtd->params->client, prtd->params->channel);
> -
> - prtd->params->ops = samsung_dma_get_ops();
> -
> - req.cap = (samsung_dma_has_circular() ?
> - DMA_CYCLIC : DMA_SLAVE);
> - req.client = prtd->params->client;
> - config.direction =
> - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK
> - ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM);
> - config.width = prtd->params->dma_size;
> - config.fifo = prtd->params->dma_addr;
> - prtd->params->ch = prtd->params->ops->request(
> - prtd->params->channel, &req, rtd->cpu_dai->dev,
> - prtd->params->ch_name);
> - prtd->params->ops->config(prtd->params->ch, &config);
> + pr_debug("params %p, channel %d\n", prtd->params,
> + prtd->params->channel);
> +
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_CYCLIC, mask);
> +
> + prtd->params->ch = dma_request_slave_channel_compat(mask,
> + pl330_filter, (void *)prtd->params->channel,
> + rtd->cpu_dai->dev, prtd->params->ch_name);
> +
> + memset(&config, 0, sizeof(struct dma_slave_config));
> +
> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> + config.direction = DMA_MEM_TO_DEV;
> + config.dst_addr = prtd->params->dma_size;
> + config.dst_addr_width = prtd->params->dma_addr;
dma_addr and dma_size got interchanged.
Except the above one I tested this patch on 5250. It's working fine.
> + config.dst_maxburst = 1;
> + dmaengine_slave_config(prtd->params->ch, &config);
> + } else {
> + config.direction = DMA_DEV_TO_MEM;
> + config.src_addr = prtd->params->dma_addr;
> + config.src_addr_width = prtd->params->dma_size;
> + config.src_maxburst = 1;
> + dmaengine_slave_config(prtd->params->ch, &config);
> + }
> }
>
> snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
> @@ -203,9 +210,8 @@ static int dma_hw_free(struct snd_pcm_substream *substream)
> snd_pcm_set_runtime_buffer(substream, NULL);
>
> if (prtd->params) {
> - prtd->params->ops->flush(prtd->params->ch);
> - prtd->params->ops->release(prtd->params->ch,
> - prtd->params->client);
> + dmaengine_terminate_all(prtd->params->ch);
> + dma_release_channel(prtd->params->ch);
> prtd->params = NULL;
> }
>
> @@ -225,7 +231,7 @@ static int dma_prepare(struct snd_pcm_substream *substream)
> return 0;
>
> /* flush the DMA channel */
> - prtd->params->ops->flush(prtd->params->ch);
> + dmaengine_terminate_all(prtd->params->ch);
>
> prtd->dma_loaded = 0;
> prtd->dma_pos = prtd->dma_start;
> @@ -248,12 +254,12 @@ static int dma_trigger(struct snd_pcm_substream *substream, int cmd)
> switch (cmd) {
> case SNDRV_PCM_TRIGGER_START:
> prtd->state |= ST_RUNNING;
> - prtd->params->ops->trigger(prtd->params->ch);
> + dma_async_issue_pending(prtd->params->ch);
> break;
>
> case SNDRV_PCM_TRIGGER_STOP:
> prtd->state &= ~ST_RUNNING;
> - prtd->params->ops->stop(prtd->params->ch);
> + dmaengine_terminate_all(prtd->params->ch);
> break;
>
> default:
> diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h
> index 189a7a6..f7381be 100644
> --- a/sound/soc/samsung/dma.h
> +++ b/sound/soc/samsung/dma.h
> @@ -13,12 +13,10 @@
> #define _S3C_AUDIO_H
>
> struct s3c_dma_params {
> - struct s3c2410_dma_client *client; /* stream identifier */
> int channel; /* Channel ID */
> dma_addr_t dma_addr;
> int dma_size; /* Size of the DMA transfer */
> - unsigned ch;
> - struct samsung_dma_ops *ops;
> + struct dma_chan *ch;
> char *ch_name;
> };
>
> diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
> index d7231e3..2eed7a3 100644
> --- a/sound/soc/samsung/i2s.c
> +++ b/sound/soc/samsung/i2s.c
> @@ -18,12 +18,11 @@
> #include <linux/of.h>
> #include <linux/of_gpio.h>
> #include <linux/pm_runtime.h>
> +#include <linux/dmaengine.h>
>
> #include <sound/soc.h>
> #include <sound/pcm_params.h>
>
> -#include <mach/dma.h>
> -
> #include <linux/platform_data/asoc-s3c.h>
>
> #include "dma.h"
> @@ -1183,11 +1182,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
>
> pri_dai->dma_playback.dma_addr = regs_base + I2STXD;
> pri_dai->dma_capture.dma_addr = regs_base + I2SRXD;
> - pri_dai->dma_playback.client =
> - (struct s3c2410_dma_client *)&pri_dai->dma_playback;
> pri_dai->dma_playback.ch_name = "tx";
> - pri_dai->dma_capture.client =
> - (struct s3c2410_dma_client *)&pri_dai->dma_capture;
> pri_dai->dma_capture.ch_name = "rx";
> pri_dai->dma_playback.dma_size = 4;
> pri_dai->dma_capture.dma_size = 4;
> @@ -1205,8 +1200,6 @@ static int samsung_i2s_probe(struct platform_device *pdev)
> goto err;
> }
> sec_dai->dma_playback.dma_addr = regs_base + I2STXDS;
> - sec_dai->dma_playback.client =
> - (struct s3c2410_dma_client *)&sec_dai->dma_playback;
> sec_dai->dma_playback.ch_name = "tx-sec";
>
> if (!np) {
> diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c
> index 13bab79..525b2d2 100644
> --- a/sound/soc/samsung/pcm.c
> +++ b/sound/soc/samsung/pcm.c
> @@ -20,7 +20,6 @@
> #include <sound/pcm_params.h>
>
> #include <linux/platform_data/asoc-s3c.h>
> -#include <mach/dma.h>
>
> #include "dma.h"
> #include "pcm.h"
> @@ -132,32 +131,20 @@ struct s3c_pcm_info {
> struct s3c_dma_params *dma_capture;
> };
>
> -static struct s3c2410_dma_client s3c_pcm_dma_client_out = {
> - .name = "PCM Stereo out"
> -};
> -
> -static struct s3c2410_dma_client s3c_pcm_dma_client_in = {
> - .name = "PCM Stereo in"
> -};
> -
> static struct s3c_dma_params s3c_pcm_stereo_out[] = {
> [0] = {
> - .client = &s3c_pcm_dma_client_out,
> .dma_size = 4,
> },
> [1] = {
> - .client = &s3c_pcm_dma_client_out,
> .dma_size = 4,
> },
> };
>
> static struct s3c_dma_params s3c_pcm_stereo_in[] = {
> [0] = {
> - .client = &s3c_pcm_dma_client_in,
> .dma_size = 4,
> },
> [1] = {
> - .client = &s3c_pcm_dma_client_in,
> .dma_size = 4,
> },
> };
> diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c
> index 2213377..d43f00e 100644
> --- a/sound/soc/samsung/s3c2412-i2s.c
> +++ b/sound/soc/samsung/s3c2412-i2s.c
> @@ -31,23 +31,13 @@
> #include "regs-i2s-v2.h"
> #include "s3c2412-i2s.h"
>
> -static struct s3c2410_dma_client s3c2412_dma_client_out = {
> - .name = "I2S PCM Stereo out"
> -};
> -
> -static struct s3c2410_dma_client s3c2412_dma_client_in = {
> - .name = "I2S PCM Stereo in"
> -};
> -
> static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = {
> - .client = &s3c2412_dma_client_out,
> .channel = DMACH_I2S_OUT,
> .dma_addr = S3C2410_PA_IIS + S3C2412_IISTXD,
> .dma_size = 4,
> };
>
> static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = {
> - .client = &s3c2412_dma_client_in,
> .channel = DMACH_I2S_IN,
> .dma_addr = S3C2410_PA_IIS + S3C2412_IISRXD,
> .dma_size = 4,
> diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c
> index a7b17c1..d68c23d 100644
> --- a/sound/soc/samsung/s3c24xx-i2s.c
> +++ b/sound/soc/samsung/s3c24xx-i2s.c
> @@ -29,23 +29,13 @@
> #include "dma.h"
> #include "s3c24xx-i2s.h"
>
> -static struct s3c2410_dma_client s3c24xx_dma_client_out = {
> - .name = "I2S PCM Stereo out"
> -};
> -
> -static struct s3c2410_dma_client s3c24xx_dma_client_in = {
> - .name = "I2S PCM Stereo in"
> -};
> -
> static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = {
> - .client = &s3c24xx_dma_client_out,
> .channel = DMACH_I2S_OUT,
> .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
> .dma_size = 2,
> };
>
> static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = {
> - .client = &s3c24xx_dma_client_in,
> .channel = DMACH_I2S_IN,
> .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
> .dma_size = 2,
> diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c
> index 5008e5b..5c78c78 100644
> --- a/sound/soc/samsung/spdif.c
> +++ b/sound/soc/samsung/spdif.c
> @@ -18,7 +18,6 @@
> #include <sound/pcm_params.h>
>
> #include <linux/platform_data/asoc-s3c.h>
> -#include <mach/dma.h>
>
> #include "dma.h"
> #include "spdif.h"
> @@ -94,10 +93,6 @@ struct samsung_spdif_info {
> struct s3c_dma_params *dma_playback;
> };
>
> -static struct s3c2410_dma_client spdif_dma_client_out = {
> - .name = "S/PDIF Stereo out",
> -};
> -
> static struct s3c_dma_params spdif_stereo_out;
> static struct samsung_spdif_info spdif_info;
>
> @@ -431,7 +426,6 @@ static int spdif_probe(struct platform_device *pdev)
> }
>
> spdif_stereo_out.dma_size = 2;
> - spdif_stereo_out.client = &spdif_dma_client_out;
> spdif_stereo_out.dma_addr = mem_res->start + DATA_OUTBUF;
> spdif_stereo_out.channel = dma_res->start;
>
> --
> 1.8.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks
Padma
next prev parent reply other threads:[~2013-03-06 8:58 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 17:42 [PATCH 00/23] RFC: exynos multiplatform support Arnd Bergmann
2013-03-05 17:42 ` [PATCH 01/23] ARM: exynos: introduce EXYNOS_ATAGS symbol Arnd Bergmann
2013-03-05 17:42 ` [PATCH 02/23] irqchip: exynos: remove dependency on mach/irqs.h Arnd Bergmann
2013-03-05 17:42 ` [PATCH 03/23] tty: serial/samsung: prepare for common clock API Arnd Bergmann
2013-03-05 17:42 ` [PATCH 04/23] tty: serial/samsung: make register definitions global Arnd Bergmann
2013-03-05 17:42 ` [PATCH 05/23] tty: serial/samsung: fix modular build Arnd Bergmann
2013-03-05 17:42 ` [PATCH 06/23] ARM: exynos: move debug-macro.S to include/debug/ Arnd Bergmann
2013-03-05 17:42 ` [PATCH 07/23] i2c: s3c2410: make header file local Arnd Bergmann
2013-04-02 20:36 ` Heiko Stübner
2013-03-05 17:42 ` [PATCH 08/23] mmc: sdhci-s3c: remove platform dependencies Arnd Bergmann
2013-03-05 17:42 ` [PATCH 09/23] usb: exynos: do not include plat/usb-phy.h Arnd Bergmann
2013-03-05 17:42 ` [PATCH 10/23] [media] exynos: remove unnecessary header inclusions Arnd Bergmann
2013-04-02 13:08 ` Sylwester Nawrocki
2013-03-05 17:42 ` [PATCH 11/23] video/exynos: " Arnd Bergmann
2013-03-05 17:42 ` [PATCH 12/23] thermal/exynos: " Arnd Bergmann
2013-03-05 17:42 ` [PATCH 13/23] mtd: onenand/samsung: make regs-onenand.h file local Arnd Bergmann
2013-03-05 17:42 ` [PATCH 14/23] rtc: s3c: make header " Arnd Bergmann
2013-03-05 17:42 ` [PATCH 15/23] spi: s3c64xx: move to generic dmaengine API Arnd Bergmann
2013-03-06 9:14 ` Padma Venkat
2013-03-05 17:42 ` [PATCH 16/23] pwm: samsung: repair the worst MMIO abuses Arnd Bergmann
2013-03-05 17:42 ` [PATCH 17/23] ASoC: samsung: move plat/ headers to local directory Arnd Bergmann
2013-03-05 17:42 ` [PATCH 18/23] ASoC: samsung: convert to dmaengine API Arnd Bergmann
2013-03-06 8:58 ` Padma Venkat [this message]
2013-03-06 12:01 ` Arnd Bergmann
2013-03-05 17:42 ` [PATCH 19/23] ASoC: samsung: use irq resource for idma Arnd Bergmann
2013-03-05 17:42 ` [PATCH 20/23] ARM: exynos: prepare for sparse IRQ Arnd Bergmann
2013-03-05 17:42 ` [PATCH 21/23] ARM: exynos: hack to disable private clock code Arnd Bergmann
2013-03-05 17:42 ` [PATCH 22/23] ARM: exynos: work around missing gpio code on multiplatform Arnd Bergmann
2013-03-05 17:42 ` [PATCH 23/23] ARM: exynos: experimental multiplatform support Arnd Bergmann
2013-03-05 18:27 ` [PATCH 00/23] RFC: exynos " Tony Lindgren
2013-03-05 18:28 ` Tomasz Figa
2013-03-05 19:19 ` Arnd Bergmann
2013-03-05 22:48 ` Tomasz Figa
2013-03-06 10:50 ` Arnd Bergmann
2013-03-06 12:34 ` Thierry Reding
2013-03-06 22:57 ` Tomasz Figa
2013-03-07 3:02 ` Arnd Bergmann
2013-03-07 7:22 ` Thierry Reding
2013-03-08 0:40 ` Tomasz Figa
2013-03-08 12:52 ` Arnd Bergmann
2013-03-06 22:14 ` Heiko Stübner
2013-03-06 22:55 ` Tomasz Figa
2013-03-05 20:50 ` Heiko Stübner
2013-03-05 21:24 ` Arnd Bergmann
2013-03-05 21:54 ` Arnd Bergmann
2013-03-05 22:12 ` Tomasz Figa
2013-03-05 22:21 ` Arnd Bergmann
2013-03-05 22:25 ` Heiko Stübner
2013-03-05 22:43 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAgF-Bd=b721r_hiJKGDhw1AqRKC8bNkLh6f9ipcGdFtkM62vQ@mail.gmail.com' \
--to=padma.kvr@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).