17
17
#include <linux/dmaengine.h>
18
18
#include <linux/dma/pxa-dma.h>
19
19
20
+ #include <sound/ac97/controller.h>
20
21
#include <sound/core.h>
21
22
#include <sound/ac97_codec.h>
22
23
#include <sound/soc.h>
27
28
#include <mach/regs-ac97.h>
28
29
#include <mach/audio.h>
29
30
30
- static void pxa2xx_ac97_warm_reset (struct snd_ac97 * ac97 )
31
+ static void pxa2xx_ac97_warm_reset (struct ac97_controller * adrv )
31
32
{
32
33
pxa2xx_ac97_try_warm_reset ();
33
34
34
35
pxa2xx_ac97_finish_reset ();
35
36
}
36
37
37
- static void pxa2xx_ac97_cold_reset (struct snd_ac97 * ac97 )
38
+ static void pxa2xx_ac97_cold_reset (struct ac97_controller * adrv )
38
39
{
39
40
pxa2xx_ac97_try_cold_reset ();
40
41
41
42
pxa2xx_ac97_finish_reset ();
42
43
}
43
44
44
- static unsigned short pxa2xx_ac97_legacy_read (struct snd_ac97 * ac97 ,
45
- unsigned short reg )
45
+ static int pxa2xx_ac97_read_actrl (struct ac97_controller * adrv , int slot ,
46
+ unsigned short reg )
46
47
{
47
- int ret ;
48
-
49
- ret = pxa2xx_ac97_read (ac97 -> num , reg );
50
- if (ret < 0 )
51
- return 0 ;
52
- else
53
- return (unsigned short )(ret & 0xffff );
48
+ return pxa2xx_ac97_read (slot , reg );
54
49
}
55
50
56
- static void pxa2xx_ac97_legacy_write (struct snd_ac97 * ac97 ,
57
- unsigned short reg , unsigned short val )
51
+ static int pxa2xx_ac97_write_actrl (struct ac97_controller * adrv , int slot ,
52
+ unsigned short reg , unsigned short val )
58
53
{
59
- int ret ;
60
-
61
- ret = pxa2xx_ac97_write (ac97 -> num , reg , val );
54
+ return pxa2xx_ac97_write (slot , reg , val );
62
55
}
63
56
64
- static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
65
- .read = pxa2xx_ac97_legacy_read ,
66
- .write = pxa2xx_ac97_legacy_write ,
57
+ static struct ac97_controller_ops pxa2xx_ac97_ops = {
58
+ .read = pxa2xx_ac97_read_actrl ,
59
+ .write = pxa2xx_ac97_write_actrl ,
67
60
.warm_reset = pxa2xx_ac97_warm_reset ,
68
61
.reset = pxa2xx_ac97_cold_reset ,
69
62
};
@@ -233,6 +226,9 @@ MODULE_DEVICE_TABLE(of, pxa2xx_ac97_dt_ids);
233
226
static int pxa2xx_ac97_dev_probe (struct platform_device * pdev )
234
227
{
235
228
int ret ;
229
+ struct ac97_controller * ctrl ;
230
+ pxa2xx_audio_ops_t * pdata = pdev -> dev .platform_data ;
231
+ void * * codecs_pdata ;
236
232
237
233
if (pdev -> id != -1 ) {
238
234
dev_err (& pdev -> dev , "PXA2xx has only one AC97 port.\n" );
@@ -245,10 +241,14 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
245
241
return ret ;
246
242
}
247
243
248
- ret = snd_soc_set_ac97_ops (& pxa2xx_ac97_ops );
249
- if (ret != 0 )
250
- return ret ;
244
+ codecs_pdata = pdata ? pdata -> codec_pdata : NULL ;
245
+ ctrl = snd_ac97_controller_register (& pxa2xx_ac97_ops , & pdev -> dev ,
246
+ AC97_SLOTS_AVAILABLE_ALL ,
247
+ codecs_pdata );
248
+ if (IS_ERR (ctrl ))
249
+ return PTR_ERR (ctrl );
251
250
251
+ platform_set_drvdata (pdev , ctrl );
252
252
/* Punt most of the init to the SoC probe; we may need the machine
253
253
* driver to do interesting things with the clocking to get us up
254
254
* and running.
@@ -259,8 +259,10 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
259
259
260
260
static int pxa2xx_ac97_dev_remove (struct platform_device * pdev )
261
261
{
262
+ struct ac97_controller * ctrl = platform_get_drvdata (pdev );
263
+
262
264
snd_soc_unregister_component (& pdev -> dev );
263
- snd_soc_set_ac97_ops ( NULL );
265
+ snd_ac97_controller_unregister ( ctrl );
264
266
pxa2xx_ac97_hw_remove (pdev );
265
267
return 0 ;
266
268
}
0 commit comments