public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: <tiwai@suse.de>, <lrg@ti.com>,
	<broonie@opensource.wolfsonmicro.com>, <lars@metafoo.de>,
	<swarren@nvidia.com>, <perex@perex.cz>, <clemens@ladisch.de>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/3] ASoC: add apis for creating/free pcm dma buffer
Date: Fri, 29 Jun 2012 15:53:17 +0530	[thread overview]
Message-ID: <1340965398-20872-3-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1340965398-20872-1-git-send-email-ldewangan@nvidia.com>

Add APIs for creating and freeing the new pcm writecombine
dma buffer.
Adding these APIs for ARM only and if other architecture
supports the write combine dma buffer then these APIs can
be extended to that architecture.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 include/sound/soc.h  |   13 +++++++++++++
 sound/soc/soc-core.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e063380..6050ac7 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1153,6 +1153,19 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname);
 
+/**
+ * Create the snd_soc_pcm using the writecombine dma buffer.
+ * The writecombine dma buffer is supported on some architecture
+ * like ARM and so restricting this for ARM only.
+ * The more architecture can be added here or make it available for
+ * all architecture if writecombine dma buffer is supported.
+ */
+#ifdef CONFIG_ARM
+int snd_soc_pcm_new_writecombine_dma_buffer(struct snd_soc_pcm_runtime *rtd,
+		size_t max_bytes);
+void snd_soc_pcm_free_writecombine_dma_buffer(struct snd_pcm *pcm);
+#endif
+
 #include <sound/soc-dai.h>
 
 #ifdef CONFIG_DEBUG_FS
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe16135..d2c0dc4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -29,6 +29,7 @@
 #include <linux/pm.h>
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
+#include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/ctype.h>
 #include <linux/slab.h>
@@ -4094,6 +4095,55 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
 
+#ifdef CONFIG_ARM
+static u64 snd_soc_pcm_wc_dma_mask = DMA_BIT_MASK(32);
+int snd_soc_pcm_new_writecombine_dma_buffer(struct snd_soc_pcm_runtime *rtd,
+		size_t max_bytes)
+{
+	struct snd_card *card = rtd->card->snd_card;
+	struct snd_pcm *pcm = rtd->pcm;
+	int ret = 0;
+
+	if (!card->dev->dma_mask)
+		card->dev->dma_mask = &snd_soc_pcm_wc_dma_mask;
+	if (!card->dev->coherent_dma_mask)
+		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
+
+	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
+		ret = snd_pcm_lib_alloc_writecombine_dma_buffer(pcm,
+				max_bytes, SNDRV_PCM_STREAM_PLAYBACK);
+		if (ret)
+			goto err;
+	}
+	if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
+		ret = snd_pcm_lib_alloc_writecombine_dma_buffer(pcm,
+				max_bytes, SNDRV_PCM_STREAM_CAPTURE);
+		if (ret)
+			goto err_free_play;
+	}
+
+	return 0;
+
+err_free_play:
+	snd_pcm_lib_dealloc_writecombine_dma_buffer(pcm,
+				SNDRV_PCM_STREAM_PLAYBACK);
+err:
+	return ret;
+
+}
+EXPORT_SYMBOL_GPL(snd_soc_pcm_new_writecombine_dma_buffer);
+
+void snd_soc_pcm_free_writecombine_dma_buffer(struct snd_pcm *pcm)
+{
+	snd_pcm_lib_dealloc_writecombine_dma_buffer(pcm,
+					SNDRV_PCM_STREAM_CAPTURE);
+	snd_pcm_lib_dealloc_writecombine_dma_buffer(pcm,
+					SNDRV_PCM_STREAM_PLAYBACK);
+}
+EXPORT_SYMBOL_GPL(snd_soc_pcm_free_writecombine_dma_buffer);
+#endif
+
+
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname)
 {
-- 
1.7.1.1


  parent reply	other threads:[~2012-06-29 10:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 10:23 [PATCH 0/3] ASoC: Move pcm writecombine dma buffer allocation to core Laxman Dewangan
2012-06-29 10:23 ` [PATCH 1/3] ALSA: pcm: add apis for writecombine dma buffer allocation Laxman Dewangan
2012-06-29 10:23 ` Laxman Dewangan [this message]
2012-06-29 10:23 ` [PATCH 3/3] ASoC: tegra: use core/pcm library for pcm " Laxman Dewangan
2012-06-29 12:13 ` [PATCH 0/3] ASoC: Move pcm writecombine dma buffer allocation to core Takashi Iwai
2012-06-29 15:04   ` Laxman Dewangan
2012-06-29 15:22     ` Takashi Iwai
2012-06-29 15:49       ` Laxman Dewangan
2012-06-29 16:06     ` Lars-Peter Clausen
2012-06-29 16:18       ` Takashi Iwai
2012-06-29 16:32         ` Lars-Peter Clausen

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=1340965398-20872-3-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=clemens@ladisch.de \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=perex@perex.cz \
    --cc=swarren@nvidia.com \
    --cc=tiwai@suse.de \
    /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