diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-03-05 09:30:55 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-05 19:03:08 -0500 |
commit | 4762fbab0b1cf1d4f3e02b78351dc6fa59ca564e (patch) | |
tree | 08c59b48b0b3f7e24f84820683f9961e5664da90 /sound/soc/imx/imx-ssi.c | |
parent | af4872fb39301bbe196d0778f80d22ec51d8884b (diff) |
ASoC: imx: separate imx-pcm bits from imx-ssi driver
Currently the imx-ssi.c[h] accommodates the imx-pcm common bits which
are shared between imx-pcm-dma-mx2 and imx-pcm-fiq drivers. It assumes
that imx-pcm-dma-mx2 and imx-pcm-fiq will always be used together with
imx-ssi driver. However this becomes untrue when we see that driver
sound/soc/fsl/fsl_ssi could possibly work with imx-pcm-dma-mx2 too.
The patch moves the imx-pcm common bits from imx-ssi.c[h] into new
files imx-pcm.c[h], and let imx-pcm-dma-mx2 and imx-pcm-fiq drivers
build it in, so that imx-pcm-dma-mx2 can work with no dependency on
imx-ssi driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/imx/imx-ssi.c')
-rw-r--r-- | sound/soc/imx/imx-ssi.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index 25c623115a9f..9203cdd0a154 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c | |||
@@ -363,94 +363,6 @@ static const struct snd_soc_dai_ops imx_ssi_pcm_dai_ops = { | |||
363 | .trigger = imx_ssi_trigger, | 363 | .trigger = imx_ssi_trigger, |
364 | }; | 364 | }; |
365 | 365 | ||
366 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
367 | struct vm_area_struct *vma) | ||
368 | { | ||
369 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
370 | int ret; | ||
371 | |||
372 | ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
373 | runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
374 | |||
375 | pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
376 | runtime->dma_area, | ||
377 | runtime->dma_addr, | ||
378 | runtime->dma_bytes); | ||
379 | return ret; | ||
380 | } | ||
381 | EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); | ||
382 | |||
383 | static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
384 | { | ||
385 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
386 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
387 | size_t size = IMX_SSI_DMABUF_SIZE; | ||
388 | |||
389 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
390 | buf->dev.dev = pcm->card->dev; | ||
391 | buf->private_data = NULL; | ||
392 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
393 | &buf->addr, GFP_KERNEL); | ||
394 | if (!buf->area) | ||
395 | return -ENOMEM; | ||
396 | buf->bytes = size; | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
402 | |||
403 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
404 | { | ||
405 | struct snd_card *card = rtd->card->snd_card; | ||
406 | struct snd_pcm *pcm = rtd->pcm; | ||
407 | int ret = 0; | ||
408 | |||
409 | if (!card->dev->dma_mask) | ||
410 | card->dev->dma_mask = &imx_pcm_dmamask; | ||
411 | if (!card->dev->coherent_dma_mask) | ||
412 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
413 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
414 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
415 | SNDRV_PCM_STREAM_PLAYBACK); | ||
416 | if (ret) | ||
417 | goto out; | ||
418 | } | ||
419 | |||
420 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
421 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
422 | SNDRV_PCM_STREAM_CAPTURE); | ||
423 | if (ret) | ||
424 | goto out; | ||
425 | } | ||
426 | |||
427 | out: | ||
428 | return ret; | ||
429 | } | ||
430 | EXPORT_SYMBOL_GPL(imx_pcm_new); | ||
431 | |||
432 | void imx_pcm_free(struct snd_pcm *pcm) | ||
433 | { | ||
434 | struct snd_pcm_substream *substream; | ||
435 | struct snd_dma_buffer *buf; | ||
436 | int stream; | ||
437 | |||
438 | for (stream = 0; stream < 2; stream++) { | ||
439 | substream = pcm->streams[stream].substream; | ||
440 | if (!substream) | ||
441 | continue; | ||
442 | |||
443 | buf = &substream->dma_buffer; | ||
444 | if (!buf->area) | ||
445 | continue; | ||
446 | |||
447 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
448 | buf->area, buf->addr); | ||
449 | buf->area = NULL; | ||
450 | } | ||
451 | } | ||
452 | EXPORT_SYMBOL_GPL(imx_pcm_free); | ||
453 | |||
454 | static int imx_ssi_dai_probe(struct snd_soc_dai *dai) | 366 | static int imx_ssi_dai_probe(struct snd_soc_dai *dai) |
455 | { | 367 | { |
456 | struct imx_ssi *ssi = dev_get_drvdata(dai->dev); | 368 | struct imx_ssi *ssi = dev_get_drvdata(dai->dev); |