aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl/fsl_dma.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-08-23 12:58:01 +0100
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-08-23 12:58:01 +0100
commit97e15b1fcf79a60cb146d4123e7c72ac2736e258 (patch)
tree5923cd4d4f2e1945b66a7aab27acf684f8590c47 /sound/soc/fsl/fsl_dma.c
parenta8165e0e6f0511d14132423b4bce2d285e890fc8 (diff)
parent38fec7272bc033b75a0eb8976c56c2024d371b7d (diff)
downloadkernel_samsung_smdk4412-97e15b1fcf79a60cb146d4123e7c72ac2736e258.zip
kernel_samsung_smdk4412-97e15b1fcf79a60cb146d4123e7c72ac2736e258.tar.gz
kernel_samsung_smdk4412-97e15b1fcf79a60cb146d4123e7c72ac2736e258.tar.bz2
Merge remote branch 'broonie-asoc/for-2.6.37' into for-2.6.37
Diffstat (limited to 'sound/soc/fsl/fsl_dma.c')
-rw-r--r--sound/soc/fsl/fsl_dma.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index dfe1cb9..4cf98c0 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -23,6 +23,7 @@
#include <linux/gfp.h>
#include <linux/of_platform.h>
#include <linux/list.h>
+#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
@@ -305,21 +306,29 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
if (!card->dev->coherent_dma_mask)
card->dev->coherent_dma_mask = fsl_dma_dmamask;
- 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 allocate playback dma buffer\n");
- return ret;
+ /* Some codecs have separate DAIs for playback and capture, so we
+ * should allocate a DMA buffer only for the streams that are valid.
+ */
+
+ if (dai->driver->playback.channels_min) {
+ 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,
- fsl_dma_hardware.buffer_bytes_max,
- &pcm->streams[1].substream->dma_buffer);
- if (ret) {
- snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
- dev_err(card->dev, "can't allocate capture dma buffer\n");
- return ret;
+ if (dai->driver->capture.channels_min) {
+ ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
+ fsl_dma_hardware.buffer_bytes_max,
+ &pcm->streams[1].substream->dma_buffer);
+ if (ret) {
+ snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
+ dev_err(card->dev, "can't alloc capture dma buffer\n");
+ return ret;
+ }
}
return 0;
@@ -887,11 +896,11 @@ static struct snd_pcm_ops fsl_dma_ops = {
.pointer = fsl_dma_pointer,
};
-static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
+static int __devinit fsl_soc_dma_probe(struct platform_device *pdev,
const struct of_device_id *match)
{
struct dma_object *dma;
- struct device_node *np = of_dev->dev.of_node;
+ struct device_node *np = pdev->dev.of_node;
struct device_node *ssi_np;
struct resource res;
const uint32_t *iprop;
@@ -900,13 +909,13 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
/* Find the SSI node that points to us. */
ssi_np = find_ssi_node(np);
if (!ssi_np) {
- dev_err(&of_dev->dev, "cannot find parent SSI node\n");
+ dev_err(&pdev->dev, "cannot find parent SSI node\n");
return -ENODEV;
}
ret = of_address_to_resource(ssi_np, 0, &res);
if (ret) {
- dev_err(&of_dev->dev, "could not determine resources for %s\n",
+ dev_err(&pdev->dev, "could not determine resources for %s\n",
ssi_np->full_name);
of_node_put(ssi_np);
return ret;
@@ -914,7 +923,7 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
if (!dma) {
- dev_err(&of_dev->dev, "could not allocate dma object\n");
+ dev_err(&pdev->dev, "could not allocate dma object\n");
of_node_put(ssi_np);
return -ENOMEM;
}
@@ -937,9 +946,9 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
of_node_put(ssi_np);
- ret = snd_soc_register_platform(&of_dev->dev, &dma->dai);
+ ret = snd_soc_register_platform(&pdev->dev, &dma->dai);
if (ret) {
- dev_err(&of_dev->dev, "could not register platform\n");
+ dev_err(&pdev->dev, "could not register platform\n");
kfree(dma);
return ret;
}
@@ -947,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->channel = of_iomap(np, 0);
dma->irq = irq_of_parse_and_map(np, 0);
- dev_set_drvdata(&of_dev->dev, dma);
+ dev_set_drvdata(&pdev->dev, dma);
return 0;
}
-static int __devexit fsl_soc_dma_remove(struct of_device *of_dev)
+static int __devexit fsl_soc_dma_remove(struct platform_device *pdev)
{
- struct dma_object *dma = dev_get_drvdata(&of_dev->dev);
+ struct dma_object *dma = dev_get_drvdata(&pdev->dev);
- snd_soc_unregister_platform(&of_dev->dev);
+ snd_soc_unregister_platform(&pdev->dev);
iounmap(dma->channel);
irq_dispose_mapping(dma->irq);
kfree(dma);