aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/kirkwood/kirkwood-dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/kirkwood/kirkwood-dma.c')
-rw-r--r--sound/soc/kirkwood/kirkwood-dma.c64
1 files changed, 42 insertions, 22 deletions
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index a30205be3e2b..693049d42d24 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -18,7 +18,6 @@
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/mbus.h> 19#include <linux/mbus.h>
20#include <sound/soc.h> 20#include <sound/soc.h>
21#include "kirkwood-dma.h"
22#include "kirkwood.h" 21#include "kirkwood.h"
23 22
24#define KIRKWOOD_RATES \ 23#define KIRKWOOD_RATES \
@@ -123,9 +122,10 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
123 int err; 122 int err;
124 struct snd_pcm_runtime *runtime = substream->runtime; 123 struct snd_pcm_runtime *runtime = substream->runtime;
125 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 124 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
126 struct snd_soc_dai *cpu_dai = soc_runtime->dai->cpu_dai; 125 struct snd_soc_platform *platform = soc_runtime->platform;
126 struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
127 struct kirkwood_dma_data *priv; 127 struct kirkwood_dma_data *priv;
128 struct kirkwood_dma_priv *prdata = cpu_dai->private_data; 128 struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
129 unsigned long addr; 129 unsigned long addr;
130 130
131 priv = snd_soc_dai_get_dma_data(cpu_dai, substream); 131 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
@@ -151,7 +151,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
151 if (err < 0) 151 if (err < 0)
152 return err; 152 return err;
153 153
154 if (soc_runtime->dai->cpu_dai->private_data == NULL) { 154 if (prdata == NULL) {
155 prdata = kzalloc(sizeof(struct kirkwood_dma_priv), GFP_KERNEL); 155 prdata = kzalloc(sizeof(struct kirkwood_dma_priv), GFP_KERNEL);
156 if (prdata == NULL) 156 if (prdata == NULL)
157 return -ENOMEM; 157 return -ENOMEM;
@@ -165,7 +165,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
165 return -EBUSY; 165 return -EBUSY;
166 } 166 }
167 167
168 soc_runtime->dai->cpu_dai->private_data = prdata; 168 snd_soc_platform_set_drvdata(platform, prdata);
169 169
170 /* 170 /*
171 * Enable Error interrupts. We're only ack'ing them but 171 * Enable Error interrupts. We're only ack'ing them but
@@ -191,8 +191,9 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
191static int kirkwood_dma_close(struct snd_pcm_substream *substream) 191static int kirkwood_dma_close(struct snd_pcm_substream *substream)
192{ 192{
193 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 193 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
194 struct snd_soc_dai *cpu_dai = soc_runtime->dai->cpu_dai; 194 struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
195 struct kirkwood_dma_priv *prdata = cpu_dai->private_data; 195 struct snd_soc_platform *platform = soc_runtime->platform;
196 struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
196 struct kirkwood_dma_data *priv; 197 struct kirkwood_dma_data *priv;
197 198
198 priv = snd_soc_dai_get_dma_data(cpu_dai, substream); 199 priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
@@ -209,7 +210,7 @@ static int kirkwood_dma_close(struct snd_pcm_substream *substream)
209 writel(0, priv->io + KIRKWOOD_ERR_MASK); 210 writel(0, priv->io + KIRKWOOD_ERR_MASK);
210 free_irq(priv->irq, prdata); 211 free_irq(priv->irq, prdata);
211 kfree(prdata); 212 kfree(prdata);
212 soc_runtime->dai->cpu_dai->private_data = NULL; 213 snd_soc_platform_set_drvdata(platform, NULL);
213 } 214 }
214 215
215 return 0; 216 return 0;
@@ -236,7 +237,7 @@ static int kirkwood_dma_prepare(struct snd_pcm_substream *substream)
236{ 237{
237 struct snd_pcm_runtime *runtime = substream->runtime; 238 struct snd_pcm_runtime *runtime = substream->runtime;
238 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 239 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
239 struct snd_soc_dai *cpu_dai = soc_runtime->dai->cpu_dai; 240 struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
240 struct kirkwood_dma_data *priv; 241 struct kirkwood_dma_data *priv;
241 unsigned long size, count; 242 unsigned long size, count;
242 243
@@ -265,7 +266,7 @@ static snd_pcm_uframes_t kirkwood_dma_pointer(struct snd_pcm_substream
265 *substream) 266 *substream)
266{ 267{
267 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 268 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
268 struct snd_soc_dai *cpu_dai = soc_runtime->dai->cpu_dai; 269 struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
269 struct kirkwood_dma_data *priv; 270 struct kirkwood_dma_data *priv;
270 snd_pcm_uframes_t count; 271 snd_pcm_uframes_t count;
271 272
@@ -320,14 +321,14 @@ static int kirkwood_dma_new(struct snd_card *card,
320 if (!card->dev->coherent_dma_mask) 321 if (!card->dev->coherent_dma_mask)
321 card->dev->coherent_dma_mask = 0xffffffff; 322 card->dev->coherent_dma_mask = 0xffffffff;
322 323
323 if (dai->playback.channels_min) { 324 if (dai->driver->playback.channels_min) {
324 ret = kirkwood_dma_preallocate_dma_buffer(pcm, 325 ret = kirkwood_dma_preallocate_dma_buffer(pcm,
325 SNDRV_PCM_STREAM_PLAYBACK); 326 SNDRV_PCM_STREAM_PLAYBACK);
326 if (ret) 327 if (ret)
327 return ret; 328 return ret;
328 } 329 }
329 330
330 if (dai->capture.channels_min) { 331 if (dai->driver->capture.channels_min) {
331 ret = kirkwood_dma_preallocate_dma_buffer(pcm, 332 ret = kirkwood_dma_preallocate_dma_buffer(pcm,
332 SNDRV_PCM_STREAM_CAPTURE); 333 SNDRV_PCM_STREAM_CAPTURE);
333 if (ret) 334 if (ret)
@@ -357,25 +358,44 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm)
357 } 358 }
358} 359}
359 360
360struct snd_soc_platform kirkwood_soc_platform = { 361static struct snd_soc_platform_driver kirkwood_soc_platform = {
361 .name = "kirkwood-dma", 362 .ops = &kirkwood_dma_ops,
362 .pcm_ops = &kirkwood_dma_ops,
363 .pcm_new = kirkwood_dma_new, 363 .pcm_new = kirkwood_dma_new,
364 .pcm_free = kirkwood_dma_free_dma_buffers, 364 .pcm_free = kirkwood_dma_free_dma_buffers,
365}; 365};
366EXPORT_SYMBOL_GPL(kirkwood_soc_platform);
367 366
368static int __init kirkwood_soc_platform_init(void) 367static int __devinit kirkwood_soc_platform_probe(struct platform_device *pdev)
369{ 368{
370 return snd_soc_register_platform(&kirkwood_soc_platform); 369 return snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform);
371} 370}
372module_init(kirkwood_soc_platform_init);
373 371
374static void __exit kirkwood_soc_platform_exit(void) 372static int __devexit kirkwood_soc_platform_remove(struct platform_device *pdev)
375{ 373{
376 snd_soc_unregister_platform(&kirkwood_soc_platform); 374 snd_soc_unregister_platform(&pdev->dev);
375 return 0;
376}
377
378static struct platform_driver kirkwood_pcm_driver = {
379 .driver = {
380 .name = "kirkwood-pcm-audio",
381 .owner = THIS_MODULE,
382 },
383
384 .probe = kirkwood_soc_platform_probe,
385 .remove = __devexit_p(kirkwood_soc_platform_remove),
386};
387
388static int __init kirkwood_pcm_init(void)
389{
390 return platform_driver_register(&kirkwood_pcm_driver);
391}
392module_init(kirkwood_pcm_init);
393
394static void __exit kirkwood_pcm_exit(void)
395{
396 platform_driver_unregister(&kirkwood_pcm_driver);
377} 397}
378module_exit(kirkwood_soc_platform_exit); 398module_exit(kirkwood_pcm_exit);
379 399
380MODULE_AUTHOR("Arnaud Patard <apatard@mandriva.com>"); 400MODULE_AUTHOR("Arnaud Patard <apatard@mandriva.com>");
381MODULE_DESCRIPTION("Marvell Kirkwood Audio DMA module"); 401MODULE_DESCRIPTION("Marvell Kirkwood Audio DMA module");