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