linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine
@ 2012-09-13 13:37 Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 01/15] dmaengine: omap: Support for element mode in cyclic DMA Peter Ujfalusi
                   ` (14 more replies)
  0 siblings, 15 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Hello,

Changelog:
- Support for pause/resume for OMAP audio via dmaengine
- dmaengine: support for NO_PERIOD_WAKEUP in cyclic mode
 - OMAP to keep supporting NO_PERIOD_WAKEUP for audio
 - Other plaforms can also try to enable this mode since we have now generic
   interface to do so.

This series will switch the OMAP audio to use dmaengine.
The final patch which does the switch was based on Russell King's earlier patch.

The first 10 patch is to prepare the OMAP audio drivers for a smooth change to
dmaengine:
- sDMA FRAME sync mode is removed and replaced with PACKET mode
- dai drivers no longer need to configure sDMA sync mode
- dai drivers does not need to specify the DMA word length - with the exception
  of the omap-hdmi driver which requires 32bit word length regardless of the
  audio format in use
- the McPDM driver used (to my surprise) hackish way of getting the DMA channel
  and address - via defines from some header files

After the conversion OMAP audio support should have the same features as before,
no regressions expected.

I have tested the series on:
- BeagleBoard (audio via McBSP): 
 - aplay/arecord. In element mode and in threshold mode with different period
   sizes
 - mplayer -ao alsa: for direct ALSA access
 - mplayer -ao pulse: via PulseAudio to test NO_PERIOD_WAKEUP feature
- OMAP4 Blaze (audio via McPDM and DMIC)
 - aplay/arecord
 - mplayer -ao alsa: for direct ALSA access
 - mplayer -ao pulse: via PulseAudio to test NO_PERIOD_WAKEUP feature

The patches has been generated against:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-3.7

Janusz: Can you retest this series on OMAP1 to be sure I have not broken it?
Ricardo: Can you test the omap-hmdi if it is still working?

Regards,
Peter
---
Peter Ujfalusi (15):
  dmaengine: omap: Support for element mode in cyclic DMA
  dmaengine: omap: Add support for pause/resume in cyclic dma mode
  dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic()
    callback
  dmaengine: omap-dma: Add support for no_wakeup in cyclic mode
  ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode
  ASoC: omap-pcm: Select sDMA synchronization based on packet_size
  ASoC: OMAP: Remove sync_mode from omap_pcm_dma_data struct
  ASoC: omap-pcm: Prepare to configure the DMA data_type based on
    stream properties
  ARM: OMAP4: hwmod_data: Add resource names to McPDM memory ranges
  ASoC: omap-mcpdm: Use platform_get_resource_* to get resources
  ASoC: OMAP: mcbsp, mcpdm, dmic: Let omap-pcm to pick the dma_type
  ASoC: omap-pcm, omap-dmic: Change the use of
    omap_pcm_dma_data->data_type
  ASoC: OMAP: mcbsp, mcpdm, dmic, hdmi: Set dma_data at startup time
  ASoC: omap-pcm: Convert to use dmaengine

 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   2 +
 drivers/dma/at_hdmac.c                     |   3 +-
 drivers/dma/ep93xx_dma.c                   |   4 +-
 drivers/dma/imx-dma.c                      |   2 +-
 drivers/dma/imx-sdma.c                     |   2 +-
 drivers/dma/mmp_tdma.c                     |   2 +-
 drivers/dma/mxs-dma.c                      |   2 +-
 drivers/dma/omap-dma.c                     |  47 ++++--
 drivers/dma/pl330.c                        |   2 +-
 drivers/dma/sa11x0-dma.c                   |   2 +-
 drivers/dma/sirf-dma.c                     |   2 +-
 drivers/dma/ste_dma40.c                    |   3 +-
 drivers/dma/tegra20-apb-dma.c              |   2 +-
 include/linux/dmaengine.h                  |   8 +-
 sound/soc/omap/Kconfig                     |   3 +-
 sound/soc/omap/omap-dmic.c                 |   9 +-
 sound/soc/omap/omap-hdmi.c                 |  17 ++-
 sound/soc/omap/omap-mcbsp.c                |  60 +++-----
 sound/soc/omap/omap-mcpdm.c                |  40 +++--
 sound/soc/omap/omap-pcm.c                  | 236 ++++++++---------------------
 sound/soc/omap/omap-pcm.h                  |   4 +-
 sound/soc/soc-dmaengine-pcm.c              |   3 +-
 22 files changed, 186 insertions(+), 269 deletions(-)

-- 
1.7.12


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH v2 01/15] dmaengine: omap: Support for element mode in cyclic DMA
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode Peter Ujfalusi
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

When src_maxburst/dst_maxburst is set to 0 by the users of cyclic DMA
(mostly audio) indicates that we should configure the omap DMA to element
sync mode instead of packet mode.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/dma/omap-dma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index ae05618..b77a40d 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -413,7 +413,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
 	d->dev_addr = dev_addr;
 	d->fi = burst;
 	d->es = es;
-	d->sync_mode = OMAP_DMA_SYNC_PACKET;
+	if (burst)
+		d->sync_mode = OMAP_DMA_SYNC_PACKET;
+	else
+		d->sync_mode = OMAP_DMA_SYNC_ELEMENT;
 	d->sync_type = sync_type;
 	d->periph_port = OMAP_DMA_PORT_MPUI;
 	d->sg[0].addr = buf_addr;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 01/15] dmaengine: omap: Support for element mode in cyclic DMA Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic() Peter Ujfalusi
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

The audio stack used omap_stop_dma/omap_start_dma to pause/resume the DMA.
This method has been used for years on OMAP based products.
We only allow pause/resume when the DMA has been configured in cyclic mode
which is used by the audio stack.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/dma/omap-dma.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index b77a40d..71d7869 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -34,6 +34,7 @@ struct omap_chan {
 	struct dma_slave_config	cfg;
 	unsigned dma_sig;
 	bool cyclic;
+	bool paused;
 
 	int dma_ch;
 	struct omap_desc *desc;
@@ -470,11 +471,14 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 	 */
 	if (c->desc) {
 		c->desc = NULL;
-		omap_stop_dma(c->dma_ch);
+		/* Avoid stopping the dma twice */
+		if (!c->paused)
+			omap_stop_dma(c->dma_ch);
 	}
 
 	if (c->cyclic) {
 		c->cyclic = false;
+		c->paused = false;
 		omap_dma_unlink_lch(c->dma_ch, c->dma_ch);
 	}
 
@@ -487,14 +491,30 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 
 static int omap_dma_pause(struct omap_chan *c)
 {
-	/* FIXME: not supported by platform private API */
-	return -EINVAL;
+	/* Pause/Resume only allowed with cyclic mode */
+	if (!c->cyclic)
+		return -EINVAL;
+
+	if (!c->paused) {
+		omap_stop_dma(c->dma_ch);
+		c->paused = true;
+	}
+
+	return 0;
 }
 
 static int omap_dma_resume(struct omap_chan *c)
 {
-	/* FIXME: not supported by platform private API */
-	return -EINVAL;
+	/* Pause/Resume only allowed with cyclic mode */
+	if (!c->cyclic)
+		return -EINVAL;
+
+	if (c->paused) {
+		omap_start_dma(c->dma_ch);
+		c->paused = false;
+	}
+
+	return 0;
 }
 
 static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 01/15] dmaengine: omap: Support for element mode in cyclic DMA Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 15:27   ` Lars-Peter Clausen
  2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

The dmaengine_prep_dma_cyclic() function primarily used by audio for cyclic
transfer required by ALSA.
With this new parameter it is going to be possible to enable the
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP mode on platforms where it is possible.
This patch only changes the public API first. Followup patch will change
the device_prep_dma_cyclic() callback parameters to pass this information
towards the dma drivers.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Lars-Peter Clausen <lars@metafoo.de>
---
 include/linux/dmaengine.h     | 3 ++-
 sound/soc/soc-dmaengine-pcm.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 9c02a45..990444b 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -653,7 +653,8 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_rio_sg(
 
 static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
-		size_t period_len, enum dma_transfer_direction dir)
+		size_t period_len, enum dma_transfer_direction dir,
+		bool no_wakeup)
 {
 	return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
 						period_len, dir, NULL);
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
index 5df529e..6b70adb 100644
--- a/sound/soc/soc-dmaengine-pcm.c
+++ b/sound/soc/soc-dmaengine-pcm.c
@@ -147,7 +147,8 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
 	desc = dmaengine_prep_dma_cyclic(chan,
 		substream->runtime->dma_addr,
 		snd_pcm_lib_buffer_bytes(substream),
-		snd_pcm_lib_period_bytes(substream), direction);
+		snd_pcm_lib_period_bytes(substream), direction,
+		substream->runtime->no_period_wakeup);
 
 	if (!desc)
 		return -ENOMEM;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic() Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-14  3:24   ` Vinod Koul
                     ` (2 more replies)
  2012-09-13 13:37 ` [PATCH v2 05/15] dmaengine: omap-dma: Add support for no_wakeup in cyclic mode Peter Ujfalusi
                   ` (10 subsequent siblings)
  14 siblings, 3 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen,
	Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao, Shawn Guo,
	Laxman Dewangan

Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
can receive the no_wakeup request coming from client drivers.
This feature can be used during audio operation to disable all audio
related interrupts.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Barry Song <baohua.song@csr.com>
CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
CC: Vista Silicon <javier.martin@vista-silicon.com>
CC: Zhangfei Gao <zhangfei.gao@marvell.com>
CC: Shawn Guo <shawn.guo@linaro.org>
CC: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/dma/at_hdmac.c        | 3 ++-
 drivers/dma/ep93xx_dma.c      | 4 +++-
 drivers/dma/imx-dma.c         | 2 +-
 drivers/dma/imx-sdma.c        | 2 +-
 drivers/dma/mmp_tdma.c        | 2 +-
 drivers/dma/mxs-dma.c         | 2 +-
 drivers/dma/omap-dma.c        | 3 ++-
 drivers/dma/pl330.c           | 2 +-
 drivers/dma/sa11x0-dma.c      | 2 +-
 drivers/dma/sirf-dma.c        | 2 +-
 drivers/dma/ste_dma40.c       | 3 ++-
 drivers/dma/tegra20-apb-dma.c | 2 +-
 include/linux/dmaengine.h     | 5 +++--
 13 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 3934fcc..c1ea42c 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -841,12 +841,13 @@ atc_dma_cyclic_fill_desc(struct dma_chan *chan, struct at_desc *desc,
  * @buf_len: total number of bytes for the entire buffer
  * @period_len: number of bytes for each period
  * @direction: transfer direction, to or from device
+ * @no_wakeup: suppress interrupts
  * @context: transfer context (ignored)
  */
 static struct dma_async_tx_descriptor *
 atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
 	struct at_dma_slave	*atslave = chan->private;
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index c64917e..dfaf0df 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -1120,6 +1120,7 @@ fail:
  * @buf_len: length of the buffer (in bytes)
  * @period_len: lenght of a single period
  * @dir: direction of the operation
+ * @no_wakeup: suppress interrupts
  * @context: operation context (ignored)
  *
  * Prepares a descriptor for cyclic DMA operation. This means that once the
@@ -1133,7 +1134,8 @@ fail:
 static struct dma_async_tx_descriptor *
 ep93xx_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
 			   size_t buf_len, size_t period_len,
-			   enum dma_transfer_direction dir, void *context)
+			   enum dma_transfer_direction dir, bool no_wakeup,
+			   void *context)
 {
 	struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
 	struct ep93xx_dma_desc *desc, *first;
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index 5084975..8f05eb2 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -801,7 +801,7 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
 static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
 	struct imxdma_engine *imxdma = imxdmac->imxdma;
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 1dc2a4a..3109fa0 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1012,7 +1012,7 @@ err_out:
 static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
 	struct sdma_engine *sdma = sdmac->sdma;
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index 8a15cf2..6d70d9c 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -358,7 +358,7 @@ struct mmp_tdma_desc *mmp_tdma_alloc_descriptor(struct mmp_tdma_chan *tdmac)
 static struct dma_async_tx_descriptor *mmp_tdma_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
 	struct mmp_tdma_desc *desc;
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 7f41b25..d137ebb 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -531,7 +531,7 @@ err_out:
 static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
 	struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 71d7869..c6a711d 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -366,7 +366,8 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
 
 static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
 	struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
-	size_t period_len, enum dma_transfer_direction dir, void *context)
+	size_t period_len, enum dma_transfer_direction dir, bool no_wakeup,
+	void *context)
 {
 	struct omap_chan *c = to_omap_dma_chan(chan);
 	enum dma_slave_buswidth dev_width;
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index e4feba6..865db3f 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2683,7 +2683,7 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len)
 static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context)
+		bool no_wakeup, void *context)
 {
 	struct dma_pl330_desc *desc;
 	struct dma_pl330_chan *pch = to_pchan(chan);
diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index f5a7360..f26132c 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -614,7 +614,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
 
 static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic(
 	struct dma_chan *chan, dma_addr_t addr, size_t size, size_t period,
-	enum dma_transfer_direction dir, void *context)
+	enum dma_transfer_direction dir, bool no_wakeup, void *context)
 {
 	struct sa11x0_dma_chan *c = to_sa11x0_dma_chan(chan);
 	struct sa11x0_dma_desc *txd;
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 434ad31..2db0574 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -489,7 +489,7 @@ err_dir:
 static struct dma_async_tx_descriptor *
 sirfsoc_dma_prep_cyclic(struct dma_chan *chan, dma_addr_t addr,
 	size_t buf_len, size_t period_len,
-	enum dma_transfer_direction direction, void *context)
+	enum dma_transfer_direction direction, bool no_wakeup, void *context)
 {
 	struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan);
 	struct sirfsoc_dma_desc *sdesc = NULL;
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 000d309..b5e8e6c 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2347,7 +2347,8 @@ static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan,
 static struct dma_async_tx_descriptor *
 dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
 		     size_t buf_len, size_t period_len,
-		     enum dma_transfer_direction direction, void *context)
+		     enum dma_transfer_direction direction, bool no_wakeup,
+		     void *context)
 {
 	unsigned int periods = buf_len / period_len;
 	struct dma_async_tx_descriptor *txd;
diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 24acd71..61af0a5 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -990,7 +990,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
 struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
 	struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_len,
 	size_t period_len, enum dma_transfer_direction direction,
-	void *context)
+	bool no_wakeup, void *context)
 {
 	struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
 	struct tegra_dma_desc *dma_desc = NULL;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 990444b..a4ec3c9 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -591,7 +591,7 @@ struct dma_device {
 	struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)(
 		struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
-		void *context);
+		bool no_wakeup, void *context);
 	struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)(
 		struct dma_chan *chan, struct dma_interleaved_template *xt,
 		unsigned long flags);
@@ -657,7 +657,8 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
 		bool no_wakeup)
 {
 	return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
-						period_len, dir, NULL);
+						period_len, dir, no_wakeup,
+					        NULL);
 }
 
 static inline int dmaengine_terminate_all(struct dma_chan *chan)
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 05/15] dmaengine: omap-dma: Add support for no_wakeup in cyclic mode
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Peter Ujfalusi
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

When requested disable all DMA interrupts for the channel. In this mode
user space does not expect periodic reports from kernel about the progress
of the audio stream - PulseAudio for example support this type of mode.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/dma/omap-dma.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index c6a711d..cbe087e 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -374,6 +374,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
 	struct omap_desc *d;
 	dma_addr_t dev_addr;
 	unsigned es, sync_type;
+	unsigned long tx_flags = 0;
 	u32 burst;
 
 	if (dir == DMA_DEV_TO_MEM) {
@@ -429,7 +430,11 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
 	if (!c->cyclic) {
 		c->cyclic = true;
 		omap_dma_link_lch(c->dma_ch, c->dma_ch);
-		omap_enable_dma_irq(c->dma_ch, OMAP_DMA_FRAME_IRQ);
+
+		if (!no_wakeup) {
+			omap_enable_dma_irq(c->dma_ch, OMAP_DMA_FRAME_IRQ);
+			tx_flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
+		}
 		omap_disable_dma_irq(c->dma_ch, OMAP_DMA_BLOCK_IRQ);
 	}
 
@@ -438,7 +443,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
 		omap_set_dma_dest_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16);
 	}
 
-	return vchan_tx_prep(&c->vc, &d->vd, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
+	return vchan_tx_prep(&c->vc, &d->vd, tx_flags);
 }
 
 static int omap_dma_slave_config(struct omap_chan *c, struct dma_slave_config *cfg)
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (4 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 05/15] dmaengine: omap-dma: Add support for no_wakeup in cyclic mode Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 07/15] ASoC: omap-pcm: Select sDMA synchronization based on packet_size Peter Ujfalusi
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

When McBSP is configured in threshold mode we can use sDMA packet mode in
all cases.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-mcbsp.c | 47 ++++++++++++++++-----------------------------
 1 file changed, 17 insertions(+), 30 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 2e91a86..fe3debc 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
 	 */
 	if (dma_data->packet_size)
 		words = dma_data->packet_size;
-	else if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
-		words = snd_pcm_lib_period_bytes(substream) /
-						(mcbsp->wlen / 8);
 	else
 		words = 1;
 
@@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 		dma_data->set_threshold = omap_mcbsp_set_threshold;
 		if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
 			int period_words, max_thrsh;
+			int divider = 0;
 
 			period_words = params_period_bytes(params) / (wlen / 8);
 			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 			else
 				max_thrsh = mcbsp->max_rx_thres;
 			/*
-			 * If the period contains less or equal number of words,
-			 * we are using the original threshold mode setup:
-			 * McBSP threshold = sDMA frame size = period_size
-			 * Otherwise we switch to sDMA packet mode:
-			 * McBSP threshold = sDMA packet size
-			 * sDMA frame size = period size
+			 * Use sDMA packet mode if McBSP is in threshold mode:
+			 * If period words less than the FIFO size the packet
+			 * size is set to the number of period words, otherwise
+			 * Look for the biggest threshold value which divides
+			 * the period size evenly.
 			 */
-			if (period_words > max_thrsh) {
-				int divider = 0;
-
-				/*
-				 * Look for the biggest threshold value, which
-				 * divides the period size evenly.
-				 */
-				divider = period_words / max_thrsh;
-				if (period_words % max_thrsh)
-					divider++;
-				while (period_words % divider &&
-					divider < period_words)
-					divider++;
-				if (divider == period_words)
-					return -EINVAL;
-
-				pkt_size = period_words / divider;
-				sync_mode = OMAP_DMA_SYNC_PACKET;
-			} else {
-				sync_mode = OMAP_DMA_SYNC_FRAME;
-			}
+			divider = period_words / max_thrsh;
+			if (period_words % max_thrsh)
+				divider++;
+			while (period_words % divider &&
+				divider < period_words)
+				divider++;
+			if (divider == period_words)
+				return -EINVAL;
+
+			pkt_size = period_words / divider;
+			sync_mode = OMAP_DMA_SYNC_PACKET;
 		} else if (channels > 1) {
 			/* Use packet mode for non mono streams */
 			pkt_size = channels;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 07/15] ASoC: omap-pcm: Select sDMA synchronization based on packet_size
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (5 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 08/15] ASoC: OMAP: Remove sync_mode from omap_pcm_dma_data struct Peter Ujfalusi
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Since we only have element or packet synchronization we can use the
dma_data->packet_size to select the desired mode:
if packet_size is 0 we use ELEMENT mode
if packet_size is not 0 we use PACKET mode for sDMA synchronization.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-pcm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index f0feb06..02eeb2e 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -165,7 +165,12 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	memset(&dma_params, 0, sizeof(dma_params));
 	dma_params.data_type			= dma_data->data_type;
 	dma_params.trigger			= dma_data->dma_req;
-	dma_params.sync_mode			= dma_data->sync_mode;
+
+	if (dma_data->packet_size)
+		dma_params.sync_mode = OMAP_DMA_SYNC_PACKET;
+	else
+		dma_params.sync_mode = OMAP_DMA_SYNC_ELEMENT;
+
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		dma_params.src_amode		= OMAP_DMA_AMODE_POST_INC;
 		dma_params.dst_amode		= OMAP_DMA_AMODE_CONSTANT;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 08/15] ASoC: OMAP: Remove sync_mode from omap_pcm_dma_data struct
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (6 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 07/15] ASoC: omap-pcm: Select sDMA synchronization based on packet_size Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:37 ` [PATCH v2 09/15] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties Peter Ujfalusi
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

The omap-pcm platform driver no longer needs this parameter to select
between ELEMENT and PACKET mode. The selection is based on the configured
packet_size.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-dmic.c  | 1 -
 sound/soc/omap/omap-hdmi.c  | 1 -
 sound/soc/omap/omap-mcbsp.c | 5 +----
 sound/soc/omap/omap-mcpdm.c | 2 --
 sound/soc/omap/omap-pcm.h   | 1 -
 5 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 75f5dca..60b7b8c 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -64,7 +64,6 @@ struct omap_dmic {
 static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
 	.name		= "DMIC capture",
 	.data_type	= OMAP_DMA_DATA_TYPE_S32,
-	.sync_mode	= OMAP_DMA_SYNC_PACKET,
 };
 
 static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c
index a08245d..b194646 100644
--- a/sound/soc/omap/omap-hdmi.c
+++ b/sound/soc/omap/omap-hdmi.c
@@ -290,7 +290,6 @@ static __devinit int omap_hdmi_probe(struct platform_device *pdev)
 
 	hdmi_data->dma_params.dma_req =  hdmi_rsrc->start;
 	hdmi_data->dma_params.name = "HDMI playback";
-	hdmi_data->dma_params.sync_mode = OMAP_DMA_SYNC_PACKET;
 
 	/*
 	 * 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 fe3debc..5b3bacc 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -225,7 +225,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;
-	int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT;
+	int wlen, channels, wpf;
 	int pkt_size = 0;
 	unsigned int format, div, framesize, master;
 
@@ -272,15 +272,12 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 				return -EINVAL;
 
 			pkt_size = period_words / divider;
-			sync_mode = OMAP_DMA_SYNC_PACKET;
 		} else if (channels > 1) {
 			/* Use packet mode for non mono streams */
 			pkt_size = channels;
-			sync_mode = OMAP_DMA_SYNC_PACKET;
 		}
 	}
 
-	dma_data->sync_mode = sync_mode;
 	dma_data->packet_size = pkt_size;
 
 	snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index f7babb3..baf92da 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -73,14 +73,12 @@ static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
 		.name = "Audio playback",
 		.dma_req = OMAP44XX_DMA_MCPDM_DL,
 		.data_type = OMAP_DMA_DATA_TYPE_S32,
-		.sync_mode = OMAP_DMA_SYNC_PACKET,
 		.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_REG_DN_DATA,
 	},
 	{
 		.name = "Audio capture",
 		.dma_req = OMAP44XX_DMA_MCPDM_UP,
 		.data_type = OMAP_DMA_DATA_TYPE_S32,
-		.sync_mode = OMAP_DMA_SYNC_PACKET,
 		.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_REG_UP_DATA,
 	},
 };
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index b92248c..1bf47e4 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -33,7 +33,6 @@ struct omap_pcm_dma_data {
 	unsigned long	port_addr;	/* transmit/receive register */
 	void (*set_threshold)(struct snd_pcm_substream *substream);
 	int		data_type;	/* data type 8,16,32 */
-	int		sync_mode;	/* DMA sync mode */
 	int		packet_size;	/* packet size only in PACKET mode */
 };
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 09/15] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (7 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 08/15] ASoC: OMAP: Remove sync_mode from omap_pcm_dma_data struct Peter Ujfalusi
@ 2012-09-13 13:37 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 10/15] ARM: OMAP4: hwmod_data: Add resource names to McPDM memory ranges Peter Ujfalusi
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:37 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Based on the format of the stream the omap-pcm can decide alone what data
type should be used with by the sDMA.
Keep the possibility for OMAP dai drivers to tell omap-pcm if they want to
use different data type. This is needed for the omap-hdmi for example which
needs 32bit data type even if the stream format is S16_LE.

The check if (dma_data->data_type) is safe at the moment since omap-pcm
does not support 8bit samples (OMAP_DMA_DATA_TYPE_S8 == 0x00).

The next step is to redefine the meaning of dma_data->data_type to unblock
this limitation.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-pcm.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 02eeb2e..4c13a5f 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -149,6 +149,24 @@ static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
 	return 0;
 }
 
+static int omap_pcm_get_dma_type(int num_bits)
+{
+	int data_type;
+
+	switch (num_bits) {
+	case 16:
+		data_type = OMAP_DMA_DATA_TYPE_S16;
+		break;
+	case 32:
+		data_type = OMAP_DMA_DATA_TYPE_S32;
+		break;
+	default:
+		data_type = -EINVAL;
+		break;
+	}
+	return data_type;
+}
+
 static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -163,7 +181,16 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 		return 0;
 
 	memset(&dma_params, 0, sizeof(dma_params));
-	dma_params.data_type			= dma_data->data_type;
+
+	if (dma_data->data_type)
+		dma_params.data_type = dma_data->data_type;
+	else
+		dma_params.data_type = omap_pcm_get_dma_type(
+				snd_pcm_format_physical_width(runtime->format));
+
+	if (dma_params.data_type < 0)
+		return dma_params.data_type;
+
 	dma_params.trigger			= dma_data->dma_req;
 
 	if (dma_data->packet_size)
@@ -195,7 +222,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	 * still can get an interrupt at each period bounary
 	 */
 	bytes = snd_pcm_lib_period_bytes(substream);
-	dma_params.elem_count	= bytes >> dma_data->data_type;
+	dma_params.elem_count	= bytes >> dma_params.data_type;
 	dma_params.frame_count	= runtime->periods;
 	omap_set_dma_params(prtd->dma_ch, &dma_params);
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 10/15] ARM: OMAP4: hwmod_data: Add resource names to McPDM memory ranges
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (8 preceding siblings ...)
  2012-09-13 13:37 ` [PATCH v2 09/15] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 11/15] ASoC: omap-mcpdm: Use platform_get_resource_* to get resources Peter Ujfalusi
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

To help the driver to get the correct memory range to access McPDM
registers.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 242aee4..f65251e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -5059,6 +5059,7 @@ static struct omap_hwmod_ocp_if omap44xx_l4_per__mcbsp4 = {
 
 static struct omap_hwmod_addr_space omap44xx_mcpdm_addrs[] = {
 	{
+		.name		= "mpu",
 		.pa_start	= 0x40132000,
 		.pa_end		= 0x4013207f,
 		.flags		= ADDR_TYPE_RT
@@ -5077,6 +5078,7 @@ static struct omap_hwmod_ocp_if omap44xx_l4_abe__mcpdm = {
 
 static struct omap_hwmod_addr_space omap44xx_mcpdm_dma_addrs[] = {
 	{
+		.name		= "dma",
 		.pa_start	= 0x49032000,
 		.pa_end		= 0x4903207f,
 		.flags		= ADDR_TYPE_RT
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 11/15] ASoC: omap-mcpdm: Use platform_get_resource_* to get resources
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (9 preceding siblings ...)
  2012-09-13 13:38 ` [PATCH v2 10/15] ARM: OMAP4: hwmod_data: Add resource names to McPDM memory ranges Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 12/15] ASoC: OMAP: mcbsp, mcpdm, dmic: Let omap-pcm to pick the dma_type Peter Ujfalusi
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Get the needed resources in a correct way and avoid using defines for them.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-mcpdm.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index baf92da..f90d5de 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -71,15 +71,11 @@ struct omap_mcpdm {
 static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
 	{
 		.name = "Audio playback",
-		.dma_req = OMAP44XX_DMA_MCPDM_DL,
 		.data_type = OMAP_DMA_DATA_TYPE_S32,
-		.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_REG_DN_DATA,
 	},
 	{
 		.name = "Audio capture",
-		.dma_req = OMAP44XX_DMA_MCPDM_UP,
 		.data_type = OMAP_DMA_DATA_TYPE_S32,
-		.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_REG_UP_DATA,
 	},
 };
 
@@ -452,10 +448,33 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
 
 	mutex_init(&mcpdm->mutex);
 
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
+	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;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL)
 		return -ENOMEM;
 
+	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link");
+	if (!res)
+		return -ENODEV;
+
+	omap_mcpdm_dai_dma_params[0].dma_req = res->start;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
+	if (!res)
+		return -ENODEV;
+
+	omap_mcpdm_dai_dma_params[1].dma_req = res->start;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
+	if (res == NULL)
+		return -ENOMEM;
+
 	if (!devm_request_mem_region(&pdev->dev, res->start,
 				     resource_size(res), "McPDM"))
 		return -EBUSY;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 12/15] ASoC: OMAP: mcbsp, mcpdm, dmic: Let omap-pcm to pick the dma_type
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (10 preceding siblings ...)
  2012-09-13 13:38 ` [PATCH v2 11/15] ASoC: omap-mcpdm: Use platform_get_resource_* to get resources Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 13/15] ASoC: omap-pcm, omap-dmic: Change the use of omap_pcm_dma_data->data_type Peter Ujfalusi
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

omap-pcm can figure out the correct dma_type based on the stream's format.
In this way we can get rid of the plat/dma.h include from these drivers.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-dmic.c  | 2 --
 sound/soc/omap/omap-mcbsp.c | 3 ---
 sound/soc/omap/omap-mcpdm.c | 3 ---
 3 files changed, 8 deletions(-)

diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 60b7b8c..df0ff24 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -33,7 +33,6 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/of_device.h>
-#include <plat/dma.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -63,7 +62,6 @@ struct omap_dmic {
  */
 static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
 	.name		= "DMIC capture",
-	.data_type	= OMAP_DMA_DATA_TYPE_S32,
 };
 
 static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 5b3bacc..a230646 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -34,7 +34,6 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 
-#include <plat/dma.h>
 #include <plat/mcbsp.h>
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
@@ -234,11 +233,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 
 	switch (params_format(params)) {
 	case SNDRV_PCM_FORMAT_S16_LE:
-		dma_data->data_type = OMAP_DMA_DATA_TYPE_S16;
 		wlen = 16;
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
-		dma_data->data_type = OMAP_DMA_DATA_TYPE_S32;
 		wlen = 32;
 		break;
 	default:
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index f90d5de..84743d4 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -40,7 +40,6 @@
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 
-#include <plat/dma.h>
 #include <plat/omap_hwmod.h>
 #include "omap-mcpdm.h"
 #include "omap-pcm.h"
@@ -71,11 +70,9 @@ struct omap_mcpdm {
 static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
 	{
 		.name = "Audio playback",
-		.data_type = OMAP_DMA_DATA_TYPE_S32,
 	},
 	{
 		.name = "Audio capture",
-		.data_type = OMAP_DMA_DATA_TYPE_S32,
 	},
 };
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 13/15] ASoC: omap-pcm, omap-dmic: Change the use of omap_pcm_dma_data->data_type
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (11 preceding siblings ...)
  2012-09-13 13:38 ` [PATCH v2 12/15] ASoC: OMAP: mcbsp, mcpdm, dmic: Let omap-pcm to pick the dma_type Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 14/15] ASoC: OMAP: mcbsp, mcpdm, dmic, hdmi: Set dma_data at startup time Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 15/15] ASoC: omap-pcm: Convert to use dmaengine Peter Ujfalusi
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Instead of the OMAP DMA data type definition the data_type will be used to
specify the number of bits the DMA word should be configured or 0 in case
when based on the stream's format the omap-pcm can decide the needed DMA
word size.
This feature is needed for the omap-hdmi where the sDMA need to be
configured for 32bit word type regardless of the audio format used.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-hdmi.c | 3 +--
 sound/soc/omap/omap-pcm.c  | 3 ++-
 sound/soc/omap/omap-pcm.h  | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c
index b194646..0951767 100644
--- a/sound/soc/omap/omap-hdmi.c
+++ b/sound/soc/omap/omap-hdmi.c
@@ -34,7 +34,6 @@
 #include <sound/asoundef.h>
 #include <video/omapdss.h>
 
-#include <plat/dma.h>
 #include "omap-pcm.h"
 #include "omap-hdmi.h"
 
@@ -100,7 +99,7 @@ static int omap_hdmi_dai_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	priv->dma_params.data_type = OMAP_DMA_DATA_TYPE_S32;
+	priv->dma_params.data_type = 32;
 
 	snd_soc_dai_set_dma_data(dai, substream,
 				 &priv->dma_params);
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 4c13a5f..74da4b7 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -183,7 +183,8 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	memset(&dma_params, 0, sizeof(dma_params));
 
 	if (dma_data->data_type)
-		dma_params.data_type = dma_data->data_type;
+		dma_params.data_type = omap_pcm_get_dma_type(
+				dma_data->data_type);
 	else
 		dma_params.data_type = omap_pcm_get_dma_type(
 				snd_pcm_format_physical_width(runtime->format));
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index 1bf47e4..cabe74c 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -32,7 +32,8 @@ struct omap_pcm_dma_data {
 	int		dma_req;	/* DMA request line */
 	unsigned long	port_addr;	/* transmit/receive register */
 	void (*set_threshold)(struct snd_pcm_substream *substream);
-	int		data_type;	/* data type 8,16,32 */
+	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 */
 };
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 14/15] ASoC: OMAP: mcbsp, mcpdm, dmic, hdmi: Set dma_data at startup time
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (12 preceding siblings ...)
  2012-09-13 13:38 ` [PATCH v2 13/15] ASoC: omap-pcm, omap-dmic: Change the use of omap_pcm_dma_data->data_type Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  2012-09-13 13:38 ` [PATCH v2 15/15] ASoC: omap-pcm: Convert to use dmaengine Peter Ujfalusi
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Set the dma_data for the stream (snd_soc_dai_set_dma_data) at dai_startup
time so omap-pcm will have access to the needed information regarding to
the DMA channel earlier.
This is needed for the clean dmaengine support.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-dmic.c  |  6 ++++--
 sound/soc/omap/omap-hdmi.c  | 15 +++++++++------
 sound/soc/omap/omap-mcbsp.c |  7 ++++---
 sound/soc/omap/omap-mcpdm.c |  8 ++++----
 4 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index df0ff24..68f2cd1 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -118,6 +118,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);
 	return ret;
 }
 
@@ -202,6 +203,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;
 	int channels;
 
 	dmic->clk_div = omap_dmic_select_divider(dmic, params_rate(params));
@@ -227,8 +229,8 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	/* packet size is threshold * channels */
-	omap_dmic_dai_dma_params.packet_size = dmic->threshold * channels;
-	snd_soc_dai_set_dma_data(dai, substream, &omap_dmic_dai_dma_params);
+	dma_data = snd_soc_dai_get_dma_data(dai, substream);
+	dma_data->packet_size = dmic->threshold * channels;
 
 	return 0;
 }
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c
index 0951767..f59c69f 100644
--- a/sound/soc/omap/omap-hdmi.c
+++ b/sound/soc/omap/omap-hdmi.c
@@ -67,6 +67,9 @@ static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream,
 		dev_err(dai->dev, "audio not supported\n");
 		return -ENODEV;
 	}
+
+	snd_soc_dai_set_dma_data(dai, substream, &priv->dma_params);
+
 	return 0;
 }
 
@@ -85,24 +88,24 @@ 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:
-		priv->dma_params.packet_size = 16;
+		dma_data->packet_size = 16;
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
-		priv->dma_params.packet_size = 32;
+		dma_data->packet_size = 32;
 		break;
 	default:
 		dev_err(dai->dev, "format not supported!\n");
 		return -EINVAL;
 	}
 
-	priv->dma_params.data_type = 32;
-
-	snd_soc_dai_set_dma_data(dai, substream,
-				 &priv->dma_params);
+	dma_data->data_type = 32;
 
 	/*
 	 * fill the IEC-60958 channel status word
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index a230646..fef2f59 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -151,6 +151,9 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
 					   SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2);
 	}
 
+	snd_soc_dai_set_dma_data(cpu_dai, substream,
+				 &mcbsp->dma_data[substream->stream]);
+
 	return err;
 }
 
@@ -228,7 +231,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	int pkt_size = 0;
 	unsigned int format, div, framesize, master;
 
-	dma_data = &mcbsp->dma_data[substream->stream];
+	dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream);
 	channels = params_channels(params);
 
 	switch (params_format(params)) {
@@ -277,8 +280,6 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 
 	dma_data->packet_size = pkt_size;
 
-	snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
-
 	if (mcbsp->configured) {
 		/* McBSP already configured by another stream */
 		return 0;
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 84743d4..7755650 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -267,9 +267,11 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
 		}
 		omap_mcpdm_open_streams(mcpdm);
 	}
-
 	mutex_unlock(&mcpdm->mutex);
 
+	snd_soc_dai_set_dma_data(dai, substream,
+				 &omap_mcpdm_dai_dma_params[substream->stream]);
+
 	return 0;
 }
 
@@ -324,7 +326,7 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	dma_data = &omap_mcpdm_dai_dma_params[stream];
+	dma_data = snd_soc_dai_get_dma_data(dai, substream);
 
 	/* Configure McPDM channels, and DMA packet size */
 	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -336,8 +338,6 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
 		dma_data->packet_size = mcpdm->up_threshold * channels;
 	}
 
-	snd_soc_dai_set_dma_data(dai, substream, dma_data);
-
 	return 0;
 }
 
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 15/15] ASoC: omap-pcm: Convert to use dmaengine
  2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
                   ` (13 preceding siblings ...)
  2012-09-13 13:38 ` [PATCH v2 14/15] ASoC: OMAP: mcbsp, mcpdm, dmic, hdmi: Set dma_data at startup time Peter Ujfalusi
@ 2012-09-13 13:38 ` Peter Ujfalusi
  14 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-13 13:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula
  Cc: alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen

Original author: Russell King <rmk+kernel@arm.linux.org.uk>

Switch the omap-pcm to use dmaengine.
Certain features are not supported by after dmaengine conversion:
1. No period wakeup mode
   DMA engine has no way to communicate this information through
   standard channels.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Russell King <rmk+kernel@arm.linux.org.uk>
---
 sound/soc/omap/Kconfig    |   3 +-
 sound/soc/omap/omap-pcm.c | 269 ++++++++++------------------------------------
 2 files changed, 61 insertions(+), 211 deletions(-)

diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index 2c484a5..7048137 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -1,6 +1,7 @@
 config SND_OMAP_SOC
 	tristate "SoC Audio for the Texas Instruments OMAP chips"
-	depends on ARCH_OMAP
+	depends on ARCH_OMAP && DMA_OMAP
+	select SND_SOC_DMAENGINE_PCM
 
 config SND_OMAP_SOC_DMIC
 	tristate
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 74da4b7..a2636f6 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -25,12 +25,13 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/omap-dma.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
+#include <sound/dmaengine_pcm.h>
 #include <sound/soc.h>
 
-#include <plat/dma.h>
 #include "omap-pcm.h"
 
 static const struct snd_pcm_hardware omap_pcm_hardware = {
@@ -49,61 +50,34 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
 	.buffer_bytes_max	= 128 * 1024,
 };
 
-struct omap_runtime_data {
-	spinlock_t			lock;
-	struct omap_pcm_dma_data	*dma_data;
-	int				dma_ch;
-	int				period_index;
-};
-
-static void omap_pcm_dma_irq(int ch, u16 stat, void *data)
+static int omap_pcm_get_dma_buswidth(int num_bits)
 {
-	struct snd_pcm_substream *substream = data;
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd = runtime->private_data;
-	unsigned long flags;
-
-	if ((cpu_is_omap1510())) {
-		/*
-		 * OMAP1510 doesn't fully support DMA progress counter
-		 * and there is no software emulation implemented yet,
-		 * so have to maintain our own progress counters
-		 * that can be used by omap_pcm_pointer() instead.
-		 */
-		spin_lock_irqsave(&prtd->lock, flags);
-		if ((stat == OMAP_DMA_LAST_IRQ) &&
-				(prtd->period_index == runtime->periods - 1)) {
-			/* we are in sync, do nothing */
-			spin_unlock_irqrestore(&prtd->lock, flags);
-			return;
-		}
-		if (prtd->period_index >= 0) {
-			if (stat & OMAP_DMA_BLOCK_IRQ) {
-				/* end of buffer reached, loop back */
-				prtd->period_index = 0;
-			} else if (stat & OMAP_DMA_LAST_IRQ) {
-				/* update the counter for the last period */
-				prtd->period_index = runtime->periods - 1;
-			} else if (++prtd->period_index >= runtime->periods) {
-				/* end of buffer missed? loop back */
-				prtd->period_index = 0;
-			}
-		}
-		spin_unlock_irqrestore(&prtd->lock, flags);
-	}
+	int buswidth;
 
-	snd_pcm_period_elapsed(substream);
+	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)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct omap_runtime_data *prtd = runtime->private_data;
 	struct omap_pcm_dma_data *dma_data;
-
+	struct dma_slave_config config;
+	struct dma_chan *chan;
 	int err = 0;
 
 	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
@@ -116,195 +90,78 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
 	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
 	runtime->dma_bytes = params_buffer_bytes(params);
 
-	if (prtd->dma_data)
-		return 0;
-	prtd->dma_data = dma_data;
-	err = omap_request_dma(dma_data->dma_req, dma_data->name,
-			       omap_pcm_dma_irq, substream, &prtd->dma_ch);
-	if (!err) {
-		/*
-		 * Link channel with itself so DMA doesn't need any
-		 * reprogramming while looping the buffer
-		 */
-		omap_dma_link_lch(prtd->dma_ch, prtd->dma_ch);
-	}
-
-	return err;
-}
-
-static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
-{
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd = runtime->private_data;
-
-	if (prtd->dma_data == NULL)
-		return 0;
+	chan = snd_dmaengine_pcm_get_chan(substream);
+	if (!chan)
+		return -EINVAL;
 
-	omap_dma_unlink_lch(prtd->dma_ch, prtd->dma_ch);
-	omap_free_dma(prtd->dma_ch);
-	prtd->dma_data = NULL;
+	/* fills in addr_width and direction */
+	err = snd_hwparams_to_dma_slave_config(substream, params, &config);
+	if (err)
+		return err;
 
-	snd_pcm_set_runtime_buffer(substream, NULL);
+	/* 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);
 
-	return 0;
-}
+		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+			config.dst_addr_width = buswidth;
+		else
+			config.src_addr_width = buswidth;
+	}
 
-static int omap_pcm_get_dma_type(int num_bits)
-{
-	int data_type;
+	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;
 
-	switch (num_bits) {
-	case 16:
-		data_type = OMAP_DMA_DATA_TYPE_S16;
-		break;
-	case 32:
-		data_type = OMAP_DMA_DATA_TYPE_S32;
-		break;
-	default:
-		data_type = -EINVAL;
-		break;
-	}
-	return data_type;
+	return dmaengine_slave_config(chan, &config);
 }
 
-static int omap_pcm_prepare(struct snd_pcm_substream *substream)
+static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
 {
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd = runtime->private_data;
-	struct omap_pcm_dma_data *dma_data = prtd->dma_data;
-	struct omap_dma_channel_params dma_params;
-	int bytes;
-
-	/* return if this is a bufferless transfer e.g.
-	 * codec <--> BT codec or GSM modem -- lg FIXME */
-	if (!prtd->dma_data)
-		return 0;
-
-	memset(&dma_params, 0, sizeof(dma_params));
-
-	if (dma_data->data_type)
-		dma_params.data_type = omap_pcm_get_dma_type(
-				dma_data->data_type);
-	else
-		dma_params.data_type = omap_pcm_get_dma_type(
-				snd_pcm_format_physical_width(runtime->format));
-
-	if (dma_params.data_type < 0)
-		return dma_params.data_type;
-
-	dma_params.trigger			= dma_data->dma_req;
-
-	if (dma_data->packet_size)
-		dma_params.sync_mode = OMAP_DMA_SYNC_PACKET;
-	else
-		dma_params.sync_mode = OMAP_DMA_SYNC_ELEMENT;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		dma_params.src_amode		= OMAP_DMA_AMODE_POST_INC;
-		dma_params.dst_amode		= OMAP_DMA_AMODE_CONSTANT;
-		dma_params.src_or_dst_synch	= OMAP_DMA_DST_SYNC;
-		dma_params.src_start		= runtime->dma_addr;
-		dma_params.dst_start		= dma_data->port_addr;
-		dma_params.dst_port		= OMAP_DMA_PORT_MPUI;
-		dma_params.dst_fi		= dma_data->packet_size;
-	} else {
-		dma_params.src_amode		= OMAP_DMA_AMODE_CONSTANT;
-		dma_params.dst_amode		= OMAP_DMA_AMODE_POST_INC;
-		dma_params.src_or_dst_synch	= OMAP_DMA_SRC_SYNC;
-		dma_params.src_start		= dma_data->port_addr;
-		dma_params.dst_start		= runtime->dma_addr;
-		dma_params.src_port		= OMAP_DMA_PORT_MPUI;
-		dma_params.src_fi		= dma_data->packet_size;
-	}
-	/*
-	 * Set DMA transfer frame size equal to ALSA period size and frame
-	 * count as no. of ALSA periods. Then with DMA frame interrupt enabled,
-	 * we can transfer the whole ALSA buffer with single DMA transfer but
-	 * still can get an interrupt at each period bounary
-	 */
-	bytes = snd_pcm_lib_period_bytes(substream);
-	dma_params.elem_count	= bytes >> dma_params.data_type;
-	dma_params.frame_count	= runtime->periods;
-	omap_set_dma_params(prtd->dma_ch, &dma_params);
-
-	if ((cpu_is_omap1510()))
-		omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ |
-			      OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ);
-	else if (!substream->runtime->no_period_wakeup)
-		omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ);
-	else {
-		/*
-		 * No period wakeup:
-		 * we need to disable BLOCK_IRQ, which is enabled by the omap
-		 * dma core at request dma time.
-		 */
-		omap_disable_dma_irq(prtd->dma_ch, OMAP_DMA_BLOCK_IRQ);
-	}
-
-	if (!(cpu_class_is_omap1())) {
-		omap_set_dma_src_burst_mode(prtd->dma_ch,
-						OMAP_DMA_DATA_BURST_16);
-		omap_set_dma_dest_burst_mode(prtd->dma_ch,
-						OMAP_DMA_DATA_BURST_16);
-	}
-
+	snd_pcm_set_runtime_buffer(substream, NULL);
 	return 0;
 }
 
 static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd = runtime->private_data;
-	struct omap_pcm_dma_data *dma_data = prtd->dma_data;
-	unsigned long flags;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct omap_pcm_dma_data *dma_data;
 	int ret = 0;
 
-	spin_lock_irqsave(&prtd->lock, flags);
+	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		prtd->period_index = 0;
 		/* Configure McBSP internal buffer usage */
 		if (dma_data->set_threshold)
 			dma_data->set_threshold(substream);
-
-		omap_start_dma(prtd->dma_ch);
 		break;
 
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		prtd->period_index = -1;
-		omap_stop_dma(prtd->dma_ch);
 		break;
 	default:
 		ret = -EINVAL;
 	}
-	spin_unlock_irqrestore(&prtd->lock, flags);
+
+	if (ret == 0)
+		ret = snd_dmaengine_pcm_trigger(substream, cmd);
 
 	return ret;
 }
 
 static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream)
 {
-	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd = runtime->private_data;
-	dma_addr_t ptr;
 	snd_pcm_uframes_t offset;
 
-	if (cpu_is_omap1510()) {
-		offset = prtd->period_index * runtime->period_size;
-	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		ptr = omap_get_dma_dst_pos(prtd->dma_ch);
-		offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
-	} else {
-		ptr = omap_get_dma_src_pos(prtd->dma_ch);
-		offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
-	}
-
-	if (offset >= runtime->buffer_size)
-		offset = 0;
+	if (cpu_is_omap1510())
+		offset = snd_dmaengine_pcm_pointer_no_residue(substream);
+	else
+		offset = snd_dmaengine_pcm_pointer(substream);
 
 	return offset;
 }
@@ -312,7 +169,8 @@ 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_pcm_runtime *runtime = substream->runtime;
-	struct omap_runtime_data *prtd;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct omap_pcm_dma_data *dma_data;
 	int ret;
 
 	snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
@@ -321,25 +179,17 @@ static int omap_pcm_open(struct snd_pcm_substream *substream)
 	ret = snd_pcm_hw_constraint_integer(runtime,
 					    SNDRV_PCM_HW_PARAM_PERIODS);
 	if (ret < 0)
-		goto out;
-
-	prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
-	if (prtd == NULL) {
-		ret = -ENOMEM;
-		goto out;
-	}
-	spin_lock_init(&prtd->lock);
-	runtime->private_data = prtd;
+		return ret;
 
-out:
+	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+	ret = snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
+				     &dma_data->dma_req);
 	return ret;
 }
 
 static int omap_pcm_close(struct snd_pcm_substream *substream)
 {
-	struct snd_pcm_runtime *runtime = substream->runtime;
-
-	kfree(runtime->private_data);
+	snd_dmaengine_pcm_close(substream);
 	return 0;
 }
 
@@ -360,7 +210,6 @@ static struct snd_pcm_ops omap_pcm_ops = {
 	.ioctl		= snd_pcm_lib_ioctl,
 	.hw_params	= omap_pcm_hw_params,
 	.hw_free	= omap_pcm_hw_free,
-	.prepare	= omap_pcm_prepare,
 	.trigger	= omap_pcm_trigger,
 	.pointer	= omap_pcm_pointer,
 	.mmap		= omap_pcm_mmap,
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 13:37 ` [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic() Peter Ujfalusi
@ 2012-09-13 15:27   ` Lars-Peter Clausen
  2012-09-13 15:38     ` Russell King - ARM Linux
                       ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Lars-Peter Clausen @ 2012-09-13 15:27 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri

On 09/13/2012 03:37 PM, Peter Ujfalusi wrote:
> The dmaengine_prep_dma_cyclic() function primarily used by audio for cyclic
> transfer required by ALSA.
> With this new parameter it is going to be possible to enable the
> SNDRV_PCM_INFO_NO_PERIOD_WAKEUP mode on platforms where it is possible.
> This patch only changes the public API first. Followup patch will change
> the device_prep_dma_cyclic() callback parameters to pass this information
> towards the dma drivers.
> 

Hi,

Hm... Do you think it would work as well if we implement this by setting the
callback for the descriptor to NULL? If the callback is NULL there is
nothing to at the end of a transfer/period and the dma engine driver may
choose to disable interrupts. This would also benefit non cyclic transfers
where the callback is NULL and we do not need add the new parameter to
dmaengine_prep_dma_cyclic.

- Lars

> ---
>  include/linux/dmaengine.h     | 3 ++-
>  sound/soc/soc-dmaengine-pcm.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 9c02a45..990444b 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -653,7 +653,8 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_rio_sg(
>  
>  static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
>  		struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
> -		size_t period_len, enum dma_transfer_direction dir)
> +		size_t period_len, enum dma_transfer_direction dir,
> +		bool no_wakeup)
>  {
>  	return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
>  						period_len, dir, NULL);
> diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
> index 5df529e..6b70adb 100644
> --- a/sound/soc/soc-dmaengine-pcm.c
> +++ b/sound/soc/soc-dmaengine-pcm.c
> @@ -147,7 +147,8 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
>  	desc = dmaengine_prep_dma_cyclic(chan,
>  		substream->runtime->dma_addr,
>  		snd_pcm_lib_buffer_bytes(substream),
> -		snd_pcm_lib_period_bytes(substream), direction);
> +		snd_pcm_lib_period_bytes(substream), direction,
> +		substream->runtime->no_period_wakeup);
>  
>  	if (!desc)
>  		return -ENOMEM;


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 15:27   ` Lars-Peter Clausen
@ 2012-09-13 15:38     ` Russell King - ARM Linux
  2012-09-14  3:27       ` Vinod Koul
  2012-09-14  7:15       ` Peter Ujfalusi
  2012-09-14  3:26     ` Vinod Koul
  2012-09-14  7:12     ` Peter Ujfalusi
  2 siblings, 2 replies; 37+ messages in thread
From: Russell King - ARM Linux @ 2012-09-13 15:38 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Tony Lindgren,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri

On Thu, Sep 13, 2012 at 05:27:09PM +0200, Lars-Peter Clausen wrote:
> Hm... Do you think it would work as well if we implement this by setting the
> callback for the descriptor to NULL? If the callback is NULL there is
> nothing to at the end of a transfer/period and the dma engine driver may
> choose to disable interrupts. This would also benefit non cyclic transfers
> where the callback is NULL and we do not need add the new parameter to
> dmaengine_prep_dma_cyclic.

Actually, there's a way to do that already.  DMA_PREP_INTERRUPT.
Unfortunately, most DMA engine slave API users don't set it when they
setup their transfer:

 * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
 *  this transaction

if we fixed that, then we could use the lack of it to avoid the interrupt.

However, cyclic transfers don't have the flags parameter used to pass this
bit.  Yet another bit of yucky inconsistent design in DMA engine land...

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
@ 2012-09-14  3:24   ` Vinod Koul
  2012-09-14  7:07     ` Peter Ujfalusi
  2012-09-17  6:34   ` Shawn Guo
  2012-09-17  9:01   ` Linus Walleij
  2 siblings, 1 reply; 37+ messages in thread
From: Vinod Koul @ 2012-09-14  3:24 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao, Shawn Guo,
	Laxman Dewangan

On Thu, 2012-09-13 at 16:37 +0300, Peter Ujfalusi wrote:
> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> can receive the no_wakeup request coming from client drivers.
> This feature can be used during audio operation to disable all audio
> related interrupts.
We already have a flag to indicate this, see 
* @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion  of
*  this transaction

Unfortunately, the addition of cyclic API missed having this flag. So
right way would be to add flag argument in the API.

-- 
~Vinod


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 15:27   ` Lars-Peter Clausen
  2012-09-13 15:38     ` Russell King - ARM Linux
@ 2012-09-14  3:26     ` Vinod Koul
  2012-09-14  7:18       ` [alsa-devel] " Peter Ujfalusi
  2012-09-14  8:13       ` Lars-Peter Clausen
  2012-09-14  7:12     ` Peter Ujfalusi
  2 siblings, 2 replies; 37+ messages in thread
From: Vinod Koul @ 2012-09-14  3:26 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Tony Lindgren,
	Russell King, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

On Thu, 2012-09-13 at 17:27 +0200, Lars-Peter Clausen wrote:
> Hi,
> 
> Hm... Do you think it would work as well if we implement this by
> setting the
> callback for the descriptor to NULL? If the callback is NULL there is
> nothing to at the end of a transfer/period and the dma engine driver
> may
> choose to disable interrupts. This would also benefit non cyclic
> transfers
> where the callback is NULL and we do not need add the new parameter to
> dmaengine_prep_dma_cyclic.
That will work too.... BUT the idea of no_wake mode in ALSA is that we
should not have any interrupts, so anything which is going to cause
interrupts to AP in undesired. The interrupts still happen and it just
that dmaengine driver is not notifying client.


-- 
~Vinod


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 15:38     ` Russell King - ARM Linux
@ 2012-09-14  3:27       ` Vinod Koul
  2012-09-14  7:15       ` Peter Ujfalusi
  1 sibling, 0 replies; 37+ messages in thread
From: Vinod Koul @ 2012-09-14  3:27 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: vinod.koul, Lars-Peter Clausen, alsa-devel, Janusz Krzysztofik,
	Tony Lindgren, Ricardo Neri, Mark Brown, linux-kernel,
	Peter Ujfalusi, linux-arm-kernel, Dan Williams, linux-omap,
	Liam Girdwood, Jarkko Nikula

On Thu, 2012-09-13 at 16:38 +0100, Russell King - ARM Linux wrote:
> On Thu, Sep 13, 2012 at 05:27:09PM +0200, Lars-Peter Clausen wrote:
> > Hm... Do you think it would work as well if we implement this by setting the
> > callback for the descriptor to NULL? If the callback is NULL there is
> > nothing to at the end of a transfer/period and the dma engine driver may
> > choose to disable interrupts. This would also benefit non cyclic transfers
> > where the callback is NULL and we do not need add the new parameter to
> > dmaengine_prep_dma_cyclic.
> 
> Actually, there's a way to do that already.  DMA_PREP_INTERRUPT.
> Unfortunately, most DMA engine slave API users don't set it when they
> setup their transfer:
> 
>  * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
>  *  this transaction
Looks like I have repeated the correct action!
> 
> if we fixed that, then we could use the lack of it to avoid the interrupt.
> 
> However, cyclic transfers don't have the flags parameter used to pass this
> bit.  Yet another bit of yucky inconsistent design in DMA engine land...
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-14  3:24   ` Vinod Koul
@ 2012-09-14  7:07     ` Peter Ujfalusi
  0 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-14  7:07 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao, Shawn Guo,
	Laxman Dewangan

On 09/14/2012 06:24 AM, Vinod Koul wrote:
> On Thu, 2012-09-13 at 16:37 +0300, Peter Ujfalusi wrote:
>> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
>> can receive the no_wakeup request coming from client drivers.
>> This feature can be used during audio operation to disable all audio
>> related interrupts.
> We already have a flag to indicate this, see 
> * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion  of
> *  this transaction

I have also noticed this flag. It is not really a direct match for our case
since the notion of "completion of this transfer" is not applicable for cyclic
mode, but it is close enough.

> Unfortunately, the addition of cyclic API missed having this flag. So
> right way would be to add flag argument in the API.

I have not looked at the non cyclic APIs, but I think I can modify the
dmaengine_prep_dma_cyclic() to pass the flags instead of the 'bool no_wakeup'.
If the DMA_PREP_INTERRUPT is not set dma drivers can interpret it in a way
that they will disable all interrupts during cyclic mode.
None of the dma drivers in cyclic mode cares about the flags AFAIK or they can
just ignore this parameter for now (as they did with my no_wakeup parameter).
Will resend the series soon with this change.

-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 15:27   ` Lars-Peter Clausen
  2012-09-13 15:38     ` Russell King - ARM Linux
  2012-09-14  3:26     ` Vinod Koul
@ 2012-09-14  7:12     ` Peter Ujfalusi
  2 siblings, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-14  7:12 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri

Hi,

On 09/13/2012 06:27 PM, Lars-Peter Clausen wrote:
> On 09/13/2012 03:37 PM, Peter Ujfalusi wrote:
>> The dmaengine_prep_dma_cyclic() function primarily used by audio for cyclic
>> transfer required by ALSA.
>> With this new parameter it is going to be possible to enable the
>> SNDRV_PCM_INFO_NO_PERIOD_WAKEUP mode on platforms where it is possible.
>> This patch only changes the public API first. Followup patch will change
>> the device_prep_dma_cyclic() callback parameters to pass this information
>> towards the dma drivers.
>>
> 
> Hi,
> 
> Hm... Do you think it would work as well if we implement this by setting the
> callback for the descriptor to NULL? If the callback is NULL there is
> nothing to at the end of a transfer/period and the dma engine driver may
> choose to disable interrupts. This would also benefit non cyclic transfers
> where the callback is NULL and we do not need add the new parameter to
> dmaengine_prep_dma_cyclic.

We could do that but dma drivers enable the interrupts within
dmaengine_prep_dma_cyclic() call, and we fill up the callback for
dmaengine_submit() dmaengine API call.
We need to tell the dma drivers in dmaengine_prep_dma_cyclic() to suppress the
interrupts.

Note: First I was trying this to be done in hw_params() time via the
dmaengine_slave_config() call, but substream->runtime->no_period_wakeup is not
configured in there. It is set for _prepare() and _trigger().

As Vinod and Russell suggested I will modify the dmaengine_prep_dma_cyclic()
API to pass flags as well instead of the no_wakeup parameter.

> 
> - Lars
> 
>> ---
>>  include/linux/dmaengine.h     | 3 ++-
>>  sound/soc/soc-dmaengine-pcm.c | 3 ++-
>>  2 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
>> index 9c02a45..990444b 100644
>> --- a/include/linux/dmaengine.h
>> +++ b/include/linux/dmaengine.h
>> @@ -653,7 +653,8 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_rio_sg(
>>  
>>  static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
>>  		struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
>> -		size_t period_len, enum dma_transfer_direction dir)
>> +		size_t period_len, enum dma_transfer_direction dir,
>> +		bool no_wakeup)
>>  {
>>  	return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
>>  						period_len, dir, NULL);
>> diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
>> index 5df529e..6b70adb 100644
>> --- a/sound/soc/soc-dmaengine-pcm.c
>> +++ b/sound/soc/soc-dmaengine-pcm.c
>> @@ -147,7 +147,8 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
>>  	desc = dmaengine_prep_dma_cyclic(chan,
>>  		substream->runtime->dma_addr,
>>  		snd_pcm_lib_buffer_bytes(substream),
>> -		snd_pcm_lib_period_bytes(substream), direction);
>> +		snd_pcm_lib_period_bytes(substream), direction,
>> +		substream->runtime->no_period_wakeup);
>>  
>>  	if (!desc)
>>  		return -ENOMEM;
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-13 15:38     ` Russell King - ARM Linux
  2012-09-14  3:27       ` Vinod Koul
@ 2012-09-14  7:15       ` Peter Ujfalusi
  1 sibling, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-14  7:15 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Lars-Peter Clausen, Mark Brown, Liam Girdwood, Tony Lindgren,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri

On 09/13/2012 06:38 PM, Russell King - ARM Linux wrote:
> On Thu, Sep 13, 2012 at 05:27:09PM +0200, Lars-Peter Clausen wrote:
>> Hm... Do you think it would work as well if we implement this by setting the
>> callback for the descriptor to NULL? If the callback is NULL there is
>> nothing to at the end of a transfer/period and the dma engine driver may
>> choose to disable interrupts. This would also benefit non cyclic transfers
>> where the callback is NULL and we do not need add the new parameter to
>> dmaengine_prep_dma_cyclic.
> 
> Actually, there's a way to do that already.  DMA_PREP_INTERRUPT.
> Unfortunately, most DMA engine slave API users don't set it when they
> setup their transfer:
> 
>  * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
>  *  this transaction

As I mentioned already to Vinod: the description of this flag is close enough
for our needs (other than the notion of 'this transaction' is not really
correct for cyclic mode).
I will resend the series to add the flags as new parameter instead of the
no_wakeup.

> 
> if we fixed that, then we could use the lack of it to avoid the interrupt.
> 
> However, cyclic transfers don't have the flags parameter used to pass this
> bit.  Yet another bit of yucky inconsistent design in DMA engine land...
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [alsa-devel] [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  3:26     ` Vinod Koul
@ 2012-09-14  7:18       ` Peter Ujfalusi
  2012-09-14  8:13       ` Lars-Peter Clausen
  1 sibling, 0 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-14  7:18 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Lars-Peter Clausen, alsa-devel, Janusz Krzysztofik,
	Tony Lindgren, Ricardo Neri, Mark Brown, linux-kernel,
	linux-arm-kernel, Dan Williams, Russell King, linux-omap,
	Liam Girdwood, Jarkko Nikula

On 09/14/2012 06:26 AM, Vinod Koul wrote:
> On Thu, 2012-09-13 at 17:27 +0200, Lars-Peter Clausen wrote:
>> Hi,
>>
>> Hm... Do you think it would work as well if we implement this by
>> setting the
>> callback for the descriptor to NULL? If the callback is NULL there is
>> nothing to at the end of a transfer/period and the dma engine driver
>> may
>> choose to disable interrupts. This would also benefit non cyclic
>> transfers
>> where the callback is NULL and we do not need add the new parameter to
>> dmaengine_prep_dma_cyclic.
> That will work too.... BUT the idea of no_wake mode in ALSA is that we
> should not have any interrupts, so anything which is going to cause
> interrupts to AP in undesired. The interrupts still happen and it just
> that dmaengine driver is not notifying client.

Yes, this is correct. We could go and hack around later if the callback is not
present and modify the irq requests for the platform but it is really not
elegant way of dealing with the issue IMHO.


-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  3:26     ` Vinod Koul
  2012-09-14  7:18       ` [alsa-devel] " Peter Ujfalusi
@ 2012-09-14  8:13       ` Lars-Peter Clausen
  2012-09-14  8:50         ` Vinod Koul
  1 sibling, 1 reply; 37+ messages in thread
From: Lars-Peter Clausen @ 2012-09-14  8:13 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Tony Lindgren,
	Russell King, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

On 09/14/2012 05:26 AM, Vinod Koul wrote:
> On Thu, 2012-09-13 at 17:27 +0200, Lars-Peter Clausen wrote:
>> Hi,
>>
>> Hm... Do you think it would work as well if we implement this by
>> setting the
>> callback for the descriptor to NULL? If the callback is NULL there is
>> nothing to at the end of a transfer/period and the dma engine driver
>> may
>> choose to disable interrupts. This would also benefit non cyclic
>> transfers
>> where the callback is NULL and we do not need add the new parameter to
>> dmaengine_prep_dma_cyclic.
> That will work too.... BUT the idea of no_wake mode in ALSA is that we
> should not have any interrupts, so anything which is going to cause
> interrupts to AP in undesired. The interrupts still happen and it just
> that dmaengine driver is not notifying client.

Well, the idea was that the driver would disable interrupts if there is no
callback to call, since there would be nothing to do in the interrupt
handler anyway. But I guess the flags approach should work fine as well.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  8:13       ` Lars-Peter Clausen
@ 2012-09-14  8:50         ` Vinod Koul
  2012-09-14  9:28           ` Peter Ujfalusi
  0 siblings, 1 reply; 37+ messages in thread
From: Vinod Koul @ 2012-09-14  8:50 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Tony Lindgren,
	Russell King, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

On Fri, 2012-09-14 at 10:13 +0200, Lars-Peter Clausen wrote:
> On 09/14/2012 05:26 AM, Vinod Koul wrote:
> > On Thu, 2012-09-13 at 17:27 +0200, Lars-Peter Clausen wrote:
> >> Hi,
> >>
> >> Hm... Do you think it would work as well if we implement this by
> >> setting the
> >> callback for the descriptor to NULL? If the callback is NULL there is
> >> nothing to at the end of a transfer/period and the dma engine driver
> >> may
> >> choose to disable interrupts. This would also benefit non cyclic
> >> transfers
> >> where the callback is NULL and we do not need add the new parameter to
> >> dmaengine_prep_dma_cyclic.
> > That will work too.... BUT the idea of no_wake mode in ALSA is that we
> > should not have any interrupts, so anything which is going to cause
> > interrupts to AP in undesired. The interrupts still happen and it just
> > that dmaengine driver is not notifying client.
> 
> Well, the idea was that the driver would disable interrupts if there is no
> callback to call, since there would be nothing to do in the interrupt
> handler anyway. But I guess the flags approach should work fine as well.
Yes we _could_ do that, but this relies on dmaengine driver to have this
implicit understanding. Anyone using dmaengine library in ASoC may or
may not be aware of this, so i would consider it hackish.

Using this flag explicitly makes everyone aware what the intended
behaviour is.

-- 
~Vinod


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  8:50         ` Vinod Koul
@ 2012-09-14  9:28           ` Peter Ujfalusi
  2012-09-14  9:38             ` Vinod Koul
  2012-09-14 10:01             ` Russell King - ARM Linux
  0 siblings, 2 replies; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-14  9:28 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Lars-Peter Clausen, Mark Brown, Liam Girdwood, Tony Lindgren,
	Russell King, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

Hi,

On 09/14/2012 11:50 AM, Vinod Koul wrote:
>> Well, the idea was that the driver would disable interrupts if there is no
>> callback to call, since there would be nothing to do in the interrupt
>> handler anyway. But I guess the flags approach should work fine as well.
> Yes we _could_ do that, but this relies on dmaengine driver to have this
> implicit understanding. Anyone using dmaengine library in ASoC may or
> may not be aware of this, so i would consider it hackish.
> 
> Using this flag explicitly makes everyone aware what the intended
> behaviour is.

I'm not sure about which flags should ASoC set for the two case we are going
to have. I think it should be something like this:

unsigned long flags = DMA_CTRL_ACK;

if (!substream->runtime->no_period_wakeup)
	flags |= DMA_PREP_INTERRUPT;

I'm not 100% sure of the role of DMA_CTRL_ACK in this case. Or should we only
handle the DMA_PREP_INTERRUPT flag, like this:

unsigned long flags = 0;

if (!substream->runtime->no_period_wakeup)
	flags |= DMA_PREP_INTERRUPT;


What do you think?

-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  9:28           ` Peter Ujfalusi
@ 2012-09-14  9:38             ` Vinod Koul
  2012-09-14 10:01             ` Russell King - ARM Linux
  1 sibling, 0 replies; 37+ messages in thread
From: Vinod Koul @ 2012-09-14  9:38 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Lars-Peter Clausen, Mark Brown, Liam Girdwood, Tony Lindgren,
	Russell King, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

On Fri, 2012-09-14 at 12:28 +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 09/14/2012 11:50 AM, Vinod Koul wrote:
> >> Well, the idea was that the driver would disable interrupts if there is no
> >> callback to call, since there would be nothing to do in the interrupt
> >> handler anyway. But I guess the flags approach should work fine as well.
> > Yes we _could_ do that, but this relies on dmaengine driver to have this
> > implicit understanding. Anyone using dmaengine library in ASoC may or
> > may not be aware of this, so i would consider it hackish.
> > 
> > Using this flag explicitly makes everyone aware what the intended
> > behaviour is.
> 
> I'm not sure about which flags should ASoC set for the two case we are going
> to have. I think it should be something like this:
> 
> unsigned long flags = DMA_CTRL_ACK;
usage of ACK flag is mostly async_tx thingy, we can skip it for slave.
> 
> if (!substream->runtime->no_period_wakeup)
> 	flags |= DMA_PREP_INTERRUPT;
> I'm not 100% sure of the role of DMA_CTRL_ACK in this case. Or should we only
> handle the DMA_PREP_INTERRUPT flag, like this:
> 
> unsigned long flags = 0;
> 
> if (!substream->runtime->no_period_wakeup)
> 	flags |= DMA_PREP_INTERRUPT;
> 
> 
> What do you think?
Looks fine.

-- 
~Vinod


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic()
  2012-09-14  9:28           ` Peter Ujfalusi
  2012-09-14  9:38             ` Vinod Koul
@ 2012-09-14 10:01             ` Russell King - ARM Linux
  1 sibling, 0 replies; 37+ messages in thread
From: Russell King - ARM Linux @ 2012-09-14 10:01 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Vinod Koul, Lars-Peter Clausen, Mark Brown, Liam Girdwood,
	Tony Lindgren, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri

On Fri, Sep 14, 2012 at 12:28:28PM +0300, Peter Ujfalusi wrote:
> I'm not sure about which flags should ASoC set for the two case we are going
> to have. I think it should be something like this:
> 
> unsigned long flags = DMA_CTRL_ACK;
> 
> if (!substream->runtime->no_period_wakeup)
> 	flags |= DMA_PREP_INTERRUPT;

That looks about right.  I would encourage DMA_CTRL_ACK to always be set
for slave stuff, because it will (according to my understanding of it)
make the behaviour no different from the async_tx stuff... which is
important when support for that stuff gets added.

We could, of course, set DMA_CTRL_ACK in the slave APIs beneath the
user, but the user has access to tx->flags between the prepare and
submit calls...  And doing it in the submit callback will force DMA
engine drivers to have two separate submission paths (as tx'es can't
be acked at submission time.)

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
  2012-09-14  3:24   ` Vinod Koul
@ 2012-09-17  6:34   ` Shawn Guo
  2012-09-17  7:16     ` Peter Ujfalusi
  2012-09-17  9:01   ` Linus Walleij
  2 siblings, 1 reply; 37+ messages in thread
From: Shawn Guo @ 2012-09-17  6:34 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao,
	Laxman Dewangan

On Thu, Sep 13, 2012 at 04:37:54PM +0300, Peter Ujfalusi wrote:
> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> can receive the no_wakeup request coming from client drivers.
> This feature can be used during audio operation to disable all audio
> related interrupts.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> CC: Nicolas Ferre <nicolas.ferre@atmel.com>
> CC: Barry Song <baohua.song@csr.com>
> CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
> CC: Vista Silicon <javier.martin@vista-silicon.com>
> CC: Zhangfei Gao <zhangfei.gao@marvell.com>
> CC: Shawn Guo <shawn.guo@linaro.org>
> CC: Laxman Dewangan <ldewangan@nvidia.com>
> ---
>  drivers/dma/at_hdmac.c        | 3 ++-
>  drivers/dma/ep93xx_dma.c      | 4 +++-
>  drivers/dma/imx-dma.c         | 2 +-
>  drivers/dma/imx-sdma.c        | 2 +-
>  drivers/dma/mmp_tdma.c        | 2 +-
>  drivers/dma/mxs-dma.c         | 2 +-
>  drivers/dma/omap-dma.c        | 3 ++-
>  drivers/dma/pl330.c           | 2 +-
>  drivers/dma/sa11x0-dma.c      | 2 +-
>  drivers/dma/sirf-dma.c        | 2 +-
>  drivers/dma/ste_dma40.c       | 3 ++-
>  drivers/dma/tegra20-apb-dma.c | 2 +-
>  include/linux/dmaengine.h     | 5 +++--
>  13 files changed, 20 insertions(+), 14 deletions(-)
> 
API changes without updating users?

Regards,
Shawn

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-17  6:34   ` Shawn Guo
@ 2012-09-17  7:16     ` Peter Ujfalusi
  2012-09-17  7:23       ` Shawn Guo
  0 siblings, 1 reply; 37+ messages in thread
From: Peter Ujfalusi @ 2012-09-17  7:16 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao,
	Laxman Dewangan

On 09/17/2012 09:34 AM, Shawn Guo wrote:
> On Thu, Sep 13, 2012 at 04:37:54PM +0300, Peter Ujfalusi wrote:
>> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
>> can receive the no_wakeup request coming from client drivers.
>> This feature can be used during audio operation to disable all audio
>> related interrupts.
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> CC: Nicolas Ferre <nicolas.ferre@atmel.com>
>> CC: Barry Song <baohua.song@csr.com>
>> CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
>> CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
>> CC: Vista Silicon <javier.martin@vista-silicon.com>
>> CC: Zhangfei Gao <zhangfei.gao@marvell.com>
>> CC: Shawn Guo <shawn.guo@linaro.org>
>> CC: Laxman Dewangan <ldewangan@nvidia.com>
>> ---
>>  drivers/dma/at_hdmac.c        | 3 ++-
>>  drivers/dma/ep93xx_dma.c      | 4 +++-
>>  drivers/dma/imx-dma.c         | 2 +-
>>  drivers/dma/imx-sdma.c        | 2 +-
>>  drivers/dma/mmp_tdma.c        | 2 +-
>>  drivers/dma/mxs-dma.c         | 2 +-
>>  drivers/dma/omap-dma.c        | 3 ++-
>>  drivers/dma/pl330.c           | 2 +-
>>  drivers/dma/sa11x0-dma.c      | 2 +-
>>  drivers/dma/sirf-dma.c        | 2 +-
>>  drivers/dma/ste_dma40.c       | 3 ++-
>>  drivers/dma/tegra20-apb-dma.c | 2 +-
>>  include/linux/dmaengine.h     | 5 +++--
>>  13 files changed, 20 insertions(+), 14 deletions(-)
>>
> API changes without updating users?

All users of this callback is updated with this patch.
The public API (dmaengine_prep_dma_cyclic) is only used by ASoC, which has
been updated by the previous patch.
Note: this part has been updated for v3.

-- 
Péter

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-17  7:16     ` Peter Ujfalusi
@ 2012-09-17  7:23       ` Shawn Guo
  0 siblings, 0 replies; 37+ messages in thread
From: Shawn Guo @ 2012-09-17  7:23 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao,
	Laxman Dewangan

On Mon, Sep 17, 2012 at 10:16:53AM +0300, Peter Ujfalusi wrote:
> All users of this callback is updated with this patch.
> The public API (dmaengine_prep_dma_cyclic) is only used by ASoC, which has
> been updated by the previous patch.
> 
Ah, ok.  You actually changed dmaengine_prep_dma_cyclic signature before
this patch.  Sorry, I overlooked that.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
  2012-09-14  3:24   ` Vinod Koul
  2012-09-17  6:34   ` Shawn Guo
@ 2012-09-17  9:01   ` Linus Walleij
  2012-09-18  8:31     ` Russell King - ARM Linux
  2 siblings, 1 reply; 37+ messages in thread
From: Linus Walleij @ 2012-09-17  9:01 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Tony Lindgren, Russell King,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Russell King - ARM Linux, Vista Silicon, Zhangfei Gao, Shawn Guo,
	Laxman Dewangan

On Thu, Sep 13, 2012 at 3:37 PM, Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:

> Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> can receive the no_wakeup request coming from client drivers.
> This feature can be used during audio operation to disable all audio
> related interrupts.
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> CC: Nicolas Ferre <nicolas.ferre@atmel.com>
> CC: Barry Song <baohua.song@csr.com>
> CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
> CC: Vista Silicon <javier.martin@vista-silicon.com>
> CC: Zhangfei Gao <zhangfei.gao@marvell.com>
> CC: Shawn Guo <shawn.guo@linaro.org>
> CC: Laxman Dewangan <ldewangan@nvidia.com>

After some discussion with clever people I know I have come to the conclusion
that this is a good idea, so:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-17  9:01   ` Linus Walleij
@ 2012-09-18  8:31     ` Russell King - ARM Linux
  2012-09-18  9:00       ` Vinod Koul
  0 siblings, 1 reply; 37+ messages in thread
From: Russell King - ARM Linux @ 2012-09-18  8:31 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Tony Lindgren,
	Vinod Koul, Dan Williams, Jarkko Nikula, alsa-devel, linux-omap,
	linux-arm-kernel, linux-kernel, Janusz Krzysztofik, Ricardo Neri,
	Lars-Peter Clausen, Nicolas Ferre, Barry Song, Srinidhi Kasagar,
	Vista Silicon, Zhangfei Gao, Shawn Guo, Laxman Dewangan

On Mon, Sep 17, 2012 at 11:01:23AM +0200, Linus Walleij wrote:
> On Thu, Sep 13, 2012 at 3:37 PM, Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:
> 
> > Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> > can receive the no_wakeup request coming from client drivers.
> > This feature can be used during audio operation to disable all audio
> > related interrupts.
> >
> > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > CC: Nicolas Ferre <nicolas.ferre@atmel.com>
> > CC: Barry Song <baohua.song@csr.com>
> > CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> > CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
> > CC: Vista Silicon <javier.martin@vista-silicon.com>
> > CC: Zhangfei Gao <zhangfei.gao@marvell.com>
> > CC: Shawn Guo <shawn.guo@linaro.org>
> > CC: Laxman Dewangan <ldewangan@nvidia.com>
> 
> After some discussion with clever people I know I have come to the conclusion
> that this is a good idea, so:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

NAKed-by: me

If you look at the other sub-threads of the patch you're acking, you'll
notice that there's a v3 of this patch set which changes the way this is
done.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-18  8:31     ` Russell King - ARM Linux
@ 2012-09-18  9:00       ` Vinod Koul
  2012-09-18 12:22         ` Linus Walleij
  0 siblings, 1 reply; 37+ messages in thread
From: Vinod Koul @ 2012-09-18  9:00 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Linus Walleij, Peter Ujfalusi, Mark Brown, Liam Girdwood,
	Tony Lindgren, Dan Williams, Jarkko Nikula, alsa-devel,
	linux-omap, linux-arm-kernel, linux-kernel, Janusz Krzysztofik,
	Ricardo Neri, Lars-Peter Clausen, Nicolas Ferre, Barry Song,
	Srinidhi Kasagar, Vista Silicon, Zhangfei Gao, Shawn Guo,
	Laxman Dewangan

On Tue, 2012-09-18 at 09:31 +0100, Russell King - ARM Linux wrote:
> On Mon, Sep 17, 2012 at 11:01:23AM +0200, Linus Walleij wrote:
> > On Thu, Sep 13, 2012 at 3:37 PM, Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:
> > 
> > > Change the parameter list of device_prep_dma_cyclic() so the DMA drivers
> > > can receive the no_wakeup request coming from client drivers.
> > > This feature can be used during audio operation to disable all audio
> > > related interrupts.
> > >
> > > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > > CC: Nicolas Ferre <nicolas.ferre@atmel.com>
> > > CC: Barry Song <baohua.song@csr.com>
> > > CC: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> > > CC: Russell King - ARM Linux <linux@arm.linux.org.uk>
> > > CC: Vista Silicon <javier.martin@vista-silicon.com>
> > > CC: Zhangfei Gao <zhangfei.gao@marvell.com>
> > > CC: Shawn Guo <shawn.guo@linaro.org>
> > > CC: Laxman Dewangan <ldewangan@nvidia.com>
> > 
> > After some discussion with clever people I know I have come to the conclusion
> > that this is a good idea, so:
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> 
> NAKed-by: me
> 
> If you look at the other sub-threads of the patch you're acking, you'll
> notice that there's a v3 of this patch set which changes the way this is
> done.
Was it a genuine mistake, think v3 reply v2? Or less caffeine..... :)


-- 
~Vinod


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback
  2012-09-18  9:00       ` Vinod Koul
@ 2012-09-18 12:22         ` Linus Walleij
  0 siblings, 0 replies; 37+ messages in thread
From: Linus Walleij @ 2012-09-18 12:22 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Russell King - ARM Linux, Peter Ujfalusi, Mark Brown,
	Liam Girdwood, Tony Lindgren, Dan Williams, Jarkko Nikula,
	alsa-devel, linux-omap, linux-arm-kernel, linux-kernel,
	Janusz Krzysztofik, Ricardo Neri, Lars-Peter Clausen,
	Nicolas Ferre, Barry Song, Srinidhi Kasagar, Vista Silicon,
	Zhangfei Gao, Shawn Guo, Laxman Dewangan

On Tue, Sep 18, 2012 at 11:00 AM, Vinod Koul <vinod.koul@linux.intel.com> wrote:
> On Tue, 2012-09-18 at 09:31 +0100, Russell King - ARM Linux wrote:
>> On Mon, Sep 17, 2012 at 11:01:23AM +0200, Linus Walleij wrote:
>> > On Thu, Sep 13, 2012 at 3:37 PM, Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:
>> >
>> > After some discussion with clever people I know I have come to the conclusion
>> > that this is a good idea, so:
>> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
>>
>> NAKed-by: me
>>
>> If you look at the other sub-threads of the patch you're acking, you'll
>> notice that there's a v3 of this patch set which changes the way this is
>> done.
>
> Was it a genuine mistake, think v3 reply v2? Or less caffeine..... :)

I think both, stupid me.
Ack on v3 indeed, I was probably fooled by some gmail autothreading, grrr.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2012-09-18 12:23 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-13 13:37 [PATCH v2 00/15] ASoC: OMAP: Convert to use dmaengine Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 01/15] dmaengine: omap: Support for element mode in cyclic DMA Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 03/15] dmaengine: Add no_wakeup parameter to dmaengine_prep_dma_cyclic() Peter Ujfalusi
2012-09-13 15:27   ` Lars-Peter Clausen
2012-09-13 15:38     ` Russell King - ARM Linux
2012-09-14  3:27       ` Vinod Koul
2012-09-14  7:15       ` Peter Ujfalusi
2012-09-14  3:26     ` Vinod Koul
2012-09-14  7:18       ` [alsa-devel] " Peter Ujfalusi
2012-09-14  8:13       ` Lars-Peter Clausen
2012-09-14  8:50         ` Vinod Koul
2012-09-14  9:28           ` Peter Ujfalusi
2012-09-14  9:38             ` Vinod Koul
2012-09-14 10:01             ` Russell King - ARM Linux
2012-09-14  7:12     ` Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 04/15] dmaengine: Pass no_wakeup parameter via device_prep_dma_cyclic() callback Peter Ujfalusi
2012-09-14  3:24   ` Vinod Koul
2012-09-14  7:07     ` Peter Ujfalusi
2012-09-17  6:34   ` Shawn Guo
2012-09-17  7:16     ` Peter Ujfalusi
2012-09-17  7:23       ` Shawn Guo
2012-09-17  9:01   ` Linus Walleij
2012-09-18  8:31     ` Russell King - ARM Linux
2012-09-18  9:00       ` Vinod Koul
2012-09-18 12:22         ` Linus Walleij
2012-09-13 13:37 ` [PATCH v2 05/15] dmaengine: omap-dma: Add support for no_wakeup in cyclic mode Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 06/15] ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 07/15] ASoC: omap-pcm: Select sDMA synchronization based on packet_size Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 08/15] ASoC: OMAP: Remove sync_mode from omap_pcm_dma_data struct Peter Ujfalusi
2012-09-13 13:37 ` [PATCH v2 09/15] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 10/15] ARM: OMAP4: hwmod_data: Add resource names to McPDM memory ranges Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 11/15] ASoC: omap-mcpdm: Use platform_get_resource_* to get resources Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 12/15] ASoC: OMAP: mcbsp, mcpdm, dmic: Let omap-pcm to pick the dma_type Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 13/15] ASoC: omap-pcm, omap-dmic: Change the use of omap_pcm_dma_data->data_type Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 14/15] ASoC: OMAP: mcbsp, mcpdm, dmic, hdmi: Set dma_data at startup time Peter Ujfalusi
2012-09-13 13:38 ` [PATCH v2 15/15] ASoC: omap-pcm: Convert to use dmaengine Peter Ujfalusi

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).