linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ASoC: dmaengine_pcm: add snd_dmaengine_generic_pcm_open()
Date: Fri, 15 Mar 2013 11:36:41 +0800	[thread overview]
Message-ID: <1363318601-31505-3-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1363318601-31505-1-git-send-email-shawn.guo@linaro.org>

With generic DMA device tree binding and helper function
dma_request_slave_channel() in place, dmaengine_pcm should support
that in requesting DMA channel for users that support generic DMA
device tree binding.

Add a new API snd_dmaengine_generic_pcm_open() as the variant of
snd_dmaengine_pcm_open().  It takes DMA client struct device pointer
and slave channel name as arguments and calls generic DMA helper
dma_request_slave_channel() to request DMA channel from dmaengine.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: alsa-devel at alsa-project.org
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
 include/sound/dmaengine_pcm.h |    2 ++
 sound/soc/soc-dmaengine-pcm.c |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h
index b877334..452df15 100644
--- a/include/sound/dmaengine_pcm.h
+++ b/include/sound/dmaengine_pcm.h
@@ -43,6 +43,8 @@ snd_pcm_uframes_t snd_dmaengine_pcm_pointer_no_residue(struct snd_pcm_substream
 
 int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
 	dma_filter_fn filter_fn, void *filter_data);
+int snd_dmaengine_generic_pcm_open(struct snd_pcm_substream *substream,
+				   struct device *dev, const char *name);
 int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
 
 struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
index 111b7d92..970eb2b 100644
--- a/sound/soc/soc-dmaengine-pcm.c
+++ b/sound/soc/soc-dmaengine-pcm.c
@@ -304,6 +304,45 @@ int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
 EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open);
 
 /**
+ * snd_dmaengine_generic_pcm_open - Open a dmaengine based PCM substream
+ * @substream: PCM substream
+ * @dev: pointer to DMA client device structure
+ * @name: DMA slave channel name
+ *
+ * Returns 0 on success, a negative error code otherwise.
+ *
+ * This function is a variant of snd_dmaengine_pcm_open(). It takes different
+ * parameters and calls generic DMA helper dma_request_slave_channel() to
+ * request a DMA channel from dmaengine.
+ */
+int snd_dmaengine_generic_pcm_open(struct snd_pcm_substream *substream,
+				   struct device *dev, const char *name)
+{
+	struct dmaengine_pcm_runtime_data *prtd;
+	int ret;
+
+	ret = snd_pcm_hw_constraint_integer(substream->runtime,
+					    SNDRV_PCM_HW_PARAM_PERIODS);
+	if (ret < 0)
+		return ret;
+
+	prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
+	if (!prtd)
+		return -ENOMEM;
+
+	prtd->dma_chan = dma_request_slave_channel(dev, name);
+	if (!prtd->dma_chan) {
+		kfree(prtd);
+		return -ENXIO;
+	}
+
+	substream->runtime->private_data = prtd;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_dmaengine_generic_pcm_open);
+
+/**
  * snd_dmaengine_pcm_close - Close a dmaengine based PCM substream
  * @substream: PCM substream
  */
-- 
1.7.9.5

  parent reply	other threads:[~2013-03-15  3:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15  3:36 [PATCH 0/2] ASoC: dmaengine_pcm: support generic DMA binding users Shawn Guo
2013-03-15  3:36 ` [PATCH 1/2] dmaengine: add const for name parameter Shawn Guo
2013-03-15  8:53   ` Markus Pargmann
2013-03-21  9:47     ` Vinod Koul
2013-03-21 13:10       ` Markus Pargmann
2013-03-21 12:54         ` Vinod Koul
2013-03-21 14:45           ` [PATCH] DMA: of: const name fixup Markus Pargmann
2013-03-21 14:57       ` [PATCH 1/2] dmaengine: add const for name parameter Shawn Guo
2013-04-02 17:51         ` Vinod Koul
2013-04-02 19:47           ` Mark Brown
2013-03-15  3:36 ` Shawn Guo [this message]
2013-03-15 10:00   ` [PATCH 2/2] ASoC: dmaengine_pcm: add snd_dmaengine_generic_pcm_open() Sebastien Guiriec
2013-03-21  9:57   ` Vinod Koul
2013-03-21 14:53     ` Shawn Guo
2013-03-22  8:07       ` Sebastien Guiriec
2013-03-22  8:39         ` Shawn Guo
2013-03-21  2:39 ` [PATCH 0/2] ASoC: dmaengine_pcm: support generic DMA binding users Shawn Guo
2013-03-21 15:06   ` [alsa-devel] " Lars-Peter Clausen
2013-03-21 15:22     ` Mark Brown
2013-03-21 16:26       ` Lars-Peter Clausen
2013-03-21 16:47         ` Mark Brown
2013-03-22 11:30         ` Russell King - ARM Linux
2013-03-22 11:39           ` Lars-Peter Clausen
2013-03-22 11:17       ` Russell King - ARM Linux
2013-03-22 11:28         ` Mark Brown
2013-03-22 11:42           ` Lars-Peter Clausen
2013-03-22 11:48             ` Mark Brown

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=1363318601-31505-3-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.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).