diff options
Diffstat (limited to 'sound/soc/nuc900')
-rw-r--r-- | sound/soc/nuc900/nuc900-ac97.c | 30 | ||||
-rw-r--r-- | sound/soc/nuc900/nuc900-audio.c | 17 | ||||
-rw-r--r-- | sound/soc/nuc900/nuc900-audio.h | 2 | ||||
-rw-r--r-- | sound/soc/nuc900/nuc900-pcm.c | 47 |
4 files changed, 50 insertions, 46 deletions
diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c index caa7c901bc2e..dac6732da969 100644 --- a/sound/soc/nuc900/nuc900-ac97.c +++ b/sound/soc/nuc900/nuc900-ac97.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <sound/pcm.h> | 20 | #include <sound/pcm.h> |
21 | #include <sound/initval.h> | 21 | #include <sound/initval.h> |
22 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
23 | #include <linux/device.h> | ||
24 | #include <linux/clk.h> | 23 | #include <linux/clk.h> |
25 | 24 | ||
26 | #include <mach/mfp.h> | 25 | #include <mach/mfp.h> |
@@ -50,7 +49,7 @@ static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97, | |||
50 | mutex_lock(&ac97_mutex); | 49 | mutex_lock(&ac97_mutex); |
51 | 50 | ||
52 | val = nuc900_checkready(); | 51 | val = nuc900_checkready(); |
53 | if (!!val) { | 52 | if (val) { |
54 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | 53 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); |
55 | goto out; | 54 | goto out; |
56 | } | 55 | } |
@@ -103,7 +102,7 @@ static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
103 | mutex_lock(&ac97_mutex); | 102 | mutex_lock(&ac97_mutex); |
104 | 103 | ||
105 | tmp = nuc900_checkready(); | 104 | tmp = nuc900_checkready(); |
106 | if (!!tmp) | 105 | if (tmp) |
107 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | 106 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); |
108 | 107 | ||
109 | /* clear the R_WB bit and write register index */ | 108 | /* clear the R_WB bit and write register index */ |
@@ -150,7 +149,7 @@ static void nuc900_ac97_warm_reset(struct snd_ac97 *ac97) | |||
150 | udelay(100); | 149 | udelay(100); |
151 | 150 | ||
152 | val = nuc900_checkready(); | 151 | val = nuc900_checkready(); |
153 | if (!!val) | 152 | if (val) |
154 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); | 153 | dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); |
155 | 154 | ||
156 | mutex_unlock(&ac97_mutex); | 155 | mutex_unlock(&ac97_mutex); |
@@ -264,8 +263,7 @@ static int nuc900_ac97_trigger(struct snd_pcm_substream *substream, | |||
264 | return ret; | 263 | return ret; |
265 | } | 264 | } |
266 | 265 | ||
267 | static int nuc900_ac97_probe(struct platform_device *pdev, | 266 | static int nuc900_ac97_probe(struct snd_soc_dai *dai) |
268 | struct snd_soc_dai *dai) | ||
269 | { | 267 | { |
270 | struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | 268 | struct nuc900_audio *nuc900_audio = nuc900_ac97_data; |
271 | unsigned long val; | 269 | unsigned long val; |
@@ -285,20 +283,19 @@ static int nuc900_ac97_probe(struct platform_device *pdev, | |||
285 | return 0; | 283 | return 0; |
286 | } | 284 | } |
287 | 285 | ||
288 | static void nuc900_ac97_remove(struct platform_device *pdev, | 286 | static int nuc900_ac97_remove(struct snd_soc_dai *dai) |
289 | struct snd_soc_dai *dai) | ||
290 | { | 287 | { |
291 | struct nuc900_audio *nuc900_audio = nuc900_ac97_data; | 288 | struct nuc900_audio *nuc900_audio = nuc900_ac97_data; |
292 | 289 | ||
293 | clk_disable(nuc900_audio->clk); | 290 | clk_disable(nuc900_audio->clk); |
291 | return 0; | ||
294 | } | 292 | } |
295 | 293 | ||
296 | static struct snd_soc_dai_ops nuc900_ac97_dai_ops = { | 294 | static struct snd_soc_dai_ops nuc900_ac97_dai_ops = { |
297 | .trigger = nuc900_ac97_trigger, | 295 | .trigger = nuc900_ac97_trigger, |
298 | }; | 296 | }; |
299 | 297 | ||
300 | struct snd_soc_dai nuc900_ac97_dai = { | 298 | static struct snd_soc_dai_driver nuc900_ac97_dai = { |
301 | .name = "nuc900-ac97", | ||
302 | .probe = nuc900_ac97_probe, | 299 | .probe = nuc900_ac97_probe, |
303 | .remove = nuc900_ac97_remove, | 300 | .remove = nuc900_ac97_remove, |
304 | .ac97_control = 1, | 301 | .ac97_control = 1, |
@@ -315,8 +312,7 @@ struct snd_soc_dai nuc900_ac97_dai = { | |||
315 | .channels_max = 2, | 312 | .channels_max = 2, |
316 | }, | 313 | }, |
317 | .ops = &nuc900_ac97_dai_ops, | 314 | .ops = &nuc900_ac97_dai_ops, |
318 | } | 315 | }; |
319 | EXPORT_SYMBOL_GPL(nuc900_ac97_dai); | ||
320 | 316 | ||
321 | static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev) | 317 | static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev) |
322 | { | 318 | { |
@@ -365,9 +361,7 @@ static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev) | |||
365 | 361 | ||
366 | nuc900_ac97_data = nuc900_audio; | 362 | nuc900_ac97_data = nuc900_audio; |
367 | 363 | ||
368 | nuc900_audio->dev = nuc900_ac97_dai.dev = &pdev->dev; | 364 | ret = snd_soc_register_dai(&pdev->dev, &nuc900_ac97_dai); |
369 | |||
370 | ret = snd_soc_register_dai(&nuc900_ac97_dai); | ||
371 | if (ret) | 365 | if (ret) |
372 | goto out3; | 366 | goto out3; |
373 | 367 | ||
@@ -389,14 +383,14 @@ out0: | |||
389 | 383 | ||
390 | static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev) | 384 | static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev) |
391 | { | 385 | { |
392 | 386 | snd_soc_unregister_dai(&pdev->dev); | |
393 | snd_soc_unregister_dai(&nuc900_ac97_dai); | ||
394 | 387 | ||
395 | clk_put(nuc900_ac97_data->clk); | 388 | clk_put(nuc900_ac97_data->clk); |
396 | iounmap(nuc900_ac97_data->mmio); | 389 | iounmap(nuc900_ac97_data->mmio); |
397 | release_mem_region(nuc900_ac97_data->res->start, | 390 | release_mem_region(nuc900_ac97_data->res->start, |
398 | resource_size(nuc900_ac97_data->res)); | 391 | resource_size(nuc900_ac97_data->res)); |
399 | 392 | ||
393 | kfree(nuc900_ac97_data); | ||
400 | nuc900_ac97_data = NULL; | 394 | nuc900_ac97_data = NULL; |
401 | 395 | ||
402 | return 0; | 396 | return 0; |
@@ -404,7 +398,7 @@ static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev) | |||
404 | 398 | ||
405 | static struct platform_driver nuc900_ac97_driver = { | 399 | static struct platform_driver nuc900_ac97_driver = { |
406 | .driver = { | 400 | .driver = { |
407 | .name = "nuc900-audio", | 401 | .name = "nuc900-ac97", |
408 | .owner = THIS_MODULE, | 402 | .owner = THIS_MODULE, |
409 | }, | 403 | }, |
410 | .probe = nuc900_ac97_drvprobe, | 404 | .probe = nuc900_ac97_drvprobe, |
diff --git a/sound/soc/nuc900/nuc900-audio.c b/sound/soc/nuc900/nuc900-audio.c index 72e6f518f7b2..38a2d0d883b5 100644 --- a/sound/soc/nuc900/nuc900-audio.c +++ b/sound/soc/nuc900/nuc900-audio.c | |||
@@ -18,28 +18,22 @@ | |||
18 | #include <sound/core.h> | 18 | #include <sound/core.h> |
19 | #include <sound/pcm.h> | 19 | #include <sound/pcm.h> |
20 | #include <sound/soc.h> | 20 | #include <sound/soc.h> |
21 | #include <sound/soc-dapm.h> | ||
22 | 21 | ||
23 | #include "../codecs/ac97.h" | ||
24 | #include "nuc900-audio.h" | 22 | #include "nuc900-audio.h" |
25 | 23 | ||
26 | static struct snd_soc_dai_link nuc900evb_ac97_dai = { | 24 | static struct snd_soc_dai_link nuc900evb_ac97_dai = { |
27 | .name = "AC97", | 25 | .name = "AC97", |
28 | .stream_name = "AC97 HiFi", | 26 | .stream_name = "AC97 HiFi", |
29 | .cpu_dai = &nuc900_ac97_dai, | 27 | .cpu_dai_name = "nuc900-ac97", |
30 | .codec_dai = &ac97_dai, | 28 | .codec_dai_name = "ac97-hifi", |
29 | .codec_name = "ac97-codec", | ||
30 | .platform_name = "nuc900-pcm-audio", | ||
31 | }; | 31 | }; |
32 | 32 | ||
33 | static struct snd_soc_card nuc900evb_audio_machine = { | 33 | static struct snd_soc_card nuc900evb_audio_machine = { |
34 | .name = "NUC900EVB_AC97", | 34 | .name = "NUC900EVB_AC97", |
35 | .dai_link = &nuc900evb_ac97_dai, | 35 | .dai_link = &nuc900evb_ac97_dai, |
36 | .num_links = 1, | 36 | .num_links = 1, |
37 | .platform = &nuc900_soc_platform, | ||
38 | }; | ||
39 | |||
40 | static struct snd_soc_device nuc900evb_ac97_devdata = { | ||
41 | .card = &nuc900evb_audio_machine, | ||
42 | .codec_dev = &soc_codec_dev_ac97, | ||
43 | }; | 37 | }; |
44 | 38 | ||
45 | static struct platform_device *nuc900evb_asoc_dev; | 39 | static struct platform_device *nuc900evb_asoc_dev; |
@@ -54,9 +48,8 @@ static int __init nuc900evb_audio_init(void) | |||
54 | goto out; | 48 | goto out; |
55 | 49 | ||
56 | /* nuc900 board audio device */ | 50 | /* nuc900 board audio device */ |
57 | platform_set_drvdata(nuc900evb_asoc_dev, &nuc900evb_ac97_devdata); | 51 | platform_set_drvdata(nuc900evb_asoc_dev, &nuc900evb_audio_machine); |
58 | 52 | ||
59 | nuc900evb_ac97_devdata.dev = &nuc900evb_asoc_dev->dev; | ||
60 | ret = platform_device_add(nuc900evb_asoc_dev); | 53 | ret = platform_device_add(nuc900evb_asoc_dev); |
61 | 54 | ||
62 | if (ret) { | 55 | if (ret) { |
diff --git a/sound/soc/nuc900/nuc900-audio.h b/sound/soc/nuc900/nuc900-audio.h index 3038f519729f..59f7e8ed1a68 100644 --- a/sound/soc/nuc900/nuc900-audio.h +++ b/sound/soc/nuc900/nuc900-audio.h | |||
@@ -111,7 +111,5 @@ struct nuc900_audio { | |||
111 | }; | 111 | }; |
112 | 112 | ||
113 | extern struct nuc900_audio *nuc900_ac97_data; | 113 | extern struct nuc900_audio *nuc900_ac97_data; |
114 | extern struct snd_soc_dai nuc900_ac97_dai; | ||
115 | extern struct snd_soc_platform nuc900_soc_platform; | ||
116 | 114 | ||
117 | #endif /*end _NUC900_AUDIO_H */ | 115 | #endif /*end _NUC900_AUDIO_H */ |
diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index e81e803b3a63..8263f56dc665 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c | |||
@@ -50,12 +50,12 @@ static int nuc900_dma_hw_params(struct snd_pcm_substream *substream, | |||
50 | unsigned long flags; | 50 | unsigned long flags; |
51 | int ret = 0; | 51 | int ret = 0; |
52 | 52 | ||
53 | spin_lock_irqsave(&nuc900_audio->lock, flags); | ||
54 | |||
55 | ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | 53 | ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); |
56 | if (ret < 0) | 54 | if (ret < 0) |
57 | return ret; | 55 | return ret; |
58 | 56 | ||
57 | spin_lock_irqsave(&nuc900_audio->lock, flags); | ||
58 | |||
59 | nuc900_audio->substream = substream; | 59 | nuc900_audio->substream = substream; |
60 | nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr; | 60 | nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr; |
61 | nuc900_audio->buffersize[substream->stream] = | 61 | nuc900_audio->buffersize[substream->stream] = |
@@ -169,6 +169,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream) | |||
169 | struct snd_pcm_runtime *runtime = substream->runtime; | 169 | struct snd_pcm_runtime *runtime = substream->runtime; |
170 | struct nuc900_audio *nuc900_audio = runtime->private_data; | 170 | struct nuc900_audio *nuc900_audio = runtime->private_data; |
171 | unsigned long flags, val; | 171 | unsigned long flags, val; |
172 | int ret = 0; | ||
172 | 173 | ||
173 | spin_lock_irqsave(&nuc900_audio->lock, flags); | 174 | spin_lock_irqsave(&nuc900_audio->lock, flags); |
174 | 175 | ||
@@ -197,10 +198,10 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream) | |||
197 | AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); | 198 | AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); |
198 | break; | 199 | break; |
199 | default: | 200 | default: |
200 | return -EINVAL; | 201 | ret = -EINVAL; |
201 | } | 202 | } |
202 | spin_unlock_irqrestore(&nuc900_audio->lock, flags); | 203 | spin_unlock_irqrestore(&nuc900_audio->lock, flags); |
203 | return 0; | 204 | return ret; |
204 | } | 205 | } |
205 | 206 | ||
206 | static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd) | 207 | static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd) |
@@ -328,26 +329,44 @@ static int nuc900_dma_new(struct snd_card *card, | |||
328 | return 0; | 329 | return 0; |
329 | } | 330 | } |
330 | 331 | ||
331 | struct snd_soc_platform nuc900_soc_platform = { | 332 | static struct snd_soc_platform_driver nuc900_soc_platform = { |
332 | .name = "nuc900-dma", | 333 | .ops = &nuc900_dma_ops, |
333 | .pcm_ops = &nuc900_dma_ops, | ||
334 | .pcm_new = nuc900_dma_new, | 334 | .pcm_new = nuc900_dma_new, |
335 | .pcm_free = nuc900_dma_free_dma_buffers, | 335 | .pcm_free = nuc900_dma_free_dma_buffers, |
336 | }; | ||
337 | |||
338 | static int __devinit nuc900_soc_platform_probe(struct platform_device *pdev) | ||
339 | { | ||
340 | return snd_soc_register_platform(&pdev->dev, &nuc900_soc_platform); | ||
336 | } | 341 | } |
337 | EXPORT_SYMBOL_GPL(nuc900_soc_platform); | ||
338 | 342 | ||
339 | static int __init nuc900_soc_platform_init(void) | 343 | static int __devexit nuc900_soc_platform_remove(struct platform_device *pdev) |
340 | { | 344 | { |
341 | return snd_soc_register_platform(&nuc900_soc_platform); | 345 | snd_soc_unregister_platform(&pdev->dev); |
346 | return 0; | ||
342 | } | 347 | } |
343 | 348 | ||
344 | static void __exit nuc900_soc_platform_exit(void) | 349 | static struct platform_driver nuc900_pcm_driver = { |
350 | .driver = { | ||
351 | .name = "nuc900-pcm-audio", | ||
352 | .owner = THIS_MODULE, | ||
353 | }, | ||
354 | |||
355 | .probe = nuc900_soc_platform_probe, | ||
356 | .remove = __devexit_p(nuc900_soc_platform_remove), | ||
357 | }; | ||
358 | |||
359 | static int __init nuc900_pcm_init(void) | ||
345 | { | 360 | { |
346 | snd_soc_unregister_platform(&nuc900_soc_platform); | 361 | return platform_driver_register(&nuc900_pcm_driver); |
347 | } | 362 | } |
363 | module_init(nuc900_pcm_init); | ||
348 | 364 | ||
349 | module_init(nuc900_soc_platform_init); | 365 | static void __exit nuc900_pcm_exit(void) |
350 | module_exit(nuc900_soc_platform_exit); | 366 | { |
367 | platform_driver_unregister(&nuc900_pcm_driver); | ||
368 | } | ||
369 | module_exit(nuc900_pcm_exit); | ||
351 | 370 | ||
352 | MODULE_AUTHOR("Wan ZongShun, <mcuos.com@gmail.com>"); | 371 | MODULE_AUTHOR("Wan ZongShun, <mcuos.com@gmail.com>"); |
353 | MODULE_DESCRIPTION("nuc900 Audio DMA module"); | 372 | MODULE_DESCRIPTION("nuc900 Audio DMA module"); |