diff options
-rw-r--r-- | sound/soc/fsl/fsl_dma.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 57774cb91ae3..5a6f56d63756 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c | |||
@@ -303,21 +303,29 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai, | |||
303 | if (!card->dev->coherent_dma_mask) | 303 | if (!card->dev->coherent_dma_mask) |
304 | card->dev->coherent_dma_mask = fsl_dma_dmamask; | 304 | card->dev->coherent_dma_mask = fsl_dma_dmamask; |
305 | 305 | ||
306 | ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, | 306 | /* Some codecs have separate DAIs for playback and capture, so we |
307 | fsl_dma_hardware.buffer_bytes_max, | 307 | * should allocate a DMA buffer only for the streams that are valid. |
308 | &pcm->streams[0].substream->dma_buffer); | 308 | */ |
309 | if (ret) { | 309 | |
310 | dev_err(card->dev, "can't allocate playback dma buffer\n"); | 310 | if (dai->driver->playback.channels_min) { |
311 | return ret; | 311 | ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, |
312 | fsl_dma_hardware.buffer_bytes_max, | ||
313 | &pcm->streams[0].substream->dma_buffer); | ||
314 | if (ret) { | ||
315 | dev_err(card->dev, "can't alloc playback dma buffer\n"); | ||
316 | return ret; | ||
317 | } | ||
312 | } | 318 | } |
313 | 319 | ||
314 | ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, | 320 | if (dai->driver->capture.channels_min) { |
315 | fsl_dma_hardware.buffer_bytes_max, | 321 | ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, |
316 | &pcm->streams[1].substream->dma_buffer); | 322 | fsl_dma_hardware.buffer_bytes_max, |
317 | if (ret) { | 323 | &pcm->streams[1].substream->dma_buffer); |
318 | snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); | 324 | if (ret) { |
319 | dev_err(card->dev, "can't allocate capture dma buffer\n"); | 325 | snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); |
320 | return ret; | 326 | dev_err(card->dev, "can't alloc capture dma buffer\n"); |
327 | return ret; | ||
328 | } | ||
321 | } | 329 | } |
322 | 330 | ||
323 | return 0; | 331 | return 0; |