linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/12] ARM: S3C: Add info for supporting circular DMA buffers
Date: Wed, 28 Oct 2009 12:15:49 +0000	[thread overview]
Message-ID: <1256732153-22027-8-git-send-email-ben-linux@fluff.org> (raw)
In-Reply-To: <1256732153-22027-1-git-send-email-ben-linux@fluff.org>

The S3C64XX DMA implementation will work a lot better with the ability
to enqueue circular buffers as the hardware can do it's own linked-list
management.

Add a function s3c_dma_has_circular() to show that the system can do this
and a flag for the channel.

Update the s3c24xx/s3c64xx I2S DMA code to deal with this.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
CC: Mark Brown <broonie@@opensource.wolfsonmicro.com>
---
 arch/arm/mach-s3c2410/include/mach/dma.h |    7 +++++++
 arch/arm/mach-s3c6400/include/mach/dma.h |    5 +++++
 sound/soc/s3c24xx/s3c24xx-pcm.c          |   17 +++++++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-s3c2410/include/mach/dma.h b/arch/arm/mach-s3c2410/include/mach/dma.h
index c3a2629..92e2687 100644
--- a/arch/arm/mach-s3c2410/include/mach/dma.h
+++ b/arch/arm/mach-s3c2410/include/mach/dma.h
@@ -110,6 +110,8 @@ enum s3c2410_dma_loadst {
 					    * waiting for reloads */
 #define S3C2410_DMAF_AUTOSTART    (1<<1)   /* auto-start if buffer queued */
 
+#define S3C2410_DMAF_CIRCULAR	(1 << 2)	/* no circular dma support */
+
 /* dma buffer */
 
 struct s3c2410_dma_buf;
@@ -194,4 +196,9 @@ struct s3c2410_dma_chan {
 
 typedef unsigned long dma_device_t;
 
+static inline bool s3c_dma_has_circular(void)
+{
+	return false;
+}
+
 #endif /* __ASM_ARCH_DMA_H */
diff --git a/arch/arm/mach-s3c6400/include/mach/dma.h b/arch/arm/mach-s3c6400/include/mach/dma.h
index 1067619..004edab 100644
--- a/arch/arm/mach-s3c6400/include/mach/dma.h
+++ b/arch/arm/mach-s3c6400/include/mach/dma.h
@@ -68,6 +68,11 @@ static __inline__ int s3c_dma_has_circular(void)
 
 #define S3C2410_DMAF_CIRCULAR		(1 << 0)
 
+static inline bool s3c_dma_has_circular(void)
+{
+	return false;
+}
+
 #include <plat/dma.h>
 
 #endif /* __ASM_ARCH_IRQ_H */
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index 5cbbdc8..1f35c6f 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -75,11 +75,19 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
 {
 	struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
 	dma_addr_t pos = prtd->dma_pos;
+	unsigned int limit;
 	int ret;
 
 	pr_debug("Entered %s\n", __func__);
 
-	while (prtd->dma_loaded < prtd->dma_limit) {
+	if (s3c_dma_has_circular()) {
+		limit = (prtd->dma_end - prtd->dma_start) / prtd->dma_period;
+	} else
+		limit = prtd->dma_limit;
+
+	pr_debug("%s: loaded %d, limit %d\n", __func__, prtd->dma_loaded, limit);
+
+	while (prtd->dma_loaded < limit) {
 		unsigned long len = prtd->dma_period;
 
 		pr_debug("dma_loaded: %d\n", prtd->dma_loaded);
@@ -123,7 +131,7 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
 		snd_pcm_period_elapsed(substream);
 
 	spin_lock(&prtd->lock);
-	if (prtd->state & ST_RUNNING) {
+	if (prtd->state & ST_RUNNING && !s3c_dma_has_circular()) {
 		prtd->dma_loaded--;
 		s3c24xx_pcm_enqueue(substream);
 	}
@@ -164,6 +172,11 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
 			printk(KERN_ERR "failed to get dma channel\n");
 			return ret;
 		}
+
+		/* use the circular buffering if we have it available. */
+		if (s3c_dma_has_circular())
+			s3c2410_dma_setflags(prtd->params->channel,
+					     S3C2410_DMAF_CIRCULAR);
 	}
 
 	s3c2410_dma_set_buffdone_fn(prtd->params->channel,
-- 
1.6.3.3

  parent reply	other threads:[~2009-10-28 12:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 12:15 [PATCH 01/12] ARM: S3C24XX: Define a macro to avoid compilation error Ben Dooks
2009-10-28 12:15 ` [PATCH 02/12] ARM: S3C24XX: Introduce S3C2442B CPU Ben Dooks
2009-11-01 21:12   ` Pavel Machek
2009-10-28 12:15 ` [PATCH 03/12] ARM: S3C2410: Fix link if CONFIG_S3C2410_IOTIMING is not set Ben Dooks
2009-10-28 12:15 ` [PATCH 04/12] ARM: S3C: Fix adc function exports Ben Dooks
2009-10-28 12:15 ` [PATCH 05/12] ARM: S3C24XX: arch/arm/plat-s3c24xx: Move dereference after NULL test Ben Dooks
2009-10-28 12:15 ` [PATCH 06/12] ARM: S3C64XX: Fix S3C64XX_CLKDIV0_ARM_MASK value Ben Dooks
2009-10-28 12:15 ` [PATCH 07/12] ARM: S3C64XX: Set rate of crystal mux Ben Dooks
2009-10-28 12:15 ` Ben Dooks [this message]
2009-10-28 12:39   ` [PATCH 08/12] ARM: S3C: Add info for supporting circular DMA buffers Mark Brown
2009-10-28 12:47     ` Ben Dooks
2009-10-28 13:15       ` Mark Brown
2009-10-28 12:15 ` [PATCH 09/12] ARM: S3C2440: mini2440: Fix missing CONFIG_S3C_DEV_USB_HOST Ben Dooks
2009-10-28 12:15 ` [PATCH 10/12] ARM: S3C24XX: Fix warnings in arch/arm/plat-s3c24xx/gpio.c Ben Dooks
2009-10-28 12:15 ` [PATCH 11/12] ARM: S3C2440: mini2440: Fix spare warnings Ben Dooks
2009-10-28 12:15 ` [PATCH 12/12] ARM: S3C2410: Fix sparse warnings in arch/arm/mach-s3c2410/gpio.c Ben Dooks
2009-10-28 12:22 ` [PATCH 01/12] ARM: S3C24XX: Define a macro to avoid compilation error Ben Dooks

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=1256732153-22027-8-git-send-email-ben-linux@fluff.org \
    --to=ben-linux@fluff.org \
    --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).