ASoC: add support for separate codec DAIs to the fsl_dma driver

Some codecs have separate DAIs for playback and capture, so the DMA driver
should allocate a DMA buffer only for the streams that are valid when the
driver is opened.

Signed-off-by: Timur Tabi <timur@freescale.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Timur Tabi
2010-08-19 16:43:42 -05:00
committed by Mark Brown
parent b67696b40f
commit c04019d450

View File

@@ -303,21 +303,29 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
if (!card->dev->coherent_dma_mask) if (!card->dev->coherent_dma_mask)
card->dev->coherent_dma_mask = fsl_dma_dmamask; card->dev->coherent_dma_mask = fsl_dma_dmamask;
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, /* Some codecs have separate DAIs for playback and capture, so we
fsl_dma_hardware.buffer_bytes_max, * should allocate a DMA buffer only for the streams that are valid.
&pcm->streams[0].substream->dma_buffer); */
if (ret) {
dev_err(card->dev, "can't allocate playback dma buffer\n"); if (dai->driver->playback.channels_min) {
return ret; ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
fsl_dma_hardware.buffer_bytes_max,
&pcm->streams[0].substream->dma_buffer);
if (ret) {
dev_err(card->dev, "can't alloc playback dma buffer\n");
return ret;
}
} }
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, if (dai->driver->capture.channels_min) {
fsl_dma_hardware.buffer_bytes_max, ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
&pcm->streams[1].substream->dma_buffer); fsl_dma_hardware.buffer_bytes_max,
if (ret) { &pcm->streams[1].substream->dma_buffer);
snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); if (ret) {
dev_err(card->dev, "can't allocate capture dma buffer\n"); snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
return ret; dev_err(card->dev, "can't alloc capture dma buffer\n");
return ret;
}
} }
return 0; return 0;