aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-generic-dmaengine-pcm.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-01-11 08:02:18 -0500
committerMark Brown <broonie@linaro.org>2014-01-14 16:28:39 -0500
commit93b943edfc5e439f7b843535e0bb0f7d2371f67f (patch)
tree44c983ae5155d191f8dd3c2026b4adc572643efc /sound/soc/soc-generic-dmaengine-pcm.c
parentbfb9bb42d60d7cf1d8057c7c3978dcc53c4d25fd (diff)
ASoC: generic-dmaengine-pcm: Check NO_RESIDUE flag at runtime
Currently we have two different snd_soc_platform_driver structs in the generic dmaengine PCM driver. One for dmaengine drivers that support residue reporting and one for those which do not. When registering the PCM component we check whether the NO_RESIDUE flag is set or not and use the corresponding snd_soc_platform_driver. This patch modifies the driver to only have one snd_soc_platform_driver struct where the pointer() callback checks the NO_RESIDUE flag at runtime. This allows us to set the NO_RESIDUE flag after the PCM component has been registered. This becomes necessary when querying whether the dmaengine driver supports residue reporting from the dmaengine driver itself since the DMA channel might only be requested after the PCM component has been registered. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-generic-dmaengine-pcm.c')
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 2a6c569d991f..4e2bed89a4a4 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -248,6 +248,18 @@ err_free:
248 return ret; 248 return ret;
249} 249}
250 250
251static snd_pcm_uframes_t dmaengine_pcm_pointer(
252 struct snd_pcm_substream *substream)
253{
254 struct snd_soc_pcm_runtime *rtd = substream->private_data;
255 struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
256
257 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
258 return snd_dmaengine_pcm_pointer_no_residue(substream);
259 else
260 return snd_dmaengine_pcm_pointer(substream);
261}
262
251static const struct snd_pcm_ops dmaengine_pcm_ops = { 263static const struct snd_pcm_ops dmaengine_pcm_ops = {
252 .open = dmaengine_pcm_open, 264 .open = dmaengine_pcm_open,
253 .close = snd_dmaengine_pcm_close, 265 .close = snd_dmaengine_pcm_close,
@@ -255,7 +267,7 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = {
255 .hw_params = dmaengine_pcm_hw_params, 267 .hw_params = dmaengine_pcm_hw_params,
256 .hw_free = snd_pcm_lib_free_pages, 268 .hw_free = snd_pcm_lib_free_pages,
257 .trigger = snd_dmaengine_pcm_trigger, 269 .trigger = snd_dmaengine_pcm_trigger,
258 .pointer = snd_dmaengine_pcm_pointer, 270 .pointer = dmaengine_pcm_pointer,
259}; 271};
260 272
261static const struct snd_soc_platform_driver dmaengine_pcm_platform = { 273static const struct snd_soc_platform_driver dmaengine_pcm_platform = {
@@ -265,23 +277,6 @@ static const struct snd_soc_platform_driver dmaengine_pcm_platform = {
265 .probe_order = SND_SOC_COMP_ORDER_LATE, 277 .probe_order = SND_SOC_COMP_ORDER_LATE,
266}; 278};
267 279
268static const struct snd_pcm_ops dmaengine_no_residue_pcm_ops = {
269 .open = dmaengine_pcm_open,
270 .close = snd_dmaengine_pcm_close,
271 .ioctl = snd_pcm_lib_ioctl,
272 .hw_params = dmaengine_pcm_hw_params,
273 .hw_free = snd_pcm_lib_free_pages,
274 .trigger = snd_dmaengine_pcm_trigger,
275 .pointer = snd_dmaengine_pcm_pointer_no_residue,
276};
277
278static const struct snd_soc_platform_driver dmaengine_no_residue_pcm_platform = {
279 .ops = &dmaengine_no_residue_pcm_ops,
280 .pcm_new = dmaengine_pcm_new,
281 .pcm_free = dmaengine_pcm_free,
282 .probe_order = SND_SOC_COMP_ORDER_LATE,
283};
284
285static const char * const dmaengine_pcm_dma_channel_names[] = { 280static const char * const dmaengine_pcm_dma_channel_names[] = {
286 [SNDRV_PCM_STREAM_PLAYBACK] = "tx", 281 [SNDRV_PCM_STREAM_PLAYBACK] = "tx",
287 [SNDRV_PCM_STREAM_CAPTURE] = "rx", 282 [SNDRV_PCM_STREAM_CAPTURE] = "rx",
@@ -374,12 +369,8 @@ int snd_dmaengine_pcm_register(struct device *dev,
374 if (ret) 369 if (ret)
375 goto err_free_dma; 370 goto err_free_dma;
376 371
377 if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) 372 ret = snd_soc_add_platform(dev, &pcm->platform,
378 ret = snd_soc_add_platform(dev, &pcm->platform, 373 &dmaengine_pcm_platform);
379 &dmaengine_no_residue_pcm_platform);
380 else
381 ret = snd_soc_add_platform(dev, &pcm->platform,
382 &dmaengine_pcm_platform);
383 if (ret) 374 if (ret)
384 goto err_free_dma; 375 goto err_free_dma;
385 376