Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c1c1d4a authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown
Browse files

ASoC: dmaengine-pcm: Make requesting the DMA channel at PCM open optional



Refactor the dmaengine PCM library to allow the DMA channel to be requested
before opening a PCM substream. snd_dmaengine_pcm_open() now expects a DMA
channel instead of a filter function and filter parameter as its parameters.
snd_dmaengine_pcm_close() is updated to not release the DMA channel. This allows
a dmaengine based PCM driver to request its channels before the substream is
opened.

The patch also introduces two new functions, snd_dmaengine_pcm_open_request_chan()
and snd_dmaengine_pcm_close_release_chan(), which have the same signature and
behaviour of the old snd_dmaengine_pcm_{open,close}() and internally use the new
variants of these functions. All users of snd_dmaengine_pcm_{open,close}() are
updated to use snd_dmaengine_pcm_open_request_chan() and
snd_dmaengine_pcm_close_release_chan().

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Tested-by: default avatarStephen Warren <swarren@nvidia.com>
Tested-by: default avatarShawn Guo <shawn.guo@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 69b6f196
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -39,9 +39,13 @@ snd_pcm_uframes_t snd_dmaengine_pcm_pointer(struct snd_pcm_substream *substream)
snd_pcm_uframes_t snd_dmaengine_pcm_pointer_no_residue(struct snd_pcm_substream *substream);

int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
	dma_filter_fn filter_fn, void *filter_data);
	struct dma_chan *chan);
int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);

int snd_dmaengine_pcm_open_request_chan(struct snd_pcm_substream *substream,
	dma_filter_fn filter_fn, void *filter_data);
int snd_dmaengine_pcm_close_release_chan(struct snd_pcm_substream *substream);

struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);

/**
+3 −3
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
	if (ssc->pdev)
		sdata = ssc->pdev->dev.platform_data;

	ret = snd_dmaengine_pcm_open(substream, filter, sdata);
	ret = snd_dmaengine_pcm_open_request_chan(substream, filter, sdata);
	if (ret) {
		pr_err("atmel-pcm: dmaengine pcm open failed\n");
		return -EINVAL;
@@ -171,7 +171,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,

	return 0;
err:
	snd_dmaengine_pcm_close(substream);
	snd_dmaengine_pcm_close_release_chan(substream);
	return ret;
}

@@ -197,7 +197,7 @@ static int atmel_pcm_open(struct snd_pcm_substream *substream)

static struct snd_pcm_ops atmel_pcm_ops = {
	.open		= atmel_pcm_open,
	.close		= snd_dmaengine_pcm_close,
	.close		= snd_dmaengine_pcm_close_release_chan,
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= atmel_pcm_hw_params,
	.prepare	= atmel_pcm_dma_prepare,
+3 −2
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ static int ep93xx_pcm_open(struct snd_pcm_substream *substream)

	snd_soc_set_runtime_hwparams(substream, &ep93xx_pcm_hardware);

	return snd_dmaengine_pcm_open(substream, ep93xx_pcm_dma_filter,
	return snd_dmaengine_pcm_open_request_chan(substream,
			ep93xx_pcm_dma_filter,
			snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
}

@@ -100,7 +101,7 @@ static int ep93xx_pcm_mmap(struct snd_pcm_substream *substream,

static struct snd_pcm_ops ep93xx_pcm_ops = {
	.open		= ep93xx_pcm_open,
	.close		= snd_dmaengine_pcm_close,
	.close		= snd_dmaengine_pcm_close_release_chan,
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= ep93xx_pcm_hw_params,
	.hw_free	= ep93xx_pcm_hw_free,
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ static int snd_imx_open(struct snd_pcm_substream *substream)

static struct snd_pcm_ops imx_pcm_ops = {
	.open		= snd_imx_open,
	.close		= snd_dmaengine_pcm_close,
	.close		= snd_dmaengine_pcm_close_release_chan,
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= snd_imx_pcm_hw_params,
	.trigger	= snd_dmaengine_pcm_trigger,
+2 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static int snd_mxs_open(struct snd_pcm_substream *substream)

	snd_soc_set_runtime_hwparams(substream, &snd_mxs_hardware);

	return snd_dmaengine_pcm_open(substream, filter,
	return snd_dmaengine_pcm_open_request_chan(substream, filter,
		snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
}

@@ -104,7 +104,7 @@ static int snd_mxs_pcm_mmap(struct snd_pcm_substream *substream,

static struct snd_pcm_ops mxs_pcm_ops = {
	.open		= snd_mxs_open,
	.close		= snd_dmaengine_pcm_close,
	.close		= snd_dmaengine_pcm_close_release_chan,
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= snd_mxs_pcm_hw_params,
	.trigger	= snd_dmaengine_pcm_trigger,
Loading