1717#include <linux/dmaengine.h>
1818#include <linux/dma/pxa-dma.h>
1919
20+ #include <sound/ac97/controller.h>
2021#include <sound/core.h>
2122#include <sound/ac97_codec.h>
2223#include <sound/soc.h>
2728#include <mach/regs-ac97.h>
2829#include <mach/audio.h>
2930
30- static void pxa2xx_ac97_warm_reset (struct snd_ac97 * ac97 )
31+ static void pxa2xx_ac97_warm_reset (struct ac97_controller * adrv )
3132{
3233 pxa2xx_ac97_try_warm_reset ();
3334
3435 pxa2xx_ac97_finish_reset ();
3536}
3637
37- static void pxa2xx_ac97_cold_reset (struct snd_ac97 * ac97 )
38+ static void pxa2xx_ac97_cold_reset (struct ac97_controller * adrv )
3839{
3940 pxa2xx_ac97_try_cold_reset ();
4041
4142 pxa2xx_ac97_finish_reset ();
4243}
4344
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 )
4647{
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 );
5449}
5550
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 )
5853{
59- int ret ;
60-
61- ret = pxa2xx_ac97_write (ac97 -> num , reg , val );
54+ return pxa2xx_ac97_write (slot , reg , val );
6255}
6356
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 ,
6760 .warm_reset = pxa2xx_ac97_warm_reset ,
6861 .reset = pxa2xx_ac97_cold_reset ,
6962};
@@ -233,6 +226,9 @@ MODULE_DEVICE_TABLE(of, pxa2xx_ac97_dt_ids);
233226static int pxa2xx_ac97_dev_probe (struct platform_device * pdev )
234227{
235228 int ret ;
229+ struct ac97_controller * ctrl ;
230+ pxa2xx_audio_ops_t * pdata = pdev -> dev .platform_data ;
231+ void * * codecs_pdata ;
236232
237233 if (pdev -> id != -1 ) {
238234 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)
245241 return ret ;
246242 }
247243
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 );
251250
251+ platform_set_drvdata (pdev , ctrl );
252252 /* Punt most of the init to the SoC probe; we may need the machine
253253 * driver to do interesting things with the clocking to get us up
254254 * and running.
@@ -259,8 +259,10 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
259259
260260static int pxa2xx_ac97_dev_remove (struct platform_device * pdev )
261261{
262+ struct ac97_controller * ctrl = platform_get_drvdata (pdev );
263+
262264 snd_soc_unregister_component (& pdev -> dev );
263- snd_soc_set_ac97_ops ( NULL );
265+ snd_ac97_controller_unregister ( ctrl );
264266 pxa2xx_ac97_hw_remove (pdev );
265267 return 0 ;
266268}
0 commit comments