[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210519104842.977895-7-codrin.ciubotariu@microchip.com>
Date: Wed, 19 May 2021 13:48:42 +0300
From: Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
To: <alsa-devel@...a-project.org>, <linux-kernel@...r.kernel.org>
CC: <perex@...ex.cz>, <tiwai@...e.com>,
<pierre-louis.bossart@...ux.intel.com>, <broonie@...nel.org>,
<joe@...ches.com>, <lgirdwood@...il.com>, <lars@...afoo.de>,
<kuninori.morimoto.gx@...esas.com>, <nicolas.ferre@...rochip.com>,
<Cristian.Birsan@...rochip.com>,
Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
Subject: [RFC PATCH 6/6] ASoC: dmaengine: Allocate buffer if substream is unmanaged
pcm_construct/pcm_destruct callbacks are not called for BE DAIs. This means
that, if the generic dmaengine driver is used, there is no managed buffer
allocation (or pre-allocation). To be able to use the generic dmaengine
driver for BE DAI links, allocate the buffer in the hw_params callback if
there is no managed buffer.
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
---
sound/soc/soc-generic-dmaengine-pcm.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 9ef80a48707e..c915da71e1cd 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -98,6 +98,22 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,
return ret;
}
+ if (!substream->managed_buffer_alloc) {
+ substream->dma_buffer.dev.type = SNDRV_DMA_TYPE_DEV_IRAM;
+ substream->dma_buffer.dev.dev = chan->device->dev;
+ return snd_pcm_lib_malloc_pages(substream,
+ params_buffer_bytes(params));
+ }
+
+ return 0;
+}
+
+static int dmaengine_pcm_hw_free(struct snd_soc_component *component,
+ struct snd_pcm_substream *substream)
+{
+ if (!substream->managed_buffer_alloc)
+ return snd_pcm_lib_free_pages(substream);
+
return 0;
}
@@ -332,6 +348,7 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = {
.open = dmaengine_pcm_open,
.close = dmaengine_pcm_close,
.hw_params = dmaengine_pcm_hw_params,
+ .hw_free = dmaengine_pcm_hw_free,
.trigger = dmaengine_pcm_trigger,
.pointer = dmaengine_pcm_pointer,
.pcm_construct = dmaengine_pcm_new,
@@ -343,6 +360,7 @@ static const struct snd_soc_component_driver dmaengine_pcm_component_process = {
.open = dmaengine_pcm_open,
.close = dmaengine_pcm_close,
.hw_params = dmaengine_pcm_hw_params,
+ .hw_free = dmaengine_pcm_hw_free,
.trigger = dmaengine_pcm_trigger,
.pointer = dmaengine_pcm_pointer,
.copy_user = dmaengine_copy_user,
--
2.27.0
Powered by blists - more mailing lists