aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2006-01-24 15:34:47 -0500
committerDave Kleikamp <shaggy@austin.ibm.com>2006-01-24 15:34:47 -0500
commit0a0fc0ddbe732779366ab6b1b879f62195e65967 (patch)
tree7b42490a676cf39ae0691b6859ecf7fd410f229b /sound/isa
parent4d5dbd0945d9e0833dd7964a3d6ee33157f7cc7a (diff)
parent3ee68c4af3fd7228c1be63254b9f884614f9ebb2 (diff)
Merge with /home/shaggy/git/linus-clean/
Diffstat (limited to 'sound/isa')
-rw-r--r--sound/isa/Kconfig171
-rw-r--r--sound/isa/ad1816a/Makefile5
-rw-r--r--sound/isa/ad1816a/ad1816a.c26
-rw-r--r--sound/isa/ad1816a/ad1816a_lib.c209
-rw-r--r--sound/isa/ad1848/ad1848.c105
-rw-r--r--sound/isa/ad1848/ad1848_lib.c206
-rw-r--r--sound/isa/als100.c57
-rw-r--r--sound/isa/azt2320.c52
-rw-r--r--sound/isa/cmi8330.c299
-rw-r--r--sound/isa/cs423x/cs4231.c110
-rw-r--r--sound/isa/cs423x/cs4231_lib.c334
-rw-r--r--sound/isa/cs423x/cs4236.c591
-rw-r--r--sound/isa/cs423x/cs4236_lib.c106
-rw-r--r--sound/isa/dt019x.c57
-rw-r--r--sound/isa/es1688/es1688.c130
-rw-r--r--sound/isa/es1688/es1688_lib.c158
-rw-r--r--sound/isa/es18xx.c630
-rw-r--r--sound/isa/gus/gus_dma.c24
-rw-r--r--sound/isa/gus/gus_dram.c8
-rw-r--r--sound/isa/gus/gus_instr.c42
-rw-r--r--sound/isa/gus/gus_io.c72
-rw-r--r--sound/isa/gus/gus_irq.c16
-rw-r--r--sound/isa/gus/gus_main.c54
-rw-r--r--sound/isa/gus/gus_mem.c64
-rw-r--r--sound/isa/gus/gus_mem_proc.c26
-rw-r--r--sound/isa/gus/gus_mixer.c28
-rw-r--r--sound/isa/gus/gus_pcm.c202
-rw-r--r--sound/isa/gus/gus_reset.c54
-rw-r--r--sound/isa/gus/gus_sample.c42
-rw-r--r--sound/isa/gus/gus_simple.c86
-rw-r--r--sound/isa/gus/gus_synth.c90
-rw-r--r--sound/isa/gus/gus_timer.c44
-rw-r--r--sound/isa/gus/gus_uart.c38
-rw-r--r--sound/isa/gus/gus_volume.c4
-rw-r--r--sound/isa/gus/gusclassic.c136
-rw-r--r--sound/isa/gus/gusextreme.c150
-rw-r--r--sound/isa/gus/gusmax.c153
-rw-r--r--sound/isa/gus/interwave.c368
-rw-r--r--sound/isa/opl3sa2.c556
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c720
-rw-r--r--sound/isa/sb/emu8000.c121
-rw-r--r--sound/isa/sb/emu8000_callback.c107
-rw-r--r--sound/isa/sb/emu8000_local.h13
-rw-r--r--sound/isa/sb/emu8000_patch.c20
-rw-r--r--sound/isa/sb/emu8000_pcm.c104
-rw-r--r--sound/isa/sb/emu8000_synth.c17
-rw-r--r--sound/isa/sb/es968.c53
-rw-r--r--sound/isa/sb/sb16.c369
-rw-r--r--sound/isa/sb/sb16_csp.c174
-rw-r--r--sound/isa/sb/sb16_main.c130
-rw-r--r--sound/isa/sb/sb8.c176
-rw-r--r--sound/isa/sb/sb8_main.c94
-rw-r--r--sound/isa/sb/sb8_midi.c44
-rw-r--r--sound/isa/sb/sb_common.c28
-rw-r--r--sound/isa/sb/sb_mixer.c262
-rw-r--r--sound/isa/sgalaxy.c117
-rw-r--r--sound/isa/sscape.c373
-rw-r--r--sound/isa/wavefront/wavefront.c316
-rw-r--r--sound/isa/wavefront/wavefront_fx.c8
-rw-r--r--sound/isa/wavefront/wavefront_midi.c22
-rw-r--r--sound/isa/wavefront/wavefront_synth.c31
61 files changed, 4892 insertions, 3910 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 5d6c300ac0d5..ff8fef932786 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -6,12 +6,10 @@ menu "ISA devices"
6config SND_AD1848_LIB 6config SND_AD1848_LIB
7 tristate 7 tristate
8 select SND_PCM 8 select SND_PCM
9 select SND_GENERIC_DRIVER
10 9
11config SND_CS4231_LIB 10config SND_CS4231_LIB
12 tristate 11 tristate
13 select SND_PCM 12 select SND_PCM
14 select SND_GENERIC_DRIVER
15 13
16config SND_AD1816A 14config SND_AD1816A
17 tristate "Analog Devices SoundPort AD1816A" 15 tristate "Analog Devices SoundPort AD1816A"
@@ -41,6 +39,45 @@ config SND_AD1848
41 To compile this driver as a module, choose M here: the module 39 To compile this driver as a module, choose M here: the module
42 will be called snd-ad1848. 40 will be called snd-ad1848.
43 41
42config SND_ALS100
43 tristate "Avance Logic ALS100/ALS120"
44 depends on SND && PNP && ISA
45 select ISAPNP
46 select SND_OPL3_LIB
47 select SND_MPU401_UART
48 select SND_PCM
49 help
50 Say Y here to include support for soundcards based on Avance
51 Logic ALS100, ALS110, ALS120 and ALS200 chips.
52
53 To compile this driver as a module, choose M here: the module
54 will be called snd-als100.
55
56config SND_AZT2320
57 tristate "Aztech Systems AZT2320"
58 depends on SND && PNP && ISA
59 select ISAPNP
60 select SND_OPL3_LIB
61 select SND_MPU401_UART
62 select SND_CS4231_LIB
63 help
64 Say Y here to include support for soundcards based on the
65 Aztech Systems AZT2320 chip.
66
67 To compile this driver as a module, choose M here: the module
68 will be called snd-azt2320.
69
70config SND_CMI8330
71 tristate "C-Media CMI8330"
72 depends on SND
73 select SND_AD1848_LIB
74 help
75 Say Y here to include support for soundcards based on the
76 C-Media CMI8330 chip.
77
78 To compile this driver as a module, choose M here: the module
79 will be called snd-cmi8330.
80
44config SND_CS4231 81config SND_CS4231
45 tristate "Generic Cirrus Logic CS4231 driver" 82 tristate "Generic Cirrus Logic CS4231 driver"
46 depends on SND 83 depends on SND
@@ -79,6 +116,20 @@ config SND_CS4236
79 To compile this driver as a module, choose M here: the module 116 To compile this driver as a module, choose M here: the module
80 will be called snd-cs4236. 117 will be called snd-cs4236.
81 118
119config SND_DT019X
120 tristate "Diamond Technologies DT-019X, Avance Logic ALS-007"
121 depends on SND && PNP && ISA
122 select ISAPNP
123 select SND_OPL3_LIB
124 select SND_MPU401_UART
125 select SND_PCM
126 help
127 Say Y here to include support for soundcards based on the
128 Diamond Technologies DT-019X or Avance Logic ALS-007 chips.
129
130 To compile this driver as a module, choose M here: the module
131 will be called snd-dt019x.
132
82config SND_ES968 133config SND_ES968
83 tristate "Generic ESS ES968 driver" 134 tristate "Generic ESS ES968 driver"
84 depends on SND && PNP && ISA 135 depends on SND && PNP && ISA
@@ -97,7 +148,6 @@ config SND_ES1688
97 select SND_OPL3_LIB 148 select SND_OPL3_LIB
98 select SND_MPU401_UART 149 select SND_MPU401_UART
99 select SND_PCM 150 select SND_PCM
100 select SND_GENERIC_DRIVER
101 help 151 help
102 Say Y here to include support for ESS AudioDrive ES688 or 152 Say Y here to include support for ESS AudioDrive ES688 or
103 ES1688 chips. 153 ES1688 chips.
@@ -111,7 +161,6 @@ config SND_ES18XX
111 select SND_OPL3_LIB 161 select SND_OPL3_LIB
112 select SND_MPU401_UART 162 select SND_MPU401_UART
113 select SND_PCM 163 select SND_PCM
114 select SND_GENERIC_DRIVER
115 help 164 help
116 Say Y here to include support for ESS AudioDrive ES18xx chips. 165 Say Y here to include support for ESS AudioDrive ES18xx chips.
117 166
@@ -127,7 +176,6 @@ config SND_GUSCLASSIC
127 select SND_RAWMIDI 176 select SND_RAWMIDI
128 select SND_PCM 177 select SND_PCM
129 select SND_GUS_SYNTH 178 select SND_GUS_SYNTH
130 select SND_GENERIC_DRIVER
131 help 179 help
132 Say Y here to include support for Gravis UltraSound Classic 180 Say Y here to include support for Gravis UltraSound Classic
133 soundcards. 181 soundcards.
@@ -142,7 +190,6 @@ config SND_GUSEXTREME
142 select SND_MPU401_UART 190 select SND_MPU401_UART
143 select SND_PCM 191 select SND_PCM
144 select SND_GUS_SYNTH 192 select SND_GUS_SYNTH
145 select SND_GENERIC_DRIVER
146 help 193 help
147 Say Y here to include support for Gravis UltraSound Extreme 194 Say Y here to include support for Gravis UltraSound Extreme
148 soundcards. 195 soundcards.
@@ -156,7 +203,6 @@ config SND_GUSMAX
156 select SND_RAWMIDI 203 select SND_RAWMIDI
157 select SND_CS4231_LIB 204 select SND_CS4231_LIB
158 select SND_GUS_SYNTH 205 select SND_GUS_SYNTH
159 select SND_GENERIC_DRIVER
160 help 206 help
161 Say Y here to include support for Gravis UltraSound MAX 207 Say Y here to include support for Gravis UltraSound MAX
162 soundcards. 208 soundcards.
@@ -170,7 +216,6 @@ config SND_INTERWAVE
170 select SND_RAWMIDI 216 select SND_RAWMIDI
171 select SND_CS4231_LIB 217 select SND_CS4231_LIB
172 select SND_GUS_SYNTH 218 select SND_GUS_SYNTH
173 select SND_GENERIC_DRIVER
174 help 219 help
175 Say Y here to include support for AMD InterWave based 220 Say Y here to include support for AMD InterWave based
176 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, 221 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32,
@@ -185,7 +230,6 @@ config SND_INTERWAVE_STB
185 select SND_RAWMIDI 230 select SND_RAWMIDI
186 select SND_CS4231_LIB 231 select SND_CS4231_LIB
187 select SND_GUS_SYNTH 232 select SND_GUS_SYNTH
188 select SND_GENERIC_DRIVER
189 help 233 help
190 Say Y here to include support for AMD InterWave based 234 Say Y here to include support for AMD InterWave based
191 soundcards with a TEA6330T bass and treble regulator 235 soundcards with a TEA6330T bass and treble regulator
@@ -194,6 +238,19 @@ config SND_INTERWAVE_STB
194 To compile this driver as a module, choose M here: the module 238 To compile this driver as a module, choose M here: the module
195 will be called snd-interwave-stb. 239 will be called snd-interwave-stb.
196 240
241config SND_OPL3SA2
242 tristate "Yamaha OPL3-SA2/SA3"
243 depends on SND
244 select SND_OPL3_LIB
245 select SND_MPU401_UART
246 select SND_CS4231_LIB
247 help
248 Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3
249 chips.
250
251 To compile this driver as a module, choose M here: the module
252 will be called snd-opl3sa2.
253
197config SND_OPTI92X_AD1848 254config SND_OPTI92X_AD1848
198 tristate "OPTi 82C92x - AD1848" 255 tristate "OPTi 82C92x - AD1848"
199 depends on SND 256 depends on SND
@@ -228,7 +285,6 @@ config SND_OPTI93X
228 select SND_OPL3_LIB 285 select SND_OPL3_LIB
229 select SND_MPU401_UART 286 select SND_MPU401_UART
230 select SND_PCM 287 select SND_PCM
231 select SND_GENERIC_DRIVER
232 help 288 help
233 Say Y here to include support for soundcards based on Opti 289 Say Y here to include support for soundcards based on Opti
234 82C93x chips. 290 82C93x chips.
@@ -242,7 +298,6 @@ config SND_SB8
242 select SND_OPL3_LIB 298 select SND_OPL3_LIB
243 select SND_RAWMIDI 299 select SND_RAWMIDI
244 select SND_PCM 300 select SND_PCM
245 select SND_GENERIC_DRIVER
246 help 301 help
247 Say Y here to include support for Creative Sound Blaster 1.0/ 302 Say Y here to include support for Creative Sound Blaster 1.0/
248 2.0/Pro (8-bit) or 100% compatible soundcards. 303 2.0/Pro (8-bit) or 100% compatible soundcards.
@@ -256,7 +311,6 @@ config SND_SB16
256 select SND_OPL3_LIB 311 select SND_OPL3_LIB
257 select SND_MPU401_UART 312 select SND_MPU401_UART
258 select SND_PCM 313 select SND_PCM
259 select SND_GENERIC_DRIVER
260 help 314 help
261 Say Y here to include support for Sound Blaster 16 soundcards 315 Say Y here to include support for Sound Blaster 16 soundcards
262 (including the Plug and Play version). 316 (including the Plug and Play version).
@@ -270,7 +324,6 @@ config SND_SBAWE
270 select SND_OPL3_LIB 324 select SND_OPL3_LIB
271 select SND_MPU401_UART 325 select SND_MPU401_UART
272 select SND_PCM 326 select SND_PCM
273 select SND_GENERIC_DRIVER
274 help 327 help
275 Say Y here to include support for Sound Blaster AWE soundcards 328 Say Y here to include support for Sound Blaster AWE soundcards
276 (including the Plug and Play version). 329 (including the Plug and Play version).
@@ -286,85 +339,6 @@ config SND_SB16_CSP
286 coprocessor can do variable tasks like various compression and 339 coprocessor can do variable tasks like various compression and
287 decompression algorithms. 340 decompression algorithms.
288 341
289config SND_WAVEFRONT
290 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
291 depends on SND
292 select SND_OPL3_LIB
293 select SND_MPU401_UART
294 select SND_CS4231_LIB
295 help
296 Say Y here to include support for Turtle Beach Maui, Tropez
297 and Tropez+ soundcards based on the Wavefront chip.
298
299 To compile this driver as a module, choose M here: the module
300 will be called snd-wavefront.
301
302config SND_ALS100
303 tristate "Avance Logic ALS100/ALS120"
304 depends on SND && PNP && ISA
305 select ISAPNP
306 select SND_OPL3_LIB
307 select SND_MPU401_UART
308 select SND_PCM
309 help
310 Say Y here to include support for soundcards based on Avance
311 Logic ALS100, ALS110, ALS120 and ALS200 chips.
312
313 To compile this driver as a module, choose M here: the module
314 will be called snd-als100.
315
316config SND_AZT2320
317 tristate "Aztech Systems AZT2320"
318 depends on SND && PNP && ISA
319 select ISAPNP
320 select SND_OPL3_LIB
321 select SND_MPU401_UART
322 select SND_CS4231_LIB
323 help
324 Say Y here to include support for soundcards based on the
325 Aztech Systems AZT2320 chip.
326
327 To compile this driver as a module, choose M here: the module
328 will be called snd-azt2320.
329
330config SND_CMI8330
331 tristate "C-Media CMI8330"
332 depends on SND
333 select SND_AD1848_LIB
334 help
335 Say Y here to include support for soundcards based on the
336 C-Media CMI8330 chip.
337
338 To compile this driver as a module, choose M here: the module
339 will be called snd-cmi8330.
340
341config SND_DT019X
342 tristate "Diamond Technologies DT-019X, Avance Logic ALS-007"
343 depends on SND && PNP && ISA
344 select ISAPNP
345 select SND_OPL3_LIB
346 select SND_MPU401_UART
347 select SND_PCM
348 help
349 Say Y here to include support for soundcards based on the
350 Diamond Technologies DT-019X or Avance Logic ALS-007 chips.
351
352 To compile this driver as a module, choose M here: the module
353 will be called snd-dt019x.
354
355config SND_OPL3SA2
356 tristate "Yamaha OPL3-SA2/SA3"
357 depends on SND
358 select SND_OPL3_LIB
359 select SND_MPU401_UART
360 select SND_CS4231_LIB
361 help
362 Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3
363 chips.
364
365 To compile this driver as a module, choose M here: the module
366 will be called snd-opl3sa2.
367
368config SND_SGALAXY 342config SND_SGALAXY
369 tristate "Aztech Sound Galaxy" 343 tristate "Aztech Sound Galaxy"
370 depends on SND 344 depends on SND
@@ -389,4 +363,17 @@ config SND_SSCAPE
389 To compile this driver as a module, choose M here: the module 363 To compile this driver as a module, choose M here: the module
390 will be called snd-sscape. 364 will be called snd-sscape.
391 365
366config SND_WAVEFRONT
367 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
368 depends on SND
369 select SND_OPL3_LIB
370 select SND_MPU401_UART
371 select SND_CS4231_LIB
372 help
373 Say Y here to include support for Turtle Beach Maui, Tropez
374 and Tropez+ soundcards based on the Wavefront chip.
375
376 To compile this driver as a module, choose M here: the module
377 will be called snd-wavefront.
378
392endmenu 379endmenu
diff --git a/sound/isa/ad1816a/Makefile b/sound/isa/ad1816a/Makefile
index a42b29cf8549..90e00e842e49 100644
--- a/sound/isa/ad1816a/Makefile
+++ b/sound/isa/ad1816a/Makefile
@@ -3,8 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-ad1816a-lib-objs := ad1816a_lib.o 6snd-ad1816a-objs := ad1816a.o ad1816a_lib.o
7snd-ad1816a-objs := ad1816a.o
8 7
9# Toplevel Module Dependency 8# Toplevel Module Dependency
10obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o snd-ad1816a-lib.o 9obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 0eb442ca23d6..7051f7798ed7 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -188,10 +188,10 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
188 const struct pnp_card_device_id *pid) 188 const struct pnp_card_device_id *pid)
189{ 189{
190 int error; 190 int error;
191 snd_card_t *card; 191 struct snd_card *card;
192 struct snd_card_ad1816a *acard; 192 struct snd_card_ad1816a *acard;
193 ad1816a_t *chip; 193 struct snd_ad1816a *chip;
194 opl3_t *opl3; 194 struct snd_opl3 *opl3;
195 195
196 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 196 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
197 sizeof(struct snd_card_ad1816a))) == NULL) 197 sizeof(struct snd_card_ad1816a))) == NULL)
@@ -282,10 +282,8 @@ static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card,
282 282
283static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) 283static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard)
284{ 284{
285 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 285 snd_card_free(pnp_get_card_drvdata(pcard));
286 286 pnp_set_card_drvdata(pcard, NULL);
287 snd_card_disconnect(card);
288 snd_card_free_in_thread(card);
289} 287}
290 288
291static struct pnp_card_driver ad1816a_pnpc_driver = { 289static struct pnp_card_driver ad1816a_pnpc_driver = {
@@ -294,20 +292,22 @@ static struct pnp_card_driver ad1816a_pnpc_driver = {
294 .id_table = snd_ad1816a_pnpids, 292 .id_table = snd_ad1816a_pnpids,
295 .probe = snd_ad1816a_pnp_detect, 293 .probe = snd_ad1816a_pnp_detect,
296 .remove = __devexit_p(snd_ad1816a_pnp_remove), 294 .remove = __devexit_p(snd_ad1816a_pnp_remove),
295 /* FIXME: suspend/resume */
297}; 296};
298 297
299static int __init alsa_card_ad1816a_init(void) 298static int __init alsa_card_ad1816a_init(void)
300{ 299{
301 int cards = 0; 300 int cards;
302 301
303 cards += pnp_register_card_driver(&ad1816a_pnpc_driver); 302 cards = pnp_register_card_driver(&ad1816a_pnpc_driver);
304#ifdef MODULE 303 if (cards <= 0) {
305 if (!cards) {
306 pnp_unregister_card_driver(&ad1816a_pnpc_driver); 304 pnp_unregister_card_driver(&ad1816a_pnpc_driver);
305#ifdef MODULE
307 printk(KERN_ERR "no AD1816A based soundcards found.\n"); 306 printk(KERN_ERR "no AD1816A based soundcards found.\n");
308 }
309#endif /* MODULE */ 307#endif /* MODULE */
310 return cards ? 0 : -ENODEV; 308 return -ENODEV;
309 }
310 return 0;
311} 311}
312 312
313static void __exit alsa_card_ad1816a_exit(void) 313static void __exit alsa_card_ad1816a_exit(void)
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index 7ae02396cae2..ac0d808fff57 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -30,11 +30,7 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/dma.h> 31#include <asm/dma.h>
32 32
33MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); 33static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip)
34MODULE_DESCRIPTION("lowlevel code for Analog Devices AD1816A chip");
35MODULE_LICENSE("GPL");
36
37static inline int snd_ad1816a_busy_wait(ad1816a_t *chip)
38{ 34{
39 int timeout; 35 int timeout;
40 36
@@ -46,34 +42,34 @@ static inline int snd_ad1816a_busy_wait(ad1816a_t *chip)
46 return -EBUSY; 42 return -EBUSY;
47} 43}
48 44
49static inline unsigned char snd_ad1816a_in(ad1816a_t *chip, unsigned char reg) 45static inline unsigned char snd_ad1816a_in(struct snd_ad1816a *chip, unsigned char reg)
50{ 46{
51 snd_ad1816a_busy_wait(chip); 47 snd_ad1816a_busy_wait(chip);
52 return inb(AD1816A_REG(reg)); 48 return inb(AD1816A_REG(reg));
53} 49}
54 50
55static inline void snd_ad1816a_out(ad1816a_t *chip, unsigned char reg, 51static inline void snd_ad1816a_out(struct snd_ad1816a *chip, unsigned char reg,
56 unsigned char value) 52 unsigned char value)
57{ 53{
58 snd_ad1816a_busy_wait(chip); 54 snd_ad1816a_busy_wait(chip);
59 outb(value, AD1816A_REG(reg)); 55 outb(value, AD1816A_REG(reg));
60} 56}
61 57
62static inline void snd_ad1816a_out_mask(ad1816a_t *chip, unsigned char reg, 58static inline void snd_ad1816a_out_mask(struct snd_ad1816a *chip, unsigned char reg,
63 unsigned char mask, unsigned char value) 59 unsigned char mask, unsigned char value)
64{ 60{
65 snd_ad1816a_out(chip, reg, 61 snd_ad1816a_out(chip, reg,
66 (value & mask) | (snd_ad1816a_in(chip, reg) & ~mask)); 62 (value & mask) | (snd_ad1816a_in(chip, reg) & ~mask));
67} 63}
68 64
69static unsigned short snd_ad1816a_read(ad1816a_t *chip, unsigned char reg) 65static unsigned short snd_ad1816a_read(struct snd_ad1816a *chip, unsigned char reg)
70{ 66{
71 snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); 67 snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f);
72 return snd_ad1816a_in(chip, AD1816A_INDIR_DATA_LOW) | 68 return snd_ad1816a_in(chip, AD1816A_INDIR_DATA_LOW) |
73 (snd_ad1816a_in(chip, AD1816A_INDIR_DATA_HIGH) << 8); 69 (snd_ad1816a_in(chip, AD1816A_INDIR_DATA_HIGH) << 8);
74} 70}
75 71
76static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg, 72static void snd_ad1816a_write(struct snd_ad1816a *chip, unsigned char reg,
77 unsigned short value) 73 unsigned short value)
78{ 74{
79 snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); 75 snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f);
@@ -81,7 +77,7 @@ static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg,
81 snd_ad1816a_out(chip, AD1816A_INDIR_DATA_HIGH, (value >> 8) & 0xff); 77 snd_ad1816a_out(chip, AD1816A_INDIR_DATA_HIGH, (value >> 8) & 0xff);
82} 78}
83 79
84static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg, 80static void snd_ad1816a_write_mask(struct snd_ad1816a *chip, unsigned char reg,
85 unsigned short mask, unsigned short value) 81 unsigned short mask, unsigned short value)
86{ 82{
87 snd_ad1816a_write(chip, reg, 83 snd_ad1816a_write(chip, reg,
@@ -89,7 +85,7 @@ static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg,
89} 85}
90 86
91 87
92static unsigned char snd_ad1816a_get_format(ad1816a_t *chip, 88static unsigned char snd_ad1816a_get_format(struct snd_ad1816a *chip,
93 unsigned int format, int channels) 89 unsigned int format, int channels)
94{ 90{
95 unsigned char retval = AD1816A_FMT_LINEAR_8; 91 unsigned char retval = AD1816A_FMT_LINEAR_8;
@@ -110,7 +106,7 @@ static unsigned char snd_ad1816a_get_format(ad1816a_t *chip,
110 return (channels > 1) ? (retval | AD1816A_FMT_STEREO) : retval; 106 return (channels > 1) ? (retval | AD1816A_FMT_STEREO) : retval;
111} 107}
112 108
113static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode) 109static int snd_ad1816a_open(struct snd_ad1816a *chip, unsigned int mode)
114{ 110{
115 unsigned long flags; 111 unsigned long flags;
116 112
@@ -146,7 +142,7 @@ static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode)
146 return 0; 142 return 0;
147} 143}
148 144
149static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode) 145static void snd_ad1816a_close(struct snd_ad1816a *chip, unsigned int mode)
150{ 146{
151 unsigned long flags; 147 unsigned long flags;
152 148
@@ -178,7 +174,7 @@ static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode)
178} 174}
179 175
180 176
181static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what, 177static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what,
182 int channel, int cmd) 178 int channel, int cmd)
183{ 179{
184 int error = 0; 180 int error = 0;
@@ -204,36 +200,36 @@ static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what,
204 return error; 200 return error;
205} 201}
206 202
207static int snd_ad1816a_playback_trigger(snd_pcm_substream_t *substream, int cmd) 203static int snd_ad1816a_playback_trigger(struct snd_pcm_substream *substream, int cmd)
208{ 204{
209 ad1816a_t *chip = snd_pcm_substream_chip(substream); 205 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
210 return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE, 206 return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,
211 SNDRV_PCM_STREAM_PLAYBACK, cmd); 207 SNDRV_PCM_STREAM_PLAYBACK, cmd);
212} 208}
213 209
214static int snd_ad1816a_capture_trigger(snd_pcm_substream_t *substream, int cmd) 210static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd)
215{ 211{
216 ad1816a_t *chip = snd_pcm_substream_chip(substream); 212 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
217 return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE, 213 return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,
218 SNDRV_PCM_STREAM_CAPTURE, cmd); 214 SNDRV_PCM_STREAM_CAPTURE, cmd);
219} 215}
220 216
221static int snd_ad1816a_hw_params(snd_pcm_substream_t * substream, 217static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,
222 snd_pcm_hw_params_t * hw_params) 218 struct snd_pcm_hw_params *hw_params)
223{ 219{
224 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 220 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
225} 221}
226 222
227static int snd_ad1816a_hw_free(snd_pcm_substream_t * substream) 223static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream)
228{ 224{
229 return snd_pcm_lib_free_pages(substream); 225 return snd_pcm_lib_free_pages(substream);
230} 226}
231 227
232static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream) 228static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream)
233{ 229{
234 ad1816a_t *chip = snd_pcm_substream_chip(substream); 230 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
235 unsigned long flags; 231 unsigned long flags;
236 snd_pcm_runtime_t *runtime = substream->runtime; 232 struct snd_pcm_runtime *runtime = substream->runtime;
237 unsigned int size, rate; 233 unsigned int size, rate;
238 234
239 spin_lock_irqsave(&chip->lock, flags); 235 spin_lock_irqsave(&chip->lock, flags);
@@ -261,11 +257,11 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream)
261 return 0; 257 return 0;
262} 258}
263 259
264static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream) 260static int snd_ad1816a_capture_prepare(struct snd_pcm_substream *substream)
265{ 261{
266 ad1816a_t *chip = snd_pcm_substream_chip(substream); 262 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
267 unsigned long flags; 263 unsigned long flags;
268 snd_pcm_runtime_t *runtime = substream->runtime; 264 struct snd_pcm_runtime *runtime = substream->runtime;
269 unsigned int size, rate; 265 unsigned int size, rate;
270 266
271 spin_lock_irqsave(&chip->lock, flags); 267 spin_lock_irqsave(&chip->lock, flags);
@@ -294,9 +290,9 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream)
294} 290}
295 291
296 292
297static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *substream) 293static snd_pcm_uframes_t snd_ad1816a_playback_pointer(struct snd_pcm_substream *substream)
298{ 294{
299 ad1816a_t *chip = snd_pcm_substream_chip(substream); 295 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
300 size_t ptr; 296 size_t ptr;
301 if (!(chip->mode & AD1816A_MODE_PLAYBACK)) 297 if (!(chip->mode & AD1816A_MODE_PLAYBACK))
302 return 0; 298 return 0;
@@ -304,9 +300,9 @@ static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *subst
304 return bytes_to_frames(substream->runtime, ptr); 300 return bytes_to_frames(substream->runtime, ptr);
305} 301}
306 302
307static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substream) 303static snd_pcm_uframes_t snd_ad1816a_capture_pointer(struct snd_pcm_substream *substream)
308{ 304{
309 ad1816a_t *chip = snd_pcm_substream_chip(substream); 305 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
310 size_t ptr; 306 size_t ptr;
311 if (!(chip->mode & AD1816A_MODE_CAPTURE)) 307 if (!(chip->mode & AD1816A_MODE_CAPTURE))
312 return 0; 308 return 0;
@@ -317,7 +313,7 @@ static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substr
317 313
318static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs) 314static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
319{ 315{
320 ad1816a_t *chip = dev_id; 316 struct snd_ad1816a *chip = dev_id;
321 unsigned char status; 317 unsigned char status;
322 318
323 spin_lock(&chip->lock); 319 spin_lock(&chip->lock);
@@ -340,7 +336,7 @@ static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *
340} 336}
341 337
342 338
343static snd_pcm_hardware_t snd_ad1816a_playback = { 339static struct snd_pcm_hardware snd_ad1816a_playback = {
344 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 340 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
345 SNDRV_PCM_INFO_MMAP_VALID), 341 SNDRV_PCM_INFO_MMAP_VALID),
346 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | 342 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
@@ -359,7 +355,7 @@ static snd_pcm_hardware_t snd_ad1816a_playback = {
359 .fifo_size = 0, 355 .fifo_size = 0,
360}; 356};
361 357
362static snd_pcm_hardware_t snd_ad1816a_capture = { 358static struct snd_pcm_hardware snd_ad1816a_capture = {
363 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 359 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
364 SNDRV_PCM_INFO_MMAP_VALID), 360 SNDRV_PCM_INFO_MMAP_VALID),
365 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | 361 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
@@ -379,32 +375,32 @@ static snd_pcm_hardware_t snd_ad1816a_capture = {
379}; 375};
380 376
381#if 0 /* not used now */ 377#if 0 /* not used now */
382static int snd_ad1816a_timer_close(snd_timer_t *timer) 378static int snd_ad1816a_timer_close(struct snd_timer *timer)
383{ 379{
384 ad1816a_t *chip = snd_timer_chip(timer); 380 struct snd_ad1816a *chip = snd_timer_chip(timer);
385 snd_ad1816a_close(chip, AD1816A_MODE_TIMER); 381 snd_ad1816a_close(chip, AD1816A_MODE_TIMER);
386 return 0; 382 return 0;
387} 383}
388 384
389static int snd_ad1816a_timer_open(snd_timer_t *timer) 385static int snd_ad1816a_timer_open(struct snd_timer *timer)
390{ 386{
391 ad1816a_t *chip = snd_timer_chip(timer); 387 struct snd_ad1816a *chip = snd_timer_chip(timer);
392 snd_ad1816a_open(chip, AD1816A_MODE_TIMER); 388 snd_ad1816a_open(chip, AD1816A_MODE_TIMER);
393 return 0; 389 return 0;
394} 390}
395 391
396static unsigned long snd_ad1816a_timer_resolution(snd_timer_t *timer) 392static unsigned long snd_ad1816a_timer_resolution(struct snd_timer *timer)
397{ 393{
398 snd_assert(timer != NULL, return 0); 394 snd_assert(timer != NULL, return 0);
399 395
400 return 10000; 396 return 10000;
401} 397}
402 398
403static int snd_ad1816a_timer_start(snd_timer_t *timer) 399static int snd_ad1816a_timer_start(struct snd_timer *timer)
404{ 400{
405 unsigned short bits; 401 unsigned short bits;
406 unsigned long flags; 402 unsigned long flags;
407 ad1816a_t *chip = snd_timer_chip(timer); 403 struct snd_ad1816a *chip = snd_timer_chip(timer);
408 spin_lock_irqsave(&chip->lock, flags); 404 spin_lock_irqsave(&chip->lock, flags);
409 bits = snd_ad1816a_read(chip, AD1816A_INTERRUPT_ENABLE); 405 bits = snd_ad1816a_read(chip, AD1816A_INTERRUPT_ENABLE);
410 406
@@ -419,10 +415,10 @@ static int snd_ad1816a_timer_start(snd_timer_t *timer)
419 return 0; 415 return 0;
420} 416}
421 417
422static int snd_ad1816a_timer_stop(snd_timer_t *timer) 418static int snd_ad1816a_timer_stop(struct snd_timer *timer)
423{ 419{
424 unsigned long flags; 420 unsigned long flags;
425 ad1816a_t *chip = snd_timer_chip(timer); 421 struct snd_ad1816a *chip = snd_timer_chip(timer);
426 spin_lock_irqsave(&chip->lock, flags); 422 spin_lock_irqsave(&chip->lock, flags);
427 423
428 snd_ad1816a_write_mask(chip, AD1816A_INTERRUPT_ENABLE, 424 snd_ad1816a_write_mask(chip, AD1816A_INTERRUPT_ENABLE,
@@ -432,7 +428,7 @@ static int snd_ad1816a_timer_stop(snd_timer_t *timer)
432 return 0; 428 return 0;
433} 429}
434 430
435static struct _snd_timer_hardware snd_ad1816a_timer_table = { 431static struct snd_timer_hardware snd_ad1816a_timer_table = {
436 .flags = SNDRV_TIMER_HW_AUTO, 432 .flags = SNDRV_TIMER_HW_AUTO,
437 .resolution = 10000, 433 .resolution = 10000,
438 .ticks = 65535, 434 .ticks = 65535,
@@ -445,10 +441,10 @@ static struct _snd_timer_hardware snd_ad1816a_timer_table = {
445#endif /* not used now */ 441#endif /* not used now */
446 442
447 443
448static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream) 444static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream)
449{ 445{
450 ad1816a_t *chip = snd_pcm_substream_chip(substream); 446 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
451 snd_pcm_runtime_t *runtime = substream->runtime; 447 struct snd_pcm_runtime *runtime = substream->runtime;
452 int error; 448 int error;
453 449
454 if ((error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK)) < 0) 450 if ((error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK)) < 0)
@@ -461,10 +457,10 @@ static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream)
461 return 0; 457 return 0;
462} 458}
463 459
464static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream) 460static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream)
465{ 461{
466 ad1816a_t *chip = snd_pcm_substream_chip(substream); 462 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
467 snd_pcm_runtime_t *runtime = substream->runtime; 463 struct snd_pcm_runtime *runtime = substream->runtime;
468 int error; 464 int error;
469 465
470 if ((error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE)) < 0) 466 if ((error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE)) < 0)
@@ -477,18 +473,18 @@ static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream)
477 return 0; 473 return 0;
478} 474}
479 475
480static int snd_ad1816a_playback_close(snd_pcm_substream_t *substream) 476static int snd_ad1816a_playback_close(struct snd_pcm_substream *substream)
481{ 477{
482 ad1816a_t *chip = snd_pcm_substream_chip(substream); 478 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
483 479
484 chip->playback_substream = NULL; 480 chip->playback_substream = NULL;
485 snd_ad1816a_close(chip, AD1816A_MODE_PLAYBACK); 481 snd_ad1816a_close(chip, AD1816A_MODE_PLAYBACK);
486 return 0; 482 return 0;
487} 483}
488 484
489static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream) 485static int snd_ad1816a_capture_close(struct snd_pcm_substream *substream)
490{ 486{
491 ad1816a_t *chip = snd_pcm_substream_chip(substream); 487 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
492 488
493 chip->capture_substream = NULL; 489 chip->capture_substream = NULL;
494 snd_ad1816a_close(chip, AD1816A_MODE_CAPTURE); 490 snd_ad1816a_close(chip, AD1816A_MODE_CAPTURE);
@@ -496,7 +492,7 @@ static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream)
496} 492}
497 493
498 494
499static void snd_ad1816a_init(ad1816a_t *chip) 495static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip)
500{ 496{
501 unsigned long flags; 497 unsigned long flags;
502 498
@@ -516,7 +512,7 @@ static void snd_ad1816a_init(ad1816a_t *chip)
516 spin_unlock_irqrestore(&chip->lock, flags); 512 spin_unlock_irqrestore(&chip->lock, flags);
517} 513}
518 514
519static int snd_ad1816a_probe(ad1816a_t *chip) 515static int __devinit snd_ad1816a_probe(struct snd_ad1816a *chip)
520{ 516{
521 unsigned long flags; 517 unsigned long flags;
522 518
@@ -540,7 +536,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip)
540 return 0; 536 return 0;
541} 537}
542 538
543static int snd_ad1816a_free(ad1816a_t *chip) 539static int snd_ad1816a_free(struct snd_ad1816a *chip)
544{ 540{
545 release_and_free_resource(chip->res_port); 541 release_and_free_resource(chip->res_port);
546 if (chip->irq >= 0) 542 if (chip->irq >= 0)
@@ -557,13 +553,13 @@ static int snd_ad1816a_free(ad1816a_t *chip)
557 return 0; 553 return 0;
558} 554}
559 555
560static int snd_ad1816a_dev_free(snd_device_t *device) 556static int snd_ad1816a_dev_free(struct snd_device *device)
561{ 557{
562 ad1816a_t *chip = device->device_data; 558 struct snd_ad1816a *chip = device->device_data;
563 return snd_ad1816a_free(chip); 559 return snd_ad1816a_free(chip);
564} 560}
565 561
566static const char *snd_ad1816a_chip_id(ad1816a_t *chip) 562static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip)
567{ 563{
568 switch (chip->hardware) { 564 switch (chip->hardware) {
569 case AD1816A_HW_AD1816A: return "AD1816A"; 565 case AD1816A_HW_AD1816A: return "AD1816A";
@@ -576,15 +572,15 @@ static const char *snd_ad1816a_chip_id(ad1816a_t *chip)
576 } 572 }
577} 573}
578 574
579int snd_ad1816a_create(snd_card_t *card, 575int __devinit snd_ad1816a_create(struct snd_card *card,
580 unsigned long port, int irq, int dma1, int dma2, 576 unsigned long port, int irq, int dma1, int dma2,
581 ad1816a_t **rchip) 577 struct snd_ad1816a **rchip)
582{ 578{
583 static snd_device_ops_t ops = { 579 static struct snd_device_ops ops = {
584 .dev_free = snd_ad1816a_dev_free, 580 .dev_free = snd_ad1816a_dev_free,
585 }; 581 };
586 int error; 582 int error;
587 ad1816a_t *chip; 583 struct snd_ad1816a *chip;
588 584
589 *rchip = NULL; 585 *rchip = NULL;
590 586
@@ -640,7 +636,7 @@ int snd_ad1816a_create(snd_card_t *card,
640 return 0; 636 return 0;
641} 637}
642 638
643static snd_pcm_ops_t snd_ad1816a_playback_ops = { 639static struct snd_pcm_ops snd_ad1816a_playback_ops = {
644 .open = snd_ad1816a_playback_open, 640 .open = snd_ad1816a_playback_open,
645 .close = snd_ad1816a_playback_close, 641 .close = snd_ad1816a_playback_close,
646 .ioctl = snd_pcm_lib_ioctl, 642 .ioctl = snd_pcm_lib_ioctl,
@@ -651,7 +647,7 @@ static snd_pcm_ops_t snd_ad1816a_playback_ops = {
651 .pointer = snd_ad1816a_playback_pointer, 647 .pointer = snd_ad1816a_playback_pointer,
652}; 648};
653 649
654static snd_pcm_ops_t snd_ad1816a_capture_ops = { 650static struct snd_pcm_ops snd_ad1816a_capture_ops = {
655 .open = snd_ad1816a_capture_open, 651 .open = snd_ad1816a_capture_open,
656 .close = snd_ad1816a_capture_close, 652 .close = snd_ad1816a_capture_close,
657 .ioctl = snd_pcm_lib_ioctl, 653 .ioctl = snd_pcm_lib_ioctl,
@@ -662,17 +658,10 @@ static snd_pcm_ops_t snd_ad1816a_capture_ops = {
662 .pointer = snd_ad1816a_capture_pointer, 658 .pointer = snd_ad1816a_capture_pointer,
663}; 659};
664 660
665static void snd_ad1816a_pcm_free(snd_pcm_t *pcm) 661int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm)
666{
667 ad1816a_t *chip = pcm->private_data;
668 chip->pcm = NULL;
669 snd_pcm_lib_preallocate_free_for_all(pcm);
670}
671
672int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm)
673{ 662{
674 int error; 663 int error;
675 snd_pcm_t *pcm; 664 struct snd_pcm *pcm;
676 665
677 if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm))) 666 if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm)))
678 return error; 667 return error;
@@ -681,7 +670,6 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm)
681 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1816a_capture_ops); 670 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1816a_capture_ops);
682 671
683 pcm->private_data = chip; 672 pcm->private_data = chip;
684 pcm->private_free = snd_ad1816a_pcm_free;
685 pcm->info_flags = (chip->dma1 == chip->dma2 ) ? SNDRV_PCM_INFO_JOINT_DUPLEX : 0; 673 pcm->info_flags = (chip->dma1 == chip->dma2 ) ? SNDRV_PCM_INFO_JOINT_DUPLEX : 0;
686 674
687 strcpy(pcm->name, snd_ad1816a_chip_id(chip)); 675 strcpy(pcm->name, snd_ad1816a_chip_id(chip));
@@ -698,16 +686,10 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm)
698} 686}
699 687
700#if 0 /* not used now */ 688#if 0 /* not used now */
701static void snd_ad1816a_timer_free(snd_timer_t *timer) 689int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer)
702{ 690{
703 ad1816a_t *chip = timer->private_data; 691 struct snd_timer *timer;
704 chip->timer = NULL; 692 struct snd_timer_id tid;
705}
706
707int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer)
708{
709 snd_timer_t *timer;
710 snd_timer_id_t tid;
711 int error; 693 int error;
712 694
713 tid.dev_class = SNDRV_TIMER_CLASS_CARD; 695 tid.dev_class = SNDRV_TIMER_CLASS_CARD;
@@ -719,7 +701,6 @@ int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer)
719 return error; 701 return error;
720 strcpy(timer->name, snd_ad1816a_chip_id(chip)); 702 strcpy(timer->name, snd_ad1816a_chip_id(chip));
721 timer->private_data = chip; 703 timer->private_data = chip;
722 timer->private_free = snd_ad1816a_timer_free;
723 chip->timer = timer; 704 chip->timer = timer;
724 timer->hw = snd_ad1816a_timer_table; 705 timer->hw = snd_ad1816a_timer_table;
725 if (rtimer) 706 if (rtimer)
@@ -732,7 +713,7 @@ int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer)
732 * 713 *
733 */ 714 */
734 715
735static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 716static int snd_ad1816a_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
736{ 717{
737 static char *texts[8] = { 718 static char *texts[8] = {
738 "Line", "Mix", "CD", "Synth", "Video", 719 "Line", "Mix", "CD", "Synth", "Video",
@@ -748,9 +729,9 @@ static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
748 return 0; 729 return 0;
749} 730}
750 731
751static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 732static int snd_ad1816a_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
752{ 733{
753 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 734 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
754 unsigned long flags; 735 unsigned long flags;
755 unsigned short val; 736 unsigned short val;
756 737
@@ -762,9 +743,9 @@ static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
762 return 0; 743 return 0;
763} 744}
764 745
765static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 746static int snd_ad1816a_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
766{ 747{
767 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 748 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
768 unsigned long flags; 749 unsigned long flags;
769 unsigned short val; 750 unsigned short val;
770 int change; 751 int change;
@@ -786,7 +767,7 @@ static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
786 .get = snd_ad1816a_get_single, .put = snd_ad1816a_put_single, \ 767 .get = snd_ad1816a_get_single, .put = snd_ad1816a_put_single, \
787 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 768 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
788 769
789static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 770static int snd_ad1816a_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
790{ 771{
791 int mask = (kcontrol->private_value >> 16) & 0xff; 772 int mask = (kcontrol->private_value >> 16) & 0xff;
792 773
@@ -797,9 +778,9 @@ static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
797 return 0; 778 return 0;
798} 779}
799 780
800static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 781static int snd_ad1816a_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
801{ 782{
802 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 783 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
803 unsigned long flags; 784 unsigned long flags;
804 int reg = kcontrol->private_value & 0xff; 785 int reg = kcontrol->private_value & 0xff;
805 int shift = (kcontrol->private_value >> 8) & 0xff; 786 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -814,9 +795,9 @@ static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
814 return 0; 795 return 0;
815} 796}
816 797
817static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 798static int snd_ad1816a_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
818{ 799{
819 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 800 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
820 unsigned long flags; 801 unsigned long flags;
821 int reg = kcontrol->private_value & 0xff; 802 int reg = kcontrol->private_value & 0xff;
822 int shift = (kcontrol->private_value >> 8) & 0xff; 803 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -843,7 +824,7 @@ static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
843 .get = snd_ad1816a_get_double, .put = snd_ad1816a_put_double, \ 824 .get = snd_ad1816a_get_double, .put = snd_ad1816a_put_double, \
844 .private_value = reg | (shift_left << 8) | (shift_right << 12) | (mask << 16) | (invert << 24) } 825 .private_value = reg | (shift_left << 8) | (shift_right << 12) | (mask << 16) | (invert << 24) }
845 826
846static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 827static int snd_ad1816a_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
847{ 828{
848 int mask = (kcontrol->private_value >> 16) & 0xff; 829 int mask = (kcontrol->private_value >> 16) & 0xff;
849 830
@@ -854,9 +835,9 @@ static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
854 return 0; 835 return 0;
855} 836}
856 837
857static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 838static int snd_ad1816a_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
858{ 839{
859 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 840 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
860 unsigned long flags; 841 unsigned long flags;
861 int reg = kcontrol->private_value & 0xff; 842 int reg = kcontrol->private_value & 0xff;
862 int shift_left = (kcontrol->private_value >> 8) & 0x0f; 843 int shift_left = (kcontrol->private_value >> 8) & 0x0f;
@@ -877,9 +858,9 @@ static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
877 return 0; 858 return 0;
878} 859}
879 860
880static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 861static int snd_ad1816a_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
881{ 862{
882 ad1816a_t *chip = snd_kcontrol_chip(kcontrol); 863 struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol);
883 unsigned long flags; 864 unsigned long flags;
884 int reg = kcontrol->private_value & 0xff; 865 int reg = kcontrol->private_value & 0xff;
885 int shift_left = (kcontrol->private_value >> 8) & 0x0f; 866 int shift_left = (kcontrol->private_value >> 8) & 0x0f;
@@ -906,7 +887,7 @@ static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
906 return change; 887 return change;
907} 888}
908 889
909static snd_kcontrol_new_t snd_ad1816a_controls[] = { 890static struct snd_kcontrol_new snd_ad1816a_controls[] __devinitdata = {
910AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1), 891AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1),
911AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1), 892AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1),
912AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1), 893AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1),
@@ -941,9 +922,9 @@ AD1816A_SINGLE("3D Control - Switch", AD1816A_3D_PHAT_CTRL, 15, 1, 1),
941AD1816A_SINGLE("3D Control - Level", AD1816A_3D_PHAT_CTRL, 0, 15, 0), 922AD1816A_SINGLE("3D Control - Level", AD1816A_3D_PHAT_CTRL, 0, 15, 0),
942}; 923};
943 924
944int snd_ad1816a_mixer(ad1816a_t *chip) 925int __devinit snd_ad1816a_mixer(struct snd_ad1816a *chip)
945{ 926{
946 snd_card_t *card; 927 struct snd_card *card;
947 unsigned int idx; 928 unsigned int idx;
948 int err; 929 int err;
949 930
@@ -959,19 +940,3 @@ int snd_ad1816a_mixer(ad1816a_t *chip)
959 } 940 }
960 return 0; 941 return 0;
961} 942}
962
963EXPORT_SYMBOL(snd_ad1816a_create);
964EXPORT_SYMBOL(snd_ad1816a_pcm);
965EXPORT_SYMBOL(snd_ad1816a_mixer);
966
967static int __init alsa_ad1816a_init(void)
968{
969 return 0;
970}
971
972static void __exit alsa_ad1816a_exit(void)
973{
974}
975
976module_init(alsa_ad1816a_init)
977module_exit(alsa_ad1816a_exit)
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 3ebcc482b07a..e091bbeffd2a 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -23,6 +23,8 @@
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h>
27#include <linux/platform_device.h>
26#include <linux/time.h> 28#include <linux/time.h>
27#include <linux/wait.h> 29#include <linux/wait.h>
28#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
@@ -60,14 +62,15 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver.");
60module_param_array(thinkpad, bool, NULL, 0444); 62module_param_array(thinkpad, bool, NULL, 0444);
61MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); 63MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
62 64
63static snd_card_t *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 65static struct platform_device *devices[SNDRV_CARDS];
64 66
65 67
66static int __init snd_card_ad1848_probe(int dev) 68static int __init snd_ad1848_probe(struct platform_device *pdev)
67{ 69{
68 snd_card_t *card; 70 int dev = pdev->id;
69 ad1848_t *chip; 71 struct snd_card *card;
70 snd_pcm_t *pcm; 72 struct snd_ad1848 *chip;
73 struct snd_pcm *pcm;
71 int err; 74 int err;
72 75
73 if (port[dev] == SNDRV_AUTO_PORT) { 76 if (port[dev] == SNDRV_AUTO_PORT) {
@@ -93,6 +96,7 @@ static int __init snd_card_ad1848_probe(int dev)
93 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, 96 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT,
94 &chip)) < 0) 97 &chip)) < 0)
95 goto _err; 98 goto _err;
99 card->private_data = chip;
96 100
97 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) 101 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0)
98 goto _err; 102 goto _err;
@@ -109,13 +113,12 @@ static int __init snd_card_ad1848_probe(int dev)
109 if (thinkpad[dev]) 113 if (thinkpad[dev])
110 strcat(card->longname, " [Thinkpad]"); 114 strcat(card->longname, " [Thinkpad]");
111 115
112 if ((err = snd_card_set_generic_dev(card)) < 0) 116 snd_card_set_dev(card, &pdev->dev);
113 goto _err;
114 117
115 if ((err = snd_card_register(card)) < 0) 118 if ((err = snd_card_register(card)) < 0)
116 goto _err; 119 goto _err;
117 120
118 snd_ad1848_cards[dev] = card; 121 platform_set_drvdata(pdev, card);
119 return 0; 122 return 0;
120 123
121 _err: 124 _err:
@@ -123,29 +126,95 @@ static int __init snd_card_ad1848_probe(int dev)
123 return err; 126 return err;
124} 127}
125 128
126static int __init alsa_card_ad1848_init(void) 129static int __devexit snd_ad1848_remove(struct platform_device *devptr)
130{
131 snd_card_free(platform_get_drvdata(devptr));
132 platform_set_drvdata(devptr, NULL);
133 return 0;
134}
135
136#ifdef CONFIG_PM
137static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state)
138{
139 struct snd_card *card = platform_get_drvdata(pdev);
140 struct snd_ad1848 *chip = card->private_data;
141
142 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
143 chip->suspend(chip);
144 return 0;
145}
146
147static int snd_ad1848_resume(struct platform_device *pdev)
127{ 148{
128 int dev, cards; 149 struct snd_card *card = platform_get_drvdata(pdev);
150 struct snd_ad1848 *chip = card->private_data;
129 151
130 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) 152 chip->resume(chip);
131 if (snd_card_ad1848_probe(dev) >= 0) 153 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
132 cards++; 154 return 0;
155}
156#endif
133 157
158#define SND_AD1848_DRIVER "snd_ad1848"
159
160static struct platform_driver snd_ad1848_driver = {
161 .probe = snd_ad1848_probe,
162 .remove = __devexit_p(snd_ad1848_remove),
163#ifdef CONFIG_PM
164 .suspend = snd_ad1848_suspend,
165 .resume = snd_ad1848_resume,
166#endif
167 .driver = {
168 .name = SND_AD1848_DRIVER
169 },
170};
171
172static void __init_or_module snd_ad1848_unregister_all(void)
173{
174 int i;
175
176 for (i = 0; i < ARRAY_SIZE(devices); ++i)
177 platform_device_unregister(devices[i]);
178 platform_driver_unregister(&snd_ad1848_driver);
179}
180
181static int __init alsa_card_ad1848_init(void)
182{
183 int i, cards, err;
184
185 err = platform_driver_register(&snd_ad1848_driver);
186 if (err < 0)
187 return err;
188
189 cards = 0;
190 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
191 struct platform_device *device;
192 device = platform_device_register_simple(SND_AD1848_DRIVER,
193 i, NULL, 0);
194 if (IS_ERR(device)) {
195 err = PTR_ERR(device);
196 goto errout;
197 }
198 devices[i] = device;
199 cards++;
200 }
134 if (!cards) { 201 if (!cards) {
135#ifdef MODULE 202#ifdef MODULE
136 printk(KERN_ERR "AD1848 soundcard not found or device busy\n"); 203 printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
137#endif 204#endif
138 return -ENODEV; 205 err = -ENODEV;
206 goto errout;
139 } 207 }
140 return 0; 208 return 0;
209
210 errout:
211 snd_ad1848_unregister_all();
212 return err;
141} 213}
142 214
143static void __exit alsa_card_ad1848_exit(void) 215static void __exit alsa_card_ad1848_exit(void)
144{ 216{
145 int idx; 217 snd_ad1848_unregister_all();
146
147 for (idx = 0; idx < SNDRV_CARDS; idx++)
148 snd_card_free(snd_ad1848_cards[idx]);
149} 218}
150 219
151module_init(alsa_card_ad1848_init) 220module_init(alsa_card_ad1848_init)
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 891bacc94f68..b78530d7ea90 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -24,7 +24,6 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pm.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
29#include <linux/ioport.h> 28#include <linux/ioport.h>
30#include <sound/core.h> 29#include <sound/core.h>
@@ -69,7 +68,7 @@ static unsigned int rates[14] = {
69 27042, 32000, 33075, 37800, 44100, 48000 68 27042, 32000, 33075, 37800, 44100, 48000
70}; 69};
71 70
72static snd_pcm_hw_constraint_list_t hw_constraints_rates = { 71static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
73 .count = 14, 72 .count = 14,
74 .list = rates, 73 .list = rates,
75 .mask = 0, 74 .mask = 0,
@@ -99,7 +98,7 @@ static unsigned char snd_ad1848_original_image[16] =
99 * Basic I/O functions 98 * Basic I/O functions
100 */ 99 */
101 100
102void snd_ad1848_out(ad1848_t *chip, 101void snd_ad1848_out(struct snd_ad1848 *chip,
103 unsigned char reg, 102 unsigned char reg,
104 unsigned char value) 103 unsigned char value)
105{ 104{
@@ -119,7 +118,7 @@ void snd_ad1848_out(ad1848_t *chip,
119#endif 118#endif
120} 119}
121 120
122static void snd_ad1848_dout(ad1848_t *chip, 121static void snd_ad1848_dout(struct snd_ad1848 *chip,
123 unsigned char reg, unsigned char value) 122 unsigned char reg, unsigned char value)
124{ 123{
125 int timeout; 124 int timeout;
@@ -131,7 +130,7 @@ static void snd_ad1848_dout(ad1848_t *chip,
131 mb(); 130 mb();
132} 131}
133 132
134static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg) 133static unsigned char snd_ad1848_in(struct snd_ad1848 *chip, unsigned char reg)
135{ 134{
136 int timeout; 135 int timeout;
137 136
@@ -148,7 +147,7 @@ static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg)
148 147
149#if 0 148#if 0
150 149
151static void snd_ad1848_debug(ad1848_t *chip) 150static void snd_ad1848_debug(struct snd_ad1848 *chip)
152{ 151{
153 printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip, REGSEL))); 152 printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip, REGSEL)));
154 printk(" STATUS = 0x%02x\n", inb(AD1848P(chip, STATUS))); 153 printk(" STATUS = 0x%02x\n", inb(AD1848P(chip, STATUS)));
@@ -176,7 +175,7 @@ static void snd_ad1848_debug(ad1848_t *chip)
176 * AD1848 detection / MCE routines 175 * AD1848 detection / MCE routines
177 */ 176 */
178 177
179static void snd_ad1848_mce_up(ad1848_t *chip) 178static void snd_ad1848_mce_up(struct snd_ad1848 *chip)
180{ 179{
181 unsigned long flags; 180 unsigned long flags;
182 int timeout; 181 int timeout;
@@ -197,7 +196,7 @@ static void snd_ad1848_mce_up(ad1848_t *chip)
197 spin_unlock_irqrestore(&chip->reg_lock, flags); 196 spin_unlock_irqrestore(&chip->reg_lock, flags);
198} 197}
199 198
200static void snd_ad1848_mce_down(ad1848_t *chip) 199static void snd_ad1848_mce_down(struct snd_ad1848 *chip)
201{ 200{
202 unsigned long flags; 201 unsigned long flags;
203 int timeout; 202 int timeout;
@@ -279,7 +278,7 @@ static unsigned int snd_ad1848_get_count(unsigned char format,
279 return size; 278 return size;
280} 279}
281 280
282static int snd_ad1848_trigger(ad1848_t *chip, unsigned char what, 281static int snd_ad1848_trigger(struct snd_ad1848 *chip, unsigned char what,
283 int channel, int cmd) 282 int channel, int cmd)
284{ 283{
285 int result = 0; 284 int result = 0;
@@ -324,7 +323,7 @@ static unsigned char snd_ad1848_get_rate(unsigned int rate)
324 return freq_bits[13]; 323 return freq_bits[13];
325} 324}
326 325
327static int snd_ad1848_ioctl(snd_pcm_substream_t * substream, 326static int snd_ad1848_ioctl(struct snd_pcm_substream *substream,
328 unsigned int cmd, void *arg) 327 unsigned int cmd, void *arg)
329{ 328{
330 return snd_pcm_lib_ioctl(substream, cmd, arg); 329 return snd_pcm_lib_ioctl(substream, cmd, arg);
@@ -348,7 +347,7 @@ static unsigned char snd_ad1848_get_format(int format, int channels)
348 return rformat; 347 return rformat;
349} 348}
350 349
351static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute) 350static void snd_ad1848_calibrate_mute(struct snd_ad1848 *chip, int mute)
352{ 351{
353 unsigned long flags; 352 unsigned long flags;
354 353
@@ -372,7 +371,7 @@ static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute)
372 spin_unlock_irqrestore(&chip->reg_lock, flags); 371 spin_unlock_irqrestore(&chip->reg_lock, flags);
373} 372}
374 373
375static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_params) 374static void snd_ad1848_set_data_format(struct snd_ad1848 *chip, struct snd_pcm_hw_params *hw_params)
376{ 375{
377 if (hw_params == NULL) { 376 if (hw_params == NULL) {
378 chip->image[AD1848_DATA_FORMAT] = 0x20; 377 chip->image[AD1848_DATA_FORMAT] = 0x20;
@@ -384,7 +383,7 @@ static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_p
384 // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]); 383 // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]);
385} 384}
386 385
387static int snd_ad1848_open(ad1848_t *chip, unsigned int mode) 386static int snd_ad1848_open(struct snd_ad1848 *chip, unsigned int mode)
388{ 387{
389 unsigned long flags; 388 unsigned long flags;
390 389
@@ -438,7 +437,7 @@ static int snd_ad1848_open(ad1848_t *chip, unsigned int mode)
438 return 0; 437 return 0;
439} 438}
440 439
441static void snd_ad1848_close(ad1848_t *chip) 440static void snd_ad1848_close(struct snd_ad1848 *chip)
442{ 441{
443 unsigned long flags; 442 unsigned long flags;
444 443
@@ -479,24 +478,24 @@ static void snd_ad1848_close(ad1848_t *chip)
479 * ok.. exported functions.. 478 * ok.. exported functions..
480 */ 479 */
481 480
482static int snd_ad1848_playback_trigger(snd_pcm_substream_t * substream, 481static int snd_ad1848_playback_trigger(struct snd_pcm_substream *substream,
483 int cmd) 482 int cmd)
484{ 483{
485 ad1848_t *chip = snd_pcm_substream_chip(substream); 484 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
486 return snd_ad1848_trigger(chip, AD1848_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd); 485 return snd_ad1848_trigger(chip, AD1848_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd);
487} 486}
488 487
489static int snd_ad1848_capture_trigger(snd_pcm_substream_t * substream, 488static int snd_ad1848_capture_trigger(struct snd_pcm_substream *substream,
490 int cmd) 489 int cmd)
491{ 490{
492 ad1848_t *chip = snd_pcm_substream_chip(substream); 491 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
493 return snd_ad1848_trigger(chip, AD1848_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd); 492 return snd_ad1848_trigger(chip, AD1848_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd);
494} 493}
495 494
496static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream, 495static int snd_ad1848_playback_hw_params(struct snd_pcm_substream *substream,
497 snd_pcm_hw_params_t * hw_params) 496 struct snd_pcm_hw_params *hw_params)
498{ 497{
499 ad1848_t *chip = snd_pcm_substream_chip(substream); 498 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
500 unsigned long flags; 499 unsigned long flags;
501 int err; 500 int err;
502 501
@@ -513,15 +512,15 @@ static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream,
513 return 0; 512 return 0;
514} 513}
515 514
516static int snd_ad1848_playback_hw_free(snd_pcm_substream_t * substream) 515static int snd_ad1848_playback_hw_free(struct snd_pcm_substream *substream)
517{ 516{
518 return snd_pcm_lib_free_pages(substream); 517 return snd_pcm_lib_free_pages(substream);
519} 518}
520 519
521static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream) 520static int snd_ad1848_playback_prepare(struct snd_pcm_substream *substream)
522{ 521{
523 ad1848_t *chip = snd_pcm_substream_chip(substream); 522 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
524 snd_pcm_runtime_t *runtime = substream->runtime; 523 struct snd_pcm_runtime *runtime = substream->runtime;
525 unsigned long flags; 524 unsigned long flags;
526 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 525 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
527 unsigned int count = snd_pcm_lib_period_bytes(substream); 526 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -537,10 +536,10 @@ static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream)
537 return 0; 536 return 0;
538} 537}
539 538
540static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream, 539static int snd_ad1848_capture_hw_params(struct snd_pcm_substream *substream,
541 snd_pcm_hw_params_t * hw_params) 540 struct snd_pcm_hw_params *hw_params)
542{ 541{
543 ad1848_t *chip = snd_pcm_substream_chip(substream); 542 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
544 unsigned long flags; 543 unsigned long flags;
545 int err; 544 int err;
546 545
@@ -557,15 +556,15 @@ static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream,
557 return 0; 556 return 0;
558} 557}
559 558
560static int snd_ad1848_capture_hw_free(snd_pcm_substream_t * substream) 559static int snd_ad1848_capture_hw_free(struct snd_pcm_substream *substream)
561{ 560{
562 return snd_pcm_lib_free_pages(substream); 561 return snd_pcm_lib_free_pages(substream);
563} 562}
564 563
565static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream) 564static int snd_ad1848_capture_prepare(struct snd_pcm_substream *substream)
566{ 565{
567 ad1848_t *chip = snd_pcm_substream_chip(substream); 566 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
568 snd_pcm_runtime_t *runtime = substream->runtime; 567 struct snd_pcm_runtime *runtime = substream->runtime;
569 unsigned long flags; 568 unsigned long flags;
570 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 569 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
571 unsigned int count = snd_pcm_lib_period_bytes(substream); 570 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -583,7 +582,7 @@ static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream)
583 582
584static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs) 583static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs)
585{ 584{
586 ad1848_t *chip = dev_id; 585 struct snd_ad1848 *chip = dev_id;
587 586
588 if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && 587 if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream &&
589 (chip->mode & AD1848_MODE_RUNNING)) 588 (chip->mode & AD1848_MODE_RUNNING))
@@ -595,9 +594,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *r
595 return IRQ_HANDLED; 594 return IRQ_HANDLED;
596} 595}
597 596
598static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * substream) 597static snd_pcm_uframes_t snd_ad1848_playback_pointer(struct snd_pcm_substream *substream)
599{ 598{
600 ad1848_t *chip = snd_pcm_substream_chip(substream); 599 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
601 size_t ptr; 600 size_t ptr;
602 601
603 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE)) 602 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE))
@@ -606,9 +605,9 @@ static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * subst
606 return bytes_to_frames(substream->runtime, ptr); 605 return bytes_to_frames(substream->runtime, ptr);
607} 606}
608 607
609static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substream) 608static snd_pcm_uframes_t snd_ad1848_capture_pointer(struct snd_pcm_substream *substream)
610{ 609{
611 ad1848_t *chip = snd_pcm_substream_chip(substream); 610 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
612 size_t ptr; 611 size_t ptr;
613 612
614 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE)) 613 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE))
@@ -621,7 +620,7 @@ static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substr
621 620
622 */ 621 */
623 622
624static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) { 623static void snd_ad1848_thinkpad_twiddle(struct snd_ad1848 *chip, int on) {
625 624
626 int tmp; 625 int tmp;
627 626
@@ -642,33 +641,34 @@ static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) {
642} 641}
643 642
644#ifdef CONFIG_PM 643#ifdef CONFIG_PM
645static int snd_ad1848_suspend(snd_card_t *card, pm_message_t state) 644static void snd_ad1848_suspend(struct snd_ad1848 *chip)
646{ 645{
647 ad1848_t *chip = card->pm_private_data;
648
649 snd_pcm_suspend_all(chip->pcm); 646 snd_pcm_suspend_all(chip->pcm);
650 /* FIXME: save registers? */
651
652 if (chip->thinkpad_flag) 647 if (chip->thinkpad_flag)
653 snd_ad1848_thinkpad_twiddle(chip, 0); 648 snd_ad1848_thinkpad_twiddle(chip, 0);
654
655 return 0;
656} 649}
657 650
658static int snd_ad1848_resume(snd_card_t *card) 651static void snd_ad1848_resume(struct snd_ad1848 *chip)
659{ 652{
660 ad1848_t *chip = card->pm_private_data; 653 int i;
661 654
662 if (chip->thinkpad_flag) 655 if (chip->thinkpad_flag)
663 snd_ad1848_thinkpad_twiddle(chip, 1); 656 snd_ad1848_thinkpad_twiddle(chip, 1);
664 657
665 /* FIXME: restore registers? */ 658 /* clear any pendings IRQ */
659 inb(AD1848P(chip, STATUS));
660 outb(0, AD1848P(chip, STATUS));
661 mb();
666 662
667 return 0; 663 snd_ad1848_mce_down(chip);
664 for (i = 0; i < 16; i++)
665 snd_ad1848_out(chip, i, chip->image[i]);
666 snd_ad1848_mce_up(chip);
667 snd_ad1848_mce_down(chip);
668} 668}
669#endif /* CONFIG_PM */ 669#endif /* CONFIG_PM */
670 670
671static int snd_ad1848_probe(ad1848_t * chip) 671static int snd_ad1848_probe(struct snd_ad1848 * chip)
672{ 672{
673 unsigned long flags; 673 unsigned long flags;
674 int i, id, rev, ad1847; 674 int i, id, rev, ad1847;
@@ -748,7 +748,7 @@ static int snd_ad1848_probe(ad1848_t * chip)
748 748
749 */ 749 */
750 750
751static snd_pcm_hardware_t snd_ad1848_playback = 751static struct snd_pcm_hardware snd_ad1848_playback =
752{ 752{
753 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 753 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
754 SNDRV_PCM_INFO_MMAP_VALID), 754 SNDRV_PCM_INFO_MMAP_VALID),
@@ -767,7 +767,7 @@ static snd_pcm_hardware_t snd_ad1848_playback =
767 .fifo_size = 0, 767 .fifo_size = 0,
768}; 768};
769 769
770static snd_pcm_hardware_t snd_ad1848_capture = 770static struct snd_pcm_hardware snd_ad1848_capture =
771{ 771{
772 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 772 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
773 SNDRV_PCM_INFO_MMAP_VALID), 773 SNDRV_PCM_INFO_MMAP_VALID),
@@ -790,10 +790,10 @@ static snd_pcm_hardware_t snd_ad1848_capture =
790 790
791 */ 791 */
792 792
793static int snd_ad1848_playback_open(snd_pcm_substream_t * substream) 793static int snd_ad1848_playback_open(struct snd_pcm_substream *substream)
794{ 794{
795 ad1848_t *chip = snd_pcm_substream_chip(substream); 795 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
796 snd_pcm_runtime_t *runtime = substream->runtime; 796 struct snd_pcm_runtime *runtime = substream->runtime;
797 int err; 797 int err;
798 798
799 if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0) 799 if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0)
@@ -806,10 +806,10 @@ static int snd_ad1848_playback_open(snd_pcm_substream_t * substream)
806 return 0; 806 return 0;
807} 807}
808 808
809static int snd_ad1848_capture_open(snd_pcm_substream_t * substream) 809static int snd_ad1848_capture_open(struct snd_pcm_substream *substream)
810{ 810{
811 ad1848_t *chip = snd_pcm_substream_chip(substream); 811 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
812 snd_pcm_runtime_t *runtime = substream->runtime; 812 struct snd_pcm_runtime *runtime = substream->runtime;
813 int err; 813 int err;
814 814
815 if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0) 815 if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0)
@@ -822,9 +822,9 @@ static int snd_ad1848_capture_open(snd_pcm_substream_t * substream)
822 return 0; 822 return 0;
823} 823}
824 824
825static int snd_ad1848_playback_close(snd_pcm_substream_t * substream) 825static int snd_ad1848_playback_close(struct snd_pcm_substream *substream)
826{ 826{
827 ad1848_t *chip = snd_pcm_substream_chip(substream); 827 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
828 828
829 chip->mode &= ~AD1848_MODE_PLAY; 829 chip->mode &= ~AD1848_MODE_PLAY;
830 chip->playback_substream = NULL; 830 chip->playback_substream = NULL;
@@ -832,9 +832,9 @@ static int snd_ad1848_playback_close(snd_pcm_substream_t * substream)
832 return 0; 832 return 0;
833} 833}
834 834
835static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) 835static int snd_ad1848_capture_close(struct snd_pcm_substream *substream)
836{ 836{
837 ad1848_t *chip = snd_pcm_substream_chip(substream); 837 struct snd_ad1848 *chip = snd_pcm_substream_chip(substream);
838 838
839 chip->mode &= ~AD1848_MODE_CAPTURE; 839 chip->mode &= ~AD1848_MODE_CAPTURE;
840 chip->capture_substream = NULL; 840 chip->capture_substream = NULL;
@@ -842,7 +842,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream)
842 return 0; 842 return 0;
843} 843}
844 844
845static int snd_ad1848_free(ad1848_t *chip) 845static int snd_ad1848_free(struct snd_ad1848 *chip)
846{ 846{
847 release_and_free_resource(chip->res_port); 847 release_and_free_resource(chip->res_port);
848 if (chip->irq >= 0) 848 if (chip->irq >= 0)
@@ -855,13 +855,13 @@ static int snd_ad1848_free(ad1848_t *chip)
855 return 0; 855 return 0;
856} 856}
857 857
858static int snd_ad1848_dev_free(snd_device_t *device) 858static int snd_ad1848_dev_free(struct snd_device *device)
859{ 859{
860 ad1848_t *chip = device->device_data; 860 struct snd_ad1848 *chip = device->device_data;
861 return snd_ad1848_free(chip); 861 return snd_ad1848_free(chip);
862} 862}
863 863
864static const char *snd_ad1848_chip_id(ad1848_t *chip) 864static const char *snd_ad1848_chip_id(struct snd_ad1848 *chip)
865{ 865{
866 switch (chip->hardware) { 866 switch (chip->hardware) {
867 case AD1848_HW_AD1847: return "AD1847"; 867 case AD1848_HW_AD1847: return "AD1847";
@@ -872,16 +872,16 @@ static const char *snd_ad1848_chip_id(ad1848_t *chip)
872 } 872 }
873} 873}
874 874
875int snd_ad1848_create(snd_card_t * card, 875int snd_ad1848_create(struct snd_card *card,
876 unsigned long port, 876 unsigned long port,
877 int irq, int dma, 877 int irq, int dma,
878 unsigned short hardware, 878 unsigned short hardware,
879 ad1848_t ** rchip) 879 struct snd_ad1848 ** rchip)
880{ 880{
881 static snd_device_ops_t ops = { 881 static struct snd_device_ops ops = {
882 .dev_free = snd_ad1848_dev_free, 882 .dev_free = snd_ad1848_dev_free,
883 }; 883 };
884 ad1848_t *chip; 884 struct snd_ad1848 *chip;
885 int err; 885 int err;
886 886
887 *rchip = NULL; 887 *rchip = NULL;
@@ -919,7 +919,6 @@ int snd_ad1848_create(snd_card_t * card,
919 chip->thinkpad_flag = 1; 919 chip->thinkpad_flag = 1;
920 chip->hardware = AD1848_HW_DETECT; /* reset */ 920 chip->hardware = AD1848_HW_DETECT; /* reset */
921 snd_ad1848_thinkpad_twiddle(chip, 1); 921 snd_ad1848_thinkpad_twiddle(chip, 1);
922 snd_card_set_isa_pm_callback(card, snd_ad1848_suspend, snd_ad1848_resume, chip);
923 } 922 }
924 923
925 if (snd_ad1848_probe(chip) < 0) { 924 if (snd_ad1848_probe(chip) < 0) {
@@ -933,11 +932,16 @@ int snd_ad1848_create(snd_card_t * card,
933 return err; 932 return err;
934 } 933 }
935 934
935#ifdef CONFIG_PM
936 chip->suspend = snd_ad1848_suspend;
937 chip->resume = snd_ad1848_resume;
938#endif
939
936 *rchip = chip; 940 *rchip = chip;
937 return 0; 941 return 0;
938} 942}
939 943
940static snd_pcm_ops_t snd_ad1848_playback_ops = { 944static struct snd_pcm_ops snd_ad1848_playback_ops = {
941 .open = snd_ad1848_playback_open, 945 .open = snd_ad1848_playback_open,
942 .close = snd_ad1848_playback_close, 946 .close = snd_ad1848_playback_close,
943 .ioctl = snd_ad1848_ioctl, 947 .ioctl = snd_ad1848_ioctl,
@@ -948,7 +952,7 @@ static snd_pcm_ops_t snd_ad1848_playback_ops = {
948 .pointer = snd_ad1848_playback_pointer, 952 .pointer = snd_ad1848_playback_pointer,
949}; 953};
950 954
951static snd_pcm_ops_t snd_ad1848_capture_ops = { 955static struct snd_pcm_ops snd_ad1848_capture_ops = {
952 .open = snd_ad1848_capture_open, 956 .open = snd_ad1848_capture_open,
953 .close = snd_ad1848_capture_close, 957 .close = snd_ad1848_capture_close,
954 .ioctl = snd_ad1848_ioctl, 958 .ioctl = snd_ad1848_ioctl,
@@ -959,16 +963,9 @@ static snd_pcm_ops_t snd_ad1848_capture_ops = {
959 .pointer = snd_ad1848_capture_pointer, 963 .pointer = snd_ad1848_capture_pointer,
960}; 964};
961 965
962static void snd_ad1848_pcm_free(snd_pcm_t *pcm) 966int snd_ad1848_pcm(struct snd_ad1848 *chip, int device, struct snd_pcm **rpcm)
963{
964 ad1848_t *chip = pcm->private_data;
965 chip->pcm = NULL;
966 snd_pcm_lib_preallocate_free_for_all(pcm);
967}
968
969int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm)
970{ 967{
971 snd_pcm_t *pcm; 968 struct snd_pcm *pcm;
972 int err; 969 int err;
973 970
974 if ((err = snd_pcm_new(chip->card, "AD1848", device, 1, 1, &pcm)) < 0) 971 if ((err = snd_pcm_new(chip->card, "AD1848", device, 1, 1, &pcm)) < 0)
@@ -977,7 +974,6 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm)
977 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1848_playback_ops); 974 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1848_playback_ops);
978 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1848_capture_ops); 975 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1848_capture_ops);
979 976
980 pcm->private_free = snd_ad1848_pcm_free;
981 pcm->private_data = chip; 977 pcm->private_data = chip;
982 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; 978 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
983 strcpy(pcm->name, snd_ad1848_chip_id(chip)); 979 strcpy(pcm->name, snd_ad1848_chip_id(chip));
@@ -992,7 +988,7 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm)
992 return 0; 988 return 0;
993} 989}
994 990
995const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction) 991const struct snd_pcm_ops *snd_ad1848_get_pcm_ops(int direction)
996{ 992{
997 return direction == SNDRV_PCM_STREAM_PLAYBACK ? 993 return direction == SNDRV_PCM_STREAM_PLAYBACK ?
998 &snd_ad1848_playback_ops : &snd_ad1848_capture_ops; 994 &snd_ad1848_playback_ops : &snd_ad1848_capture_ops;
@@ -1002,7 +998,7 @@ const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction)
1002 * MIXER part 998 * MIXER part
1003 */ 999 */
1004 1000
1005static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1001static int snd_ad1848_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1006{ 1002{
1007 static char *texts[4] = { 1003 static char *texts[4] = {
1008 "Line", "Aux", "Mic", "Mix" 1004 "Line", "Aux", "Mic", "Mix"
@@ -1017,9 +1013,9 @@ static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
1017 return 0; 1013 return 0;
1018} 1014}
1019 1015
1020static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1016static int snd_ad1848_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1021{ 1017{
1022 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1018 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1023 unsigned long flags; 1019 unsigned long flags;
1024 1020
1025 spin_lock_irqsave(&chip->reg_lock, flags); 1021 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1029,9 +1025,9 @@ static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1029 return 0; 1025 return 0;
1030} 1026}
1031 1027
1032static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1028static int snd_ad1848_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1033{ 1029{
1034 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1030 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1035 unsigned long flags; 1031 unsigned long flags;
1036 unsigned short left, right; 1032 unsigned short left, right;
1037 int change; 1033 int change;
@@ -1052,7 +1048,7 @@ static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1052 return change; 1048 return change;
1053} 1049}
1054 1050
1055static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1051static int snd_ad1848_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1056{ 1052{
1057 int mask = (kcontrol->private_value >> 16) & 0xff; 1053 int mask = (kcontrol->private_value >> 16) & 0xff;
1058 1054
@@ -1063,9 +1059,9 @@ static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1063 return 0; 1059 return 0;
1064} 1060}
1065 1061
1066static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1062static int snd_ad1848_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1067{ 1063{
1068 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1064 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1069 unsigned long flags; 1065 unsigned long flags;
1070 int reg = kcontrol->private_value & 0xff; 1066 int reg = kcontrol->private_value & 0xff;
1071 int shift = (kcontrol->private_value >> 8) & 0xff; 1067 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1080,9 +1076,9 @@ static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1080 return 0; 1076 return 0;
1081} 1077}
1082 1078
1083static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1079static int snd_ad1848_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1084{ 1080{
1085 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1081 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1086 unsigned long flags; 1082 unsigned long flags;
1087 int reg = kcontrol->private_value & 0xff; 1083 int reg = kcontrol->private_value & 0xff;
1088 int shift = (kcontrol->private_value >> 8) & 0xff; 1084 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1103,7 +1099,7 @@ static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1103 return change; 1099 return change;
1104} 1100}
1105 1101
1106static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1102static int snd_ad1848_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1107{ 1103{
1108 int mask = (kcontrol->private_value >> 24) & 0xff; 1104 int mask = (kcontrol->private_value >> 24) & 0xff;
1109 1105
@@ -1114,9 +1110,9 @@ static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1114 return 0; 1110 return 0;
1115} 1111}
1116 1112
1117static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1113static int snd_ad1848_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1118{ 1114{
1119 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1115 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1120 unsigned long flags; 1116 unsigned long flags;
1121 int left_reg = kcontrol->private_value & 0xff; 1117 int left_reg = kcontrol->private_value & 0xff;
1122 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1118 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1136,9 +1132,9 @@ static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1136 return 0; 1132 return 0;
1137} 1133}
1138 1134
1139static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1135static int snd_ad1848_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1140{ 1136{
1141 ad1848_t *chip = snd_kcontrol_chip(kcontrol); 1137 struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol);
1142 unsigned long flags; 1138 unsigned long flags;
1143 int left_reg = kcontrol->private_value & 0xff; 1139 int left_reg = kcontrol->private_value & 0xff;
1144 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1140 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1175,9 +1171,9 @@ static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1175 1171
1176/* 1172/*
1177 */ 1173 */
1178int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value) 1174int snd_ad1848_add_ctl(struct snd_ad1848 *chip, const char *name, int index, int type, unsigned long value)
1179{ 1175{
1180 static snd_kcontrol_new_t newctls[] = { 1176 static struct snd_kcontrol_new newctls[] = {
1181 [AD1848_MIX_SINGLE] = { 1177 [AD1848_MIX_SINGLE] = {
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1183 .info = snd_ad1848_info_single, 1179 .info = snd_ad1848_info_single,
@@ -1197,7 +1193,7 @@ int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, un
1197 .put = snd_ad1848_put_mux, 1193 .put = snd_ad1848_put_mux,
1198 }, 1194 },
1199 }; 1195 };
1200 snd_kcontrol_t *ctl; 1196 struct snd_kcontrol *ctl;
1201 int err; 1197 int err;
1202 1198
1203 ctl = snd_ctl_new1(&newctls[type], chip); 1199 ctl = snd_ctl_new1(&newctls[type], chip);
@@ -1230,10 +1226,10 @@ AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK, 0, 1, 0),
1230AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0) 1226AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0)
1231}; 1227};
1232 1228
1233int snd_ad1848_mixer(ad1848_t *chip) 1229int snd_ad1848_mixer(struct snd_ad1848 *chip)
1234{ 1230{
1235 snd_card_t *card; 1231 struct snd_card *card;
1236 snd_pcm_t *pcm; 1232 struct snd_pcm *pcm;
1237 unsigned int idx; 1233 unsigned int idx;
1238 int err; 1234 int err;
1239 1235
diff --git a/sound/isa/als100.c b/sound/isa/als100.c
index ac8f13664983..9b77c17b3f66 100644
--- a/sound/isa/als100.c
+++ b/sound/isa/als100.c
@@ -83,6 +83,7 @@ struct snd_card_als100 {
83 struct pnp_dev *dev; 83 struct pnp_dev *dev;
84 struct pnp_dev *devmpu; 84 struct pnp_dev *devmpu;
85 struct pnp_dev *devopl; 85 struct pnp_dev *devopl;
86 struct snd_sb *chip;
86}; 87};
87 88
88static struct pnp_card_device_id snd_als100_pnpids[] = { 89static struct pnp_card_device_id snd_als100_pnpids[] = {
@@ -203,15 +204,15 @@ static int __init snd_card_als100_probe(int dev,
203 const struct pnp_card_device_id *pid) 204 const struct pnp_card_device_id *pid)
204{ 205{
205 int error; 206 int error;
206 sb_t *chip; 207 struct snd_sb *chip;
207 snd_card_t *card; 208 struct snd_card *card;
208 struct snd_card_als100 *acard; 209 struct snd_card_als100 *acard;
209 opl3_t *opl3; 210 struct snd_opl3 *opl3;
210 211
211 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 212 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
212 sizeof(struct snd_card_als100))) == NULL) 213 sizeof(struct snd_card_als100))) == NULL)
213 return -ENOMEM; 214 return -ENOMEM;
214 acard = (struct snd_card_als100 *)card->private_data; 215 acard = card->private_data;
215 216
216 if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { 217 if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) {
217 snd_card_free(card); 218 snd_card_free(card);
@@ -228,6 +229,7 @@ static int __init snd_card_als100_probe(int dev,
228 snd_card_free(card); 229 snd_card_free(card);
229 return error; 230 return error;
230 } 231 }
232 acard->chip = chip;
231 233
232 strcpy(card->driver, "ALS100"); 234 strcpy(card->driver, "ALS100");
233 strcpy(card->shortname, "Avance Logic ALS100"); 235 strcpy(card->shortname, "Avance Logic ALS100");
@@ -299,32 +301,61 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
299 301
300static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) 302static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard)
301{ 303{
302 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 304 snd_card_free(pnp_get_card_drvdata(pcard));
305 pnp_set_card_drvdata(pcard, NULL);
306}
307
308#ifdef CONFIG_PM
309static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
310{
311 struct snd_card *card = pnp_get_card_drvdata(pcard);
312 struct snd_card_als100 *acard = card->private_data;
313 struct snd_sb *chip = acard->chip;
303 314
304 snd_card_disconnect(card); 315 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
305 snd_card_free_in_thread(card); 316 snd_pcm_suspend_all(chip->pcm);
317 snd_sbmixer_suspend(chip);
318 return 0;
306} 319}
307 320
321static int snd_als100_pnp_resume(struct pnp_card_link *pcard)
322{
323 struct snd_card *card = pnp_get_card_drvdata(pcard);
324 struct snd_card_als100 *acard = card->private_data;
325 struct snd_sb *chip = acard->chip;
326
327 snd_sbdsp_reset(chip);
328 snd_sbmixer_resume(chip);
329 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
330 return 0;
331}
332#endif
333
308static struct pnp_card_driver als100_pnpc_driver = { 334static struct pnp_card_driver als100_pnpc_driver = {
309 .flags = PNP_DRIVER_RES_DISABLE, 335 .flags = PNP_DRIVER_RES_DISABLE,
310 .name = "als100", 336 .name = "als100",
311 .id_table = snd_als100_pnpids, 337 .id_table = snd_als100_pnpids,
312 .probe = snd_als100_pnp_detect, 338 .probe = snd_als100_pnp_detect,
313 .remove = __devexit_p(snd_als100_pnp_remove), 339 .remove = __devexit_p(snd_als100_pnp_remove),
340#ifdef CONFIG_PM
341 .suspend = snd_als100_pnp_suspend,
342 .resume = snd_als100_pnp_resume,
343#endif
314}; 344};
315 345
316static int __init alsa_card_als100_init(void) 346static int __init alsa_card_als100_init(void)
317{ 347{
318 int cards = 0; 348 int cards;
319 349
320 cards += pnp_register_card_driver(&als100_pnpc_driver); 350 cards = pnp_register_card_driver(&als100_pnpc_driver);
321#ifdef MODULE 351 if (cards <= 0) {
322 if (!cards) {
323 pnp_unregister_card_driver(&als100_pnpc_driver); 352 pnp_unregister_card_driver(&als100_pnpc_driver);
353#ifdef MODULE
324 snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); 354 snd_printk(KERN_ERR "no ALS100 based soundcards found\n");
325 }
326#endif 355#endif
327 return cards ? 0 : -ENODEV; 356 return -ENODEV;
357 }
358 return 0;
328} 359}
329 360
330static void __exit alsa_card_als100_exit(void) 361static void __exit alsa_card_als100_exit(void)
diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c
index bb41c6ec2f43..a530691bf4f7 100644
--- a/sound/isa/azt2320.c
+++ b/sound/isa/azt2320.c
@@ -93,6 +93,7 @@ struct snd_card_azt2320 {
93 int dev_no; 93 int dev_no;
94 struct pnp_dev *dev; 94 struct pnp_dev *dev;
95 struct pnp_dev *devmpu; 95 struct pnp_dev *devmpu;
96 struct snd_cs4231 *chip;
96}; 97};
97 98
98static struct pnp_card_device_id snd_azt2320_pnpids[] = { 99static struct pnp_card_device_id snd_azt2320_pnpids[] = {
@@ -227,10 +228,10 @@ static int __devinit snd_card_azt2320_probe(int dev,
227 const struct pnp_card_device_id *pid) 228 const struct pnp_card_device_id *pid)
228{ 229{
229 int error; 230 int error;
230 snd_card_t *card; 231 struct snd_card *card;
231 struct snd_card_azt2320 *acard; 232 struct snd_card_azt2320 *acard;
232 cs4231_t *chip; 233 struct snd_cs4231 *chip;
233 opl3_t *opl3; 234 struct snd_opl3 *opl3;
234 235
235 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 236 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
236 sizeof(struct snd_card_azt2320))) == NULL) 237 sizeof(struct snd_card_azt2320))) == NULL)
@@ -329,32 +330,59 @@ static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card,
329 330
330static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard) 331static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard)
331{ 332{
332 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 333 snd_card_free(pnp_get_card_drvdata(pcard));
334 pnp_set_card_drvdata(pcard, NULL);
335}
336
337#ifdef CONFIG_PM
338static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
339{
340 struct snd_card *card = pnp_get_card_drvdata(pcard);
341 struct snd_card_azt2320 *acard = card->private_data;
342 struct snd_cs4231 *chip = acard->chip;
333 343
334 snd_card_disconnect(card); 344 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
335 snd_card_free_in_thread(card); 345 chip->suspend(chip);
346 return 0;
336} 347}
337 348
349static int snd_azt2320_pnp_resume(struct pnp_card_link *pcard)
350{
351 struct snd_card *card = pnp_get_card_drvdata(pcard);
352 struct snd_card_azt2320 *acard = card->private_data;
353 struct snd_cs4231 *chip = acard->chip;
354
355 chip->resume(chip);
356 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
357 return 0;
358}
359#endif
360
338static struct pnp_card_driver azt2320_pnpc_driver = { 361static struct pnp_card_driver azt2320_pnpc_driver = {
339 .flags = PNP_DRIVER_RES_DISABLE, 362 .flags = PNP_DRIVER_RES_DISABLE,
340 .name = "azt2320", 363 .name = "azt2320",
341 .id_table = snd_azt2320_pnpids, 364 .id_table = snd_azt2320_pnpids,
342 .probe = snd_azt2320_pnp_detect, 365 .probe = snd_azt2320_pnp_detect,
343 .remove = __devexit_p(snd_azt2320_pnp_remove), 366 .remove = __devexit_p(snd_azt2320_pnp_remove),
367#ifdef CONFIG_PM
368 .suspend = snd_azt2320_pnp_suspend,
369 .resume = snd_azt2320_pnp_resume,
370#endif
344}; 371};
345 372
346static int __init alsa_card_azt2320_init(void) 373static int __init alsa_card_azt2320_init(void)
347{ 374{
348 int cards = 0; 375 int cards;
349 376
350 cards += pnp_register_card_driver(&azt2320_pnpc_driver); 377 cards = pnp_register_card_driver(&azt2320_pnpc_driver);
351#ifdef MODULE 378 if (cards <= 0) {
352 if (!cards) {
353 pnp_unregister_card_driver(&azt2320_pnpc_driver); 379 pnp_unregister_card_driver(&azt2320_pnpc_driver);
380#ifdef MODULE
354 snd_printk(KERN_ERR "no AZT2320 based soundcards found\n"); 381 snd_printk(KERN_ERR "no AZT2320 based soundcards found\n");
355 }
356#endif 382#endif
357 return cards ? 0 : -ENODEV; 383 return -ENODEV;
384 }
385 return 0;
358} 386}
359 387
360static void __exit alsa_card_azt2320_exit(void) 388static void __exit alsa_card_azt2320_exit(void)
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 5252206ea388..bd8e23818460 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -45,6 +45,8 @@
45 45
46#include <sound/driver.h> 46#include <sound/driver.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/err.h>
49#include <linux/platform_device.h>
48#include <linux/slab.h> 50#include <linux/slab.h>
49#include <linux/pnp.h> 51#include <linux/pnp.h>
50#include <linux/moduleparam.h> 52#include <linux/moduleparam.h>
@@ -106,6 +108,9 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver.");
106module_param_array(wssdma, int, NULL, 0444); 108module_param_array(wssdma, int, NULL, 0444);
107MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
108 110
111static struct platform_device *platform_devices[SNDRV_CARDS];
112static int pnp_registered;
113
109#define CMI8330_RMUX3D 16 114#define CMI8330_RMUX3D 16
110#define CMI8330_MUTEMUX 17 115#define CMI8330_MUTEMUX 17
111#define CMI8330_OUTPUTVOL 18 116#define CMI8330_OUTPUTVOL 18
@@ -137,27 +142,25 @@ static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] =
137 0x0 /* 26 - cd-in rec gain */ 142 0x0 /* 26 - cd-in rec gain */
138}; 143};
139 144
140typedef int (*snd_pcm_open_callback_t)(snd_pcm_substream_t *); 145typedef int (*snd_pcm_open_callback_t)(struct snd_pcm_substream *);
141 146
142struct snd_cmi8330 { 147struct snd_cmi8330 {
143#ifdef CONFIG_PNP 148#ifdef CONFIG_PNP
144 struct pnp_dev *cap; 149 struct pnp_dev *cap;
145 struct pnp_dev *play; 150 struct pnp_dev *play;
146#endif 151#endif
147 snd_card_t *card; 152 struct snd_card *card;
148 ad1848_t *wss; 153 struct snd_ad1848 *wss;
149 sb_t *sb; 154 struct snd_sb *sb;
150 155
151 snd_pcm_t *pcm; 156 struct snd_pcm *pcm;
152 struct snd_cmi8330_stream { 157 struct snd_cmi8330_stream {
153 snd_pcm_ops_t ops; 158 struct snd_pcm_ops ops;
154 snd_pcm_open_callback_t open; 159 snd_pcm_open_callback_t open;
155 void *private_data; /* sb or wss */ 160 void *private_data; /* sb or wss */
156 } streams[2]; 161 } streams[2];
157}; 162};
158 163
159static snd_card_t *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
160
161#ifdef CONFIG_PNP 164#ifdef CONFIG_PNP
162 165
163static struct pnp_card_device_id snd_cmi8330_pnpids[] = { 166static struct pnp_card_device_id snd_cmi8330_pnpids[] = {
@@ -231,7 +234,7 @@ static unsigned char cmi8330_sb_init_values[][2] __initdata = {
231}; 234};
232 235
233 236
234static int __devinit cmi8330_add_sb_mixers(sb_t *chip) 237static int __devinit cmi8330_add_sb_mixers(struct snd_sb *chip)
235{ 238{
236 int idx, err; 239 int idx, err;
237 unsigned long flags; 240 unsigned long flags;
@@ -256,7 +259,7 @@ static int __devinit cmi8330_add_sb_mixers(sb_t *chip)
256} 259}
257#endif 260#endif
258 261
259static int __devinit snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard) 262static int __devinit snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard)
260{ 263{
261 unsigned int idx; 264 unsigned int idx;
262 int err; 265 int err;
@@ -370,7 +373,7 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
370#define CMI_AD_STREAM SNDRV_PCM_STREAM_PLAYBACK 373#define CMI_AD_STREAM SNDRV_PCM_STREAM_PLAYBACK
371#endif 374#endif
372 375
373static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream) 376static int snd_cmi8330_playback_open(struct snd_pcm_substream *substream)
374{ 377{
375 struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); 378 struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream);
376 379
@@ -379,7 +382,7 @@ static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream)
379 return chip->streams[SNDRV_PCM_STREAM_PLAYBACK].open(substream); 382 return chip->streams[SNDRV_PCM_STREAM_PLAYBACK].open(substream);
380} 383}
381 384
382static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) 385static int snd_cmi8330_capture_open(struct snd_pcm_substream *substream)
383{ 386{
384 struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); 387 struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream);
385 388
@@ -388,15 +391,10 @@ static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream)
388 return chip->streams[SNDRV_PCM_STREAM_CAPTURE].open(substream); 391 return chip->streams[SNDRV_PCM_STREAM_CAPTURE].open(substream);
389} 392}
390 393
391static void snd_cmi8330_pcm_free(snd_pcm_t *pcm) 394static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
392{ 395{
393 snd_pcm_lib_preallocate_free_for_all(pcm); 396 struct snd_pcm *pcm;
394} 397 const struct snd_pcm_ops *ops;
395
396static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)
397{
398 snd_pcm_t *pcm;
399 const snd_pcm_ops_t *ops;
400 int err; 398 int err;
401 static snd_pcm_open_callback_t cmi_open_callbacks[2] = { 399 static snd_pcm_open_callback_t cmi_open_callbacks[2] = {
402 snd_cmi8330_playback_open, 400 snd_cmi8330_playback_open,
@@ -407,7 +405,6 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)
407 return err; 405 return err;
408 strcpy(pcm->name, "CMI8330"); 406 strcpy(pcm->name, "CMI8330");
409 pcm->private_data = chip; 407 pcm->private_data = chip;
410 pcm->private_free = snd_cmi8330_pcm_free;
411 408
412 /* SB16 */ 409 /* SB16 */
413 ops = snd_sb16dsp_get_pcm_ops(CMI_SB_STREAM); 410 ops = snd_sb16dsp_get_pcm_ops(CMI_SB_STREAM);
@@ -435,6 +432,31 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)
435} 432}
436 433
437 434
435#ifdef CONFIG_PM
436static int snd_cmi8330_suspend(struct snd_card *card)
437{
438 struct snd_cmi8330 *acard = card->private_data;
439
440 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
441 snd_pcm_suspend_all(acard->pcm);
442 acard->wss->suspend(acard->wss);
443 snd_sbmixer_suspend(acard->sb);
444 return 0;
445}
446
447static int snd_cmi8330_resume(struct snd_card *card)
448{
449 struct snd_cmi8330 *acard = card->private_data;
450
451 snd_sbdsp_reset(acard->sb);
452 snd_sbmixer_suspend(acard->sb);
453 acard->wss->resume(acard->wss);
454 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
455 return 0;
456}
457#endif
458
459
438/* 460/*
439 */ 461 */
440 462
@@ -446,44 +468,28 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)
446 468
447#define PFX "cmi8330: " 469#define PFX "cmi8330: "
448 470
449static int __devinit snd_cmi8330_probe(int dev, 471static struct snd_card *snd_cmi8330_card_new(int dev)
450 struct pnp_card_link *pcard,
451 const struct pnp_card_device_id *pid)
452{ 472{
453 snd_card_t *card; 473 struct snd_card *card;
454 struct snd_cmi8330 *acard; 474 struct snd_cmi8330 *acard;
455 int i, err;
456
457 if (! is_isapnp_selected(dev)) {
458 if (wssport[dev] == SNDRV_AUTO_PORT) {
459 snd_printk(KERN_ERR PFX "specify wssport\n");
460 return -EINVAL;
461 }
462 if (sbport[dev] == SNDRV_AUTO_PORT) {
463 snd_printk(KERN_ERR PFX "specify sbport\n");
464 return -EINVAL;
465 }
466 }
467 475
468 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 476 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
469 sizeof(struct snd_cmi8330)); 477 sizeof(struct snd_cmi8330));
470 if (card == NULL) { 478 if (card == NULL) {
471 snd_printk(KERN_ERR PFX "could not get a new card\n"); 479 snd_printk(KERN_ERR PFX "could not get a new card\n");
472 return -ENOMEM; 480 return NULL;
473 } 481 }
474 acard = (struct snd_cmi8330 *)card->private_data; 482 acard = card->private_data;
475 acard->card = card; 483 acard->card = card;
484 return card;
485}
476 486
477#ifdef CONFIG_PNP 487static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
478 if (isapnp[dev]) { 488{
479 if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { 489 struct snd_cmi8330 *acard;
480 snd_printk(KERN_ERR PFX "PnP detection failed\n"); 490 int i, err;
481 goto _err;
482 }
483 snd_card_set_dev(card, &pcard->card->dev);
484 }
485#endif
486 491
492 acard = card->private_data;
487 if ((err = snd_ad1848_create(card, 493 if ((err = snd_ad1848_create(card,
488 wssport[dev] + 4, 494 wssport[dev] + 4,
489 wssirq[dev], 495 wssirq[dev],
@@ -491,12 +497,11 @@ static int __devinit snd_cmi8330_probe(int dev,
491 AD1848_HW_DETECT, 497 AD1848_HW_DETECT,
492 &acard->wss)) < 0) { 498 &acard->wss)) < 0) {
493 snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); 499 snd_printk(KERN_ERR PFX "(AD1848) device busy??\n");
494 goto _err; 500 return err;
495 } 501 }
496 if (acard->wss->hardware != AD1848_HW_CMI8330) { 502 if (acard->wss->hardware != AD1848_HW_CMI8330) {
497 snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); 503 snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n");
498 err = -ENODEV; 504 return -ENODEV;
499 goto _err;
500 } 505 }
501 506
502 if ((err = snd_sbdsp_create(card, sbport[dev], 507 if ((err = snd_sbdsp_create(card, sbport[dev],
@@ -506,11 +511,11 @@ static int __devinit snd_cmi8330_probe(int dev,
506 sbdma16[dev], 511 sbdma16[dev],
507 SB_HW_AUTO, &acard->sb)) < 0) { 512 SB_HW_AUTO, &acard->sb)) < 0) {
508 snd_printk(KERN_ERR PFX "(SB16) device busy??\n"); 513 snd_printk(KERN_ERR PFX "(SB16) device busy??\n");
509 goto _err; 514 return err;
510 } 515 }
511 if (acard->sb->hardware != SB_HW_16) { 516 if (acard->sb->hardware != SB_HW_16) {
512 snd_printk(KERN_ERR PFX "(SB16) not found during probe\n"); 517 snd_printk(KERN_ERR PFX "(SB16) not found during probe\n");
513 goto _err; 518 return err;
514 } 519 }
515 520
516 snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */ 521 snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */
@@ -519,12 +524,12 @@ static int __devinit snd_cmi8330_probe(int dev,
519 524
520 if ((err = snd_cmi8330_mixer(card, acard)) < 0) { 525 if ((err = snd_cmi8330_mixer(card, acard)) < 0) {
521 snd_printk(KERN_ERR PFX "failed to create mixers\n"); 526 snd_printk(KERN_ERR PFX "failed to create mixers\n");
522 goto _err; 527 return err;
523 } 528 }
524 529
525 if ((err = snd_cmi8330_pcm(card, acard)) < 0) { 530 if ((err = snd_cmi8330_pcm(card, acard)) < 0) {
526 snd_printk(KERN_ERR PFX "failed to create pcms\n"); 531 snd_printk(KERN_ERR PFX "failed to create pcms\n");
527 goto _err; 532 return err;
528 } 533 }
529 534
530 strcpy(card->driver, "CMI8330/C3D"); 535 strcpy(card->driver, "CMI8330/C3D");
@@ -535,49 +540,120 @@ static int __devinit snd_cmi8330_probe(int dev,
535 wssirq[dev], 540 wssirq[dev],
536 wssdma[dev]); 541 wssdma[dev]);
537 542
538 if ((err = snd_card_set_generic_dev(card)) < 0) 543 return snd_card_register(card);
539 goto _err; 544}
540 545
541 if ((err = snd_card_register(card)) < 0) 546static int __init snd_cmi8330_nonpnp_probe(struct platform_device *pdev)
542 goto _err; 547{
548 struct snd_card *card;
549 int err;
550 int dev = pdev->id;
551
552 if (wssport[dev] == SNDRV_AUTO_PORT) {
553 snd_printk(KERN_ERR PFX "specify wssport\n");
554 return -EINVAL;
555 }
556 if (sbport[dev] == SNDRV_AUTO_PORT) {
557 snd_printk(KERN_ERR PFX "specify sbport\n");
558 return -EINVAL;
559 }
543 560
544 if (pcard) 561 card = snd_cmi8330_card_new(dev);
545 pnp_set_card_drvdata(pcard, card); 562 if (! card)
546 else 563 return -ENOMEM;
547 snd_cmi8330_legacy[dev] = card; 564 snd_card_set_dev(card, &pdev->dev);
565 if ((err = snd_cmi8330_probe(card, dev)) < 0) {
566 snd_card_free(card);
567 return err;
568 }
569 platform_set_drvdata(pdev, card);
548 return 0; 570 return 0;
571}
549 572
550 _err: 573static int snd_cmi8330_nonpnp_remove(struct platform_device *devptr)
551 snd_card_free(card); 574{
552 return err; 575 snd_card_free(platform_get_drvdata(devptr));
576 platform_set_drvdata(devptr, NULL);
577 return 0;
553} 578}
554 579
580#ifdef CONFIG_PM
581static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state)
582{
583 return snd_cmi8330_suspend(platform_get_drvdata(dev));
584}
585
586static int snd_cmi8330_nonpnp_resume(struct platform_device *dev)
587{
588 return snd_cmi8330_resume(platform_get_drvdata(dev));
589}
590#endif
591
592#define CMI8330_DRIVER "snd_cmi8330"
593
594static struct platform_driver snd_cmi8330_driver = {
595 .probe = snd_cmi8330_nonpnp_probe,
596 .remove = snd_cmi8330_nonpnp_remove,
597#ifdef CONFIG_PM
598 .suspend = snd_cmi8330_nonpnp_suspend,
599 .resume = snd_cmi8330_nonpnp_resume,
600#endif
601 .driver = {
602 .name = CMI8330_DRIVER
603 },
604};
605
606
555#ifdef CONFIG_PNP 607#ifdef CONFIG_PNP
556static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, 608static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
557 const struct pnp_card_device_id *id) 609 const struct pnp_card_device_id *pid)
558{ 610{
559 static int dev; 611 static int dev;
612 struct snd_card *card;
560 int res; 613 int res;
561 614
562 for ( ; dev < SNDRV_CARDS; dev++) { 615 for ( ; dev < SNDRV_CARDS; dev++) {
563 if (!enable[dev] || !isapnp[dev]) 616 if (enable[dev] && isapnp[dev])
564 continue; 617 break;
565 res = snd_cmi8330_probe(dev, card, id);
566 if (res < 0)
567 return res;
568 dev++;
569 return 0;
570 } 618 }
571 return -ENODEV; 619 if (dev >= SNDRV_CARDS)
620 return -ENODEV;
621
622 card = snd_cmi8330_card_new(dev);
623 if (! card)
624 return -ENOMEM;
625 if ((res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid)) < 0) {
626 snd_printk(KERN_ERR PFX "PnP detection failed\n");
627 snd_card_free(card);
628 return res;
629 }
630 snd_card_set_dev(card, &pcard->card->dev);
631 if ((res = snd_cmi8330_probe(card, dev)) < 0) {
632 snd_card_free(card);
633 return res;
634 }
635 pnp_set_card_drvdata(pcard, card);
636 dev++;
637 return 0;
572} 638}
573 639
574static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) 640static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard)
575{ 641{
576 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 642 snd_card_free(pnp_get_card_drvdata(pcard));
643 pnp_set_card_drvdata(pcard, NULL);
644}
645
646#ifdef CONFIG_PM
647static int snd_cmi8330_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
648{
649 return snd_cmi8330_suspend(pnp_get_card_drvdata(pcard));
650}
577 651
578 snd_card_disconnect(card); 652static int snd_cmi8330_pnp_resume(struct pnp_card_link *pcard)
579 snd_card_free_in_thread(card); 653{
654 return snd_cmi8330_resume(pnp_get_card_drvdata(pcard));
580} 655}
656#endif
581 657
582static struct pnp_card_driver cmi8330_pnpc_driver = { 658static struct pnp_card_driver cmi8330_pnpc_driver = {
583 .flags = PNP_DRIVER_RES_DISABLE, 659 .flags = PNP_DRIVER_RES_DISABLE,
@@ -585,47 +661,68 @@ static struct pnp_card_driver cmi8330_pnpc_driver = {
585 .id_table = snd_cmi8330_pnpids, 661 .id_table = snd_cmi8330_pnpids,
586 .probe = snd_cmi8330_pnp_detect, 662 .probe = snd_cmi8330_pnp_detect,
587 .remove = __devexit_p(snd_cmi8330_pnp_remove), 663 .remove = __devexit_p(snd_cmi8330_pnp_remove),
664#ifdef CONFIG_PM
665 .suspend = snd_cmi8330_pnp_suspend,
666 .resume = snd_cmi8330_pnp_resume,
667#endif
588}; 668};
589#endif /* CONFIG_PNP */ 669#endif /* CONFIG_PNP */
590 670
671static void __init_or_module snd_cmi8330_unregister_all(void)
672{
673 int i;
674
675 if (pnp_registered)
676 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
677 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
678 platform_device_unregister(platform_devices[i]);
679 platform_driver_unregister(&snd_cmi8330_driver);
680}
681
591static int __init alsa_card_cmi8330_init(void) 682static int __init alsa_card_cmi8330_init(void)
592{ 683{
593 int dev, cards = 0; 684 int i, err, cards = 0;
594 685
595 for (dev = 0; dev < SNDRV_CARDS; dev++) { 686 if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0)
596 if (!enable[dev]) 687 return err;
597 continue; 688
598 if (is_isapnp_selected(dev)) 689 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
690 struct platform_device *device;
691 if (is_isapnp_selected(i))
599 continue; 692 continue;
600 if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) 693 device = platform_device_register_simple(CMI8330_DRIVER,
601 cards++; 694 i, NULL, 0);
695 if (IS_ERR(device)) {
696 err = PTR_ERR(device);
697 goto errout;
698 }
699 platform_devices[i] = device;
700 cards++;
701 }
702
703 err = pnp_register_card_driver(&cmi8330_pnpc_driver);
704 if (err >= 0) {
705 pnp_registered = 1;
706 cards += err;
602 } 707 }
603#ifdef CONFIG_PNP
604 cards += pnp_register_card_driver(&cmi8330_pnpc_driver);
605#endif
606 708
607 if (!cards) { 709 if (!cards) {
608#ifdef CONFIG_PNP
609 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
610#endif
611#ifdef MODULE 710#ifdef MODULE
612 snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); 711 snd_printk(KERN_ERR "CMI8330 not found or device busy\n");
613#endif 712#endif
614 return -ENODEV; 713 err = -ENODEV;
714 goto errout;
615 } 715 }
616 return 0; 716 return 0;
717
718 errout:
719 snd_cmi8330_unregister_all();
720 return err;
617} 721}
618 722
619static void __exit alsa_card_cmi8330_exit(void) 723static void __exit alsa_card_cmi8330_exit(void)
620{ 724{
621 int i; 725 snd_cmi8330_unregister_all();
622
623#ifdef CONFIG_PNP
624 /* PnP cards first */
625 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
626#endif
627 for (i = 0; i < SNDRV_CARDS; i++)
628 snd_card_free(snd_cmi8330_legacy[i]);
629} 726}
630 727
631module_init(alsa_card_cmi8330_init) 728module_init(alsa_card_cmi8330_init)
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 9be5416bcb92..ab67b5c2590d 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -22,6 +22,8 @@
22 22
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/err.h>
26#include <linux/platform_device.h>
25#include <linux/time.h> 27#include <linux/time.h>
26#include <linux/wait.h> 28#include <linux/wait.h>
27#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
@@ -64,15 +66,15 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver.");
64module_param_array(dma2, int, NULL, 0444); 66module_param_array(dma2, int, NULL, 0444);
65MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); 67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver.");
66 68
67static snd_card_t *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 69static struct platform_device *devices[SNDRV_CARDS];
68 70
69 71
70static int __init snd_card_cs4231_probe(int dev) 72static int __init snd_cs4231_probe(struct platform_device *pdev)
71{ 73{
72 snd_card_t *card; 74 int dev = pdev->id;
73 struct snd_card_cs4231 *acard; 75 struct snd_card *card;
74 snd_pcm_t *pcm = NULL; 76 struct snd_pcm *pcm;
75 cs4231_t *chip; 77 struct snd_cs4231 *chip;
76 int err; 78 int err;
77 79
78 if (port[dev] == SNDRV_AUTO_PORT) { 80 if (port[dev] == SNDRV_AUTO_PORT) {
@@ -90,7 +92,6 @@ static int __init snd_card_cs4231_probe(int dev)
90 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 92 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
91 if (card == NULL) 93 if (card == NULL)
92 return -ENOMEM; 94 return -ENOMEM;
93 acard = (struct snd_card_cs4231 *)card->private_data;
94 if ((err = snd_cs4231_create(card, port[dev], -1, 95 if ((err = snd_cs4231_create(card, port[dev], -1,
95 irq[dev], 96 irq[dev],
96 dma1[dev], 97 dma1[dev],
@@ -98,6 +99,7 @@ static int __init snd_card_cs4231_probe(int dev)
98 CS4231_HW_DETECT, 99 CS4231_HW_DETECT,
99 0, &chip)) < 0) 100 0, &chip)) < 0)
100 goto _err; 101 goto _err;
102 card->private_data = chip;
101 103
102 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) 104 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0)
103 goto _err; 105 goto _err;
@@ -125,12 +127,12 @@ static int __init snd_card_cs4231_probe(int dev)
125 printk(KERN_WARNING "cs4231: MPU401 not detected\n"); 127 printk(KERN_WARNING "cs4231: MPU401 not detected\n");
126 } 128 }
127 129
128 if ((err = snd_card_set_generic_dev(card)) < 0) 130 snd_card_set_dev(card, &pdev->dev);
129 goto _err;
130 131
131 if ((err = snd_card_register(card)) < 0) 132 if ((err = snd_card_register(card)) < 0)
132 goto _err; 133 goto _err;
133 snd_cs4231_cards[dev] = card; 134
135 platform_set_drvdata(pdev, card);
134 return 0; 136 return 0;
135 137
136 _err: 138 _err:
@@ -138,29 +140,97 @@ static int __init snd_card_cs4231_probe(int dev)
138 return err; 140 return err;
139} 141}
140 142
141static int __init alsa_card_cs4231_init(void) 143static int __devexit snd_cs4231_remove(struct platform_device *devptr)
144{
145 snd_card_free(platform_get_drvdata(devptr));
146 platform_set_drvdata(devptr, NULL);
147 return 0;
148}
149
150#ifdef CONFIG_PM
151static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state)
152{
153 struct snd_card *card;
154 struct snd_cs4231 *chip;
155 card = platform_get_drvdata(dev);
156 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
157 chip = card->private_data;
158 chip->suspend(chip);
159 return 0;
160}
161
162static int snd_cs4231_resume(struct platform_device *dev)
163{
164 struct snd_card *card;
165 struct snd_cs4231 *chip;
166 card = platform_get_drvdata(dev);
167 chip = card->private_data;
168 chip->resume(chip);
169 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
170 return 0;
171}
172#endif
173
174#define SND_CS4231_DRIVER "snd_cs4231"
175
176static struct platform_driver snd_cs4231_driver = {
177 .probe = snd_cs4231_probe,
178 .remove = __devexit_p(snd_cs4231_remove),
179#ifdef CONFIG_PM
180 .suspend = snd_cs4231_suspend,
181 .resume = snd_cs4231_resume,
182#endif
183 .driver = {
184 .name = SND_CS4231_DRIVER
185 },
186};
187
188static void __init_or_module snd_cs4231_unregister_all(void)
142{ 189{
143 int dev, cards; 190 int i;
144 191
145 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { 192 for (i = 0; i < ARRAY_SIZE(devices); ++i)
146 if (snd_card_cs4231_probe(dev) >= 0) 193 platform_device_unregister(devices[i]);
147 cards++; 194 platform_driver_unregister(&snd_cs4231_driver);
195}
196
197static int __init alsa_card_cs4231_init(void)
198{
199 int i, cards, err;
200
201 err = platform_driver_register(&snd_cs4231_driver);
202 if (err < 0)
203 return err;
204
205 cards = 0;
206 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
207 struct platform_device *device;
208 device = platform_device_register_simple(SND_CS4231_DRIVER,
209 i, NULL, 0);
210 if (IS_ERR(device)) {
211 err = PTR_ERR(device);
212 goto errout;
213 }
214 devices[i] = device;
215 cards++;
148 } 216 }
149 if (!cards) { 217 if (!cards) {
150#ifdef MODULE 218#ifdef MODULE
151 printk(KERN_ERR "CS4231 soundcard not found or device busy\n"); 219 printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
152#endif 220#endif
153 return -ENODEV; 221 err = -ENODEV;
222 goto errout;
154 } 223 }
155 return 0; 224 return 0;
225
226 errout:
227 snd_cs4231_unregister_all();
228 return err;
156} 229}
157 230
158static void __exit alsa_card_cs4231_exit(void) 231static void __exit alsa_card_cs4231_exit(void)
159{ 232{
160 int idx; 233 snd_cs4231_unregister_all();
161
162 for (idx = 0; idx < SNDRV_CARDS; idx++)
163 snd_card_free(snd_cs4231_cards[idx]);
164} 234}
165 235
166module_init(alsa_card_cs4231_init) 236module_init(alsa_card_cs4231_init)
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 4af769030beb..eab7eb59b5f7 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -73,13 +73,13 @@ static unsigned int rates[14] = {
73 27042, 32000, 33075, 37800, 44100, 48000 73 27042, 32000, 33075, 37800, 44100, 48000
74}; 74};
75 75
76static snd_pcm_hw_constraint_list_t hw_constraints_rates = { 76static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
77 .count = 14, 77 .count = 14,
78 .list = rates, 78 .list = rates,
79 .mask = 0, 79 .mask = 0,
80}; 80};
81 81
82static int snd_cs4231_xrate(snd_pcm_runtime_t *runtime) 82static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime)
83{ 83{
84 return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); 84 return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
85} 85}
@@ -124,49 +124,17 @@ static unsigned char snd_cs4231_original_image[32] =
124 * Basic I/O functions 124 * Basic I/O functions
125 */ 125 */
126 126
127#if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT) 127static inline void cs4231_outb(struct snd_cs4231 *chip, u8 offset, u8 val)
128#define __CS4231_INLINE__ inline
129#else
130#define __CS4231_INLINE__ /* nothing */
131#endif
132
133static __CS4231_INLINE__ void cs4231_outb(cs4231_t *chip, u8 offset, u8 val)
134{ 128{
135#ifdef EBUS_SUPPORT
136 if (chip->ebus->flag) {
137 writeb(val, chip->port + (offset << 2));
138 } else {
139#endif
140#ifdef SBUS_SUPPORT
141 sbus_writeb(val, chip->port + (offset << 2));
142#endif
143#ifdef EBUS_SUPPORT
144 }
145#endif
146#ifdef LEGACY_SUPPORT
147 outb(val, chip->port + offset); 129 outb(val, chip->port + offset);
148#endif
149} 130}
150 131
151static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset) 132static inline u8 cs4231_inb(struct snd_cs4231 *chip, u8 offset)
152{ 133{
153#ifdef EBUS_SUPPORT
154 if (chip->ebus_flag) {
155 return readb(chip->port + (offset << 2));
156 } else {
157#endif
158#ifdef SBUS_SUPPORT
159 return sbus_readb(chip->port + (offset << 2));
160#endif
161#ifdef EBUS_SUPPORT
162 }
163#endif
164#ifdef LEGACY_SUPPORT
165 return inb(chip->port + offset); 134 return inb(chip->port + offset);
166#endif
167} 135}
168 136
169static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, 137static void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg,
170 unsigned char mask, unsigned char value) 138 unsigned char mask, unsigned char value)
171{ 139{
172 int timeout; 140 int timeout;
@@ -193,7 +161,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg,
193 } 161 }
194} 162}
195 163
196static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char value) 164static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value)
197{ 165{
198 int timeout; 166 int timeout;
199 167
@@ -206,7 +174,7 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val
206 mb(); 174 mb();
207} 175}
208 176
209void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) 177void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char value)
210{ 178{
211 int timeout; 179 int timeout;
212 180
@@ -227,7 +195,7 @@ void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value)
227#endif 195#endif
228} 196}
229 197
230unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) 198unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg)
231{ 199{
232 int timeout; 200 int timeout;
233 201
@@ -244,7 +212,7 @@ unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg)
244 return cs4231_inb(chip, CS4231P(REG)); 212 return cs4231_inb(chip, CS4231P(REG));
245} 213}
246 214
247void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) 215void snd_cs4236_ext_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val)
248{ 216{
249 cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); 217 cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17);
250 cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); 218 cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01));
@@ -255,7 +223,7 @@ void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val)
255#endif 223#endif
256} 224}
257 225
258unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) 226unsigned char snd_cs4236_ext_in(struct snd_cs4231 *chip, unsigned char reg)
259{ 227{
260 cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); 228 cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17);
261 cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); 229 cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01));
@@ -273,7 +241,7 @@ unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg)
273 241
274#if 0 242#if 0
275 243
276static void snd_cs4231_debug(cs4231_t *chip) 244static void snd_cs4231_debug(struct snd_cs4231 *chip)
277{ 245{
278 printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL))); 246 printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL)));
279 printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS))); 247 printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS)));
@@ -317,7 +285,7 @@ static void snd_cs4231_debug(cs4231_t *chip)
317 * CS4231 detection / MCE routines 285 * CS4231 detection / MCE routines
318 */ 286 */
319 287
320static void snd_cs4231_busy_wait(cs4231_t *chip) 288static void snd_cs4231_busy_wait(struct snd_cs4231 *chip)
321{ 289{
322 int timeout; 290 int timeout;
323 291
@@ -331,7 +299,7 @@ static void snd_cs4231_busy_wait(cs4231_t *chip)
331 udelay(10); 299 udelay(10);
332} 300}
333 301
334void snd_cs4231_mce_up(cs4231_t *chip) 302void snd_cs4231_mce_up(struct snd_cs4231 *chip)
335{ 303{
336 unsigned long flags; 304 unsigned long flags;
337 int timeout; 305 int timeout;
@@ -352,7 +320,7 @@ void snd_cs4231_mce_up(cs4231_t *chip)
352 spin_unlock_irqrestore(&chip->reg_lock, flags); 320 spin_unlock_irqrestore(&chip->reg_lock, flags);
353} 321}
354 322
355void snd_cs4231_mce_down(cs4231_t *chip) 323void snd_cs4231_mce_down(struct snd_cs4231 *chip)
356{ 324{
357 unsigned long flags; 325 unsigned long flags;
358 int timeout; 326 int timeout;
@@ -431,14 +399,14 @@ static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size
431 return size; 399 return size;
432} 400}
433 401
434static int snd_cs4231_trigger(snd_pcm_substream_t *substream, 402static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
435 int cmd) 403 int cmd)
436{ 404{
437 cs4231_t *chip = snd_pcm_substream_chip(substream); 405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
438 int result = 0; 406 int result = 0;
439 unsigned int what; 407 unsigned int what;
440 struct list_head *pos; 408 struct list_head *pos;
441 snd_pcm_substream_t *s; 409 struct snd_pcm_substream *s;
442 int do_start; 410 int do_start;
443 411
444#if 0 412#if 0
@@ -500,7 +468,7 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate)
500 return freq_bits[13]; 468 return freq_bits[13];
501} 469}
502 470
503static unsigned char snd_cs4231_get_format(cs4231_t *chip, 471static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip,
504 int format, 472 int format,
505 int channels) 473 int channels)
506{ 474{
@@ -522,7 +490,7 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip,
522 return rformat; 490 return rformat;
523} 491}
524 492
525static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) 493static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute)
526{ 494{
527 unsigned long flags; 495 unsigned long flags;
528 496
@@ -556,8 +524,8 @@ static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute)
556 spin_unlock_irqrestore(&chip->reg_lock, flags); 524 spin_unlock_irqrestore(&chip->reg_lock, flags);
557} 525}
558 526
559static void snd_cs4231_playback_format(cs4231_t *chip, 527static void snd_cs4231_playback_format(struct snd_cs4231 *chip,
560 snd_pcm_hw_params_t *params, 528 struct snd_pcm_hw_params *params,
561 unsigned char pdfr) 529 unsigned char pdfr)
562{ 530{
563 unsigned long flags; 531 unsigned long flags;
@@ -595,8 +563,8 @@ static void snd_cs4231_playback_format(cs4231_t *chip,
595 up(&chip->mce_mutex); 563 up(&chip->mce_mutex);
596} 564}
597 565
598static void snd_cs4231_capture_format(cs4231_t *chip, 566static void snd_cs4231_capture_format(struct snd_cs4231 *chip,
599 snd_pcm_hw_params_t *params, 567 struct snd_pcm_hw_params *params,
600 unsigned char cdfr) 568 unsigned char cdfr)
601{ 569{
602 unsigned long flags; 570 unsigned long flags;
@@ -642,20 +610,20 @@ static void snd_cs4231_capture_format(cs4231_t *chip,
642 * Timer interface 610 * Timer interface
643 */ 611 */
644 612
645static unsigned long snd_cs4231_timer_resolution(snd_timer_t * timer) 613static unsigned long snd_cs4231_timer_resolution(struct snd_timer * timer)
646{ 614{
647 cs4231_t *chip = snd_timer_chip(timer); 615 struct snd_cs4231 *chip = snd_timer_chip(timer);
648 if (chip->hardware & CS4231_HW_CS4236B_MASK) 616 if (chip->hardware & CS4231_HW_CS4236B_MASK)
649 return 14467; 617 return 14467;
650 else 618 else
651 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; 619 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920;
652} 620}
653 621
654static int snd_cs4231_timer_start(snd_timer_t * timer) 622static int snd_cs4231_timer_start(struct snd_timer * timer)
655{ 623{
656 unsigned long flags; 624 unsigned long flags;
657 unsigned int ticks; 625 unsigned int ticks;
658 cs4231_t *chip = snd_timer_chip(timer); 626 struct snd_cs4231 *chip = snd_timer_chip(timer);
659 spin_lock_irqsave(&chip->reg_lock, flags); 627 spin_lock_irqsave(&chip->reg_lock, flags);
660 ticks = timer->sticks; 628 ticks = timer->sticks;
661 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || 629 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 ||
@@ -669,17 +637,17 @@ static int snd_cs4231_timer_start(snd_timer_t * timer)
669 return 0; 637 return 0;
670} 638}
671 639
672static int snd_cs4231_timer_stop(snd_timer_t * timer) 640static int snd_cs4231_timer_stop(struct snd_timer * timer)
673{ 641{
674 unsigned long flags; 642 unsigned long flags;
675 cs4231_t *chip = snd_timer_chip(timer); 643 struct snd_cs4231 *chip = snd_timer_chip(timer);
676 spin_lock_irqsave(&chip->reg_lock, flags); 644 spin_lock_irqsave(&chip->reg_lock, flags);
677 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); 645 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE);
678 spin_unlock_irqrestore(&chip->reg_lock, flags); 646 spin_unlock_irqrestore(&chip->reg_lock, flags);
679 return 0; 647 return 0;
680} 648}
681 649
682static void snd_cs4231_init(cs4231_t *chip) 650static void snd_cs4231_init(struct snd_cs4231 *chip)
683{ 651{
684 unsigned long flags; 652 unsigned long flags;
685 653
@@ -737,7 +705,7 @@ static void snd_cs4231_init(cs4231_t *chip)
737#endif 705#endif
738} 706}
739 707
740static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) 708static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
741{ 709{
742 unsigned long flags; 710 unsigned long flags;
743 711
@@ -773,7 +741,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode)
773 return 0; 741 return 0;
774} 742}
775 743
776static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) 744static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
777{ 745{
778 unsigned long flags; 746 unsigned long flags;
779 747
@@ -824,21 +792,21 @@ static void snd_cs4231_close(cs4231_t *chip, unsigned int mode)
824 * timer open/close 792 * timer open/close
825 */ 793 */
826 794
827static int snd_cs4231_timer_open(snd_timer_t * timer) 795static int snd_cs4231_timer_open(struct snd_timer * timer)
828{ 796{
829 cs4231_t *chip = snd_timer_chip(timer); 797 struct snd_cs4231 *chip = snd_timer_chip(timer);
830 snd_cs4231_open(chip, CS4231_MODE_TIMER); 798 snd_cs4231_open(chip, CS4231_MODE_TIMER);
831 return 0; 799 return 0;
832} 800}
833 801
834static int snd_cs4231_timer_close(snd_timer_t * timer) 802static int snd_cs4231_timer_close(struct snd_timer * timer)
835{ 803{
836 cs4231_t *chip = snd_timer_chip(timer); 804 struct snd_cs4231 *chip = snd_timer_chip(timer);
837 snd_cs4231_close(chip, CS4231_MODE_TIMER); 805 snd_cs4231_close(chip, CS4231_MODE_TIMER);
838 return 0; 806 return 0;
839} 807}
840 808
841static struct _snd_timer_hardware snd_cs4231_timer_table = 809static struct snd_timer_hardware snd_cs4231_timer_table =
842{ 810{
843 .flags = SNDRV_TIMER_HW_AUTO, 811 .flags = SNDRV_TIMER_HW_AUTO,
844 .resolution = 9945, 812 .resolution = 9945,
@@ -854,10 +822,10 @@ static struct _snd_timer_hardware snd_cs4231_timer_table =
854 * ok.. exported functions.. 822 * ok.. exported functions..
855 */ 823 */
856 824
857static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, 825static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream,
858 snd_pcm_hw_params_t * hw_params) 826 struct snd_pcm_hw_params *hw_params)
859{ 827{
860 cs4231_t *chip = snd_pcm_substream_chip(substream); 828 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
861 unsigned char new_pdfr; 829 unsigned char new_pdfr;
862 int err; 830 int err;
863 831
@@ -869,16 +837,15 @@ static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream,
869 return 0; 837 return 0;
870} 838}
871 839
872static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) 840static int snd_cs4231_playback_hw_free(struct snd_pcm_substream *substream)
873{ 841{
874 return snd_pcm_lib_free_pages(substream); 842 return snd_pcm_lib_free_pages(substream);
875} 843}
876 844
877#ifdef LEGACY_SUPPORT 845static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream)
878static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream)
879{ 846{
880 cs4231_t *chip = snd_pcm_substream_chip(substream); 847 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
881 snd_pcm_runtime_t *runtime = substream->runtime; 848 struct snd_pcm_runtime *runtime = substream->runtime;
882 unsigned long flags; 849 unsigned long flags;
883 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 850 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
884 unsigned int count = snd_pcm_lib_period_bytes(substream); 851 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -896,12 +863,11 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream)
896#endif 863#endif
897 return 0; 864 return 0;
898} 865}
899#endif /* LEGACY_SUPPORT */
900 866
901static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, 867static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream,
902 snd_pcm_hw_params_t * hw_params) 868 struct snd_pcm_hw_params *hw_params)
903{ 869{
904 cs4231_t *chip = snd_pcm_substream_chip(substream); 870 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
905 unsigned char new_cdfr; 871 unsigned char new_cdfr;
906 int err; 872 int err;
907 873
@@ -913,16 +879,15 @@ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream,
913 return 0; 879 return 0;
914} 880}
915 881
916static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) 882static int snd_cs4231_capture_hw_free(struct snd_pcm_substream *substream)
917{ 883{
918 return snd_pcm_lib_free_pages(substream); 884 return snd_pcm_lib_free_pages(substream);
919} 885}
920 886
921#ifdef LEGACY_SUPPORT 887static int snd_cs4231_capture_prepare(struct snd_pcm_substream *substream)
922static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream)
923{ 888{
924 cs4231_t *chip = snd_pcm_substream_chip(substream); 889 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
925 snd_pcm_runtime_t *runtime = substream->runtime; 890 struct snd_pcm_runtime *runtime = substream->runtime;
926 unsigned long flags; 891 unsigned long flags;
927 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 892 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
928 unsigned int count = snd_pcm_lib_period_bytes(substream); 893 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -942,9 +907,8 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream)
942 spin_unlock_irqrestore(&chip->reg_lock, flags); 907 spin_unlock_irqrestore(&chip->reg_lock, flags);
943 return 0; 908 return 0;
944} 909}
945#endif
946 910
947static void snd_cs4231_overrange(cs4231_t *chip) 911static void snd_cs4231_overrange(struct snd_cs4231 *chip)
948{ 912{
949 unsigned long flags; 913 unsigned long flags;
950 unsigned char res; 914 unsigned char res;
@@ -958,7 +922,7 @@ static void snd_cs4231_overrange(cs4231_t *chip)
958 922
959irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) 923irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)
960{ 924{
961 cs4231_t *chip = dev_id; 925 struct snd_cs4231 *chip = dev_id;
962 unsigned char status; 926 unsigned char status;
963 927
964 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); 928 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS);
@@ -998,10 +962,9 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)
998 return IRQ_HANDLED; 962 return IRQ_HANDLED;
999} 963}
1000 964
1001#ifdef LEGACY_SUPPORT 965static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream)
1002static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream)
1003{ 966{
1004 cs4231_t *chip = snd_pcm_substream_chip(substream); 967 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1005 size_t ptr; 968 size_t ptr;
1006 969
1007 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) 970 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE))
@@ -1010,9 +973,9 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * subst
1010 return bytes_to_frames(substream->runtime, ptr); 973 return bytes_to_frames(substream->runtime, ptr);
1011} 974}
1012 975
1013static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substream) 976static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream)
1014{ 977{
1015 cs4231_t *chip = snd_pcm_substream_chip(substream); 978 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1016 size_t ptr; 979 size_t ptr;
1017 980
1018 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) 981 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE))
@@ -1020,13 +983,12 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr
1020 ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); 983 ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
1021 return bytes_to_frames(substream->runtime, ptr); 984 return bytes_to_frames(substream->runtime, ptr);
1022} 985}
1023#endif /* LEGACY_SUPPORT */
1024 986
1025/* 987/*
1026 988
1027 */ 989 */
1028 990
1029static int snd_cs4231_probe(cs4231_t *chip) 991static int snd_cs4231_probe(struct snd_cs4231 *chip)
1030{ 992{
1031 unsigned long flags; 993 unsigned long flags;
1032 int i, id, rev; 994 int i, id, rev;
@@ -1190,7 +1152,7 @@ static int snd_cs4231_probe(cs4231_t *chip)
1190 1152
1191 */ 1153 */
1192 1154
1193static snd_pcm_hardware_t snd_cs4231_playback = 1155static struct snd_pcm_hardware snd_cs4231_playback =
1194{ 1156{
1195 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1157 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1196 SNDRV_PCM_INFO_MMAP_VALID | 1158 SNDRV_PCM_INFO_MMAP_VALID |
@@ -1211,7 +1173,7 @@ static snd_pcm_hardware_t snd_cs4231_playback =
1211 .fifo_size = 0, 1173 .fifo_size = 0,
1212}; 1174};
1213 1175
1214static snd_pcm_hardware_t snd_cs4231_capture = 1176static struct snd_pcm_hardware snd_cs4231_capture =
1215{ 1177{
1216 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1178 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1217 SNDRV_PCM_INFO_MMAP_VALID | 1179 SNDRV_PCM_INFO_MMAP_VALID |
@@ -1236,10 +1198,10 @@ static snd_pcm_hardware_t snd_cs4231_capture =
1236 1198
1237 */ 1199 */
1238 1200
1239static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) 1201static int snd_cs4231_playback_open(struct snd_pcm_substream *substream)
1240{ 1202{
1241 cs4231_t *chip = snd_pcm_substream_chip(substream); 1203 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1242 snd_pcm_runtime_t *runtime = substream->runtime; 1204 struct snd_pcm_runtime *runtime = substream->runtime;
1243 int err; 1205 int err;
1244 1206
1245 runtime->hw = snd_cs4231_playback; 1207 runtime->hw = snd_cs4231_playback;
@@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream)
1253 chip->hardware == CS4231_HW_CS4239) 1215 chip->hardware == CS4231_HW_CS4239)
1254 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; 1216 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE;
1255 1217
1256#ifdef LEGACY_SUPPORT
1257 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); 1218 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
1258 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); 1219 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max);
1259 1220
@@ -1261,29 +1222,23 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream)
1261 if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) 1222 if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0)
1262 return err; 1223 return err;
1263 } 1224 }
1264#endif
1265 1225
1266 if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { 1226 if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) {
1267#ifdef LEGACY_SUPPORT
1268 if (chip->release_dma) 1227 if (chip->release_dma)
1269 chip->release_dma(chip, chip->dma_private_data, chip->dma1); 1228 chip->release_dma(chip, chip->dma_private_data, chip->dma1);
1270#endif
1271 snd_free_pages(runtime->dma_area, runtime->dma_bytes); 1229 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
1272 return err; 1230 return err;
1273 } 1231 }
1274 chip->playback_substream = substream; 1232 chip->playback_substream = substream;
1275#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
1276 chip->p_periods_sent = 0;
1277#endif
1278 snd_pcm_set_sync(substream); 1233 snd_pcm_set_sync(substream);
1279 chip->rate_constraint(runtime); 1234 chip->rate_constraint(runtime);
1280 return 0; 1235 return 0;
1281} 1236}
1282 1237
1283static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) 1238static int snd_cs4231_capture_open(struct snd_pcm_substream *substream)
1284{ 1239{
1285 cs4231_t *chip = snd_pcm_substream_chip(substream); 1240 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1286 snd_pcm_runtime_t *runtime = substream->runtime; 1241 struct snd_pcm_runtime *runtime = substream->runtime;
1287 int err; 1242 int err;
1288 1243
1289 runtime->hw = snd_cs4231_capture; 1244 runtime->hw = snd_cs4231_capture;
@@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream)
1293 chip->hardware == CS4231_HW_CS4239) 1248 chip->hardware == CS4231_HW_CS4239)
1294 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; 1249 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE;
1295 1250
1296#ifdef LEGACY_SUPPORT
1297 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); 1251 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
1298 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); 1252 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max);
1299 1253
@@ -1301,37 +1255,31 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream)
1301 if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) 1255 if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0)
1302 return err; 1256 return err;
1303 } 1257 }
1304#endif
1305 1258
1306 if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { 1259 if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) {
1307#ifdef LEGACY_SUPPORT
1308 if (chip->release_dma) 1260 if (chip->release_dma)
1309 chip->release_dma(chip, chip->dma_private_data, chip->dma2); 1261 chip->release_dma(chip, chip->dma_private_data, chip->dma2);
1310#endif
1311 snd_free_pages(runtime->dma_area, runtime->dma_bytes); 1262 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
1312 return err; 1263 return err;
1313 } 1264 }
1314 chip->capture_substream = substream; 1265 chip->capture_substream = substream;
1315#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
1316 chip->c_periods_sent = 0;
1317#endif
1318 snd_pcm_set_sync(substream); 1266 snd_pcm_set_sync(substream);
1319 chip->rate_constraint(runtime); 1267 chip->rate_constraint(runtime);
1320 return 0; 1268 return 0;
1321} 1269}
1322 1270
1323static int snd_cs4231_playback_close(snd_pcm_substream_t * substream) 1271static int snd_cs4231_playback_close(struct snd_pcm_substream *substream)
1324{ 1272{
1325 cs4231_t *chip = snd_pcm_substream_chip(substream); 1273 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1326 1274
1327 chip->playback_substream = NULL; 1275 chip->playback_substream = NULL;
1328 snd_cs4231_close(chip, CS4231_MODE_PLAY); 1276 snd_cs4231_close(chip, CS4231_MODE_PLAY);
1329 return 0; 1277 return 0;
1330} 1278}
1331 1279
1332static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) 1280static int snd_cs4231_capture_close(struct snd_pcm_substream *substream)
1333{ 1281{
1334 cs4231_t *chip = snd_pcm_substream_chip(substream); 1282 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
1335 1283
1336 chip->capture_substream = NULL; 1284 chip->capture_substream = NULL;
1337 snd_cs4231_close(chip, CS4231_MODE_RECORD); 1285 snd_cs4231_close(chip, CS4231_MODE_RECORD);
@@ -1341,13 +1289,12 @@ static int snd_cs4231_capture_close(snd_pcm_substream_t * substream)
1341#ifdef CONFIG_PM 1289#ifdef CONFIG_PM
1342 1290
1343/* lowlevel suspend callback for CS4231 */ 1291/* lowlevel suspend callback for CS4231 */
1344static void snd_cs4231_suspend(cs4231_t *chip) 1292static void snd_cs4231_suspend(struct snd_cs4231 *chip)
1345{ 1293{
1346 int reg; 1294 int reg;
1347 unsigned long flags; 1295 unsigned long flags;
1348 1296
1349 if (chip->pcm) 1297 snd_pcm_suspend_all(chip->pcm);
1350 snd_pcm_suspend_all(chip->pcm);
1351 spin_lock_irqsave(&chip->reg_lock, flags); 1298 spin_lock_irqsave(&chip->reg_lock, flags);
1352 for (reg = 0; reg < 32; reg++) 1299 for (reg = 0; reg < 32; reg++)
1353 chip->image[reg] = snd_cs4231_in(chip, reg); 1300 chip->image[reg] = snd_cs4231_in(chip, reg);
@@ -1355,11 +1302,11 @@ static void snd_cs4231_suspend(cs4231_t *chip)
1355} 1302}
1356 1303
1357/* lowlevel resume callback for CS4231 */ 1304/* lowlevel resume callback for CS4231 */
1358static void snd_cs4231_resume(cs4231_t *chip) 1305static void snd_cs4231_resume(struct snd_cs4231 *chip)
1359{ 1306{
1360 int reg; 1307 int reg;
1361 unsigned long flags; 1308 unsigned long flags;
1362 int timeout; 1309 /* int timeout; */
1363 1310
1364 snd_cs4231_mce_up(chip); 1311 snd_cs4231_mce_up(chip);
1365 spin_lock_irqsave(&chip->reg_lock, flags); 1312 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1373,7 +1320,7 @@ static void snd_cs4231_resume(cs4231_t *chip)
1373 } 1320 }
1374 } 1321 }
1375 spin_unlock_irqrestore(&chip->reg_lock, flags); 1322 spin_unlock_irqrestore(&chip->reg_lock, flags);
1376#if 0 1323#if 1
1377 snd_cs4231_mce_down(chip); 1324 snd_cs4231_mce_down(chip);
1378#else 1325#else
1379 /* The following is a workaround to avoid freeze after resume on TP600E. 1326 /* The following is a workaround to avoid freeze after resume on TP600E.
@@ -1395,27 +1342,9 @@ static void snd_cs4231_resume(cs4231_t *chip)
1395 snd_cs4231_busy_wait(chip); 1342 snd_cs4231_busy_wait(chip);
1396#endif 1343#endif
1397} 1344}
1398
1399static int snd_cs4231_pm_suspend(snd_card_t *card, pm_message_t state)
1400{
1401 cs4231_t *chip = card->pm_private_data;
1402 if (chip->suspend)
1403 chip->suspend(chip);
1404 return 0;
1405}
1406
1407static int snd_cs4231_pm_resume(snd_card_t *card)
1408{
1409 cs4231_t *chip = card->pm_private_data;
1410 if (chip->resume)
1411 chip->resume(chip);
1412 return 0;
1413}
1414#endif /* CONFIG_PM */ 1345#endif /* CONFIG_PM */
1415 1346
1416#ifdef LEGACY_SUPPORT 1347static int snd_cs4231_free(struct snd_cs4231 *chip)
1417
1418static int snd_cs4231_free(cs4231_t *chip)
1419{ 1348{
1420 release_and_free_resource(chip->res_port); 1349 release_and_free_resource(chip->res_port);
1421 release_and_free_resource(chip->res_cport); 1350 release_and_free_resource(chip->res_cport);
@@ -1438,15 +1367,13 @@ static int snd_cs4231_free(cs4231_t *chip)
1438 return 0; 1367 return 0;
1439} 1368}
1440 1369
1441static int snd_cs4231_dev_free(snd_device_t *device) 1370static int snd_cs4231_dev_free(struct snd_device *device)
1442{ 1371{
1443 cs4231_t *chip = device->device_data; 1372 struct snd_cs4231 *chip = device->device_data;
1444 return snd_cs4231_free(chip); 1373 return snd_cs4231_free(chip);
1445} 1374}
1446 1375
1447#endif /* LEGACY_SUPPORT */ 1376const char *snd_cs4231_chip_id(struct snd_cs4231 *chip)
1448
1449const char *snd_cs4231_chip_id(cs4231_t *chip)
1450{ 1377{
1451 switch (chip->hardware) { 1378 switch (chip->hardware) {
1452 case CS4231_HW_CS4231: return "CS4231"; 1379 case CS4231_HW_CS4231: return "CS4231";
@@ -1466,12 +1393,12 @@ const char *snd_cs4231_chip_id(cs4231_t *chip)
1466 } 1393 }
1467} 1394}
1468 1395
1469static int snd_cs4231_new(snd_card_t * card, 1396static int snd_cs4231_new(struct snd_card *card,
1470 unsigned short hardware, 1397 unsigned short hardware,
1471 unsigned short hwshare, 1398 unsigned short hwshare,
1472 cs4231_t ** rchip) 1399 struct snd_cs4231 ** rchip)
1473{ 1400{
1474 cs4231_t *chip; 1401 struct snd_cs4231 *chip;
1475 1402
1476 *rchip = NULL; 1403 *rchip = NULL;
1477 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1404 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
@@ -1493,20 +1420,18 @@ static int snd_cs4231_new(snd_card_t * card,
1493 return 0; 1420 return 0;
1494} 1421}
1495 1422
1496#ifdef LEGACY_SUPPORT 1423int snd_cs4231_create(struct snd_card *card,
1497
1498int snd_cs4231_create(snd_card_t * card,
1499 unsigned long port, 1424 unsigned long port,
1500 unsigned long cport, 1425 unsigned long cport,
1501 int irq, int dma1, int dma2, 1426 int irq, int dma1, int dma2,
1502 unsigned short hardware, 1427 unsigned short hardware,
1503 unsigned short hwshare, 1428 unsigned short hwshare,
1504 cs4231_t ** rchip) 1429 struct snd_cs4231 ** rchip)
1505{ 1430{
1506 static snd_device_ops_t ops = { 1431 static struct snd_device_ops ops = {
1507 .dev_free = snd_cs4231_dev_free, 1432 .dev_free = snd_cs4231_dev_free,
1508 }; 1433 };
1509 cs4231_t *chip; 1434 struct snd_cs4231 *chip;
1510 int err; 1435 int err;
1511 1436
1512 err = snd_cs4231_new(card, hardware, hwshare, &chip); 1437 err = snd_cs4231_new(card, hardware, hwshare, &chip);
@@ -1559,10 +1484,12 @@ int snd_cs4231_create(snd_card_t * card,
1559 } 1484 }
1560 snd_cs4231_init(chip); 1485 snd_cs4231_init(chip);
1561 1486
1487#if 0
1562 if (chip->hardware & CS4231_HW_CS4232_MASK) { 1488 if (chip->hardware & CS4231_HW_CS4232_MASK) {
1563 if (chip->res_cport == NULL) 1489 if (chip->res_cport == NULL)
1564 snd_printk("CS4232 control port features are not accessible\n"); 1490 snd_printk("CS4232 control port features are not accessible\n");
1565 } 1491 }
1492#endif
1566 1493
1567 /* Register device */ 1494 /* Register device */
1568 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 1495 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
@@ -1574,16 +1501,13 @@ int snd_cs4231_create(snd_card_t * card,
1574 /* Power Management */ 1501 /* Power Management */
1575 chip->suspend = snd_cs4231_suspend; 1502 chip->suspend = snd_cs4231_suspend;
1576 chip->resume = snd_cs4231_resume; 1503 chip->resume = snd_cs4231_resume;
1577 snd_card_set_isa_pm_callback(card, snd_cs4231_pm_suspend, snd_cs4231_pm_resume, chip);
1578#endif 1504#endif
1579 1505
1580 *rchip = chip; 1506 *rchip = chip;
1581 return 0; 1507 return 0;
1582} 1508}
1583 1509
1584#endif /* LEGACY_SUPPORT */ 1510static struct snd_pcm_ops snd_cs4231_playback_ops = {
1585
1586static snd_pcm_ops_t snd_cs4231_playback_ops = {
1587 .open = snd_cs4231_playback_open, 1511 .open = snd_cs4231_playback_open,
1588 .close = snd_cs4231_playback_close, 1512 .close = snd_cs4231_playback_close,
1589 .ioctl = snd_pcm_lib_ioctl, 1513 .ioctl = snd_pcm_lib_ioctl,
@@ -1594,7 +1518,7 @@ static snd_pcm_ops_t snd_cs4231_playback_ops = {
1594 .pointer = snd_cs4231_playback_pointer, 1518 .pointer = snd_cs4231_playback_pointer,
1595}; 1519};
1596 1520
1597static snd_pcm_ops_t snd_cs4231_capture_ops = { 1521static struct snd_pcm_ops snd_cs4231_capture_ops = {
1598 .open = snd_cs4231_capture_open, 1522 .open = snd_cs4231_capture_open,
1599 .close = snd_cs4231_capture_close, 1523 .close = snd_cs4231_capture_close,
1600 .ioctl = snd_pcm_lib_ioctl, 1524 .ioctl = snd_pcm_lib_ioctl,
@@ -1605,16 +1529,9 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = {
1605 .pointer = snd_cs4231_capture_pointer, 1529 .pointer = snd_cs4231_capture_pointer,
1606}; 1530};
1607 1531
1608static void snd_cs4231_pcm_free(snd_pcm_t *pcm) 1532int snd_cs4231_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm)
1609{ 1533{
1610 cs4231_t *chip = pcm->private_data; 1534 struct snd_pcm *pcm;
1611 chip->pcm = NULL;
1612 snd_pcm_lib_preallocate_free_for_all(pcm);
1613}
1614
1615int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
1616{
1617 snd_pcm_t *pcm;
1618 int err; 1535 int err;
1619 1536
1620 if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0) 1537 if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0)
@@ -1629,7 +1546,6 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
1629 1546
1630 /* global setup */ 1547 /* global setup */
1631 pcm->private_data = chip; 1548 pcm->private_data = chip;
1632 pcm->private_free = snd_cs4231_pcm_free;
1633 pcm->info_flags = 0; 1549 pcm->info_flags = 0;
1634 if (chip->single_dma) 1550 if (chip->single_dma)
1635 pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; 1551 pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
@@ -1637,27 +1553,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
1637 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; 1553 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX;
1638 strcpy(pcm->name, snd_cs4231_chip_id(chip)); 1554 strcpy(pcm->name, snd_cs4231_chip_id(chip));
1639 1555
1640#ifdef LEGACY_SUPPORT
1641 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1556 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1642 snd_dma_isa_data(), 1557 snd_dma_isa_data(),
1643 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); 1558 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
1644#else
1645# ifdef EBUS_SUPPORT
1646 if (chip->ebus_flag) {
1647 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1648 chip->dev_u.pdev,
1649 64*1024, 128*1024);
1650 } else {
1651# endif
1652# ifdef SBUS_SUPPORT
1653 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS,
1654 chip->dev_u.sdev,
1655 64*1024, 128*1024);
1656# endif
1657# ifdef EBUS_SUPPORT
1658 }
1659# endif
1660#endif
1661 1559
1662 chip->pcm = pcm; 1560 chip->pcm = pcm;
1663 if (rpcm) 1561 if (rpcm)
@@ -1665,16 +1563,16 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
1665 return 0; 1563 return 0;
1666} 1564}
1667 1565
1668static void snd_cs4231_timer_free(snd_timer_t *timer) 1566static void snd_cs4231_timer_free(struct snd_timer *timer)
1669{ 1567{
1670 cs4231_t *chip = timer->private_data; 1568 struct snd_cs4231 *chip = timer->private_data;
1671 chip->timer = NULL; 1569 chip->timer = NULL;
1672} 1570}
1673 1571
1674int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) 1572int snd_cs4231_timer(struct snd_cs4231 *chip, int device, struct snd_timer **rtimer)
1675{ 1573{
1676 snd_timer_t *timer; 1574 struct snd_timer *timer;
1677 snd_timer_id_t tid; 1575 struct snd_timer_id tid;
1678 int err; 1576 int err;
1679 1577
1680 /* Timer initialization */ 1578 /* Timer initialization */
@@ -1699,7 +1597,7 @@ int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer)
1699 * MIXER part 1597 * MIXER part
1700 */ 1598 */
1701 1599
1702static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1600static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1703{ 1601{
1704 static char *texts[4] = { 1602 static char *texts[4] = {
1705 "Line", "Aux", "Mic", "Mix" 1603 "Line", "Aux", "Mic", "Mix"
@@ -1711,7 +1609,7 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
1711 "Line", "Synth", "Mic", "Mix" 1609 "Line", "Synth", "Mic", "Mix"
1712 }; 1610 };
1713 char **ptexts = texts; 1611 char **ptexts = texts;
1714 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1612 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1715 1613
1716 snd_assert(chip->card != NULL, return -EINVAL); 1614 snd_assert(chip->card != NULL, return -EINVAL);
1717 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1615 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1729,9 +1627,9 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
1729 return 0; 1627 return 0;
1730} 1628}
1731 1629
1732static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1630static int snd_cs4231_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1733{ 1631{
1734 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1632 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1735 unsigned long flags; 1633 unsigned long flags;
1736 1634
1737 spin_lock_irqsave(&chip->reg_lock, flags); 1635 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1741,9 +1639,9 @@ static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1741 return 0; 1639 return 0;
1742} 1640}
1743 1641
1744static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1642static int snd_cs4231_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1745{ 1643{
1746 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1644 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1747 unsigned long flags; 1645 unsigned long flags;
1748 unsigned short left, right; 1646 unsigned short left, right;
1749 int change; 1647 int change;
@@ -1764,7 +1662,7 @@ static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1764 return change; 1662 return change;
1765} 1663}
1766 1664
1767int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1665int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1768{ 1666{
1769 int mask = (kcontrol->private_value >> 16) & 0xff; 1667 int mask = (kcontrol->private_value >> 16) & 0xff;
1770 1668
@@ -1775,9 +1673,9 @@ int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo
1775 return 0; 1673 return 0;
1776} 1674}
1777 1675
1778int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1676int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1779{ 1677{
1780 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1678 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1781 unsigned long flags; 1679 unsigned long flags;
1782 int reg = kcontrol->private_value & 0xff; 1680 int reg = kcontrol->private_value & 0xff;
1783 int shift = (kcontrol->private_value >> 8) & 0xff; 1681 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1792,9 +1690,9 @@ int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon
1792 return 0; 1690 return 0;
1793} 1691}
1794 1692
1795int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1693int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1796{ 1694{
1797 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1695 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1798 unsigned long flags; 1696 unsigned long flags;
1799 int reg = kcontrol->private_value & 0xff; 1697 int reg = kcontrol->private_value & 0xff;
1800 int shift = (kcontrol->private_value >> 8) & 0xff; 1698 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1815,7 +1713,7 @@ int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon
1815 return change; 1713 return change;
1816} 1714}
1817 1715
1818int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1716int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1819{ 1717{
1820 int mask = (kcontrol->private_value >> 24) & 0xff; 1718 int mask = (kcontrol->private_value >> 24) & 0xff;
1821 1719
@@ -1826,9 +1724,9 @@ int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo
1826 return 0; 1724 return 0;
1827} 1725}
1828 1726
1829int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1727int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1830{ 1728{
1831 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1729 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1832 unsigned long flags; 1730 unsigned long flags;
1833 int left_reg = kcontrol->private_value & 0xff; 1731 int left_reg = kcontrol->private_value & 0xff;
1834 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1732 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1848,9 +1746,9 @@ int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon
1848 return 0; 1746 return 0;
1849} 1747}
1850 1748
1851int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1749int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1852{ 1750{
1853 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 1751 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
1854 unsigned long flags; 1752 unsigned long flags;
1855 int left_reg = kcontrol->private_value & 0xff; 1753 int left_reg = kcontrol->private_value & 0xff;
1856 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1754 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1879,7 +1777,7 @@ int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon
1879 return change; 1777 return change;
1880} 1778}
1881 1779
1882static snd_kcontrol_new_t snd_cs4231_controls[] = { 1780static struct snd_kcontrol_new snd_cs4231_controls[] = {
1883CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), 1781CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
1884CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), 1782CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1),
1885CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), 1783CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
@@ -1905,9 +1803,9 @@ CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0),
1905CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1) 1803CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1)
1906}; 1804};
1907 1805
1908int snd_cs4231_mixer(cs4231_t *chip) 1806int snd_cs4231_mixer(struct snd_cs4231 *chip)
1909{ 1807{
1910 snd_card_t *card; 1808 struct snd_card *card;
1911 unsigned int idx; 1809 unsigned int idx;
1912 int err; 1810 int err;
1913 1811
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index d60a55e6a0b1..e1683337e6cd 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -21,6 +21,8 @@
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
24#include <linux/slab.h> 26#include <linux/slab.h>
25#include <linux/pnp.h> 27#include <linux/pnp.h>
26#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -122,7 +124,14 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
122module_param_array(dma2, int, NULL, 0444); 124module_param_array(dma2, int, NULL, 0444);
123MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 125MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
124 126
127static struct platform_device *platform_devices[SNDRV_CARDS];
128static int pnpc_registered;
129#ifdef CS4232
130static int pnp_registered;
131#endif
132
125struct snd_card_cs4236 { 133struct snd_card_cs4236 {
134 struct snd_cs4231 *chip;
126 struct resource *res_sb_port; 135 struct resource *res_sb_port;
127#ifdef CONFIG_PNP 136#ifdef CONFIG_PNP
128 struct pnp_dev *wss; 137 struct pnp_dev *wss;
@@ -131,33 +140,26 @@ struct snd_card_cs4236 {
131#endif 140#endif
132}; 141};
133 142
134static snd_card_t *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
135
136#ifdef CONFIG_PNP 143#ifdef CONFIG_PNP
137 144
138#define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ 145#ifdef CS4232
139 { \ 146/*
140 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 147 * PNP BIOS
141 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ 148 */
142 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ 149static const struct pnp_device_id snd_cs4232_pnpbiosids[] = {
143 ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401) } \ 150 { .id = "CSC0100" },
144 } 151 { .id = "CSC0000" },
145#define ISAPNP_CS4232_1(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ 152 /* Guillemot Turtlebeach something appears to be cs4232 compatible
146 { \ 153 * (untested) */
147 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 154 { .id = "GIM0100" },
148 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ 155 { .id = "" }
149 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ 156};
150 ISAPNP_DEVICE_ID('P', 'N', 'P', _mpu401) } \ 157MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids);
151 } 158#endif /* CS4232 */
152#define ISAPNP_CS4232_WOMPU(_va, _vb, _vc, _device, _wss, _ctrl) \
153 { \
154 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
155 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \
156 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl) } \
157 }
158
159 159
160#ifdef CS4232 160#ifdef CS4232
161#define CS423X_DRIVER "snd_cs4232"
162#define CS423X_ISAPNP_DRIVER "cs4232_isapnp"
161static struct pnp_card_device_id snd_cs423x_pnpids[] = { 163static struct pnp_card_device_id snd_cs423x_pnpids[] = {
162 /* Philips PCA70PS */ 164 /* Philips PCA70PS */
163 { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, 165 { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
@@ -177,6 +179,8 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = {
177 { .id = "" } /* end */ 179 { .id = "" } /* end */
178}; 180};
179#else /* CS4236 */ 181#else /* CS4236 */
182#define CS423X_DRIVER "snd_cs4236"
183#define CS423X_ISAPNP_DRIVER "cs4236_isapnp"
180static struct pnp_card_device_id snd_cs423x_pnpids[] = { 184static struct pnp_card_device_id snd_cs423x_pnpids[] = {
181 /* Intel Marlin Spike Motherboard - CS4235 */ 185 /* Intel Marlin Spike Motherboard - CS4235 */
182 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 186 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
@@ -261,37 +265,12 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = {
261 265
262MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); 266MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids);
263 267
264static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, 268/* WSS initialization */
265 struct pnp_card_link *card, 269static int __devinit snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev,
266 const struct pnp_card_device_id *id) 270 struct pnp_resource_table *cfg)
267{ 271{
268 struct pnp_dev *pdev;
269 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
270 int err; 272 int err;
271 273
272 if (!cfg)
273 return -ENOMEM;
274
275 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
276 if (acard->wss == NULL) {
277 kfree(cfg);
278 return -EBUSY;
279 }
280 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL);
281 if (acard->ctrl == NULL) {
282 kfree(cfg);
283 return -EBUSY;
284 }
285 if (id->devs[2].id[0]) {
286 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
287 if (acard->mpu == NULL) {
288 kfree(cfg);
289 return -EBUSY;
290 }
291 }
292
293 /* WSS initialization */
294 pdev = acard->wss;
295 pnp_init_resource_table(cfg); 274 pnp_init_resource_table(cfg);
296 if (port[dev] != SNDRV_AUTO_PORT) 275 if (port[dev] != SNDRV_AUTO_PORT)
297 pnp_resource_change(&cfg->port_resource[0], port[dev], 4); 276 pnp_resource_change(&cfg->port_resource[0], port[dev], 4);
@@ -310,7 +289,6 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard,
310 snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n"); 289 snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n");
311 err = pnp_activate_dev(pdev); 290 err = pnp_activate_dev(pdev);
312 if (err < 0) { 291 if (err < 0) {
313 kfree(cfg);
314 printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n"); 292 printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n");
315 return -EBUSY; 293 return -EBUSY;
316 } 294 }
@@ -325,63 +303,124 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard,
325 port[dev], fm_port[dev], sb_port[dev]); 303 port[dev], fm_port[dev], sb_port[dev]);
326 snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n", 304 snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n",
327 irq[dev], dma1[dev], dma2[dev]); 305 irq[dev], dma1[dev], dma2[dev]);
328 /* CTRL initialization */ 306 return 0;
329 if (acard->ctrl && cport[dev] > 0) { 307}
330 pdev = acard->ctrl; 308
331 pnp_init_resource_table(cfg); 309/* CTRL initialization */
332 if (cport[dev] != SNDRV_AUTO_PORT) 310static int __devinit snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev,
333 pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); 311 struct pnp_resource_table *cfg)
334 err = pnp_manual_config_dev(pdev, cfg, 0); 312{
335 if (err < 0) 313 int err;
336 snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); 314
337 err = pnp_activate_dev(pdev); 315 pnp_init_resource_table(cfg);
338 if (err < 0) { 316 if (cport[dev] != SNDRV_AUTO_PORT)
339 kfree(cfg); 317 pnp_resource_change(&cfg->port_resource[0], cport[dev], 8);
340 printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); 318 err = pnp_manual_config_dev(pdev, cfg, 0);
341 return -EBUSY; 319 if (err < 0)
342 } 320 snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n");
343 cport[dev] = pnp_port_start(pdev, 0); 321 err = pnp_activate_dev(pdev);
344 snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); 322 if (err < 0) {
323 printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n");
324 return -EBUSY;
345 } 325 }
346 /* MPU initialization */ 326 cport[dev] = pnp_port_start(pdev, 0);
347 if (acard->mpu && mpu_port[dev] > 0) { 327 snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]);
348 pdev = acard->mpu; 328 return 0;
349 pnp_init_resource_table(cfg); 329}
350 if (mpu_port[dev] != SNDRV_AUTO_PORT) 330
351 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 331/* MPU initialization */
352 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) 332static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev,
353 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 333 struct pnp_resource_table *cfg)
354 err = pnp_manual_config_dev(pdev, cfg, 0); 334{
355 if (err < 0) 335 int err;
356 snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); 336
357 err = pnp_activate_dev(pdev); 337 pnp_init_resource_table(cfg);
358 if (err < 0) { 338 if (mpu_port[dev] != SNDRV_AUTO_PORT)
359 printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); 339 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);
360 mpu_port[dev] = SNDRV_AUTO_PORT; 340 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0)
361 mpu_irq[dev] = SNDRV_AUTO_IRQ; 341 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);
342 err = pnp_manual_config_dev(pdev, cfg, 0);
343 if (err < 0)
344 snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n");
345 err = pnp_activate_dev(pdev);
346 if (err < 0) {
347 printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n");
348 mpu_port[dev] = SNDRV_AUTO_PORT;
349 mpu_irq[dev] = SNDRV_AUTO_IRQ;
350 } else {
351 mpu_port[dev] = pnp_port_start(pdev, 0);
352 if (mpu_irq[dev] >= 0 &&
353 pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
354 mpu_irq[dev] = pnp_irq(pdev, 0);
362 } else { 355 } else {
363 mpu_port[dev] = pnp_port_start(pdev, 0); 356 mpu_irq[dev] = -1; /* disable interrupt */
364 if (mpu_irq[dev] >= 0 &&
365 pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
366 mpu_irq[dev] = pnp_irq(pdev, 0);
367 } else {
368 mpu_irq[dev] = -1; /* disable interrupt */
369 }
370 } 357 }
371 snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); 358 }
359 snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]);
360 return 0;
361}
362
363#ifdef CS4232
364static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard,
365 struct pnp_dev *pdev)
366{
367 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
368
369 if (!cfg)
370 return -ENOMEM;
371 if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) {
372 kfree(cfg);
373 return -EBUSY;
372 } 374 }
373 kfree(cfg); 375 kfree(cfg);
376 cport[dev] = -1;
374 return 0; 377 return 0;
375} 378}
376#endif /* CONFIG_PNP */ 379#endif
377 380
378static void snd_card_cs4236_free(snd_card_t *card) 381static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard,
382 struct pnp_card_link *card,
383 const struct pnp_card_device_id *id)
379{ 384{
380 struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; 385 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
386
387 if (!cfg)
388 return -ENOMEM;
389
390 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
391 if (acard->wss == NULL)
392 goto error;
393 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL);
394 if (acard->ctrl == NULL)
395 goto error;
396 if (id->devs[2].id[0]) {
397 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
398 if (acard->mpu == NULL)
399 goto error;
400 }
381 401
382 if (acard) 402 /* WSS initialization */
383 release_and_free_resource(acard->res_sb_port); 403 if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0)
404 goto error;
405
406 /* CTRL initialization */
407 if (acard->ctrl && cport[dev] > 0) {
408 if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl, cfg) < 0)
409 goto error;
410 }
411 /* MPU initialization */
412 if (acard->mpu && mpu_port[dev] > 0) {
413 if (snd_cs423x_pnp_init_mpu(dev, acard->ctrl, cfg) < 0)
414 goto error;
415 }
416 kfree(cfg);
417 return 0;
418
419 error:
420 kfree(cfg);
421 return -EBUSY;
384} 422}
423#endif /* CONFIG_PNP */
385 424
386#ifdef CONFIG_PNP 425#ifdef CONFIG_PNP
387#define is_isapnp_selected(dev) isapnp[dev] 426#define is_isapnp_selected(dev) isapnp[dev]
@@ -389,46 +428,38 @@ static void snd_card_cs4236_free(snd_card_t *card)
389#define is_isapnp_selected(dev) 0 428#define is_isapnp_selected(dev) 0
390#endif 429#endif
391 430
392static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, 431static void snd_card_cs4236_free(struct snd_card *card)
393 const struct pnp_card_device_id *pid)
394{ 432{
395 snd_card_t *card; 433 struct snd_card_cs4236 *acard = card->private_data;
396 struct snd_card_cs4236 *acard; 434
397 snd_pcm_t *pcm = NULL; 435 release_and_free_resource(acard->res_sb_port);
398 cs4231_t *chip; 436}
399 opl3_t *opl3; 437
400 int err; 438static struct snd_card *snd_cs423x_card_new(int dev)
439{
440 struct snd_card *card;
401 441
402 if (! is_isapnp_selected(dev)) {
403 if (port[dev] == SNDRV_AUTO_PORT) {
404 snd_printk(KERN_ERR "specify port\n");
405 return -EINVAL;
406 }
407 if (cport[dev] == SNDRV_AUTO_PORT) {
408 snd_printk(KERN_ERR "specify cport\n");
409 return -EINVAL;
410 }
411 }
412 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 442 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
413 sizeof(struct snd_card_cs4236)); 443 sizeof(struct snd_card_cs4236));
414 if (card == NULL) 444 if (card == NULL)
415 return -ENOMEM; 445 return NULL;
416 acard = (struct snd_card_cs4236 *)card->private_data;
417 card->private_free = snd_card_cs4236_free; 446 card->private_free = snd_card_cs4236_free;
418#ifdef CONFIG_PNP 447 return card;
419 if (isapnp[dev]) { 448}
420 if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { 449
421 printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); 450static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
422 goto _err; 451{
423 } 452 struct snd_card_cs4236 *acard;
424 snd_card_set_dev(card, &pcard->card->dev); 453 struct snd_pcm *pcm;
425 } 454 struct snd_cs4231 *chip;
426#endif 455 struct snd_opl3 *opl3;
456 int err;
457
458 acard = card->private_data;
427 if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) 459 if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT)
428 if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { 460 if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) {
429 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); 461 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);
430 err = -EBUSY; 462 return -EBUSY;
431 goto _err;
432 } 463 }
433 464
434#ifdef CS4232 465#ifdef CS4232
@@ -441,13 +472,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
441 CS4231_HW_DETECT, 472 CS4231_HW_DETECT,
442 0, 473 0,
443 &chip)) < 0) 474 &chip)) < 0)
444 goto _err; 475 return err;
476 acard->chip = chip;
445 477
446 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) 478 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0)
447 goto _err; 479 return err;
448 480
449 if ((err = snd_cs4231_mixer(chip)) < 0) 481 if ((err = snd_cs4231_mixer(chip)) < 0)
450 goto _err; 482 return err;
451 483
452#else /* CS4236 */ 484#else /* CS4236 */
453 if ((err = snd_cs4236_create(card, 485 if ((err = snd_cs4236_create(card,
@@ -459,13 +491,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
459 CS4231_HW_DETECT, 491 CS4231_HW_DETECT,
460 0, 492 0,
461 &chip)) < 0) 493 &chip)) < 0)
462 goto _err; 494 return err;
495 acard->chip = chip;
463 496
464 if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) 497 if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0)
465 goto _err; 498 return err;
466 499
467 if ((err = snd_cs4236_mixer(chip)) < 0) 500 if ((err = snd_cs4236_mixer(chip)) < 0)
468 goto _err; 501 return err;
469#endif 502#endif
470 strcpy(card->driver, pcm->name); 503 strcpy(card->driver, pcm->name);
471 strcpy(card->shortname, pcm->name); 504 strcpy(card->shortname, pcm->name);
@@ -478,7 +511,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
478 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 511 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
479 512
480 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) 513 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0)
481 goto _err; 514 return err;
482 515
483 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 516 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
484 if (snd_opl3_create(card, 517 if (snd_opl3_create(card,
@@ -487,7 +520,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
487 printk(KERN_WARNING IDENT ": OPL3 not detected\n"); 520 printk(KERN_WARNING IDENT ": OPL3 not detected\n");
488 } else { 521 } else {
489 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) 522 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
490 goto _err; 523 return err;
491 } 524 }
492 } 525 }
493 526
@@ -501,95 +534,279 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
501 printk(KERN_WARNING IDENT ": MPU401 not detected\n"); 534 printk(KERN_WARNING IDENT ": MPU401 not detected\n");
502 } 535 }
503 536
504 if ((err = snd_card_set_generic_dev(card)) < 0) 537 return snd_card_register(card);
505 goto _err; 538}
506 539
507 if ((err = snd_card_register(card)) < 0) 540static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev)
508 goto _err; 541{
509 if (pcard) 542 int dev = pdev->id;
510 pnp_set_card_drvdata(pcard, card); 543 struct snd_card *card;
511 else 544 int err;
512 snd_cs4236_legacy[dev] = card; 545
546 if (port[dev] == SNDRV_AUTO_PORT) {
547 snd_printk(KERN_ERR "specify port\n");
548 return -EINVAL;
549 }
550 if (cport[dev] == SNDRV_AUTO_PORT) {
551 snd_printk(KERN_ERR "specify cport\n");
552 return -EINVAL;
553 }
554
555 card = snd_cs423x_card_new(dev);
556 if (! card)
557 return -ENOMEM;
558 snd_card_set_dev(card, &pdev->dev);
559 if ((err = snd_cs423x_probe(card, dev)) < 0) {
560 snd_card_free(card);
561 return err;
562 }
563
564 platform_set_drvdata(pdev, card);
513 return 0; 565 return 0;
566}
514 567
515 _err: 568static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr)
516 snd_card_free(card); 569{
517 return err; 570 snd_card_free(platform_get_drvdata(devptr));
571 platform_set_drvdata(devptr, NULL);
572 return 0;
518} 573}
519 574
575#ifdef CONFIG_PM
576static int snd_cs423x_suspend(struct snd_card *card)
577{
578 struct snd_card_cs4236 *acard = card->private_data;
579 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
580 acard->chip->suspend(acard->chip);
581 return 0;
582}
583
584static int snd_cs423x_resume(struct snd_card *card)
585{
586 struct snd_card_cs4236 *acard = card->private_data;
587 acard->chip->resume(acard->chip);
588 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
589 return 0;
590}
591
592static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state)
593{
594 return snd_cs423x_suspend(platform_get_drvdata(dev));
595}
596
597static int snd_cs423x_nonpnp_resume(struct platform_device *dev)
598{
599 return snd_cs423x_resume(platform_get_drvdata(dev));
600}
601#endif
602
603static struct platform_driver cs423x_nonpnp_driver = {
604 .probe = snd_cs423x_nonpnp_probe,
605 .remove = __devexit_p(snd_cs423x_nonpnp_remove),
606#ifdef CONFIG_PM
607 .suspend = snd_cs423x_nonpnp_suspend,
608 .resume = snd_cs423x_nonpnp_resume,
609#endif
610 .driver = {
611 .name = CS423X_DRIVER
612 },
613};
614
615
520#ifdef CONFIG_PNP 616#ifdef CONFIG_PNP
521static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card, 617#ifdef CS4232
522 const struct pnp_card_device_id *id) 618static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
619 const struct pnp_device_id *id)
523{ 620{
524 static int dev; 621 static int dev;
622 int err;
623 struct snd_card *card;
624
625 if (pnp_device_is_isapnp(pdev))
626 return -ENOENT; /* we have another procedure - card */
627 for (; dev < SNDRV_CARDS; dev++) {
628 if (enable[dev] && isapnp[dev])
629 break;
630 }
631 if (dev >= SNDRV_CARDS)
632 return -ENODEV;
633
634 card = snd_cs423x_card_new(dev);
635 if (! card)
636 return -ENOMEM;
637 if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) {
638 printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n");
639 snd_card_free(card);
640 return err;
641 }
642 snd_card_set_dev(card, &pdev->dev);
643 if ((err = snd_cs423x_probe(card, dev)) < 0) {
644 snd_card_free(card);
645 return err;
646 }
647 pnp_set_drvdata(pdev, card);
648 dev++;
649 return 0;
650}
651
652static void __devexit snd_cs4232_pnp_remove(struct pnp_dev * pdev)
653{
654 snd_card_free(pnp_get_drvdata(pdev));
655 pnp_set_drvdata(pdev, NULL);
656}
657
658#ifdef CONFIG_PM
659static int snd_cs4232_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
660{
661 return snd_cs423x_suspend(pnp_get_drvdata(pdev));
662}
663
664static int snd_cs4232_pnp_resume(struct pnp_dev *pdev)
665{
666 return snd_cs423x_resume(pnp_get_drvdata(pdev));
667}
668#endif
669
670static struct pnp_driver cs4232_pnp_driver = {
671 .name = "cs4232-pnpbios",
672 .id_table = snd_cs4232_pnpbiosids,
673 .probe = snd_cs4232_pnpbios_detect,
674 .remove = __devexit_p(snd_cs4232_pnp_remove),
675#ifdef CONFIG_PM
676 .suspend = snd_cs4232_pnp_suspend,
677 .resume = snd_cs4232_pnp_resume,
678#endif
679};
680#endif /* CS4232 */
681
682static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
683 const struct pnp_card_device_id *pid)
684{
685 static int dev;
686 struct snd_card *card;
525 int res; 687 int res;
526 688
527 for ( ; dev < SNDRV_CARDS; dev++) { 689 for ( ; dev < SNDRV_CARDS; dev++) {
528 if (!enable[dev] || !isapnp[dev]) 690 if (enable[dev] && isapnp[dev])
529 continue; 691 break;
530 res = snd_card_cs423x_probe(dev, card, id); 692 }
531 if (res < 0) 693 if (dev >= SNDRV_CARDS)
532 return res; 694 return -ENODEV;
533 dev++; 695
534 return 0; 696 card = snd_cs423x_card_new(dev);
697 if (! card)
698 return -ENOMEM;
699 if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) {
700 printk(KERN_ERR "isapnp detection failed and probing for " IDENT
701 " is not supported\n");
702 snd_card_free(card);
703 return res;
704 }
705 snd_card_set_dev(card, &pcard->card->dev);
706 if ((res = snd_cs423x_probe(card, dev)) < 0) {
707 snd_card_free(card);
708 return res;
535 } 709 }
536 return -ENODEV; 710 pnp_set_card_drvdata(pcard, card);
711 dev++;
712 return 0;
537} 713}
538 714
539static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) 715static void __devexit snd_cs423x_pnpc_remove(struct pnp_card_link * pcard)
540{ 716{
541 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 717 snd_card_free(pnp_get_card_drvdata(pcard));
542 718 pnp_set_card_drvdata(pcard, NULL);
543 snd_card_disconnect(card);
544 snd_card_free_in_thread(card);
545} 719}
546 720
721#ifdef CONFIG_PM
722static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state)
723{
724 return snd_cs423x_suspend(pnp_get_card_drvdata(pcard));
725}
726
727static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard)
728{
729 return snd_cs423x_resume(pnp_get_card_drvdata(pcard));
730}
731#endif
732
547static struct pnp_card_driver cs423x_pnpc_driver = { 733static struct pnp_card_driver cs423x_pnpc_driver = {
548 .flags = PNP_DRIVER_RES_DISABLE, 734 .flags = PNP_DRIVER_RES_DISABLE,
549 .name = "cs423x", 735 .name = CS423X_ISAPNP_DRIVER,
550 .id_table = snd_cs423x_pnpids, 736 .id_table = snd_cs423x_pnpids,
551 .probe = snd_cs423x_pnp_detect, 737 .probe = snd_cs423x_pnpc_detect,
552 .remove = __devexit_p(snd_cs423x_pnp_remove), 738 .remove = __devexit_p(snd_cs423x_pnpc_remove),
739#ifdef CONFIG_PM
740 .suspend = snd_cs423x_pnpc_suspend,
741 .resume = snd_cs423x_pnpc_resume,
742#endif
553}; 743};
554#endif /* CONFIG_PNP */ 744#endif /* CONFIG_PNP */
555 745
746static void __init_or_module snd_cs423x_unregister_all(void)
747{
748 int i;
749
750 if (pnpc_registered)
751 pnp_unregister_card_driver(&cs423x_pnpc_driver);
752#ifdef CS4232
753 if (pnp_registered)
754 pnp_unregister_driver(&cs4232_pnp_driver);
755#endif
756 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
757 platform_device_unregister(platform_devices[i]);
758 platform_driver_unregister(&cs423x_nonpnp_driver);
759}
760
556static int __init alsa_card_cs423x_init(void) 761static int __init alsa_card_cs423x_init(void)
557{ 762{
558 int dev, cards = 0; 763 int i, err, cards = 0;
559 764
560 for (dev = 0; dev < SNDRV_CARDS; dev++) { 765 if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0)
561 if (!enable[dev]) 766 return err;
562 continue; 767
563 if (is_isapnp_selected(dev)) 768 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
769 struct platform_device *device;
770 if (is_isapnp_selected(i))
564 continue; 771 continue;
565 if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) 772 device = platform_device_register_simple(CS423X_DRIVER,
566 cards++; 773 i, NULL, 0);
774 if (IS_ERR(device)) {
775 err = PTR_ERR(device);
776 goto errout;
777 }
778 platform_devices[i] = device;
779 cards++;
780 }
781#ifdef CS4232
782 i = pnp_register_driver(&cs4232_pnp_driver);
783 if (i >= 0) {
784 pnp_registered = 1;
785 cards += i;
567 } 786 }
568#ifdef CONFIG_PNP
569 cards += pnp_register_card_driver(&cs423x_pnpc_driver);
570#endif 787#endif
788 i = pnp_register_card_driver(&cs423x_pnpc_driver);
789 if (i >= 0) {
790 pnpc_registered = 1;
791 cards += i;
792 }
571 if (!cards) { 793 if (!cards) {
572#ifdef CONFIG_PNP
573 pnp_unregister_card_driver(&cs423x_pnpc_driver);
574#endif
575#ifdef MODULE 794#ifdef MODULE
576 printk(KERN_ERR IDENT " soundcard not found or device busy\n"); 795 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
577#endif 796#endif
578 return -ENODEV; 797 err = -ENODEV;
798 goto errout;
579 } 799 }
580 return 0; 800 return 0;
801
802 errout:
803 snd_cs423x_unregister_all();
804 return err;
581} 805}
582 806
583static void __exit alsa_card_cs423x_exit(void) 807static void __exit alsa_card_cs423x_exit(void)
584{ 808{
585 int idx; 809 snd_cs423x_unregister_all();
586
587#ifdef CONFIG_PNP
588 /* PnP cards first */
589 pnp_unregister_card_driver(&cs423x_pnpc_driver);
590#endif
591 for (idx = 0; idx < SNDRV_CARDS; idx++)
592 snd_card_free(snd_cs4236_legacy[idx]);
593} 810}
594 811
595module_init(alsa_card_cs423x_init) 812module_init(alsa_card_cs423x_init)
diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c
index 1adb88d5f8f4..e36981d64ec5 100644
--- a/sound/isa/cs423x/cs4236_lib.c
+++ b/sound/isa/cs423x/cs4236_lib.c
@@ -122,13 +122,13 @@ static unsigned char snd_cs4236_ext_map[18] = {
122 * 122 *
123 */ 123 */
124 124
125static void snd_cs4236_ctrl_out(cs4231_t *chip, unsigned char reg, unsigned char val) 125static void snd_cs4236_ctrl_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val)
126{ 126{
127 outb(reg, chip->cport + 3); 127 outb(reg, chip->cport + 3);
128 outb(chip->cimage[reg] = val, chip->cport + 4); 128 outb(chip->cimage[reg] = val, chip->cport + 4);
129} 129}
130 130
131static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg) 131static unsigned char snd_cs4236_ctrl_in(struct snd_cs4231 *chip, unsigned char reg)
132{ 132{
133 outb(reg, chip->cport + 3); 133 outb(reg, chip->cport + 3);
134 return inb(chip->cport + 4); 134 return inb(chip->cport + 4);
@@ -140,7 +140,7 @@ static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg)
140 140
141#define CLOCKS 8 141#define CLOCKS 8
142 142
143static ratnum_t clocks[CLOCKS] = { 143static struct snd_ratnum clocks[CLOCKS] = {
144 { .num = 16934400, .den_min = 353, .den_max = 353, .den_step = 1 }, 144 { .num = 16934400, .den_min = 353, .den_max = 353, .den_step = 1 },
145 { .num = 16934400, .den_min = 529, .den_max = 529, .den_step = 1 }, 145 { .num = 16934400, .den_min = 529, .den_max = 529, .den_step = 1 },
146 { .num = 16934400, .den_min = 617, .den_max = 617, .den_step = 1 }, 146 { .num = 16934400, .den_min = 617, .den_max = 617, .den_step = 1 },
@@ -151,12 +151,12 @@ static ratnum_t clocks[CLOCKS] = {
151 { .num = 16934400/16, .den_min = 21, .den_max = 192, .den_step = 1 } 151 { .num = 16934400/16, .den_min = 21, .den_max = 192, .den_step = 1 }
152}; 152};
153 153
154static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { 154static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
155 .nrats = CLOCKS, 155 .nrats = CLOCKS,
156 .rats = clocks, 156 .rats = clocks,
157}; 157};
158 158
159static int snd_cs4236_xrate(snd_pcm_runtime_t *runtime) 159static int snd_cs4236_xrate(struct snd_pcm_runtime *runtime)
160{ 160{
161 return snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 161 return snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
162 &hw_constraints_clocks); 162 &hw_constraints_clocks);
@@ -181,7 +181,7 @@ static unsigned char divisor_to_rate_register(unsigned int divisor)
181 } 181 }
182} 182}
183 183
184static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char pdfr) 184static void snd_cs4236_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr)
185{ 185{
186 unsigned long flags; 186 unsigned long flags;
187 unsigned char rate = divisor_to_rate_register(params->rate_den); 187 unsigned char rate = divisor_to_rate_register(params->rate_den);
@@ -195,7 +195,7 @@ static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *para
195 spin_unlock_irqrestore(&chip->reg_lock, flags); 195 spin_unlock_irqrestore(&chip->reg_lock, flags);
196} 196}
197 197
198static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char cdfr) 198static void snd_cs4236_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr)
199{ 199{
200 unsigned long flags; 200 unsigned long flags;
201 unsigned char rate = divisor_to_rate_register(params->rate_den); 201 unsigned char rate = divisor_to_rate_register(params->rate_den);
@@ -211,7 +211,7 @@ static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *param
211 211
212#ifdef CONFIG_PM 212#ifdef CONFIG_PM
213 213
214static void snd_cs4236_suspend(cs4231_t *chip) 214static void snd_cs4236_suspend(struct snd_cs4231 *chip)
215{ 215{
216 int reg; 216 int reg;
217 unsigned long flags; 217 unsigned long flags;
@@ -226,7 +226,7 @@ static void snd_cs4236_suspend(cs4231_t *chip)
226 spin_unlock_irqrestore(&chip->reg_lock, flags); 226 spin_unlock_irqrestore(&chip->reg_lock, flags);
227} 227}
228 228
229static void snd_cs4236_resume(cs4231_t *chip) 229static void snd_cs4236_resume(struct snd_cs4231 *chip)
230{ 230{
231 int reg; 231 int reg;
232 unsigned long flags; 232 unsigned long flags;
@@ -261,15 +261,15 @@ static void snd_cs4236_resume(cs4231_t *chip)
261 261
262#endif /* CONFIG_PM */ 262#endif /* CONFIG_PM */
263 263
264int snd_cs4236_create(snd_card_t * card, 264int snd_cs4236_create(struct snd_card *card,
265 unsigned long port, 265 unsigned long port,
266 unsigned long cport, 266 unsigned long cport,
267 int irq, int dma1, int dma2, 267 int irq, int dma1, int dma2,
268 unsigned short hardware, 268 unsigned short hardware,
269 unsigned short hwshare, 269 unsigned short hwshare,
270 cs4231_t ** rchip) 270 struct snd_cs4231 ** rchip)
271{ 271{
272 cs4231_t *chip; 272 struct snd_cs4231 *chip;
273 unsigned char ver1, ver2; 273 unsigned char ver1, ver2;
274 unsigned int reg; 274 unsigned int reg;
275 int err; 275 int err;
@@ -352,9 +352,9 @@ int snd_cs4236_create(snd_card_t * card,
352 return 0; 352 return 0;
353} 353}
354 354
355int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) 355int snd_cs4236_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm)
356{ 356{
357 snd_pcm_t *pcm; 357 struct snd_pcm *pcm;
358 int err; 358 int err;
359 359
360 if ((err = snd_cs4231_pcm(chip, device, &pcm)) < 0) 360 if ((err = snd_cs4231_pcm(chip, device, &pcm)) < 0)
@@ -375,7 +375,7 @@ int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
375 .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ 375 .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \
376 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 376 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
377 377
378static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 378static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
379{ 379{
380 int mask = (kcontrol->private_value >> 16) & 0xff; 380 int mask = (kcontrol->private_value >> 16) & 0xff;
381 381
@@ -386,9 +386,9 @@ static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
386 return 0; 386 return 0;
387} 387}
388 388
389static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 389static int snd_cs4236_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
390{ 390{
391 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 391 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
392 unsigned long flags; 392 unsigned long flags;
393 int reg = kcontrol->private_value & 0xff; 393 int reg = kcontrol->private_value & 0xff;
394 int shift = (kcontrol->private_value >> 8) & 0xff; 394 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -403,9 +403,9 @@ static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
403 return 0; 403 return 0;
404} 404}
405 405
406static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 406static int snd_cs4236_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
407{ 407{
408 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 408 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
409 unsigned long flags; 409 unsigned long flags;
410 int reg = kcontrol->private_value & 0xff; 410 int reg = kcontrol->private_value & 0xff;
411 int shift = (kcontrol->private_value >> 8) & 0xff; 411 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -432,9 +432,9 @@ static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
432 .get = snd_cs4236_get_singlec, .put = snd_cs4236_put_singlec, \ 432 .get = snd_cs4236_get_singlec, .put = snd_cs4236_put_singlec, \
433 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 433 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
434 434
435static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 435static int snd_cs4236_get_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
436{ 436{
437 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 437 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
438 unsigned long flags; 438 unsigned long flags;
439 int reg = kcontrol->private_value & 0xff; 439 int reg = kcontrol->private_value & 0xff;
440 int shift = (kcontrol->private_value >> 8) & 0xff; 440 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -449,9 +449,9 @@ static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
449 return 0; 449 return 0;
450} 450}
451 451
452static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 452static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
453{ 453{
454 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 454 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
455 unsigned long flags; 455 unsigned long flags;
456 int reg = kcontrol->private_value & 0xff; 456 int reg = kcontrol->private_value & 0xff;
457 int shift = (kcontrol->private_value >> 8) & 0xff; 457 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -478,7 +478,7 @@ static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
478 .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ 478 .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \
479 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 479 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
480 480
481static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 481static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
482{ 482{
483 int mask = (kcontrol->private_value >> 24) & 0xff; 483 int mask = (kcontrol->private_value >> 24) & 0xff;
484 484
@@ -489,9 +489,9 @@ static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
489 return 0; 489 return 0;
490} 490}
491 491
492static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 492static int snd_cs4236_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
493{ 493{
494 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 494 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
495 unsigned long flags; 495 unsigned long flags;
496 int left_reg = kcontrol->private_value & 0xff; 496 int left_reg = kcontrol->private_value & 0xff;
497 int right_reg = (kcontrol->private_value >> 8) & 0xff; 497 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -511,9 +511,9 @@ static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
511 return 0; 511 return 0;
512} 512}
513 513
514static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 514static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
515{ 515{
516 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 516 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
517 unsigned long flags; 517 unsigned long flags;
518 int left_reg = kcontrol->private_value & 0xff; 518 int left_reg = kcontrol->private_value & 0xff;
519 int right_reg = (kcontrol->private_value >> 8) & 0xff; 519 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -554,9 +554,9 @@ static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
554 .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ 554 .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \
555 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 555 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
556 556
557static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 557static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
558{ 558{
559 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 559 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
560 unsigned long flags; 560 unsigned long flags;
561 int left_reg = kcontrol->private_value & 0xff; 561 int left_reg = kcontrol->private_value & 0xff;
562 int right_reg = (kcontrol->private_value >> 8) & 0xff; 562 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -576,9 +576,9 @@ static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
576 return 0; 576 return 0;
577} 577}
578 578
579static int snd_cs4236_put_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 579static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
580{ 580{
581 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 581 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
582 unsigned long flags; 582 unsigned long flags;
583 int left_reg = kcontrol->private_value & 0xff; 583 int left_reg = kcontrol->private_value & 0xff;
584 int right_reg = (kcontrol->private_value >> 8) & 0xff; 584 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -618,9 +618,9 @@ static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol)
618 return (vol < 64) ? 63 - vol : 64 + (71 - vol); 618 return (vol < 64) ? 63 - vol : 64 + (71 - vol);
619} 619}
620 620
621static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 621static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
622{ 622{
623 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 623 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
624 unsigned long flags; 624 unsigned long flags;
625 625
626 spin_lock_irqsave(&chip->reg_lock, flags); 626 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -630,9 +630,9 @@ static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem
630 return 0; 630 return 0;
631} 631}
632 632
633static int snd_cs4236_put_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 633static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
634{ 634{
635 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 635 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
636 unsigned long flags; 636 unsigned long flags;
637 int change; 637 int change;
638 unsigned short val1, val2; 638 unsigned short val1, val2;
@@ -677,9 +677,9 @@ static inline int snd_cs4235_mixer_output_accu_set_volume(int vol)
677 return 1 << 5; 677 return 1 << 5;
678} 678}
679 679
680static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 680static int snd_cs4235_get_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
681{ 681{
682 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 682 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
683 unsigned long flags; 683 unsigned long flags;
684 684
685 spin_lock_irqsave(&chip->reg_lock, flags); 685 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -689,9 +689,9 @@ static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
689 return 0; 689 return 0;
690} 690}
691 691
692static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 692static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
693{ 693{
694 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 694 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
695 unsigned long flags; 695 unsigned long flags;
696 int change; 696 int change;
697 unsigned short val1, val2; 697 unsigned short val1, val2;
@@ -708,7 +708,7 @@ static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
708 return change; 708 return change;
709} 709}
710 710
711static snd_kcontrol_new_t snd_cs4236_controls[] = { 711static struct snd_kcontrol_new snd_cs4236_controls[] = {
712 712
713CS4236_DOUBLE("Master Digital Playback Switch", 0, CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), 713CS4236_DOUBLE("Master Digital Playback Switch", 0, CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1),
714CS4236_DOUBLE("Master Digital Capture Switch", 0, CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), 714CS4236_DOUBLE("Master Digital Capture Switch", 0, CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1),
@@ -759,7 +759,7 @@ CS4231_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0),
759CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) 759CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1)
760}; 760};
761 761
762static snd_kcontrol_new_t snd_cs4235_controls[] = { 762static struct snd_kcontrol_new snd_cs4235_controls[] = {
763 763
764CS4231_DOUBLE("Master Switch", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), 764CS4231_DOUBLE("Master Switch", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1),
765CS4231_DOUBLE("Master Volume", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), 765CS4231_DOUBLE("Master Volume", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1),
@@ -812,9 +812,9 @@ CS4231_DOUBLE("Analog Loopback Switch", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT
812 .get = snd_cs4236_get_iec958_switch, .put = snd_cs4236_put_iec958_switch, \ 812 .get = snd_cs4236_get_iec958_switch, .put = snd_cs4236_put_iec958_switch, \
813 .private_value = 1 << 16 } 813 .private_value = 1 << 16 }
814 814
815static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 815static int snd_cs4236_get_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
816{ 816{
817 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 817 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
818 unsigned long flags; 818 unsigned long flags;
819 819
820 spin_lock_irqsave(&chip->reg_lock, flags); 820 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -832,9 +832,9 @@ static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_
832 return 0; 832 return 0;
833} 833}
834 834
835static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 835static int snd_cs4236_put_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
836{ 836{
837 cs4231_t *chip = snd_kcontrol_chip(kcontrol); 837 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol);
838 unsigned long flags; 838 unsigned long flags;
839 int change; 839 int change;
840 unsigned short enable, val; 840 unsigned short enable, val;
@@ -868,7 +868,7 @@ static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_
868 return change; 868 return change;
869} 869}
870 870
871static snd_kcontrol_new_t snd_cs4236_iec958_controls[] = { 871static struct snd_kcontrol_new snd_cs4236_iec958_controls[] = {
872CS4236_IEC958_ENABLE("IEC958 Output Enable", 0), 872CS4236_IEC958_ENABLE("IEC958 Output Enable", 0),
873CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0), 873CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0),
874CS4236_SINGLEC("IEC958 Output User", 0, 4, 5, 1, 0), 874CS4236_SINGLEC("IEC958 Output User", 0, 4, 5, 1, 0),
@@ -877,12 +877,12 @@ CS4236_SINGLEC("IEC958 Output Channel Status Low", 0, 5, 1, 127, 0),
877CS4236_SINGLEC("IEC958 Output Channel Status High", 0, 6, 0, 255, 0) 877CS4236_SINGLEC("IEC958 Output Channel Status High", 0, 6, 0, 255, 0)
878}; 878};
879 879
880static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4235[] = { 880static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = {
881CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), 881CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0),
882CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1) 882CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1)
883}; 883};
884 884
885static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4237[] = { 885static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = {
886CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0), 886CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0),
887CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), 887CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1),
888CS4236_SINGLEC("3D Control - Center", 0, 2, 0, 15, 1), 888CS4236_SINGLEC("3D Control - Center", 0, 2, 0, 15, 1),
@@ -890,19 +890,19 @@ CS4236_SINGLEC("3D Control - Mono", 0, 3, 6, 1, 0),
890CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) 890CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0)
891}; 891};
892 892
893static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4238[] = { 893static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = {
894CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), 894CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0),
895CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), 895CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1),
896CS4236_SINGLEC("3D Control - Volume", 0, 2, 0, 15, 1), 896CS4236_SINGLEC("3D Control - Volume", 0, 2, 0, 15, 1),
897CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) 897CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0)
898}; 898};
899 899
900int snd_cs4236_mixer(cs4231_t *chip) 900int snd_cs4236_mixer(struct snd_cs4231 *chip)
901{ 901{
902 snd_card_t *card; 902 struct snd_card *card;
903 unsigned int idx, count; 903 unsigned int idx, count;
904 int err; 904 int err;
905 snd_kcontrol_new_t *kcontrol; 905 struct snd_kcontrol_new *kcontrol;
906 906
907 snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); 907 snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
908 card = chip->card; 908 card = chip->card;
diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c
index db7c3397b323..50e7bc5ef561 100644
--- a/sound/isa/dt019x.c
+++ b/sound/isa/dt019x.c
@@ -74,6 +74,7 @@ struct snd_card_dt019x {
74 struct pnp_dev *dev; 74 struct pnp_dev *dev;
75 struct pnp_dev *devmpu; 75 struct pnp_dev *devmpu;
76 struct pnp_dev *devopl; 76 struct pnp_dev *devopl;
77 struct snd_sb *chip;
77}; 78};
78 79
79static struct pnp_card_device_id snd_dt019x_pnpids[] = { 80static struct pnp_card_device_id snd_dt019x_pnpids[] = {
@@ -188,15 +189,15 @@ static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard,
188static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) 189static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid)
189{ 190{
190 int error; 191 int error;
191 sb_t *chip; 192 struct snd_sb *chip;
192 snd_card_t *card; 193 struct snd_card *card;
193 struct snd_card_dt019x *acard; 194 struct snd_card_dt019x *acard;
194 opl3_t *opl3; 195 struct snd_opl3 *opl3;
195 196
196 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 197 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
197 sizeof(struct snd_card_dt019x))) == NULL) 198 sizeof(struct snd_card_dt019x))) == NULL)
198 return -ENOMEM; 199 return -ENOMEM;
199 acard = (struct snd_card_dt019x *)card->private_data; 200 acard = card->private_data;
200 201
201 snd_card_set_dev(card, &pcard->card->dev); 202 snd_card_set_dev(card, &pcard->card->dev);
202 if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { 203 if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) {
@@ -214,6 +215,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard,
214 snd_card_free(card); 215 snd_card_free(card);
215 return error; 216 return error;
216 } 217 }
218 acard->chip = chip;
217 219
218 strcpy(card->driver, "DT-019X"); 220 strcpy(card->driver, "DT-019X");
219 strcpy(card->shortname, "Diamond Tech. DT-019X"); 221 strcpy(card->shortname, "Diamond Tech. DT-019X");
@@ -290,32 +292,61 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card,
290 292
291static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) 293static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard)
292{ 294{
293 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 295 snd_card_free(pnp_get_card_drvdata(pcard));
294 snd_card_disconnect(card); 296 pnp_set_card_drvdata(pcard, NULL);
295 snd_card_free_in_thread(card);
296} 297}
297 298
299#ifdef CONFIG_PM
300static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
301{
302 struct snd_card *card = pnp_get_card_drvdata(pcard);
303 struct snd_card_dt019x *acard = card->private_data;
304 struct snd_sb *chip = acard->chip;
305
306 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
307 snd_pcm_suspend_all(chip->pcm);
308 snd_sbmixer_suspend(chip);
309 return 0;
310}
311
312static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard)
313{
314 struct snd_card *card = pnp_get_card_drvdata(pcard);
315 struct snd_card_dt019x *acard = card->private_data;
316 struct snd_sb *chip = acard->chip;
317
318 snd_sbdsp_reset(chip);
319 snd_sbmixer_resume(chip);
320 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
321 return 0;
322}
323#endif
324
298static struct pnp_card_driver dt019x_pnpc_driver = { 325static struct pnp_card_driver dt019x_pnpc_driver = {
299 .flags = PNP_DRIVER_RES_DISABLE, 326 .flags = PNP_DRIVER_RES_DISABLE,
300 .name = "dt019x", 327 .name = "dt019x",
301 .id_table = snd_dt019x_pnpids, 328 .id_table = snd_dt019x_pnpids,
302 .probe = snd_dt019x_pnp_probe, 329 .probe = snd_dt019x_pnp_probe,
303 .remove = __devexit_p(snd_dt019x_pnp_remove), 330 .remove = __devexit_p(snd_dt019x_pnp_remove),
331#ifdef CONFIG_PM
332 .suspend = snd_dt019x_pnp_suspend,
333 .resume = snd_dt019x_pnp_resume,
334#endif
304}; 335};
305 336
306static int __init alsa_card_dt019x_init(void) 337static int __init alsa_card_dt019x_init(void)
307{ 338{
308 int cards = 0; 339 int cards = 0;
309 340
310 cards += pnp_register_card_driver(&dt019x_pnpc_driver); 341 cards = pnp_register_card_driver(&dt019x_pnpc_driver);
311 342 if (cards <= 0) {
312#ifdef MODULE
313 if (!cards) {
314 pnp_unregister_card_driver(&dt019x_pnpc_driver); 343 pnp_unregister_card_driver(&dt019x_pnpc_driver);
344#ifdef MODULE
315 snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); 345 snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n");
316 }
317#endif 346#endif
318 return cards ? 0 : -ENODEV; 347 return -ENODEV;
348 }
349 return 0;
319} 350}
320 351
321static void __exit alsa_card_dt019x_exit(void) 352static void __exit alsa_card_dt019x_exit(void)
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 26a7d335ed8e..50d23cf3d7cc 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -20,16 +20,17 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <asm/dma.h>
24#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
25#include <linux/time.h> 26#include <linux/time.h>
26#include <linux/wait.h> 27#include <linux/wait.h>
27#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <asm/dma.h>
28#include <sound/core.h> 30#include <sound/core.h>
29#include <sound/es1688.h> 31#include <sound/es1688.h>
30#include <sound/mpu401.h> 32#include <sound/mpu401.h>
31#include <sound/opl3.h> 33#include <sound/opl3.h>
32#define SNDRV_LEGACY_AUTO_PROBE
33#define SNDRV_LEGACY_FIND_FREE_IRQ 34#define SNDRV_LEGACY_FIND_FREE_IRQ
34#define SNDRV_LEGACY_FIND_FREE_DMA 35#define SNDRV_LEGACY_FIND_FREE_DMA
35#include <sound/initval.h> 36#include <sound/initval.h>
@@ -68,19 +69,20 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver.");
68module_param_array(dma8, int, NULL, 0444); 69module_param_array(dma8, int, NULL, 0444);
69MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); 70MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver.");
70 71
71static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 72static struct platform_device *devices[SNDRV_CARDS];
72 73
73#define PFX "es1688: " 74#define PFX "es1688: "
74 75
75static int __init snd_audiodrive_probe(int dev) 76static int __init snd_es1688_probe(struct platform_device *pdev)
76{ 77{
78 int dev = pdev->id;
77 static int possible_irqs[] = {5, 9, 10, 7, -1}; 79 static int possible_irqs[] = {5, 9, 10, 7, -1};
78 static int possible_dmas[] = {1, 3, 0, -1}; 80 static int possible_dmas[] = {1, 3, 0, -1};
79 int xirq, xdma, xmpu_irq; 81 int xirq, xdma, xmpu_irq;
80 snd_card_t *card; 82 struct snd_card *card;
81 es1688_t *chip; 83 struct snd_es1688 *chip;
82 opl3_t *opl3; 84 struct snd_opl3 *opl3;
83 snd_pcm_t *pcm; 85 struct snd_pcm *pcm;
84 int err; 86 int err;
85 87
86 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 88 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
@@ -105,10 +107,30 @@ static int __init snd_audiodrive_probe(int dev)
105 } 107 }
106 } 108 }
107 109
108 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], 110 if (port[dev] != SNDRV_AUTO_PORT) {
109 xirq, xmpu_irq, xdma, 111 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev],
110 ES1688_HW_AUTO, &chip)) < 0) 112 xirq, xmpu_irq, xdma,
111 goto _err; 113 ES1688_HW_AUTO, &chip)) < 0)
114 goto _err;
115 } else {
116 /* auto-probe legacy ports */
117 static unsigned long possible_ports[] = {
118 0x220, 0x240, 0x260,
119 };
120 int i;
121 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
122 err = snd_es1688_create(card, possible_ports[i],
123 mpu_port[dev],
124 xirq, xmpu_irq, xdma,
125 ES1688_HW_AUTO, &chip);
126 if (err >= 0) {
127 port[dev] = possible_ports[i];
128 break;
129 }
130 }
131 if (i >= ARRAY_SIZE(possible_ports))
132 goto _err;
133 }
112 134
113 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) 135 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0)
114 goto _err; 136 goto _err;
@@ -136,13 +158,12 @@ static int __init snd_audiodrive_probe(int dev)
136 goto _err; 158 goto _err;
137 } 159 }
138 160
139 if ((err = snd_card_set_generic_dev(card)) < 0) 161 snd_card_set_dev(card, &pdev->dev);
140 goto _err;
141 162
142 if ((err = snd_card_register(card)) < 0) 163 if ((err = snd_card_register(card)) < 0)
143 goto _err; 164 goto _err;
144 165
145 snd_audiodrive_cards[dev] = card; 166 platform_set_drvdata(pdev, card);
146 return 0; 167 return 0;
147 168
148 _err: 169 _err:
@@ -150,53 +171,70 @@ static int __init snd_audiodrive_probe(int dev)
150 return err; 171 return err;
151} 172}
152 173
153static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport) 174static int snd_es1688_remove(struct platform_device *devptr)
154{ 175{
155 static int dev; 176 snd_card_free(platform_get_drvdata(devptr));
156 int res; 177 platform_set_drvdata(devptr, NULL);
157 178 return 0;
158 for ( ; dev < SNDRV_CARDS; dev++) { 179}
159 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 180
160 continue; 181#define ES1688_DRIVER "snd_es1688"
161 port[dev] = xport; 182
162 res = snd_audiodrive_probe(dev); 183static struct platform_driver snd_es1688_driver = {
163 if (res < 0) 184 .probe = snd_es1688_probe,
164 port[dev] = SNDRV_AUTO_PORT; 185 .remove = snd_es1688_remove,
165 return res; 186 /* FIXME: suspend/resume */
166 } 187 .driver = {
167 return -ENODEV; 188 .name = ES1688_DRIVER
189 },
190};
191
192static void __init_or_module snd_es1688_unregister_all(void)
193{
194 int i;
195
196 for (i = 0; i < ARRAY_SIZE(devices); ++i)
197 platform_device_unregister(devices[i]);
198 platform_driver_unregister(&snd_es1688_driver);
168} 199}
169 200
170static int __init alsa_card_es1688_init(void) 201static int __init alsa_card_es1688_init(void)
171{ 202{
172 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; 203 int i, cards, err;
173 int dev, cards = 0, i; 204
174 205 err = platform_driver_register(&snd_es1688_driver);
175 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { 206 if (err < 0)
176 if (port[dev] == SNDRV_AUTO_PORT) 207 return err;
177 continue; 208
178 if (snd_audiodrive_probe(dev) >= 0) 209 cards = 0;
179 cards++; 210 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
211 struct platform_device *device;
212 device = platform_device_register_simple(ES1688_DRIVER,
213 i, NULL, 0);
214 if (IS_ERR(device)) {
215 err = PTR_ERR(device);
216 goto errout;
217 }
218 devices[i] = device;
219 cards++;
180 } 220 }
181 i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_legacy_auto_probe);
182 if (i > 0)
183 cards += i;
184
185 if (!cards) { 221 if (!cards) {
186#ifdef MODULE 222#ifdef MODULE
187 printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n"); 223 printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n");
188#endif 224#endif
189 return -ENODEV; 225 err = -ENODEV;
226 goto errout;
190 } 227 }
191 return 0; 228 return 0;
229
230 errout:
231 snd_es1688_unregister_all();
232 return err;
192} 233}
193 234
194static void __exit alsa_card_es1688_exit(void) 235static void __exit alsa_card_es1688_exit(void)
195{ 236{
196 int idx; 237 snd_es1688_unregister_all();
197
198 for (idx = 0; idx < SNDRV_CARDS; idx++)
199 snd_card_free(snd_audiodrive_cards[idx]);
200} 238}
201 239
202module_init(alsa_card_es1688_init) 240module_init(alsa_card_es1688_init)
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 2edc9c9f0445..702ad51ee9d5 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -36,7 +36,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("ESS ESx688 lowlevel module"); 36MODULE_DESCRIPTION("ESS ESx688 lowlevel module");
37MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
38 38
39static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val) 39static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val)
40{ 40{
41 int i; 41 int i;
42 42
@@ -51,7 +51,7 @@ static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val)
51 return 0; 51 return 0;
52} 52}
53 53
54static int snd_es1688_dsp_get_byte(es1688_t *chip) 54static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip)
55{ 55{
56 int i; 56 int i;
57 57
@@ -62,7 +62,7 @@ static int snd_es1688_dsp_get_byte(es1688_t *chip)
62 return -ENODEV; 62 return -ENODEV;
63} 63}
64 64
65static int snd_es1688_write(es1688_t *chip, 65static int snd_es1688_write(struct snd_es1688 *chip,
66 unsigned char reg, unsigned char data) 66 unsigned char reg, unsigned char data)
67{ 67{
68 if (!snd_es1688_dsp_command(chip, reg)) 68 if (!snd_es1688_dsp_command(chip, reg))
@@ -70,7 +70,7 @@ static int snd_es1688_write(es1688_t *chip,
70 return snd_es1688_dsp_command(chip, data); 70 return snd_es1688_dsp_command(chip, data);
71} 71}
72 72
73static int snd_es1688_read(es1688_t *chip, unsigned char reg) 73static int snd_es1688_read(struct snd_es1688 *chip, unsigned char reg)
74{ 74{
75 /* Read a byte from an extended mode register of ES1688 */ 75 /* Read a byte from an extended mode register of ES1688 */
76 if (!snd_es1688_dsp_command(chip, 0xc0)) 76 if (!snd_es1688_dsp_command(chip, 0xc0))
@@ -80,7 +80,7 @@ static int snd_es1688_read(es1688_t *chip, unsigned char reg)
80 return snd_es1688_dsp_get_byte(chip); 80 return snd_es1688_dsp_get_byte(chip);
81} 81}
82 82
83void snd_es1688_mixer_write(es1688_t *chip, 83void snd_es1688_mixer_write(struct snd_es1688 *chip,
84 unsigned char reg, unsigned char data) 84 unsigned char reg, unsigned char data)
85{ 85{
86 outb(reg, ES1688P(chip, MIXER_ADDR)); 86 outb(reg, ES1688P(chip, MIXER_ADDR));
@@ -89,7 +89,7 @@ void snd_es1688_mixer_write(es1688_t *chip,
89 udelay(10); 89 udelay(10);
90} 90}
91 91
92static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg) 92static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned char reg)
93{ 93{
94 unsigned char result; 94 unsigned char result;
95 95
@@ -100,7 +100,7 @@ static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg)
100 return result; 100 return result;
101} 101}
102 102
103static int snd_es1688_reset(es1688_t *chip) 103static int snd_es1688_reset(struct snd_es1688 *chip)
104{ 104{
105 int i; 105 int i;
106 106
@@ -117,7 +117,7 @@ static int snd_es1688_reset(es1688_t *chip)
117 return 0; 117 return 0;
118} 118}
119 119
120static int snd_es1688_probe(es1688_t *chip) 120static int snd_es1688_probe(struct snd_es1688 *chip)
121{ 121{
122 unsigned long flags; 122 unsigned long flags;
123 unsigned short major, minor, hw; 123 unsigned short major, minor, hw;
@@ -191,7 +191,7 @@ static int snd_es1688_probe(es1688_t *chip)
191 return 0; 191 return 0;
192} 192}
193 193
194static int snd_es1688_init(es1688_t * chip, int enable) 194static int snd_es1688_init(struct snd_es1688 * chip, int enable)
195{ 195{
196 static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; 196 static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1};
197 unsigned long flags; 197 unsigned long flags;
@@ -283,7 +283,7 @@ static int snd_es1688_init(es1688_t * chip, int enable)
283 283
284 */ 284 */
285 285
286static ratnum_t clocks[2] = { 286static struct snd_ratnum clocks[2] = {
287 { 287 {
288 .num = 795444, 288 .num = 795444,
289 .den_min = 1, 289 .den_min = 1,
@@ -298,14 +298,14 @@ static ratnum_t clocks[2] = {
298 } 298 }
299}; 299};
300 300
301static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { 301static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
302 .nrats = 2, 302 .nrats = 2,
303 .rats = clocks, 303 .rats = clocks,
304}; 304};
305 305
306static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream) 306static void snd_es1688_set_rate(struct snd_es1688 *chip, struct snd_pcm_substream *substream)
307{ 307{
308 snd_pcm_runtime_t *runtime = substream->runtime; 308 struct snd_pcm_runtime *runtime = substream->runtime;
309 unsigned int bits, divider; 309 unsigned int bits, divider;
310 310
311 if (runtime->rate_num == clocks[0].num) 311 if (runtime->rate_num == clocks[0].num)
@@ -319,13 +319,13 @@ static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream)
319 snd_es1688_write(chip, 0xa2, divider); 319 snd_es1688_write(chip, 0xa2, divider);
320} 320}
321 321
322static int snd_es1688_ioctl(snd_pcm_substream_t * substream, 322static int snd_es1688_ioctl(struct snd_pcm_substream *substream,
323 unsigned int cmd, void *arg) 323 unsigned int cmd, void *arg)
324{ 324{
325 return snd_pcm_lib_ioctl(substream, cmd, arg); 325 return snd_pcm_lib_ioctl(substream, cmd, arg);
326} 326}
327 327
328static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value) 328static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value)
329{ 329{
330 int val; 330 int val;
331 331
@@ -350,22 +350,22 @@ static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value)
350 return 0; 350 return 0;
351} 351}
352 352
353static int snd_es1688_hw_params(snd_pcm_substream_t * substream, 353static int snd_es1688_hw_params(struct snd_pcm_substream *substream,
354 snd_pcm_hw_params_t * hw_params) 354 struct snd_pcm_hw_params *hw_params)
355{ 355{
356 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 356 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
357} 357}
358 358
359static int snd_es1688_hw_free(snd_pcm_substream_t * substream) 359static int snd_es1688_hw_free(struct snd_pcm_substream *substream)
360{ 360{
361 return snd_pcm_lib_free_pages(substream); 361 return snd_pcm_lib_free_pages(substream);
362} 362}
363 363
364static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream) 364static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream)
365{ 365{
366 unsigned long flags; 366 unsigned long flags;
367 es1688_t *chip = snd_pcm_substream_chip(substream); 367 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
368 snd_pcm_runtime_t *runtime = substream->runtime; 368 struct snd_pcm_runtime *runtime = substream->runtime;
369 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 369 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
370 unsigned int count = snd_pcm_lib_period_bytes(substream); 370 unsigned int count = snd_pcm_lib_period_bytes(substream);
371 371
@@ -415,18 +415,18 @@ static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream)
415 return 0; 415 return 0;
416} 416}
417 417
418static int snd_es1688_playback_trigger(snd_pcm_substream_t * substream, 418static int snd_es1688_playback_trigger(struct snd_pcm_substream *substream,
419 int cmd) 419 int cmd)
420{ 420{
421 es1688_t *chip = snd_pcm_substream_chip(substream); 421 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
422 return snd_es1688_trigger(chip, cmd, 0x05); 422 return snd_es1688_trigger(chip, cmd, 0x05);
423} 423}
424 424
425static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream) 425static int snd_es1688_capture_prepare(struct snd_pcm_substream *substream)
426{ 426{
427 unsigned long flags; 427 unsigned long flags;
428 es1688_t *chip = snd_pcm_substream_chip(substream); 428 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
429 snd_pcm_runtime_t *runtime = substream->runtime; 429 struct snd_pcm_runtime *runtime = substream->runtime;
430 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 430 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
431 unsigned int count = snd_pcm_lib_period_bytes(substream); 431 unsigned int count = snd_pcm_lib_period_bytes(substream);
432 432
@@ -472,16 +472,16 @@ static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream)
472 return 0; 472 return 0;
473} 473}
474 474
475static int snd_es1688_capture_trigger(snd_pcm_substream_t * substream, 475static int snd_es1688_capture_trigger(struct snd_pcm_substream *substream,
476 int cmd) 476 int cmd)
477{ 477{
478 es1688_t *chip = snd_pcm_substream_chip(substream); 478 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
479 return snd_es1688_trigger(chip, cmd, 0x0f); 479 return snd_es1688_trigger(chip, cmd, 0x0f);
480} 480}
481 481
482static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs) 482static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs)
483{ 483{
484 es1688_t *chip = dev_id; 484 struct snd_es1688 *chip = dev_id;
485 485
486 if (chip->trigger_value == 0x05) /* ok.. playback is active */ 486 if (chip->trigger_value == 0x05) /* ok.. playback is active */
487 snd_pcm_period_elapsed(chip->playback_substream); 487 snd_pcm_period_elapsed(chip->playback_substream);
@@ -492,9 +492,9 @@ static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *r
492 return IRQ_HANDLED; 492 return IRQ_HANDLED;
493} 493}
494 494
495static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * substream) 495static snd_pcm_uframes_t snd_es1688_playback_pointer(struct snd_pcm_substream *substream)
496{ 496{
497 es1688_t *chip = snd_pcm_substream_chip(substream); 497 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
498 size_t ptr; 498 size_t ptr;
499 499
500 if (chip->trigger_value != 0x05) 500 if (chip->trigger_value != 0x05)
@@ -503,9 +503,9 @@ static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * subst
503 return bytes_to_frames(substream->runtime, ptr); 503 return bytes_to_frames(substream->runtime, ptr);
504} 504}
505 505
506static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substream) 506static snd_pcm_uframes_t snd_es1688_capture_pointer(struct snd_pcm_substream *substream)
507{ 507{
508 es1688_t *chip = snd_pcm_substream_chip(substream); 508 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
509 size_t ptr; 509 size_t ptr;
510 510
511 if (chip->trigger_value != 0x0f) 511 if (chip->trigger_value != 0x0f)
@@ -518,7 +518,7 @@ static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substr
518 518
519 */ 519 */
520 520
521static snd_pcm_hardware_t snd_es1688_playback = 521static struct snd_pcm_hardware snd_es1688_playback =
522{ 522{
523 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 523 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
524 SNDRV_PCM_INFO_MMAP_VALID), 524 SNDRV_PCM_INFO_MMAP_VALID),
@@ -536,7 +536,7 @@ static snd_pcm_hardware_t snd_es1688_playback =
536 .fifo_size = 0, 536 .fifo_size = 0,
537}; 537};
538 538
539static snd_pcm_hardware_t snd_es1688_capture = 539static struct snd_pcm_hardware snd_es1688_capture =
540{ 540{
541 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 541 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
542 SNDRV_PCM_INFO_MMAP_VALID), 542 SNDRV_PCM_INFO_MMAP_VALID),
@@ -558,10 +558,10 @@ static snd_pcm_hardware_t snd_es1688_capture =
558 558
559 */ 559 */
560 560
561static int snd_es1688_playback_open(snd_pcm_substream_t * substream) 561static int snd_es1688_playback_open(struct snd_pcm_substream *substream)
562{ 562{
563 es1688_t *chip = snd_pcm_substream_chip(substream); 563 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
564 snd_pcm_runtime_t *runtime = substream->runtime; 564 struct snd_pcm_runtime *runtime = substream->runtime;
565 565
566 if (chip->capture_substream != NULL) 566 if (chip->capture_substream != NULL)
567 return -EAGAIN; 567 return -EAGAIN;
@@ -572,10 +572,10 @@ static int snd_es1688_playback_open(snd_pcm_substream_t * substream)
572 return 0; 572 return 0;
573} 573}
574 574
575static int snd_es1688_capture_open(snd_pcm_substream_t * substream) 575static int snd_es1688_capture_open(struct snd_pcm_substream *substream)
576{ 576{
577 es1688_t *chip = snd_pcm_substream_chip(substream); 577 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
578 snd_pcm_runtime_t *runtime = substream->runtime; 578 struct snd_pcm_runtime *runtime = substream->runtime;
579 579
580 if (chip->playback_substream != NULL) 580 if (chip->playback_substream != NULL)
581 return -EAGAIN; 581 return -EAGAIN;
@@ -586,23 +586,23 @@ static int snd_es1688_capture_open(snd_pcm_substream_t * substream)
586 return 0; 586 return 0;
587} 587}
588 588
589static int snd_es1688_playback_close(snd_pcm_substream_t * substream) 589static int snd_es1688_playback_close(struct snd_pcm_substream *substream)
590{ 590{
591 es1688_t *chip = snd_pcm_substream_chip(substream); 591 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
592 592
593 chip->playback_substream = NULL; 593 chip->playback_substream = NULL;
594 return 0; 594 return 0;
595} 595}
596 596
597static int snd_es1688_capture_close(snd_pcm_substream_t * substream) 597static int snd_es1688_capture_close(struct snd_pcm_substream *substream)
598{ 598{
599 es1688_t *chip = snd_pcm_substream_chip(substream); 599 struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
600 600
601 chip->capture_substream = NULL; 601 chip->capture_substream = NULL;
602 return 0; 602 return 0;
603} 603}
604 604
605static int snd_es1688_free(es1688_t *chip) 605static int snd_es1688_free(struct snd_es1688 *chip)
606{ 606{
607 if (chip->res_port) { 607 if (chip->res_port) {
608 snd_es1688_init(chip, 0); 608 snd_es1688_init(chip, 0);
@@ -618,33 +618,33 @@ static int snd_es1688_free(es1688_t *chip)
618 return 0; 618 return 0;
619} 619}
620 620
621static int snd_es1688_dev_free(snd_device_t *device) 621static int snd_es1688_dev_free(struct snd_device *device)
622{ 622{
623 es1688_t *chip = device->device_data; 623 struct snd_es1688 *chip = device->device_data;
624 return snd_es1688_free(chip); 624 return snd_es1688_free(chip);
625} 625}
626 626
627static const char *snd_es1688_chip_id(es1688_t *chip) 627static const char *snd_es1688_chip_id(struct snd_es1688 *chip)
628{ 628{
629 static char tmp[16]; 629 static char tmp[16];
630 sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f); 630 sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f);
631 return tmp; 631 return tmp;
632} 632}
633 633
634int snd_es1688_create(snd_card_t * card, 634int snd_es1688_create(struct snd_card *card,
635 unsigned long port, 635 unsigned long port,
636 unsigned long mpu_port, 636 unsigned long mpu_port,
637 int irq, 637 int irq,
638 int mpu_irq, 638 int mpu_irq,
639 int dma8, 639 int dma8,
640 unsigned short hardware, 640 unsigned short hardware,
641 es1688_t **rchip) 641 struct snd_es1688 **rchip)
642{ 642{
643 static snd_device_ops_t ops = { 643 static struct snd_device_ops ops = {
644 .dev_free = snd_es1688_dev_free, 644 .dev_free = snd_es1688_dev_free,
645 }; 645 };
646 646
647 es1688_t *chip; 647 struct snd_es1688 *chip;
648 int err; 648 int err;
649 649
650 *rchip = NULL; 650 *rchip = NULL;
@@ -702,7 +702,7 @@ int snd_es1688_create(snd_card_t * card,
702 return 0; 702 return 0;
703} 703}
704 704
705static snd_pcm_ops_t snd_es1688_playback_ops = { 705static struct snd_pcm_ops snd_es1688_playback_ops = {
706 .open = snd_es1688_playback_open, 706 .open = snd_es1688_playback_open,
707 .close = snd_es1688_playback_close, 707 .close = snd_es1688_playback_close,
708 .ioctl = snd_es1688_ioctl, 708 .ioctl = snd_es1688_ioctl,
@@ -713,7 +713,7 @@ static snd_pcm_ops_t snd_es1688_playback_ops = {
713 .pointer = snd_es1688_playback_pointer, 713 .pointer = snd_es1688_playback_pointer,
714}; 714};
715 715
716static snd_pcm_ops_t snd_es1688_capture_ops = { 716static struct snd_pcm_ops snd_es1688_capture_ops = {
717 .open = snd_es1688_capture_open, 717 .open = snd_es1688_capture_open,
718 .close = snd_es1688_capture_close, 718 .close = snd_es1688_capture_close,
719 .ioctl = snd_es1688_ioctl, 719 .ioctl = snd_es1688_ioctl,
@@ -724,16 +724,9 @@ static snd_pcm_ops_t snd_es1688_capture_ops = {
724 .pointer = snd_es1688_capture_pointer, 724 .pointer = snd_es1688_capture_pointer,
725}; 725};
726 726
727static void snd_es1688_pcm_free(snd_pcm_t *pcm) 727int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm)
728{ 728{
729 es1688_t *chip = pcm->private_data; 729 struct snd_pcm *pcm;
730 chip->pcm = NULL;
731 snd_pcm_lib_preallocate_free_for_all(pcm);
732}
733
734int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm)
735{
736 snd_pcm_t *pcm;
737 int err; 730 int err;
738 731
739 if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) 732 if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0)
@@ -743,7 +736,6 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm)
743 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1688_capture_ops); 736 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1688_capture_ops);
744 737
745 pcm->private_data = chip; 738 pcm->private_data = chip;
746 pcm->private_free = snd_es1688_pcm_free;
747 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; 739 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
748 sprintf(pcm->name, snd_es1688_chip_id(chip)); 740 sprintf(pcm->name, snd_es1688_chip_id(chip));
749 chip->pcm = pcm; 741 chip->pcm = pcm;
@@ -761,7 +753,7 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm)
761 * MIXER part 753 * MIXER part
762 */ 754 */
763 755
764static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 756static int snd_es1688_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
765{ 757{
766 static char *texts[9] = { 758 static char *texts[9] = {
767 "Mic", "Mic Master", "CD", "AOUT", 759 "Mic", "Mic Master", "CD", "AOUT",
@@ -777,16 +769,16 @@ static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
777 return 0; 769 return 0;
778} 770}
779 771
780static int snd_es1688_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 772static int snd_es1688_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
781{ 773{
782 es1688_t *chip = snd_kcontrol_chip(kcontrol); 774 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
783 ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7; 775 ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7;
784 return 0; 776 return 0;
785} 777}
786 778
787static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 779static int snd_es1688_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
788{ 780{
789 es1688_t *chip = snd_kcontrol_chip(kcontrol); 781 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
790 unsigned long flags; 782 unsigned long flags;
791 unsigned char oval, nval; 783 unsigned char oval, nval;
792 int change; 784 int change;
@@ -809,7 +801,7 @@ static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
809 .get = snd_es1688_get_single, .put = snd_es1688_put_single, \ 801 .get = snd_es1688_get_single, .put = snd_es1688_put_single, \
810 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 802 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
811 803
812static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 804static int snd_es1688_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
813{ 805{
814 int mask = (kcontrol->private_value >> 16) & 0xff; 806 int mask = (kcontrol->private_value >> 16) & 0xff;
815 807
@@ -820,9 +812,9 @@ static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
820 return 0; 812 return 0;
821} 813}
822 814
823static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 815static int snd_es1688_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
824{ 816{
825 es1688_t *chip = snd_kcontrol_chip(kcontrol); 817 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
826 unsigned long flags; 818 unsigned long flags;
827 int reg = kcontrol->private_value & 0xff; 819 int reg = kcontrol->private_value & 0xff;
828 int shift = (kcontrol->private_value >> 8) & 0xff; 820 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -837,9 +829,9 @@ static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
837 return 0; 829 return 0;
838} 830}
839 831
840static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 832static int snd_es1688_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
841{ 833{
842 es1688_t *chip = snd_kcontrol_chip(kcontrol); 834 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
843 unsigned long flags; 835 unsigned long flags;
844 int reg = kcontrol->private_value & 0xff; 836 int reg = kcontrol->private_value & 0xff;
845 int shift = (kcontrol->private_value >> 8) & 0xff; 837 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -868,7 +860,7 @@ static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
868 .get = snd_es1688_get_double, .put = snd_es1688_put_double, \ 860 .get = snd_es1688_get_double, .put = snd_es1688_put_double, \
869 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 861 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
870 862
871static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 863static int snd_es1688_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
872{ 864{
873 int mask = (kcontrol->private_value >> 24) & 0xff; 865 int mask = (kcontrol->private_value >> 24) & 0xff;
874 866
@@ -879,9 +871,9 @@ static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
879 return 0; 871 return 0;
880} 872}
881 873
882static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 874static int snd_es1688_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
883{ 875{
884 es1688_t *chip = snd_kcontrol_chip(kcontrol); 876 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
885 unsigned long flags; 877 unsigned long flags;
886 int left_reg = kcontrol->private_value & 0xff; 878 int left_reg = kcontrol->private_value & 0xff;
887 int right_reg = (kcontrol->private_value >> 8) & 0xff; 879 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -913,9 +905,9 @@ static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
913 return 0; 905 return 0;
914} 906}
915 907
916static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 908static int snd_es1688_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
917{ 909{
918 es1688_t *chip = snd_kcontrol_chip(kcontrol); 910 struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
919 unsigned long flags; 911 unsigned long flags;
920 int left_reg = kcontrol->private_value & 0xff; 912 int left_reg = kcontrol->private_value & 0xff;
921 int right_reg = (kcontrol->private_value >> 8) & 0xff; 913 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -976,7 +968,7 @@ static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
976 return change; 968 return change;
977} 969}
978 970
979static snd_kcontrol_new_t snd_es1688_controls[] = { 971static struct snd_kcontrol_new snd_es1688_controls[] = {
980ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0), 972ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0),
981ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0), 973ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0),
982ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0), 974ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0),
@@ -1011,9 +1003,9 @@ static unsigned char snd_es1688_init_table[][2] = {
1011 { ES1688_REC_DEV, 0x17 } 1003 { ES1688_REC_DEV, 0x17 }
1012}; 1004};
1013 1005
1014int snd_es1688_mixer(es1688_t *chip) 1006int snd_es1688_mixer(struct snd_es1688 *chip)
1015{ 1007{
1016 snd_card_t *card; 1008 struct snd_card *card;
1017 unsigned int idx; 1009 unsigned int idx;
1018 int err; 1010 int err;
1019 unsigned char reg, val; 1011 unsigned char reg, val;
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 970e2aaade27..bf5de0782eb0 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -65,28 +65,28 @@
65 65
66 66
67#include <sound/driver.h> 67#include <sound/driver.h>
68#include <asm/io.h>
69#include <asm/dma.h>
70#include <linux/init.h> 68#include <linux/init.h>
71#include <linux/pm.h> 69#include <linux/err.h>
70#include <linux/platform_device.h>
72#include <linux/slab.h> 71#include <linux/slab.h>
73#include <linux/pnp.h> 72#include <linux/pnp.h>
74#include <linux/isapnp.h> 73#include <linux/isapnp.h>
75#include <linux/moduleparam.h> 74#include <linux/moduleparam.h>
75#include <asm/io.h>
76#include <asm/dma.h>
76#include <sound/core.h> 77#include <sound/core.h>
77#include <sound/control.h> 78#include <sound/control.h>
78#include <sound/pcm.h> 79#include <sound/pcm.h>
79#include <sound/pcm_params.h> 80#include <sound/pcm_params.h>
80#include <sound/mpu401.h> 81#include <sound/mpu401.h>
81#include <sound/opl3.h> 82#include <sound/opl3.h>
82#define SNDRV_LEGACY_AUTO_PROBE
83#define SNDRV_LEGACY_FIND_FREE_IRQ 83#define SNDRV_LEGACY_FIND_FREE_IRQ
84#define SNDRV_LEGACY_FIND_FREE_DMA 84#define SNDRV_LEGACY_FIND_FREE_DMA
85#include <sound/initval.h> 85#include <sound/initval.h>
86 86
87#define PFX "es18xx: " 87#define PFX "es18xx: "
88 88
89struct _snd_es18xx { 89struct snd_es18xx {
90 unsigned long port; /* port of ESS chip */ 90 unsigned long port; /* port of ESS chip */
91 unsigned long mpu_port; /* MPU-401 port of ESS chip */ 91 unsigned long mpu_port; /* MPU-401 port of ESS chip */
92 unsigned long fm_port; /* FM port */ 92 unsigned long fm_port; /* FM port */
@@ -107,18 +107,18 @@ struct _snd_es18xx {
107 unsigned int dma1_shift; 107 unsigned int dma1_shift;
108 unsigned int dma2_shift; 108 unsigned int dma2_shift;
109 109
110 snd_card_t *card; 110 struct snd_card *card;
111 snd_pcm_t *pcm; 111 struct snd_pcm *pcm;
112 snd_pcm_substream_t *playback_a_substream; 112 struct snd_pcm_substream *playback_a_substream;
113 snd_pcm_substream_t *capture_a_substream; 113 struct snd_pcm_substream *capture_a_substream;
114 snd_pcm_substream_t *playback_b_substream; 114 struct snd_pcm_substream *playback_b_substream;
115 115
116 snd_rawmidi_t *rmidi; 116 struct snd_rawmidi *rmidi;
117 117
118 snd_kcontrol_t *hw_volume; 118 struct snd_kcontrol *hw_volume;
119 snd_kcontrol_t *hw_switch; 119 struct snd_kcontrol *hw_switch;
120 snd_kcontrol_t *master_volume; 120 struct snd_kcontrol *master_volume;
121 snd_kcontrol_t *master_switch; 121 struct snd_kcontrol *master_switch;
122 122
123 spinlock_t reg_lock; 123 spinlock_t reg_lock;
124 spinlock_t mixer_lock; 124 spinlock_t mixer_lock;
@@ -128,6 +128,14 @@ struct _snd_es18xx {
128#endif 128#endif
129}; 129};
130 130
131struct snd_audiodrive {
132 struct snd_es18xx *chip;
133#ifdef CONFIG_PNP
134 struct pnp_dev *dev;
135 struct pnp_dev *devc;
136#endif
137};
138
131#define AUDIO1_IRQ 0x01 139#define AUDIO1_IRQ 0x01
132#define AUDIO2_IRQ 0x02 140#define AUDIO2_IRQ 0x02
133#define HWV_IRQ 0x04 141#define HWV_IRQ 0x04
@@ -155,8 +163,6 @@ struct _snd_es18xx {
155#define ES18XX_PM_FM 0x020 163#define ES18XX_PM_FM 0x020
156#define ES18XX_PM_SUS 0x080 164#define ES18XX_PM_SUS 0x080
157 165
158typedef struct _snd_es18xx es18xx_t;
159
160/* Lowlevel */ 166/* Lowlevel */
161 167
162#define DAC1 0x01 168#define DAC1 0x01
@@ -164,7 +170,7 @@ typedef struct _snd_es18xx es18xx_t;
164#define DAC2 0x04 170#define DAC2 0x04
165#define MILLISECOND 10000 171#define MILLISECOND 10000
166 172
167static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val) 173static int snd_es18xx_dsp_command(struct snd_es18xx *chip, unsigned char val)
168{ 174{
169 int i; 175 int i;
170 176
@@ -177,7 +183,7 @@ static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val)
177 return -EINVAL; 183 return -EINVAL;
178} 184}
179 185
180static int snd_es18xx_dsp_get_byte(es18xx_t *chip) 186static int snd_es18xx_dsp_get_byte(struct snd_es18xx *chip)
181{ 187{
182 int i; 188 int i;
183 189
@@ -191,7 +197,7 @@ static int snd_es18xx_dsp_get_byte(es18xx_t *chip)
191 197
192#undef REG_DEBUG 198#undef REG_DEBUG
193 199
194static int snd_es18xx_write(es18xx_t *chip, 200static int snd_es18xx_write(struct snd_es18xx *chip,
195 unsigned char reg, unsigned char data) 201 unsigned char reg, unsigned char data)
196{ 202{
197 unsigned long flags; 203 unsigned long flags;
@@ -210,7 +216,7 @@ static int snd_es18xx_write(es18xx_t *chip,
210 return ret; 216 return ret;
211} 217}
212 218
213static int snd_es18xx_read(es18xx_t *chip, unsigned char reg) 219static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg)
214{ 220{
215 unsigned long flags; 221 unsigned long flags;
216 int ret, data; 222 int ret, data;
@@ -232,7 +238,7 @@ static int snd_es18xx_read(es18xx_t *chip, unsigned char reg)
232} 238}
233 239
234/* Return old value */ 240/* Return old value */
235static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg, 241static int snd_es18xx_bits(struct snd_es18xx *chip, unsigned char reg,
236 unsigned char mask, unsigned char val) 242 unsigned char mask, unsigned char val)
237{ 243{
238 int ret; 244 int ret;
@@ -270,7 +276,7 @@ static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg,
270 return ret; 276 return ret;
271} 277}
272 278
273static inline void snd_es18xx_mixer_write(es18xx_t *chip, 279static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip,
274 unsigned char reg, unsigned char data) 280 unsigned char reg, unsigned char data)
275{ 281{
276 unsigned long flags; 282 unsigned long flags;
@@ -283,7 +289,7 @@ static inline void snd_es18xx_mixer_write(es18xx_t *chip,
283#endif 289#endif
284} 290}
285 291
286static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg) 292static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char reg)
287{ 293{
288 unsigned long flags; 294 unsigned long flags;
289 int data; 295 int data;
@@ -298,7 +304,7 @@ static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg)
298} 304}
299 305
300/* Return old value */ 306/* Return old value */
301static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg, 307static inline int snd_es18xx_mixer_bits(struct snd_es18xx *chip, unsigned char reg,
302 unsigned char mask, unsigned char val) 308 unsigned char mask, unsigned char val)
303{ 309{
304 unsigned char old, new, oval; 310 unsigned char old, new, oval;
@@ -319,7 +325,7 @@ static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg,
319 return oval; 325 return oval;
320} 326}
321 327
322static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg, 328static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned char reg,
323 unsigned char mask) 329 unsigned char mask)
324{ 330{
325 int old, expected, new; 331 int old, expected, new;
@@ -339,7 +345,7 @@ static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg,
339} 345}
340 346
341 347
342static int snd_es18xx_reset(es18xx_t *chip) 348static int snd_es18xx_reset(struct snd_es18xx *chip)
343{ 349{
344 int i; 350 int i;
345 outb(0x03, chip->port + 0x06); 351 outb(0x03, chip->port + 0x06);
@@ -351,7 +357,7 @@ static int snd_es18xx_reset(es18xx_t *chip)
351 return 0; 357 return 0;
352} 358}
353 359
354static int snd_es18xx_reset_fifo(es18xx_t *chip) 360static int snd_es18xx_reset_fifo(struct snd_es18xx *chip)
355{ 361{
356 outb(0x02, chip->port + 0x06); 362 outb(0x02, chip->port + 0x06);
357 inb(chip->port + 0x06); 363 inb(chip->port + 0x06);
@@ -359,7 +365,7 @@ static int snd_es18xx_reset_fifo(es18xx_t *chip)
359 return 0; 365 return 0;
360} 366}
361 367
362static ratnum_t new_clocks[2] = { 368static struct snd_ratnum new_clocks[2] = {
363 { 369 {
364 .num = 793800, 370 .num = 793800,
365 .den_min = 1, 371 .den_min = 1,
@@ -374,12 +380,12 @@ static ratnum_t new_clocks[2] = {
374 } 380 }
375}; 381};
376 382
377static snd_pcm_hw_constraint_ratnums_t new_hw_constraints_clocks = { 383static struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = {
378 .nrats = 2, 384 .nrats = 2,
379 .rats = new_clocks, 385 .rats = new_clocks,
380}; 386};
381 387
382static ratnum_t old_clocks[2] = { 388static struct snd_ratnum old_clocks[2] = {
383 { 389 {
384 .num = 795444, 390 .num = 795444,
385 .den_min = 1, 391 .den_min = 1,
@@ -394,18 +400,18 @@ static ratnum_t old_clocks[2] = {
394 } 400 }
395}; 401};
396 402
397static snd_pcm_hw_constraint_ratnums_t old_hw_constraints_clocks = { 403static struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks = {
398 .nrats = 2, 404 .nrats = 2,
399 .rats = old_clocks, 405 .rats = old_clocks,
400}; 406};
401 407
402 408
403static void snd_es18xx_rate_set(es18xx_t *chip, 409static void snd_es18xx_rate_set(struct snd_es18xx *chip,
404 snd_pcm_substream_t *substream, 410 struct snd_pcm_substream *substream,
405 int mode) 411 int mode)
406{ 412{
407 unsigned int bits, div0; 413 unsigned int bits, div0;
408 snd_pcm_runtime_t *runtime = substream->runtime; 414 struct snd_pcm_runtime *runtime = substream->runtime;
409 if (chip->caps & ES18XX_NEW_RATE) { 415 if (chip->caps & ES18XX_NEW_RATE) {
410 if (runtime->rate_num == new_clocks[0].num) 416 if (runtime->rate_num == new_clocks[0].num)
411 bits = 128 - runtime->rate_den; 417 bits = 128 - runtime->rate_den;
@@ -435,10 +441,10 @@ static void snd_es18xx_rate_set(es18xx_t *chip,
435 } 441 }
436} 442}
437 443
438static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream, 444static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream,
439 snd_pcm_hw_params_t * hw_params) 445 struct snd_pcm_hw_params *hw_params)
440{ 446{
441 es18xx_t *chip = snd_pcm_substream_chip(substream); 447 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
442 int shift, err; 448 int shift, err;
443 449
444 shift = 0; 450 shift = 0;
@@ -463,15 +469,15 @@ static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream,
463 return 0; 469 return 0;
464} 470}
465 471
466static int snd_es18xx_pcm_hw_free(snd_pcm_substream_t * substream) 472static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream)
467{ 473{
468 return snd_pcm_lib_free_pages(substream); 474 return snd_pcm_lib_free_pages(substream);
469} 475}
470 476
471static int snd_es18xx_playback1_prepare(es18xx_t *chip, 477static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip,
472 snd_pcm_substream_t *substream) 478 struct snd_pcm_substream *substream)
473{ 479{
474 snd_pcm_runtime_t *runtime = substream->runtime; 480 struct snd_pcm_runtime *runtime = substream->runtime;
475 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 481 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
476 unsigned int count = snd_pcm_lib_period_bytes(substream); 482 unsigned int count = snd_pcm_lib_period_bytes(substream);
477 483
@@ -496,8 +502,8 @@ static int snd_es18xx_playback1_prepare(es18xx_t *chip,
496 return 0; 502 return 0;
497} 503}
498 504
499static int snd_es18xx_playback1_trigger(es18xx_t *chip, 505static int snd_es18xx_playback1_trigger(struct snd_es18xx *chip,
500 snd_pcm_substream_t * substream, 506 struct snd_pcm_substream *substream,
501 int cmd) 507 int cmd)
502{ 508{
503 switch (cmd) { 509 switch (cmd) {
@@ -546,10 +552,10 @@ static int snd_es18xx_playback1_trigger(es18xx_t *chip,
546 return 0; 552 return 0;
547} 553}
548 554
549static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream, 555static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream,
550 snd_pcm_hw_params_t * hw_params) 556 struct snd_pcm_hw_params *hw_params)
551{ 557{
552 es18xx_t *chip = snd_pcm_substream_chip(substream); 558 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
553 int shift, err; 559 int shift, err;
554 560
555 shift = 0; 561 shift = 0;
@@ -569,10 +575,10 @@ static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream,
569 return 0; 575 return 0;
570} 576}
571 577
572static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream) 578static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream)
573{ 579{
574 es18xx_t *chip = snd_pcm_substream_chip(substream); 580 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
575 snd_pcm_runtime_t *runtime = substream->runtime; 581 struct snd_pcm_runtime *runtime = substream->runtime;
576 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 582 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
577 unsigned int count = snd_pcm_lib_period_bytes(substream); 583 unsigned int count = snd_pcm_lib_period_bytes(substream);
578 584
@@ -608,10 +614,10 @@ static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream)
608 return 0; 614 return 0;
609} 615}
610 616
611static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream, 617static int snd_es18xx_capture_trigger(struct snd_pcm_substream *substream,
612 int cmd) 618 int cmd)
613{ 619{
614 es18xx_t *chip = snd_pcm_substream_chip(substream); 620 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
615 621
616 switch (cmd) { 622 switch (cmd) {
617 case SNDRV_PCM_TRIGGER_START: 623 case SNDRV_PCM_TRIGGER_START:
@@ -637,10 +643,10 @@ static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream,
637 return 0; 643 return 0;
638} 644}
639 645
640static int snd_es18xx_playback2_prepare(es18xx_t *chip, 646static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip,
641 snd_pcm_substream_t *substream) 647 struct snd_pcm_substream *substream)
642{ 648{
643 snd_pcm_runtime_t *runtime = substream->runtime; 649 struct snd_pcm_runtime *runtime = substream->runtime;
644 unsigned int size = snd_pcm_lib_buffer_bytes(substream); 650 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
645 unsigned int count = snd_pcm_lib_period_bytes(substream); 651 unsigned int count = snd_pcm_lib_period_bytes(substream);
646 652
@@ -674,8 +680,8 @@ static int snd_es18xx_playback2_prepare(es18xx_t *chip,
674 return 0; 680 return 0;
675} 681}
676 682
677static int snd_es18xx_playback2_trigger(es18xx_t *chip, 683static int snd_es18xx_playback2_trigger(struct snd_es18xx *chip,
678 snd_pcm_substream_t *substream, 684 struct snd_pcm_substream *substream,
679 int cmd) 685 int cmd)
680{ 686{
681 switch (cmd) { 687 switch (cmd) {
@@ -714,19 +720,19 @@ static int snd_es18xx_playback2_trigger(es18xx_t *chip,
714 return 0; 720 return 0;
715} 721}
716 722
717static int snd_es18xx_playback_prepare(snd_pcm_substream_t *substream) 723static int snd_es18xx_playback_prepare(struct snd_pcm_substream *substream)
718{ 724{
719 es18xx_t *chip = snd_pcm_substream_chip(substream); 725 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
720 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) 726 if (substream->number == 0 && (chip->caps & ES18XX_PCM2))
721 return snd_es18xx_playback1_prepare(chip, substream); 727 return snd_es18xx_playback1_prepare(chip, substream);
722 else 728 else
723 return snd_es18xx_playback2_prepare(chip, substream); 729 return snd_es18xx_playback2_prepare(chip, substream);
724} 730}
725 731
726static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream, 732static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream,
727 int cmd) 733 int cmd)
728{ 734{
729 es18xx_t *chip = snd_pcm_substream_chip(substream); 735 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
730 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) 736 if (substream->number == 0 && (chip->caps & ES18XX_PCM2))
731 return snd_es18xx_playback1_trigger(chip, substream, cmd); 737 return snd_es18xx_playback1_trigger(chip, substream, cmd);
732 else 738 else
@@ -735,7 +741,7 @@ static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream,
735 741
736static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 742static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
737{ 743{
738 es18xx_t *chip = dev_id; 744 struct snd_es18xx *chip = dev_id;
739 unsigned char status; 745 unsigned char status;
740 746
741 if (chip->caps & ES18XX_CONTROL) { 747 if (chip->caps & ES18XX_CONTROL) {
@@ -795,9 +801,9 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *r
795 return IRQ_HANDLED; 801 return IRQ_HANDLED;
796} 802}
797 803
798static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * substream) 804static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream)
799{ 805{
800 es18xx_t *chip = snd_pcm_substream_chip(substream); 806 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
801 int pos; 807 int pos;
802 808
803 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { 809 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) {
@@ -813,9 +819,9 @@ static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * subst
813 } 819 }
814} 820}
815 821
816static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substream) 822static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream)
817{ 823{
818 es18xx_t *chip = snd_pcm_substream_chip(substream); 824 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
819 int pos; 825 int pos;
820 826
821 if (!(chip->active & ADC1)) 827 if (!(chip->active & ADC1))
@@ -824,7 +830,7 @@ static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substr
824 return pos >> chip->dma1_shift; 830 return pos >> chip->dma1_shift;
825} 831}
826 832
827static snd_pcm_hardware_t snd_es18xx_playback = 833static struct snd_pcm_hardware snd_es18xx_playback =
828{ 834{
829 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 835 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
830 SNDRV_PCM_INFO_RESUME | 836 SNDRV_PCM_INFO_RESUME |
@@ -844,7 +850,7 @@ static snd_pcm_hardware_t snd_es18xx_playback =
844 .fifo_size = 0, 850 .fifo_size = 0,
845}; 851};
846 852
847static snd_pcm_hardware_t snd_es18xx_capture = 853static struct snd_pcm_hardware snd_es18xx_capture =
848{ 854{
849 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 855 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
850 SNDRV_PCM_INFO_RESUME | 856 SNDRV_PCM_INFO_RESUME |
@@ -864,10 +870,10 @@ static snd_pcm_hardware_t snd_es18xx_capture =
864 .fifo_size = 0, 870 .fifo_size = 0,
865}; 871};
866 872
867static int snd_es18xx_playback_open(snd_pcm_substream_t * substream) 873static int snd_es18xx_playback_open(struct snd_pcm_substream *substream)
868{ 874{
869 snd_pcm_runtime_t *runtime = substream->runtime; 875 struct snd_pcm_runtime *runtime = substream->runtime;
870 es18xx_t *chip = snd_pcm_substream_chip(substream); 876 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
871 877
872 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { 878 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) {
873 if ((chip->caps & ES18XX_DUPLEX_MONO) && 879 if ((chip->caps & ES18XX_DUPLEX_MONO) &&
@@ -889,10 +895,10 @@ static int snd_es18xx_playback_open(snd_pcm_substream_t * substream)
889 return 0; 895 return 0;
890} 896}
891 897
892static int snd_es18xx_capture_open(snd_pcm_substream_t * substream) 898static int snd_es18xx_capture_open(struct snd_pcm_substream *substream)
893{ 899{
894 snd_pcm_runtime_t *runtime = substream->runtime; 900 struct snd_pcm_runtime *runtime = substream->runtime;
895 es18xx_t *chip = snd_pcm_substream_chip(substream); 901 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
896 902
897 if (chip->playback_b_substream) 903 if (chip->playback_b_substream)
898 return -EAGAIN; 904 return -EAGAIN;
@@ -907,9 +913,9 @@ static int snd_es18xx_capture_open(snd_pcm_substream_t * substream)
907 return 0; 913 return 0;
908} 914}
909 915
910static int snd_es18xx_playback_close(snd_pcm_substream_t * substream) 916static int snd_es18xx_playback_close(struct snd_pcm_substream *substream)
911{ 917{
912 es18xx_t *chip = snd_pcm_substream_chip(substream); 918 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
913 919
914 if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) 920 if (substream->number == 0 && (chip->caps & ES18XX_PCM2))
915 chip->playback_a_substream = NULL; 921 chip->playback_a_substream = NULL;
@@ -920,9 +926,9 @@ static int snd_es18xx_playback_close(snd_pcm_substream_t * substream)
920 return 0; 926 return 0;
921} 927}
922 928
923static int snd_es18xx_capture_close(snd_pcm_substream_t * substream) 929static int snd_es18xx_capture_close(struct snd_pcm_substream *substream)
924{ 930{
925 es18xx_t *chip = snd_pcm_substream_chip(substream); 931 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
926 932
927 chip->capture_a_substream = NULL; 933 chip->capture_a_substream = NULL;
928 snd_pcm_lib_free_pages(substream); 934 snd_pcm_lib_free_pages(substream);
@@ -933,7 +939,7 @@ static int snd_es18xx_capture_close(snd_pcm_substream_t * substream)
933 * MIXER part 939 * MIXER part
934 */ 940 */
935 941
936static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 942static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
937{ 943{
938 static char *texts[8] = { 944 static char *texts[8] = {
939 "Mic", "Mic Master", "CD", "AOUT", 945 "Mic", "Mic Master", "CD", "AOUT",
@@ -949,16 +955,16 @@ static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
949 return 0; 955 return 0;
950} 956}
951 957
952static int snd_es18xx_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 958static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
953{ 959{
954 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 960 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
955 ucontrol->value.enumerated.item[0] = snd_es18xx_mixer_read(chip, 0x1c) & 0x07; 961 ucontrol->value.enumerated.item[0] = snd_es18xx_mixer_read(chip, 0x1c) & 0x07;
956 return 0; 962 return 0;
957} 963}
958 964
959static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 965static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
960{ 966{
961 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 967 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
962 unsigned char val = ucontrol->value.enumerated.item[0]; 968 unsigned char val = ucontrol->value.enumerated.item[0];
963 969
964 if (val > 7) 970 if (val > 7)
@@ -966,7 +972,7 @@ static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
966 return snd_es18xx_mixer_bits(chip, 0x1c, 0x07, val) != val; 972 return snd_es18xx_mixer_bits(chip, 0x1c, 0x07, val) != val;
967} 973}
968 974
969static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 975static int snd_es18xx_info_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
970{ 976{
971 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 977 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
972 uinfo->count = 1; 978 uinfo->count = 1;
@@ -975,17 +981,17 @@ static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_
975 return 0; 981 return 0;
976} 982}
977 983
978static int snd_es18xx_get_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 984static int snd_es18xx_get_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
979{ 985{
980 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 986 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
981 unsigned char val = snd_es18xx_mixer_read(chip, 0x50); 987 unsigned char val = snd_es18xx_mixer_read(chip, 0x50);
982 ucontrol->value.integer.value[0] = !!(val & 8); 988 ucontrol->value.integer.value[0] = !!(val & 8);
983 return 0; 989 return 0;
984} 990}
985 991
986static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 992static int snd_es18xx_put_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
987{ 993{
988 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 994 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
989 unsigned char oval, nval; 995 unsigned char oval, nval;
990 int change; 996 int change;
991 nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; 997 nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04;
@@ -998,7 +1004,7 @@ static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_
998 return change; 1004 return change;
999} 1005}
1000 1006
1001static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1007static int snd_es18xx_info_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1002{ 1008{
1003 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1009 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1004 uinfo->count = 2; 1010 uinfo->count = 2;
@@ -1007,15 +1013,15 @@ static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
1007 return 0; 1013 return 0;
1008} 1014}
1009 1015
1010static int snd_es18xx_get_hw_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1016static int snd_es18xx_get_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1011{ 1017{
1012 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1018 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1013 ucontrol->value.integer.value[0] = snd_es18xx_mixer_read(chip, 0x61) & 0x3f; 1019 ucontrol->value.integer.value[0] = snd_es18xx_mixer_read(chip, 0x61) & 0x3f;
1014 ucontrol->value.integer.value[1] = snd_es18xx_mixer_read(chip, 0x63) & 0x3f; 1020 ucontrol->value.integer.value[1] = snd_es18xx_mixer_read(chip, 0x63) & 0x3f;
1015 return 0; 1021 return 0;
1016} 1022}
1017 1023
1018static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1024static int snd_es18xx_info_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1019{ 1025{
1020 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1026 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1021 uinfo->count = 2; 1027 uinfo->count = 2;
@@ -1024,24 +1030,24 @@ static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
1024 return 0; 1030 return 0;
1025} 1031}
1026 1032
1027static int snd_es18xx_get_hw_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1033static int snd_es18xx_get_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1028{ 1034{
1029 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1035 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1030 ucontrol->value.integer.value[0] = !(snd_es18xx_mixer_read(chip, 0x61) & 0x40); 1036 ucontrol->value.integer.value[0] = !(snd_es18xx_mixer_read(chip, 0x61) & 0x40);
1031 ucontrol->value.integer.value[1] = !(snd_es18xx_mixer_read(chip, 0x63) & 0x40); 1037 ucontrol->value.integer.value[1] = !(snd_es18xx_mixer_read(chip, 0x63) & 0x40);
1032 return 0; 1038 return 0;
1033} 1039}
1034 1040
1035static void snd_es18xx_hwv_free(snd_kcontrol_t *kcontrol) 1041static void snd_es18xx_hwv_free(struct snd_kcontrol *kcontrol)
1036{ 1042{
1037 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1043 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1038 chip->master_volume = NULL; 1044 chip->master_volume = NULL;
1039 chip->master_switch = NULL; 1045 chip->master_switch = NULL;
1040 chip->hw_volume = NULL; 1046 chip->hw_volume = NULL;
1041 chip->hw_switch = NULL; 1047 chip->hw_switch = NULL;
1042} 1048}
1043 1049
1044static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg, 1050static int snd_es18xx_reg_bits(struct snd_es18xx *chip, unsigned char reg,
1045 unsigned char mask, unsigned char val) 1051 unsigned char mask, unsigned char val)
1046{ 1052{
1047 if (reg < 0xa0) 1053 if (reg < 0xa0)
@@ -1050,7 +1056,7 @@ static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg,
1050 return snd_es18xx_bits(chip, reg, mask, val); 1056 return snd_es18xx_bits(chip, reg, mask, val);
1051} 1057}
1052 1058
1053static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg) 1059static int snd_es18xx_reg_read(struct snd_es18xx *chip, unsigned char reg)
1054{ 1060{
1055 if (reg < 0xa0) 1061 if (reg < 0xa0)
1056 return snd_es18xx_mixer_read(chip, reg); 1062 return snd_es18xx_mixer_read(chip, reg);
@@ -1064,7 +1070,7 @@ static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg)
1064 .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \ 1070 .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \
1065 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 1071 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
1066 1072
1067static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1073static int snd_es18xx_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1068{ 1074{
1069 int mask = (kcontrol->private_value >> 16) & 0xff; 1075 int mask = (kcontrol->private_value >> 16) & 0xff;
1070 1076
@@ -1075,9 +1081,9 @@ static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1075 return 0; 1081 return 0;
1076} 1082}
1077 1083
1078static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1084static int snd_es18xx_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1079{ 1085{
1080 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1086 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1081 int reg = kcontrol->private_value & 0xff; 1087 int reg = kcontrol->private_value & 0xff;
1082 int shift = (kcontrol->private_value >> 8) & 0xff; 1088 int shift = (kcontrol->private_value >> 8) & 0xff;
1083 int mask = (kcontrol->private_value >> 16) & 0xff; 1089 int mask = (kcontrol->private_value >> 16) & 0xff;
@@ -1091,9 +1097,9 @@ static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1091 return 0; 1097 return 0;
1092} 1098}
1093 1099
1094static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1100static int snd_es18xx_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1095{ 1101{
1096 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1102 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1097 int reg = kcontrol->private_value & 0xff; 1103 int reg = kcontrol->private_value & 0xff;
1098 int shift = (kcontrol->private_value >> 8) & 0xff; 1104 int shift = (kcontrol->private_value >> 8) & 0xff;
1099 int mask = (kcontrol->private_value >> 16) & 0xff; 1105 int mask = (kcontrol->private_value >> 16) & 0xff;
@@ -1114,7 +1120,7 @@ static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1114 .get = snd_es18xx_get_double, .put = snd_es18xx_put_double, \ 1120 .get = snd_es18xx_get_double, .put = snd_es18xx_put_double, \
1115 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 1121 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
1116 1122
1117static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1123static int snd_es18xx_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1118{ 1124{
1119 int mask = (kcontrol->private_value >> 24) & 0xff; 1125 int mask = (kcontrol->private_value >> 24) & 0xff;
1120 1126
@@ -1125,9 +1131,9 @@ static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1125 return 0; 1131 return 0;
1126} 1132}
1127 1133
1128static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1134static int snd_es18xx_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1129{ 1135{
1130 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1136 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1131 int left_reg = kcontrol->private_value & 0xff; 1137 int left_reg = kcontrol->private_value & 0xff;
1132 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1138 int right_reg = (kcontrol->private_value >> 8) & 0xff;
1133 int shift_left = (kcontrol->private_value >> 16) & 0x07; 1139 int shift_left = (kcontrol->private_value >> 16) & 0x07;
@@ -1150,9 +1156,9 @@ static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1150 return 0; 1156 return 0;
1151} 1157}
1152 1158
1153static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1159static int snd_es18xx_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1154{ 1160{
1155 es18xx_t *chip = snd_kcontrol_chip(kcontrol); 1161 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1156 int left_reg = kcontrol->private_value & 0xff; 1162 int left_reg = kcontrol->private_value & 0xff;
1157 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1163 int right_reg = (kcontrol->private_value >> 8) & 0xff;
1158 int shift_left = (kcontrol->private_value >> 16) & 0x07; 1164 int shift_left = (kcontrol->private_value >> 16) & 0x07;
@@ -1185,7 +1191,7 @@ static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1185 return change; 1191 return change;
1186} 1192}
1187 1193
1188static snd_kcontrol_new_t snd_es18xx_base_controls[] = { 1194static struct snd_kcontrol_new snd_es18xx_base_controls[] = {
1189ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), 1195ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0),
1190ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), 1196ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1),
1191ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), 1197ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0),
@@ -1207,10 +1213,10 @@ ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1),
1207} 1213}
1208}; 1214};
1209 1215
1210static snd_kcontrol_new_t snd_es18xx_mono_in_control = 1216static struct snd_kcontrol_new snd_es18xx_mono_in_control =
1211ES18XX_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0); 1217ES18XX_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0);
1212 1218
1213static snd_kcontrol_new_t snd_es18xx_recmix_controls[] = { 1219static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = {
1214ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), 1220ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0),
1215ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), 1221ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0),
1216ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), 1222ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0),
@@ -1220,16 +1226,16 @@ ES18XX_DOUBLE("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0),
1220ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) 1226ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0)
1221}; 1227};
1222 1228
1223static snd_kcontrol_new_t snd_es18xx_pcm1_controls[] = { 1229static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = {
1224ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0), 1230ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0),
1225}; 1231};
1226 1232
1227static snd_kcontrol_new_t snd_es18xx_pcm2_controls[] = { 1233static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = {
1228ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), 1234ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0),
1229ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0) 1235ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0)
1230}; 1236};
1231 1237
1232static snd_kcontrol_new_t snd_es18xx_spatializer_controls[] = { 1238static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = {
1233ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), 1239ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
1234{ 1240{
1235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1240,13 +1246,13 @@ ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
1240} 1246}
1241}; 1247};
1242 1248
1243static snd_kcontrol_new_t snd_es18xx_micpre1_control = 1249static struct snd_kcontrol_new snd_es18xx_micpre1_control =
1244ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0); 1250ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0);
1245 1251
1246static snd_kcontrol_new_t snd_es18xx_micpre2_control = 1252static struct snd_kcontrol_new snd_es18xx_micpre2_control =
1247ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0); 1253ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0);
1248 1254
1249static snd_kcontrol_new_t snd_es18xx_hw_volume_controls[] = { 1255static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = {
1250{ 1256{
1251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1252 .name = "Hardware Master Playback Volume", 1258 .name = "Hardware Master Playback Volume",
@@ -1265,7 +1271,7 @@ ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0),
1265}; 1271};
1266 1272
1267#if 0 1273#if 0
1268static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) 1274static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg)
1269{ 1275{
1270 int data; 1276 int data;
1271 unsigned long flags; 1277 unsigned long flags;
@@ -1277,7 +1283,7 @@ static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg)
1277} 1283}
1278#endif 1284#endif
1279 1285
1280static void __devinit snd_es18xx_config_write(es18xx_t *chip, 1286static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip,
1281 unsigned char reg, unsigned char data) 1287 unsigned char reg, unsigned char data)
1282{ 1288{
1283 /* No need for spinlocks, this function is used only in 1289 /* No need for spinlocks, this function is used only in
@@ -1289,7 +1295,7 @@ static void __devinit snd_es18xx_config_write(es18xx_t *chip,
1289#endif 1295#endif
1290} 1296}
1291 1297
1292static int __devinit snd_es18xx_initialize(es18xx_t *chip) 1298static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip)
1293{ 1299{
1294 int mask = 0; 1300 int mask = 0;
1295 1301
@@ -1438,7 +1444,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip)
1438 return 0; 1444 return 0;
1439} 1445}
1440 1446
1441static int __devinit snd_es18xx_identify(es18xx_t *chip) 1447static int __devinit snd_es18xx_identify(struct snd_es18xx *chip)
1442{ 1448{
1443 int hi,lo; 1449 int hi,lo;
1444 1450
@@ -1504,7 +1510,7 @@ static int __devinit snd_es18xx_identify(es18xx_t *chip)
1504 return 0; 1510 return 0;
1505} 1511}
1506 1512
1507static int __devinit snd_es18xx_probe(es18xx_t *chip) 1513static int __devinit snd_es18xx_probe(struct snd_es18xx *chip)
1508{ 1514{
1509 if (snd_es18xx_identify(chip) < 0) { 1515 if (snd_es18xx_identify(chip) < 0) {
1510 snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); 1516 snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port);
@@ -1544,7 +1550,7 @@ static int __devinit snd_es18xx_probe(es18xx_t *chip)
1544 return snd_es18xx_initialize(chip); 1550 return snd_es18xx_initialize(chip);
1545} 1551}
1546 1552
1547static snd_pcm_ops_t snd_es18xx_playback_ops = { 1553static struct snd_pcm_ops snd_es18xx_playback_ops = {
1548 .open = snd_es18xx_playback_open, 1554 .open = snd_es18xx_playback_open,
1549 .close = snd_es18xx_playback_close, 1555 .close = snd_es18xx_playback_close,
1550 .ioctl = snd_pcm_lib_ioctl, 1556 .ioctl = snd_pcm_lib_ioctl,
@@ -1555,7 +1561,7 @@ static snd_pcm_ops_t snd_es18xx_playback_ops = {
1555 .pointer = snd_es18xx_playback_pointer, 1561 .pointer = snd_es18xx_playback_pointer,
1556}; 1562};
1557 1563
1558static snd_pcm_ops_t snd_es18xx_capture_ops = { 1564static struct snd_pcm_ops snd_es18xx_capture_ops = {
1559 .open = snd_es18xx_capture_open, 1565 .open = snd_es18xx_capture_open,
1560 .close = snd_es18xx_capture_close, 1566 .close = snd_es18xx_capture_close,
1561 .ioctl = snd_pcm_lib_ioctl, 1567 .ioctl = snd_pcm_lib_ioctl,
@@ -1566,27 +1572,19 @@ static snd_pcm_ops_t snd_es18xx_capture_ops = {
1566 .pointer = snd_es18xx_capture_pointer, 1572 .pointer = snd_es18xx_capture_pointer,
1567}; 1573};
1568 1574
1569static void snd_es18xx_pcm_free(snd_pcm_t *pcm) 1575static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm)
1570{
1571 es18xx_t *codec = pcm->private_data;
1572 codec->pcm = NULL;
1573 snd_pcm_lib_preallocate_free_for_all(pcm);
1574}
1575
1576static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm)
1577{ 1576{
1578 snd_pcm_t *pcm; 1577 struct snd_pcm *pcm;
1579 char str[16]; 1578 char str[16];
1580 int err; 1579 int err;
1581 1580
1582 if (rpcm) 1581 if (rpcm)
1583 *rpcm = NULL; 1582 *rpcm = NULL;
1584 sprintf(str, "ES%x", chip->version); 1583 sprintf(str, "ES%x", chip->version);
1585 if (chip->caps & ES18XX_PCM2) { 1584 if (chip->caps & ES18XX_PCM2)
1586 err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); 1585 err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm);
1587 } else { 1586 else
1588 err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); 1587 err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm);
1589 }
1590 if (err < 0) 1588 if (err < 0)
1591 return err; 1589 return err;
1592 1590
@@ -1595,7 +1593,6 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc
1595 1593
1596 /* global setup */ 1594 /* global setup */
1597 pcm->private_data = chip; 1595 pcm->private_data = chip;
1598 pcm->private_free = snd_es18xx_pcm_free;
1599 pcm->info_flags = 0; 1596 pcm->info_flags = 0;
1600 if (chip->caps & ES18XX_DUPLEX_SAME) 1597 if (chip->caps & ES18XX_DUPLEX_SAME)
1601 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; 1598 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX;
@@ -1616,9 +1613,12 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc
1616 1613
1617/* Power Management support functions */ 1614/* Power Management support functions */
1618#ifdef CONFIG_PM 1615#ifdef CONFIG_PM
1619static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state) 1616static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
1620{ 1617{
1621 es18xx_t *chip = card->pm_private_data; 1618 struct snd_audiodrive *acard = card->private_data;
1619 struct snd_es18xx *chip = acard->chip;
1620
1621 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
1622 1622
1623 snd_pcm_suspend_all(chip->pcm); 1623 snd_pcm_suspend_all(chip->pcm);
1624 1624
@@ -1631,18 +1631,20 @@ static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state)
1631 return 0; 1631 return 0;
1632} 1632}
1633 1633
1634static int snd_es18xx_resume(snd_card_t *card) 1634static int snd_es18xx_resume(struct snd_card *card)
1635{ 1635{
1636 es18xx_t *chip = card->pm_private_data; 1636 struct snd_audiodrive *acard = card->private_data;
1637 struct snd_es18xx *chip = acard->chip;
1637 1638
1638 /* restore PM register, we won't wake till (not 0x07) i/o activity though */ 1639 /* restore PM register, we won't wake till (not 0x07) i/o activity though */
1639 snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); 1640 snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
1640 1641
1642 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
1641 return 0; 1643 return 0;
1642} 1644}
1643#endif /* CONFIG_PM */ 1645#endif /* CONFIG_PM */
1644 1646
1645static int snd_es18xx_free(es18xx_t *chip) 1647static int snd_es18xx_free(struct snd_es18xx *chip)
1646{ 1648{
1647 release_and_free_resource(chip->res_port); 1649 release_and_free_resource(chip->res_port);
1648 release_and_free_resource(chip->res_ctrl_port); 1650 release_and_free_resource(chip->res_ctrl_port);
@@ -1661,21 +1663,21 @@ static int snd_es18xx_free(es18xx_t *chip)
1661 return 0; 1663 return 0;
1662} 1664}
1663 1665
1664static int snd_es18xx_dev_free(snd_device_t *device) 1666static int snd_es18xx_dev_free(struct snd_device *device)
1665{ 1667{
1666 es18xx_t *chip = device->device_data; 1668 struct snd_es18xx *chip = device->device_data;
1667 return snd_es18xx_free(chip); 1669 return snd_es18xx_free(chip);
1668} 1670}
1669 1671
1670static int __devinit snd_es18xx_new_device(snd_card_t * card, 1672static int __devinit snd_es18xx_new_device(struct snd_card *card,
1671 unsigned long port, 1673 unsigned long port,
1672 unsigned long mpu_port, 1674 unsigned long mpu_port,
1673 unsigned long fm_port, 1675 unsigned long fm_port,
1674 int irq, int dma1, int dma2, 1676 int irq, int dma1, int dma2,
1675 es18xx_t ** rchip) 1677 struct snd_es18xx ** rchip)
1676{ 1678{
1677 es18xx_t *chip; 1679 struct snd_es18xx *chip;
1678 static snd_device_ops_t ops = { 1680 static struct snd_device_ops ops = {
1679 .dev_free = snd_es18xx_dev_free, 1681 .dev_free = snd_es18xx_dev_free,
1680 }; 1682 };
1681 int err; 1683 int err;
@@ -1736,9 +1738,9 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card,
1736 return 0; 1738 return 0;
1737} 1739}
1738 1740
1739static int __devinit snd_es18xx_mixer(es18xx_t *chip) 1741static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip)
1740{ 1742{
1741 snd_card_t *card; 1743 struct snd_card *card;
1742 int err; 1744 int err;
1743 unsigned int idx; 1745 unsigned int idx;
1744 1746
@@ -1747,7 +1749,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip)
1747 strcpy(card->mixername, chip->pcm->name); 1749 strcpy(card->mixername, chip->pcm->name);
1748 1750
1749 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { 1751 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
1750 snd_kcontrol_t *kctl; 1752 struct snd_kcontrol *kctl;
1751 kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip); 1753 kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip);
1752 if (chip->caps & ES18XX_HWV) { 1754 if (chip->caps & ES18XX_HWV) {
1753 switch (idx) { 1755 switch (idx) {
@@ -1805,7 +1807,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip)
1805 } 1807 }
1806 if (chip->caps & ES18XX_HWV) { 1808 if (chip->caps & ES18XX_HWV) {
1807 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) { 1809 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) {
1808 snd_kcontrol_t *kctl; 1810 struct snd_kcontrol *kctl;
1809 kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip); 1811 kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip);
1810 if (idx == 0) 1812 if (idx == 0)
1811 chip->hw_volume = kctl; 1813 chip->hw_volume = kctl;
@@ -1875,14 +1877,8 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver.");
1875module_param_array(dma2, int, NULL, 0444); 1877module_param_array(dma2, int, NULL, 0444);
1876MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); 1878MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
1877 1879
1878struct snd_audiodrive { 1880static struct platform_device *platform_devices[SNDRV_CARDS];
1879#ifdef CONFIG_PNP 1881static int pnp_registered;
1880 struct pnp_dev *dev;
1881 struct pnp_dev *devc;
1882#endif
1883};
1884
1885static snd_card_t *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
1886 1882
1887#ifdef CONFIG_PNP 1883#ifdef CONFIG_PNP
1888 1884
@@ -1989,227 +1985,281 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard,
1989#define is_isapnp_selected(dev) 0 1985#define is_isapnp_selected(dev) 0
1990#endif 1986#endif
1991 1987
1992static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, 1988static struct snd_card *snd_es18xx_card_new(int dev)
1993 const struct pnp_card_device_id *pid)
1994{ 1989{
1995 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; 1990 return snd_card_new(index[dev], id[dev], THIS_MODULE,
1996 static int possible_dmas[] = {1, 0, 3, 5, -1};
1997 int xirq, xdma1, xdma2;
1998 snd_card_t *card;
1999 struct snd_audiodrive *acard;
2000 es18xx_t *chip;
2001 opl3_t *opl3;
2002 int err;
2003
2004 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
2005 sizeof(struct snd_audiodrive)); 1991 sizeof(struct snd_audiodrive));
2006 if (card == NULL) 1992}
2007 return -ENOMEM;
2008 acard = (struct snd_audiodrive *)card->private_data;
2009#ifdef CONFIG_PNP
2010 if (isapnp[dev]) {
2011 if ((err = snd_audiodrive_pnp(dev, acard, pcard, pid)) < 0) {
2012 snd_card_free(card);
2013 return err;
2014 }
2015 snd_card_set_dev(card, &pcard->card->dev);
2016 }
2017#endif
2018 1993
2019 xirq = irq[dev]; 1994static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
2020 if (xirq == SNDRV_AUTO_IRQ) { 1995{
2021 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 1996 struct snd_audiodrive *acard = card->private_data;
2022 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); 1997 struct snd_es18xx *chip;
2023 err = -EBUSY; 1998 struct snd_opl3 *opl3;
2024 goto _err; 1999 int err;
2025 }
2026 }
2027 xdma1 = dma1[dev];
2028 if (xdma1 == SNDRV_AUTO_DMA) {
2029 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2030 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
2031 err = -EBUSY;
2032 goto _err;
2033 }
2034 }
2035 xdma2 = dma2[dev];
2036 if (xdma2 == SNDRV_AUTO_DMA) {
2037 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2038 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
2039 err = -EBUSY;
2040 goto _err;
2041 }
2042 }
2043 2000
2044 if ((err = snd_es18xx_new_device(card, 2001 if ((err = snd_es18xx_new_device(card,
2045 port[dev], 2002 port[dev],
2046 mpu_port[dev], 2003 mpu_port[dev],
2047 fm_port[dev], 2004 fm_port[dev],
2048 xirq, xdma1, xdma2, 2005 irq[dev], dma1[dev], dma2[dev],
2049 &chip)) < 0) 2006 &chip)) < 0)
2050 goto _err; 2007 return err;
2008 acard->chip = chip;
2051 2009
2052 sprintf(card->driver, "ES%x", chip->version); 2010 sprintf(card->driver, "ES%x", chip->version);
2011
2053 sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version); 2012 sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version);
2054 if (xdma1 != xdma2) 2013 if (dma1[dev] != dma2[dev])
2055 sprintf(card->longname, "%s at 0x%lx, irq %d, dma1 %d, dma2 %d", 2014 sprintf(card->longname, "%s at 0x%lx, irq %d, dma1 %d, dma2 %d",
2056 card->shortname, 2015 card->shortname,
2057 chip->port, 2016 chip->port,
2058 xirq, xdma1, xdma2); 2017 irq[dev], dma1[dev], dma2[dev]);
2059 else 2018 else
2060 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 2019 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
2061 card->shortname, 2020 card->shortname,
2062 chip->port, 2021 chip->port,
2063 xirq, xdma1); 2022 irq[dev], dma1[dev]);
2064 2023
2065 if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) 2024 if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0)
2066 goto _err; 2025 return err;
2067 2026
2068 if ((err = snd_es18xx_mixer(chip)) < 0) 2027 if ((err = snd_es18xx_mixer(chip)) < 0)
2069 goto _err; 2028 return err;
2070 2029
2071 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 2030 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
2072 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { 2031 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) {
2073 snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); 2032 snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port);
2074 } else { 2033 } else {
2075 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) 2034 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
2076 goto _err; 2035 return err;
2077 } 2036 }
2078 } 2037 }
2079 2038
2080 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 2039 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
2081 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, 2040 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
2082 chip->mpu_port, 0, 2041 chip->mpu_port, 0,
2083 xirq, 0, 2042 irq[dev], 0,
2084 &chip->rmidi)) < 0) 2043 &chip->rmidi)) < 0)
2085 goto _err; 2044 return err;
2086 } 2045 }
2087 2046
2088 if ((err = snd_card_set_generic_dev(card)) < 0) 2047 return snd_card_register(card);
2089 goto _err; 2048}
2090
2091 /* Power Management */
2092 snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip);
2093 2049
2094 if ((err = snd_card_register(card)) < 0) 2050static int __init snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr)
2095 goto _err; 2051{
2052 struct snd_card *card;
2053 int err;
2096 2054
2097 if (pcard) 2055 card = snd_es18xx_card_new(dev);
2098 pnp_set_card_drvdata(pcard, card); 2056 if (! card)
2099 else 2057 return -ENOMEM;
2100 snd_audiodrive_legacy[dev] = card; 2058 snd_card_set_dev(card, &devptr->dev);
2059 if ((err = snd_audiodrive_probe(card, dev)) < 0) {
2060 snd_card_free(card);
2061 return err;
2062 }
2063 platform_set_drvdata(devptr, card);
2101 return 0; 2064 return 0;
2102
2103 _err:
2104 snd_card_free(card);
2105 return err;
2106} 2065}
2107 2066
2108static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) 2067static int __init snd_es18xx_nonpnp_probe(struct platform_device *pdev)
2109{ 2068{
2110 static int dev; 2069 int dev = pdev->id;
2111 int res; 2070 int err;
2071 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2072 static int possible_dmas[] = {1, 0, 3, 5, -1};
2112 2073
2113 for ( ; dev < SNDRV_CARDS; dev++) { 2074 if (irq[dev] == SNDRV_AUTO_IRQ) {
2114 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 2075 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
2115 continue; 2076 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
2116 if (is_isapnp_selected(dev)) 2077 return -EBUSY;
2117 continue; 2078 }
2118 port[dev] = xport; 2079 }
2119 res = snd_audiodrive_probe(dev, NULL, NULL); 2080 if (dma1[dev] == SNDRV_AUTO_DMA) {
2120 if (res < 0) 2081 if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2121 port[dev] = SNDRV_AUTO_PORT; 2082 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
2122 return res; 2083 return -EBUSY;
2084 }
2085 }
2086 if (dma2[dev] == SNDRV_AUTO_DMA) {
2087 if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2088 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
2089 return -EBUSY;
2090 }
2091 }
2092
2093 if (port[dev] != SNDRV_AUTO_PORT) {
2094 return snd_es18xx_nonpnp_probe1(dev, pdev);
2095 } else {
2096 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
2097 int i;
2098 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
2099 port[dev] = possible_ports[i];
2100 err = snd_es18xx_nonpnp_probe1(dev, pdev);
2101 if (! err)
2102 return 0;
2103 }
2104 return err;
2123 } 2105 }
2124 return -ENODEV;
2125} 2106}
2126 2107
2108static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr)
2109{
2110 snd_card_free(platform_get_drvdata(devptr));
2111 platform_set_drvdata(devptr, NULL);
2112 return 0;
2113}
2114
2115#ifdef CONFIG_PM
2116static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state)
2117{
2118 return snd_es18xx_suspend(platform_get_drvdata(dev), state);
2119}
2120
2121static int snd_es18xx_nonpnp_resume(struct platform_device *dev)
2122{
2123 return snd_es18xx_resume(platform_get_drvdata(dev));
2124}
2125#endif
2126
2127#define ES18XX_DRIVER "snd_es18xx"
2128
2129static struct platform_driver snd_es18xx_nonpnp_driver = {
2130 .probe = snd_es18xx_nonpnp_probe,
2131 .remove = __devexit_p(snd_es18xx_nonpnp_remove),
2132#ifdef CONFIG_PM
2133 .suspend = snd_es18xx_nonpnp_suspend,
2134 .resume = snd_es18xx_nonpnp_resume,
2135#endif
2136 .driver = {
2137 .name = ES18XX_DRIVER
2138 },
2139};
2140
2127 2141
2128#ifdef CONFIG_PNP 2142#ifdef CONFIG_PNP
2129static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *card, 2143static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *pcard,
2130 const struct pnp_card_device_id *id) 2144 const struct pnp_card_device_id *pid)
2131{ 2145{
2132 static int dev; 2146 static int dev;
2147 struct snd_card *card;
2133 int res; 2148 int res;
2134 2149
2135 for ( ; dev < SNDRV_CARDS; dev++) { 2150 for ( ; dev < SNDRV_CARDS; dev++) {
2136 if (!enable[dev] || !isapnp[dev]) 2151 if (enable[dev] && isapnp[dev])
2137 continue; 2152 break;
2138 res = snd_audiodrive_probe(dev, card, id); 2153 }
2139 if (res < 0) 2154 if (dev >= SNDRV_CARDS)
2140 return res; 2155 return -ENODEV;
2141 dev++;
2142 return 0;
2143 }
2144 2156
2145 return -ENODEV; 2157 card = snd_es18xx_card_new(dev);
2158 if (! card)
2159 return -ENOMEM;
2160
2161 if ((res = snd_audiodrive_pnp(dev, card->private_data, pcard, pid)) < 0) {
2162 snd_card_free(card);
2163 return res;
2164 }
2165 snd_card_set_dev(card, &pcard->card->dev);
2166 if ((res = snd_audiodrive_probe(card, dev)) < 0) {
2167 snd_card_free(card);
2168 return res;
2169 }
2170
2171 pnp_set_card_drvdata(pcard, card);
2172 dev++;
2173 return 0;
2146} 2174}
2147 2175
2148static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard) 2176static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard)
2149{ 2177{
2150 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 2178 snd_card_free(pnp_get_card_drvdata(pcard));
2179 pnp_set_card_drvdata(pcard, NULL);
2180}
2181
2182#ifdef CONFIG_PM
2183static int snd_audiodrive_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
2184{
2185 return snd_es18xx_suspend(pnp_get_card_drvdata(pcard), state);
2186}
2151 2187
2152 snd_card_disconnect(card); 2188static int snd_audiodrive_pnp_resume(struct pnp_card_link *pcard)
2153 snd_card_free_in_thread(card); 2189{
2190 return snd_es18xx_resume(pnp_get_card_drvdata(pcard));
2154} 2191}
2155 2192
2193#endif
2194
2156static struct pnp_card_driver es18xx_pnpc_driver = { 2195static struct pnp_card_driver es18xx_pnpc_driver = {
2157 .flags = PNP_DRIVER_RES_DISABLE, 2196 .flags = PNP_DRIVER_RES_DISABLE,
2158 .name = "es18xx", 2197 .name = "es18xx",
2159 .id_table = snd_audiodrive_pnpids, 2198 .id_table = snd_audiodrive_pnpids,
2160 .probe = snd_audiodrive_pnp_detect, 2199 .probe = snd_audiodrive_pnp_detect,
2161 .remove = __devexit_p(snd_audiodrive_pnp_remove), 2200 .remove = __devexit_p(snd_audiodrive_pnp_remove),
2201#ifdef CONFIG_PM
2202 .suspend = snd_audiodrive_pnp_suspend,
2203 .resume = snd_audiodrive_pnp_resume,
2204#endif
2162}; 2205};
2163#endif /* CONFIG_PNP */ 2206#endif /* CONFIG_PNP */
2164 2207
2208static void __init_or_module snd_es18xx_unregister_all(void)
2209{
2210 int i;
2211
2212 if (pnp_registered)
2213 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2214 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
2215 platform_device_unregister(platform_devices[i]);
2216 platform_driver_unregister(&snd_es18xx_nonpnp_driver);
2217}
2218
2165static int __init alsa_card_es18xx_init(void) 2219static int __init alsa_card_es18xx_init(void)
2166{ 2220{
2167 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1}; 2221 int i, err, cards = 0;
2168 int dev, cards = 0, i;
2169 2222
2170 /* legacy non-auto cards at first */ 2223 if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0)
2171 for (dev = 0; dev < SNDRV_CARDS; dev++) { 2224 return err;
2172 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 2225
2173 continue; 2226 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
2174 if (is_isapnp_selected(dev)) 2227 struct platform_device *device;
2228 if (is_isapnp_selected(i))
2175 continue; 2229 continue;
2176 if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) 2230 device = platform_device_register_simple(ES18XX_DRIVER,
2177 cards++; 2231 i, NULL, 0);
2232 if (IS_ERR(device)) {
2233 err = PTR_ERR(device);
2234 goto errout;
2235 }
2236 platform_devices[i] = device;
2237 cards++;
2178 } 2238 }
2179 /* legacy auto configured cards */
2180 i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_probe_legacy_port);
2181 if (i > 0)
2182 cards += i;
2183 2239
2184#ifdef CONFIG_PNP
2185 /* ISA PnP cards at last */
2186 i = pnp_register_card_driver(&es18xx_pnpc_driver); 2240 i = pnp_register_card_driver(&es18xx_pnpc_driver);
2187 if (i > 0) 2241 if (i >= 0) {
2242 pnp_registered = 1;
2188 cards += i; 2243 cards += i;
2244 }
2189 2245
2190#endif
2191 if(!cards) { 2246 if(!cards) {
2192#ifdef CONFIG_PNP
2193 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2194#endif
2195#ifdef MODULE 2247#ifdef MODULE
2196 snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); 2248 snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");
2197#endif 2249#endif
2198 return -ENODEV; 2250 err = -ENODEV;
2251 goto errout;
2199 } 2252 }
2200 return 0; 2253 return 0;
2254
2255 errout:
2256 snd_es18xx_unregister_all();
2257 return err;
2201} 2258}
2202 2259
2203static void __exit alsa_card_es18xx_exit(void) 2260static void __exit alsa_card_es18xx_exit(void)
2204{ 2261{
2205 int idx; 2262 snd_es18xx_unregister_all();
2206
2207#ifdef CONFIG_PNP
2208 /* PnP cards first */
2209 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2210#endif
2211 for(idx = 0; idx < SNDRV_CARDS; idx++)
2212 snd_card_free(snd_audiodrive_legacy[idx]);
2213} 2263}
2214 2264
2215module_init(alsa_card_es18xx_init) 2265module_init(alsa_card_es18xx_init)
diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
index ef1b2e9832e4..930f4bc56f34 100644
--- a/sound/isa/gus/gus_dma.c
+++ b/sound/isa/gus/gus_dma.c
@@ -25,7 +25,7 @@
25#include <sound/core.h> 25#include <sound/core.h>
26#include <sound/gus.h> 26#include <sound/gus.h>
27 27
28static void snd_gf1_dma_ack(snd_gus_card_t * gus) 28static void snd_gf1_dma_ack(struct snd_gus_card * gus)
29{ 29{
30 unsigned long flags; 30 unsigned long flags;
31 31
@@ -35,7 +35,7 @@ static void snd_gf1_dma_ack(snd_gus_card_t * gus)
35 spin_unlock_irqrestore(&gus->reg_lock, flags); 35 spin_unlock_irqrestore(&gus->reg_lock, flags);
36} 36}
37 37
38static void snd_gf1_dma_program(snd_gus_card_t * gus, 38static void snd_gf1_dma_program(struct snd_gus_card * gus,
39 unsigned int addr, 39 unsigned int addr,
40 unsigned long buf_addr, 40 unsigned long buf_addr,
41 unsigned int count, 41 unsigned int count,
@@ -91,9 +91,9 @@ static void snd_gf1_dma_program(snd_gus_card_t * gus,
91 spin_unlock_irqrestore(&gus->reg_lock, flags); 91 spin_unlock_irqrestore(&gus->reg_lock, flags);
92} 92}
93 93
94static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus) 94static struct snd_gf1_dma_block *snd_gf1_dma_next_block(struct snd_gus_card * gus)
95{ 95{
96 snd_gf1_dma_block_t *block; 96 struct snd_gf1_dma_block *block;
97 97
98 /* PCM block have bigger priority than synthesizer one */ 98 /* PCM block have bigger priority than synthesizer one */
99 if (gus->gf1.dma_data_pcm) { 99 if (gus->gf1.dma_data_pcm) {
@@ -123,9 +123,9 @@ static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus)
123} 123}
124 124
125 125
126static void snd_gf1_dma_interrupt(snd_gus_card_t * gus) 126static void snd_gf1_dma_interrupt(struct snd_gus_card * gus)
127{ 127{
128 snd_gf1_dma_block_t *block; 128 struct snd_gf1_dma_block *block;
129 129
130 snd_gf1_dma_ack(gus); 130 snd_gf1_dma_ack(gus);
131 if (gus->gf1.dma_ack) 131 if (gus->gf1.dma_ack)
@@ -147,7 +147,7 @@ static void snd_gf1_dma_interrupt(snd_gus_card_t * gus)
147#endif 147#endif
148} 148}
149 149
150int snd_gf1_dma_init(snd_gus_card_t * gus) 150int snd_gf1_dma_init(struct snd_gus_card * gus)
151{ 151{
152 down(&gus->dma_mutex); 152 down(&gus->dma_mutex);
153 gus->gf1.dma_shared++; 153 gus->gf1.dma_shared++;
@@ -164,9 +164,9 @@ int snd_gf1_dma_init(snd_gus_card_t * gus)
164 return 0; 164 return 0;
165} 165}
166 166
167int snd_gf1_dma_done(snd_gus_card_t * gus) 167int snd_gf1_dma_done(struct snd_gus_card * gus)
168{ 168{
169 snd_gf1_dma_block_t *block; 169 struct snd_gf1_dma_block *block;
170 170
171 down(&gus->dma_mutex); 171 down(&gus->dma_mutex);
172 gus->gf1.dma_shared--; 172 gus->gf1.dma_shared--;
@@ -189,13 +189,13 @@ int snd_gf1_dma_done(snd_gus_card_t * gus)
189 return 0; 189 return 0;
190} 190}
191 191
192int snd_gf1_dma_transfer_block(snd_gus_card_t * gus, 192int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
193 snd_gf1_dma_block_t * __block, 193 struct snd_gf1_dma_block * __block,
194 int atomic, 194 int atomic,
195 int synth) 195 int synth)
196{ 196{
197 unsigned long flags; 197 unsigned long flags;
198 snd_gf1_dma_block_t *block; 198 struct snd_gf1_dma_block *block;
199 199
200 block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL); 200 block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL);
201 if (block == NULL) { 201 if (block == NULL) {
diff --git a/sound/isa/gus/gus_dram.c b/sound/isa/gus/gus_dram.c
index 22120b868b5c..f22fe7967fcc 100644
--- a/sound/isa/gus/gus_dram.c
+++ b/sound/isa/gus/gus_dram.c
@@ -26,7 +26,7 @@
26#include <sound/info.h> 26#include <sound/info.h>
27 27
28 28
29static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer, 29static int snd_gus_dram_poke(struct snd_gus_card *gus, char __user *_buffer,
30 unsigned int address, unsigned int size) 30 unsigned int address, unsigned int size)
31{ 31{
32 unsigned long flags; 32 unsigned long flags;
@@ -57,13 +57,13 @@ static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer,
57} 57}
58 58
59 59
60int snd_gus_dram_write(snd_gus_card_t *gus, char __user *buffer, 60int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer,
61 unsigned int address, unsigned int size) 61 unsigned int address, unsigned int size)
62{ 62{
63 return snd_gus_dram_poke(gus, buffer, address, size); 63 return snd_gus_dram_poke(gus, buffer, address, size);
64} 64}
65 65
66static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer, 66static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer,
67 unsigned int address, unsigned int size, 67 unsigned int address, unsigned int size,
68 int rom) 68 int rom)
69{ 69{
@@ -95,7 +95,7 @@ static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer,
95 return 0; 95 return 0;
96} 96}
97 97
98int snd_gus_dram_read(snd_gus_card_t *gus, char __user *buffer, 98int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer,
99 unsigned int address, unsigned int size, 99 unsigned int address, unsigned int size,
100 int rom) 100 int rom)
101{ 101{
diff --git a/sound/isa/gus/gus_instr.c b/sound/isa/gus/gus_instr.c
index 591a9a17feb5..d0c38e1856ef 100644
--- a/sound/isa/gus/gus_instr.c
+++ b/sound/isa/gus/gus_instr.c
@@ -28,11 +28,11 @@
28 * 28 *
29 */ 29 */
30 30
31int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, 31int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave,
32 char __user *data, long len, int atomic) 32 char __user *data, long len, int atomic)
33{ 33{
34 snd_gus_card_t *gus = private_data; 34 struct snd_gus_card *gus = private_data;
35 snd_gf1_mem_block_t *block; 35 struct snd_gf1_mem_block *block;
36 int err; 36 int err;
37 37
38 if (wave->format & IWFFFF_WAVE_ROM) 38 if (wave->format & IWFFFF_WAVE_ROM)
@@ -58,19 +58,19 @@ int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave,
58 return 0; 58 return 0;
59} 59}
60 60
61int snd_gus_iwffff_get_sample(void *private_data, iwffff_wave_t *wave, 61int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave,
62 char __user *data, long len, int atomic) 62 char __user *data, long len, int atomic)
63{ 63{
64 snd_gus_card_t *gus = private_data; 64 struct snd_gus_card *gus = private_data;
65 65
66 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 66 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size,
67 wave->format & IWFFFF_WAVE_ROM ? 1 : 0); 67 wave->format & IWFFFF_WAVE_ROM ? 1 : 0);
68} 68}
69 69
70int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, 70int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave,
71 int atomic) 71 int atomic)
72{ 72{
73 snd_gus_card_t *gus = private_data; 73 struct snd_gus_card *gus = private_data;
74 74
75 if (wave->format & IWFFFF_WAVE_ROM) 75 if (wave->format & IWFFFF_WAVE_ROM)
76 return 0; /* it's probably ok - verify the address? */ 76 return 0; /* it's probably ok - verify the address? */
@@ -81,11 +81,11 @@ int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave,
81 * 81 *
82 */ 82 */
83 83
84int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, 84int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave,
85 char __user *data, long len, int atomic) 85 char __user *data, long len, int atomic)
86{ 86{
87 snd_gus_card_t *gus = private_data; 87 struct snd_gus_card *gus = private_data;
88 snd_gf1_mem_block_t *block; 88 struct snd_gf1_mem_block *block;
89 int err; 89 int err;
90 90
91 if (wave->format & GF1_WAVE_STEREO) 91 if (wave->format & GF1_WAVE_STEREO)
@@ -109,18 +109,18 @@ int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave,
109 return 0; 109 return 0;
110} 110}
111 111
112int snd_gus_gf1_get_sample(void *private_data, gf1_wave_t *wave, 112int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave,
113 char __user *data, long len, int atomic) 113 char __user *data, long len, int atomic)
114{ 114{
115 snd_gus_card_t *gus = private_data; 115 struct snd_gus_card *gus = private_data;
116 116
117 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0); 117 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0);
118} 118}
119 119
120int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, 120int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave,
121 int atomic) 121 int atomic)
122{ 122{
123 snd_gus_card_t *gus = private_data; 123 struct snd_gus_card *gus = private_data;
124 124
125 return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); 125 return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory);
126} 126}
@@ -129,11 +129,11 @@ int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave,
129 * 129 *
130 */ 130 */
131 131
132int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, 132int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr,
133 char __user *data, long len, int atomic) 133 char __user *data, long len, int atomic)
134{ 134{
135 snd_gus_card_t *gus = private_data; 135 struct snd_gus_card *gus = private_data;
136 snd_gf1_mem_block_t *block; 136 struct snd_gf1_mem_block *block;
137 int err; 137 int err;
138 138
139 if (instr->format & SIMPLE_WAVE_STEREO) 139 if (instr->format & SIMPLE_WAVE_STEREO)
@@ -156,18 +156,18 @@ int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr,
156 return 0; 156 return 0;
157} 157}
158 158
159int snd_gus_simple_get_sample(void *private_data, simple_instrument_t *instr, 159int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr,
160 char __user *data, long len, int atomic) 160 char __user *data, long len, int atomic)
161{ 161{
162 snd_gus_card_t *gus = private_data; 162 struct snd_gus_card *gus = private_data;
163 163
164 return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0); 164 return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0);
165} 165}
166 166
167int snd_gus_simple_remove_sample(void *private_data, simple_instrument_t *instr, 167int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr,
168 int atomic) 168 int atomic)
169{ 169{
170 snd_gus_card_t *gus = private_data; 170 struct snd_gus_card *gus = private_data;
171 171
172 return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory); 172 return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory);
173} 173}
diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c
index 8d5752b23787..9b1fe292de4d 100644
--- a/sound/isa/gus/gus_io.c
+++ b/sound/isa/gus/gus_io.c
@@ -25,7 +25,7 @@
25#include <sound/core.h> 25#include <sound/core.h>
26#include <sound/gus.h> 26#include <sound/gus.h>
27 27
28void snd_gf1_delay(snd_gus_card_t * gus) 28void snd_gf1_delay(struct snd_gus_card * gus)
29{ 29{
30 int i; 30 int i;
31 31
@@ -44,7 +44,7 @@ void snd_gf1_delay(snd_gus_card_t * gus)
44 * big UltraClick (tm) elimination... 44 * big UltraClick (tm) elimination...
45 */ 45 */
46 46
47static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) 47static inline void __snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
48{ 48{
49 unsigned char value; 49 unsigned char value;
50 50
@@ -58,7 +58,7 @@ static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg)
58 mb(); 58 mb();
59} 59}
60 60
61static inline void __snd_gf1_write8(snd_gus_card_t * gus, 61static inline void __snd_gf1_write8(struct snd_gus_card * gus,
62 unsigned char reg, 62 unsigned char reg,
63 unsigned char data) 63 unsigned char data)
64{ 64{
@@ -68,7 +68,7 @@ static inline void __snd_gf1_write8(snd_gus_card_t * gus,
68 mb(); 68 mb();
69} 69}
70 70
71static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus, 71static inline unsigned char __snd_gf1_look8(struct snd_gus_card * gus,
72 unsigned char reg) 72 unsigned char reg)
73{ 73{
74 outb(reg, gus->gf1.reg_regsel); 74 outb(reg, gus->gf1.reg_regsel);
@@ -76,7 +76,7 @@ static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus,
76 return inb(gus->gf1.reg_data8); 76 return inb(gus->gf1.reg_data8);
77} 77}
78 78
79static inline void __snd_gf1_write16(snd_gus_card_t * gus, 79static inline void __snd_gf1_write16(struct snd_gus_card * gus,
80 unsigned char reg, unsigned int data) 80 unsigned char reg, unsigned int data)
81{ 81{
82 outb(reg, gus->gf1.reg_regsel); 82 outb(reg, gus->gf1.reg_regsel);
@@ -85,7 +85,7 @@ static inline void __snd_gf1_write16(snd_gus_card_t * gus,
85 mb(); 85 mb();
86} 86}
87 87
88static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus, 88static inline unsigned short __snd_gf1_look16(struct snd_gus_card * gus,
89 unsigned char reg) 89 unsigned char reg)
90{ 90{
91 outb(reg, gus->gf1.reg_regsel); 91 outb(reg, gus->gf1.reg_regsel);
@@ -93,7 +93,7 @@ static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus,
93 return inw(gus->gf1.reg_data16); 93 return inw(gus->gf1.reg_data16);
94} 94}
95 95
96static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus, 96static inline void __snd_gf1_adlib_write(struct snd_gus_card * gus,
97 unsigned char reg, unsigned char data) 97 unsigned char reg, unsigned char data)
98{ 98{
99 outb(reg, gus->gf1.reg_timerctrl); 99 outb(reg, gus->gf1.reg_timerctrl);
@@ -104,7 +104,7 @@ static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus,
104 inb(gus->gf1.reg_timerctrl); 104 inb(gus->gf1.reg_timerctrl);
105} 105}
106 106
107static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, 107static inline void __snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg,
108 unsigned int addr, int w_16bit) 108 unsigned int addr, int w_16bit)
109{ 109{
110 if (gus->gf1.enh_mode) { 110 if (gus->gf1.enh_mode) {
@@ -117,7 +117,7 @@ static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg,
117 __snd_gf1_write16(gus, reg + 1, (unsigned short) (addr << 5)); 117 __snd_gf1_write16(gus, reg + 1, (unsigned short) (addr << 5));
118} 118}
119 119
120static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus, 120static inline unsigned int __snd_gf1_read_addr(struct snd_gus_card * gus,
121 unsigned char reg, short w_16bit) 121 unsigned char reg, short w_16bit)
122{ 122{
123 unsigned int res; 123 unsigned int res;
@@ -138,49 +138,49 @@ static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus,
138 * ======================================================================= 138 * =======================================================================
139 */ 139 */
140 140
141void snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) 141void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
142{ 142{
143 __snd_gf1_ctrl_stop(gus, reg); 143 __snd_gf1_ctrl_stop(gus, reg);
144} 144}
145 145
146void snd_gf1_write8(snd_gus_card_t * gus, 146void snd_gf1_write8(struct snd_gus_card * gus,
147 unsigned char reg, 147 unsigned char reg,
148 unsigned char data) 148 unsigned char data)
149{ 149{
150 __snd_gf1_write8(gus, reg, data); 150 __snd_gf1_write8(gus, reg, data);
151} 151}
152 152
153unsigned char snd_gf1_look8(snd_gus_card_t * gus, unsigned char reg) 153unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg)
154{ 154{
155 return __snd_gf1_look8(gus, reg); 155 return __snd_gf1_look8(gus, reg);
156} 156}
157 157
158void snd_gf1_write16(snd_gus_card_t * gus, 158void snd_gf1_write16(struct snd_gus_card * gus,
159 unsigned char reg, 159 unsigned char reg,
160 unsigned int data) 160 unsigned int data)
161{ 161{
162 __snd_gf1_write16(gus, reg, data); 162 __snd_gf1_write16(gus, reg, data);
163} 163}
164 164
165unsigned short snd_gf1_look16(snd_gus_card_t * gus, unsigned char reg) 165unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg)
166{ 166{
167 return __snd_gf1_look16(gus, reg); 167 return __snd_gf1_look16(gus, reg);
168} 168}
169 169
170void snd_gf1_adlib_write(snd_gus_card_t * gus, 170void snd_gf1_adlib_write(struct snd_gus_card * gus,
171 unsigned char reg, 171 unsigned char reg,
172 unsigned char data) 172 unsigned char data)
173{ 173{
174 __snd_gf1_adlib_write(gus, reg, data); 174 __snd_gf1_adlib_write(gus, reg, data);
175} 175}
176 176
177void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, 177void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg,
178 unsigned int addr, short w_16bit) 178 unsigned int addr, short w_16bit)
179{ 179{
180 __snd_gf1_write_addr(gus, reg, addr, w_16bit); 180 __snd_gf1_write_addr(gus, reg, addr, w_16bit);
181} 181}
182 182
183unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, 183unsigned int snd_gf1_read_addr(struct snd_gus_card * gus,
184 unsigned char reg, 184 unsigned char reg,
185 short w_16bit) 185 short w_16bit)
186{ 186{
@@ -191,7 +191,7 @@ unsigned int snd_gf1_read_addr(snd_gus_card_t * gus,
191 191
192 */ 192 */
193 193
194void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) 194void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
195{ 195{
196 unsigned long flags; 196 unsigned long flags;
197 197
@@ -200,7 +200,7 @@ void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg)
200 spin_unlock_irqrestore(&gus->reg_lock, flags); 200 spin_unlock_irqrestore(&gus->reg_lock, flags);
201} 201}
202 202
203void snd_gf1_i_write8(snd_gus_card_t * gus, 203void snd_gf1_i_write8(struct snd_gus_card * gus,
204 unsigned char reg, 204 unsigned char reg,
205 unsigned char data) 205 unsigned char data)
206{ 206{
@@ -211,7 +211,7 @@ void snd_gf1_i_write8(snd_gus_card_t * gus,
211 spin_unlock_irqrestore(&gus->reg_lock, flags); 211 spin_unlock_irqrestore(&gus->reg_lock, flags);
212} 212}
213 213
214unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg) 214unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg)
215{ 215{
216 unsigned long flags; 216 unsigned long flags;
217 unsigned char res; 217 unsigned char res;
@@ -222,7 +222,7 @@ unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg)
222 return res; 222 return res;
223} 223}
224 224
225void snd_gf1_i_write16(snd_gus_card_t * gus, 225void snd_gf1_i_write16(struct snd_gus_card * gus,
226 unsigned char reg, 226 unsigned char reg,
227 unsigned int data) 227 unsigned int data)
228{ 228{
@@ -233,7 +233,7 @@ void snd_gf1_i_write16(snd_gus_card_t * gus,
233 spin_unlock_irqrestore(&gus->reg_lock, flags); 233 spin_unlock_irqrestore(&gus->reg_lock, flags);
234} 234}
235 235
236unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) 236unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg)
237{ 237{
238 unsigned long flags; 238 unsigned long flags;
239 unsigned short res; 239 unsigned short res;
@@ -246,7 +246,7 @@ unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg)
246 246
247#if 0 247#if 0
248 248
249void snd_gf1_i_adlib_write(snd_gus_card_t * gus, 249void snd_gf1_i_adlib_write(struct snd_gus_card * gus,
250 unsigned char reg, 250 unsigned char reg,
251 unsigned char data) 251 unsigned char data)
252{ 252{
@@ -257,7 +257,7 @@ void snd_gf1_i_adlib_write(snd_gus_card_t * gus,
257 spin_unlock_irqrestore(&gus->reg_lock, flags); 257 spin_unlock_irqrestore(&gus->reg_lock, flags);
258} 258}
259 259
260void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, 260void snd_gf1_i_write_addr(struct snd_gus_card * gus, unsigned char reg,
261 unsigned int addr, short w_16bit) 261 unsigned int addr, short w_16bit)
262{ 262{
263 unsigned long flags; 263 unsigned long flags;
@@ -270,7 +270,7 @@ void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg,
270#endif /* 0 */ 270#endif /* 0 */
271 271
272#ifdef CONFIG_SND_DEBUG 272#ifdef CONFIG_SND_DEBUG
273static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, 273static unsigned int snd_gf1_i_read_addr(struct snd_gus_card * gus,
274 unsigned char reg, short w_16bit) 274 unsigned char reg, short w_16bit)
275{ 275{
276 unsigned int res; 276 unsigned int res;
@@ -287,7 +287,7 @@ static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus,
287 287
288 */ 288 */
289 289
290void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr) 290void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr)
291{ 291{
292 outb(0x43, gus->gf1.reg_regsel); 292 outb(0x43, gus->gf1.reg_regsel);
293 mb(); 293 mb();
@@ -299,7 +299,7 @@ void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr)
299 mb(); 299 mb();
300} 300}
301 301
302void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data) 302void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data)
303{ 303{
304 unsigned long flags; 304 unsigned long flags;
305 305
@@ -316,7 +316,7 @@ void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data)
316 spin_unlock_irqrestore(&gus->reg_lock, flags); 316 spin_unlock_irqrestore(&gus->reg_lock, flags);
317} 317}
318 318
319unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) 319unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr)
320{ 320{
321 unsigned long flags; 321 unsigned long flags;
322 unsigned char res; 322 unsigned char res;
@@ -337,7 +337,7 @@ unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr)
337 337
338#if 0 338#if 0
339 339
340void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) 340void snd_gf1_pokew(struct snd_gus_card * gus, unsigned int addr, unsigned short data)
341{ 341{
342 unsigned long flags; 342 unsigned long flags;
343 343
@@ -360,7 +360,7 @@ void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data)
360 spin_unlock_irqrestore(&gus->reg_lock, flags); 360 spin_unlock_irqrestore(&gus->reg_lock, flags);
361} 361}
362 362
363unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr) 363unsigned short snd_gf1_peekw(struct snd_gus_card * gus, unsigned int addr)
364{ 364{
365 unsigned long flags; 365 unsigned long flags;
366 unsigned short res; 366 unsigned short res;
@@ -385,7 +385,7 @@ unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr)
385 return res; 385 return res;
386} 386}
387 387
388void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, 388void snd_gf1_dram_setmem(struct snd_gus_card * gus, unsigned int addr,
389 unsigned short value, unsigned int count) 389 unsigned short value, unsigned int count)
390{ 390{
391 unsigned long port; 391 unsigned long port;
@@ -415,7 +415,7 @@ void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr,
415 415
416#endif /* 0 */ 416#endif /* 0 */
417 417
418void snd_gf1_select_active_voices(snd_gus_card_t * gus) 418void snd_gf1_select_active_voices(struct snd_gus_card * gus)
419{ 419{
420 unsigned short voices; 420 unsigned short voices;
421 421
@@ -443,7 +443,7 @@ void snd_gf1_select_active_voices(snd_gus_card_t * gus)
443 443
444#ifdef CONFIG_SND_DEBUG 444#ifdef CONFIG_SND_DEBUG
445 445
446void snd_gf1_print_voice_registers(snd_gus_card_t * gus) 446void snd_gf1_print_voice_registers(struct snd_gus_card * gus)
447{ 447{
448 unsigned char mode; 448 unsigned char mode;
449 int voice, ctrl; 449 int voice, ctrl;
@@ -477,7 +477,7 @@ void snd_gf1_print_voice_registers(snd_gus_card_t * gus)
477 477
478#if 0 478#if 0
479 479
480void snd_gf1_print_global_registers(snd_gus_card_t * gus) 480void snd_gf1_print_global_registers(struct snd_gus_card * gus)
481{ 481{
482 unsigned char global_mode = 0x00; 482 unsigned char global_mode = 0x00;
483 483
@@ -504,7 +504,7 @@ void snd_gf1_print_global_registers(snd_gus_card_t * gus)
504 } 504 }
505} 505}
506 506
507void snd_gf1_print_setup_registers(snd_gus_card_t * gus) 507void snd_gf1_print_setup_registers(struct snd_gus_card * gus)
508{ 508{
509 printk(KERN_INFO " -S- mix control = 0x%x\n", inb(GUSP(gus, MIXCNTRLREG))); 509 printk(KERN_INFO " -S- mix control = 0x%x\n", inb(GUSP(gus, MIXCNTRLREG)));
510 printk(KERN_INFO " -S- IRQ status = 0x%x\n", inb(GUSP(gus, IRQSTAT))); 510 printk(KERN_INFO " -S- IRQ status = 0x%x\n", inb(GUSP(gus, IRQSTAT)));
@@ -523,7 +523,7 @@ void snd_gf1_print_setup_registers(snd_gus_card_t * gus)
523 } 523 }
524} 524}
525 525
526void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count, int w_16bit) 526void snd_gf1_peek_print_block(struct snd_gus_card * gus, unsigned int addr, int count, int w_16bit)
527{ 527{
528 if (!w_16bit) { 528 if (!w_16bit) {
529 while (count-- > 0) 529 while (count-- > 0)
diff --git a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c
index 1e2a15eb8106..c19ba2910b72 100644
--- a/sound/isa/gus/gus_irq.c
+++ b/sound/isa/gus/gus_irq.c
@@ -32,7 +32,7 @@
32 32
33irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs) 33irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
34{ 34{
35 snd_gus_card_t * gus = dev_id; 35 struct snd_gus_card * gus = dev_id;
36 unsigned char status; 36 unsigned char status;
37 int loop = 100; 37 int loop = 100;
38 int handled = 0; 38 int handled = 0;
@@ -54,7 +54,7 @@ __again:
54 if (status & (0x20 | 0x40)) { 54 if (status & (0x20 | 0x40)) {
55 unsigned int already, _current_; 55 unsigned int already, _current_;
56 unsigned char voice_status, voice; 56 unsigned char voice_status, voice;
57 snd_gus_voice_t *pvoice; 57 struct snd_gus_voice *pvoice;
58 58
59 already = 0; 59 already = 0;
60 while (((voice_status = snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ)) & 0xc0) != 0xc0) { 60 while (((voice_status = snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ)) & 0xc0) != 0xc0) {
@@ -107,11 +107,11 @@ __again:
107} 107}
108 108
109#ifdef CONFIG_SND_DEBUG 109#ifdef CONFIG_SND_DEBUG
110static void snd_gus_irq_info_read(snd_info_entry_t *entry, 110static void snd_gus_irq_info_read(struct snd_info_entry *entry,
111 snd_info_buffer_t * buffer) 111 struct snd_info_buffer *buffer)
112{ 112{
113 snd_gus_card_t *gus; 113 struct snd_gus_card *gus;
114 snd_gus_voice_t *pvoice; 114 struct snd_gus_voice *pvoice;
115 int idx; 115 int idx;
116 116
117 gus = entry->private_data; 117 gus = entry->private_data;
@@ -131,9 +131,9 @@ static void snd_gus_irq_info_read(snd_info_entry_t *entry,
131 } 131 }
132} 132}
133 133
134void snd_gus_irq_profile_init(snd_gus_card_t *gus) 134void snd_gus_irq_profile_init(struct snd_gus_card *gus)
135{ 135{
136 snd_info_entry_t *entry; 136 struct snd_info_entry *entry;
137 137
138 if (! snd_card_proc_new(gus->card, "gusirq", &entry)) 138 if (! snd_card_proc_new(gus->card, "gusirq", &entry))
139 snd_info_set_text_ops(entry, gus, 1024, snd_gus_irq_info_read); 139 snd_info_set_text_ops(entry, gus, 1024, snd_gus_irq_info_read);
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 4f57ff4ab351..6d15b3d18a87 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -35,21 +35,21 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
35MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards"); 35MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
38static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); 38static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches);
39 39
40int snd_gus_use_inc(snd_gus_card_t * gus) 40int snd_gus_use_inc(struct snd_gus_card * gus)
41{ 41{
42 if (!try_module_get(gus->card->module)) 42 if (!try_module_get(gus->card->module))
43 return 0; 43 return 0;
44 return 1; 44 return 1;
45} 45}
46 46
47void snd_gus_use_dec(snd_gus_card_t * gus) 47void snd_gus_use_dec(struct snd_gus_card * gus)
48{ 48{
49 module_put(gus->card->module); 49 module_put(gus->card->module);
50} 50}
51 51
52static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 52static int snd_gus_joystick_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
53{ 53{
54 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 54 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
55 uinfo->count = 1; 55 uinfo->count = 1;
@@ -58,17 +58,17 @@ static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
58 return 0; 58 return 0;
59} 59}
60 60
61static int snd_gus_joystick_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 61static int snd_gus_joystick_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
62{ 62{
63 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 63 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
64 64
65 ucontrol->value.integer.value[0] = gus->joystick_dac & 31; 65 ucontrol->value.integer.value[0] = gus->joystick_dac & 31;
66 return 0; 66 return 0;
67} 67}
68 68
69static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 69static int snd_gus_joystick_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
70{ 70{
71 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 71 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
72 unsigned long flags; 72 unsigned long flags;
73 int change; 73 int change;
74 unsigned char nval; 74 unsigned char nval;
@@ -82,7 +82,7 @@ static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
82 return change; 82 return change;
83} 83}
84 84
85static snd_kcontrol_new_t snd_gus_joystick_control = { 85static struct snd_kcontrol_new snd_gus_joystick_control = {
86 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 86 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
87 .name = "Joystick Speed", 87 .name = "Joystick Speed",
88 .info = snd_gus_joystick_info, 88 .info = snd_gus_joystick_info,
@@ -90,7 +90,7 @@ static snd_kcontrol_new_t snd_gus_joystick_control = {
90 .put = snd_gus_joystick_put 90 .put = snd_gus_joystick_put
91}; 91};
92 92
93static void snd_gus_init_control(snd_gus_card_t *gus) 93static void snd_gus_init_control(struct snd_gus_card *gus)
94{ 94{
95 if (!gus->ace_flag) 95 if (!gus->ace_flag)
96 snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus)); 96 snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus));
@@ -100,7 +100,7 @@ static void snd_gus_init_control(snd_gus_card_t *gus)
100 * 100 *
101 */ 101 */
102 102
103static int snd_gus_free(snd_gus_card_t *gus) 103static int snd_gus_free(struct snd_gus_card *gus)
104{ 104{
105 if (gus->gf1.res_port2 == NULL) 105 if (gus->gf1.res_port2 == NULL)
106 goto __hw_end; 106 goto __hw_end;
@@ -129,24 +129,24 @@ static int snd_gus_free(snd_gus_card_t *gus)
129 return 0; 129 return 0;
130} 130}
131 131
132static int snd_gus_dev_free(snd_device_t *device) 132static int snd_gus_dev_free(struct snd_device *device)
133{ 133{
134 snd_gus_card_t *gus = device->device_data; 134 struct snd_gus_card *gus = device->device_data;
135 return snd_gus_free(gus); 135 return snd_gus_free(gus);
136} 136}
137 137
138int snd_gus_create(snd_card_t * card, 138int snd_gus_create(struct snd_card *card,
139 unsigned long port, 139 unsigned long port,
140 int irq, int dma1, int dma2, 140 int irq, int dma1, int dma2,
141 int timer_dev, 141 int timer_dev,
142 int voices, 142 int voices,
143 int pcm_channels, 143 int pcm_channels,
144 int effect, 144 int effect,
145 snd_gus_card_t **rgus) 145 struct snd_gus_card **rgus)
146{ 146{
147 snd_gus_card_t *gus; 147 struct snd_gus_card *gus;
148 int err; 148 int err;
149 static snd_device_ops_t ops = { 149 static struct snd_device_ops ops = {
150 .dev_free = snd_gus_dev_free, 150 .dev_free = snd_gus_dev_free,
151 }; 151 };
152 152
@@ -238,7 +238,7 @@ int snd_gus_create(snd_card_t * card,
238 * Memory detection routine for plain GF1 soundcards 238 * Memory detection routine for plain GF1 soundcards
239 */ 239 */
240 240
241static int snd_gus_detect_memory(snd_gus_card_t * gus) 241static int snd_gus_detect_memory(struct snd_gus_card * gus)
242{ 242{
243 int l, idx, local; 243 int l, idx, local;
244 unsigned char d; 244 unsigned char d;
@@ -273,9 +273,9 @@ static int snd_gus_detect_memory(snd_gus_card_t * gus)
273 return 0; /* some memory were detected */ 273 return 0; /* some memory were detected */
274} 274}
275 275
276static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches) 276static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches)
277{ 277{
278 snd_card_t *card; 278 struct snd_card *card;
279 unsigned long flags; 279 unsigned long flags;
280 int irq, dma1, dma2; 280 int irq, dma1, dma2;
281 static unsigned char irqs[16] = 281 static unsigned char irqs[16] =
@@ -360,11 +360,11 @@ static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches)
360 return 0; 360 return 0;
361} 361}
362 362
363static int snd_gus_check_version(snd_gus_card_t * gus) 363static int snd_gus_check_version(struct snd_gus_card * gus)
364{ 364{
365 unsigned long flags; 365 unsigned long flags;
366 unsigned char val, rev; 366 unsigned char val, rev;
367 snd_card_t *card; 367 struct snd_card *card;
368 368
369 card = gus->card; 369 card = gus->card;
370 spin_lock_irqsave(&gus->reg_lock, flags); 370 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -409,14 +409,14 @@ static int snd_gus_check_version(snd_gus_card_t * gus)
409} 409}
410 410
411#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) 411#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
412static void snd_gus_seq_dev_free(snd_seq_device_t *seq_dev) 412static void snd_gus_seq_dev_free(struct snd_seq_device *seq_dev)
413{ 413{
414 snd_gus_card_t *gus = seq_dev->private_data; 414 struct snd_gus_card *gus = seq_dev->private_data;
415 gus->seq_dev = NULL; 415 gus->seq_dev = NULL;
416} 416}
417#endif 417#endif
418 418
419int snd_gus_initialize(snd_gus_card_t *gus) 419int snd_gus_initialize(struct snd_gus_card *gus)
420{ 420{
421 int err; 421 int err;
422 422
@@ -432,9 +432,9 @@ int snd_gus_initialize(snd_gus_card_t *gus)
432 return err; 432 return err;
433#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) 433#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
434 if (snd_seq_device_new(gus->card, 1, SNDRV_SEQ_DEV_ID_GUS, 434 if (snd_seq_device_new(gus->card, 1, SNDRV_SEQ_DEV_ID_GUS,
435 sizeof(snd_gus_card_t*), &gus->seq_dev) >= 0) { 435 sizeof(struct snd_gus_card *), &gus->seq_dev) >= 0) {
436 strcpy(gus->seq_dev->name, "GUS"); 436 strcpy(gus->seq_dev->name, "GUS");
437 *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; 437 *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus;
438 gus->seq_dev->private_data = gus; 438 gus->seq_dev->private_data = gus;
439 gus->seq_dev->private_free = snd_gus_seq_dev_free; 439 gus->seq_dev->private_free = snd_gus_seq_dev_free;
440 } 440 }
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index 2e23f2a8c627..e8bdb860a19f 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -27,11 +27,11 @@
27#include <sound/info.h> 27#include <sound/info.h>
28 28
29#ifdef CONFIG_SND_DEBUG 29#ifdef CONFIG_SND_DEBUG
30static void snd_gf1_mem_info_read(snd_info_entry_t *entry, 30static void snd_gf1_mem_info_read(struct snd_info_entry *entry,
31 snd_info_buffer_t * buffer); 31 struct snd_info_buffer *buffer);
32#endif 32#endif
33 33
34void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) 34void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup)
35{ 35{
36 if (!xup) { 36 if (!xup) {
37 down(&alloc->memory_mutex); 37 down(&alloc->memory_mutex);
@@ -40,12 +40,12 @@ void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup)
40 } 40 }
41} 41}
42 42
43static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, 43static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc,
44 snd_gf1_mem_block_t * block) 44 struct snd_gf1_mem_block * block)
45{ 45{
46 snd_gf1_mem_block_t *pblock, *nblock; 46 struct snd_gf1_mem_block *pblock, *nblock;
47 47
48 nblock = (snd_gf1_mem_block_t *) kmalloc(sizeof(snd_gf1_mem_block_t), GFP_KERNEL); 48 nblock = kmalloc(sizeof(struct snd_gf1_mem_block), GFP_KERNEL);
49 if (nblock == NULL) 49 if (nblock == NULL)
50 return NULL; 50 return NULL;
51 *nblock = *block; 51 *nblock = *block;
@@ -76,7 +76,7 @@ static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc,
76 return nblock; 76 return nblock;
77} 77}
78 78
79int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) 79int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block)
80{ 80{
81 if (block->share) { /* ok.. shared block */ 81 if (block->share) { /* ok.. shared block */
82 block->share--; 82 block->share--;
@@ -106,10 +106,10 @@ int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block)
106 return 0; 106 return 0;
107} 107}
108 108
109static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, 109static struct snd_gf1_mem_block *snd_gf1_mem_look(struct snd_gf1_mem * alloc,
110 unsigned int address) 110 unsigned int address)
111{ 111{
112 snd_gf1_mem_block_t *block; 112 struct snd_gf1_mem_block *block;
113 113
114 for (block = alloc->first; block; block = block->next) { 114 for (block = alloc->first; block; block = block->next) {
115 if (block->ptr == address) { 115 if (block->ptr == address) {
@@ -119,10 +119,10 @@ static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc,
119 return NULL; 119 return NULL;
120} 120}
121 121
122static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, 122static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc,
123 unsigned int *share_id) 123 unsigned int *share_id)
124{ 124{
125 snd_gf1_mem_block_t *block; 125 struct snd_gf1_mem_block *block;
126 126
127 if (!share_id[0] && !share_id[1] && 127 if (!share_id[0] && !share_id[1] &&
128 !share_id[2] && !share_id[3]) 128 !share_id[2] && !share_id[3])
@@ -133,14 +133,14 @@ static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc,
133 return NULL; 133 return NULL;
134} 134}
135 135
136static int snd_gf1_mem_find(snd_gf1_mem_t * alloc, 136static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
137 snd_gf1_mem_block_t * block, 137 struct snd_gf1_mem_block * block,
138 unsigned int size, int w_16, int align) 138 unsigned int size, int w_16, int align)
139{ 139{
140 snd_gf1_bank_info_t *info = w_16 ? alloc->banks_16 : alloc->banks_8; 140 struct snd_gf1_bank_info *info = w_16 ? alloc->banks_16 : alloc->banks_8;
141 unsigned int idx, boundary; 141 unsigned int idx, boundary;
142 int size1; 142 int size1;
143 snd_gf1_mem_block_t *pblock; 143 struct snd_gf1_mem_block *pblock;
144 unsigned int ptr1, ptr2; 144 unsigned int ptr1, ptr2;
145 145
146 align--; 146 align--;
@@ -186,11 +186,11 @@ static int snd_gf1_mem_find(snd_gf1_mem_t * alloc,
186 return -ENOMEM; 186 return -ENOMEM;
187} 187}
188 188
189snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, 189struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner,
190 char *name, int size, int w_16, int align, 190 char *name, int size, int w_16, int align,
191 unsigned int *share_id) 191 unsigned int *share_id)
192{ 192{
193 snd_gf1_mem_block_t block, *nblock; 193 struct snd_gf1_mem_block block, *nblock;
194 194
195 snd_gf1_mem_lock(alloc, 0); 195 snd_gf1_mem_lock(alloc, 0);
196 if (share_id != NULL) { 196 if (share_id != NULL) {
@@ -220,10 +220,10 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner,
220 return nblock; 220 return nblock;
221} 221}
222 222
223int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address) 223int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address)
224{ 224{
225 int result; 225 int result;
226 snd_gf1_mem_block_t *block; 226 struct snd_gf1_mem_block *block;
227 227
228 snd_gf1_mem_lock(alloc, 0); 228 snd_gf1_mem_lock(alloc, 0);
229 if ((block = snd_gf1_mem_look(alloc, address)) != NULL) { 229 if ((block = snd_gf1_mem_look(alloc, address)) != NULL) {
@@ -235,12 +235,12 @@ int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address)
235 return -EINVAL; 235 return -EINVAL;
236} 236}
237 237
238int snd_gf1_mem_init(snd_gus_card_t * gus) 238int snd_gf1_mem_init(struct snd_gus_card * gus)
239{ 239{
240 snd_gf1_mem_t *alloc; 240 struct snd_gf1_mem *alloc;
241 snd_gf1_mem_block_t block; 241 struct snd_gf1_mem_block block;
242#ifdef CONFIG_SND_DEBUG 242#ifdef CONFIG_SND_DEBUG
243 snd_info_entry_t *entry; 243 struct snd_info_entry *entry;
244#endif 244#endif
245 245
246 alloc = &gus->gf1.mem_alloc; 246 alloc = &gus->gf1.mem_alloc;
@@ -272,10 +272,10 @@ int snd_gf1_mem_init(snd_gus_card_t * gus)
272 return 0; 272 return 0;
273} 273}
274 274
275int snd_gf1_mem_done(snd_gus_card_t * gus) 275int snd_gf1_mem_done(struct snd_gus_card * gus)
276{ 276{
277 snd_gf1_mem_t *alloc; 277 struct snd_gf1_mem *alloc;
278 snd_gf1_mem_block_t *block, *nblock; 278 struct snd_gf1_mem_block *block, *nblock;
279 279
280 alloc = &gus->gf1.mem_alloc; 280 alloc = &gus->gf1.mem_alloc;
281 block = alloc->first; 281 block = alloc->first;
@@ -288,12 +288,12 @@ int snd_gf1_mem_done(snd_gus_card_t * gus)
288} 288}
289 289
290#ifdef CONFIG_SND_DEBUG 290#ifdef CONFIG_SND_DEBUG
291static void snd_gf1_mem_info_read(snd_info_entry_t *entry, 291static void snd_gf1_mem_info_read(struct snd_info_entry *entry,
292 snd_info_buffer_t * buffer) 292 struct snd_info_buffer *buffer)
293{ 293{
294 snd_gus_card_t *gus; 294 struct snd_gus_card *gus;
295 snd_gf1_mem_t *alloc; 295 struct snd_gf1_mem *alloc;
296 snd_gf1_mem_block_t *block; 296 struct snd_gf1_mem_block *block;
297 unsigned int total, used; 297 unsigned int total, used;
298 int i; 298 int i;
299 299
diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c
index 7f96ac237f3c..4080255007d5 100644
--- a/sound/isa/gus/gus_mem_proc.c
+++ b/sound/isa/gus/gus_mem_proc.c
@@ -25,20 +25,20 @@
25#include <sound/gus.h> 25#include <sound/gus.h>
26#include <sound/info.h> 26#include <sound/info.h>
27 27
28typedef struct gus_proc_private { 28struct gus_proc_private {
29 int rom; /* data are in ROM */ 29 int rom; /* data are in ROM */
30 unsigned int address; 30 unsigned int address;
31 unsigned int size; 31 unsigned int size;
32 snd_gus_card_t * gus; 32 struct snd_gus_card * gus;
33} gus_proc_private_t; 33};
34 34
35static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_data, 35static long snd_gf1_mem_proc_dump(struct snd_info_entry *entry, void *file_private_data,
36 struct file *file, char __user *buf, 36 struct file *file, char __user *buf,
37 unsigned long count, unsigned long pos) 37 unsigned long count, unsigned long pos)
38{ 38{
39 long size; 39 long size;
40 gus_proc_private_t *priv = entry->private_data; 40 struct gus_proc_private *priv = entry->private_data;
41 snd_gus_card_t *gus = priv->gus; 41 struct snd_gus_card *gus = priv->gus;
42 int err; 42 int err;
43 43
44 size = count; 44 size = count;
@@ -52,13 +52,13 @@ static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_da
52 return 0; 52 return 0;
53} 53}
54 54
55static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry, 55static long long snd_gf1_mem_proc_llseek(struct snd_info_entry *entry,
56 void *private_file_data, 56 void *private_file_data,
57 struct file *file, 57 struct file *file,
58 long long offset, 58 long long offset,
59 int orig) 59 int orig)
60{ 60{
61 gus_proc_private_t *priv = entry->private_data; 61 struct gus_proc_private *priv = entry->private_data;
62 62
63 switch (orig) { 63 switch (orig) {
64 case 0: /* SEEK_SET */ 64 case 0: /* SEEK_SET */
@@ -78,9 +78,9 @@ static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry,
78 return file->f_pos; 78 return file->f_pos;
79} 79}
80 80
81static void snd_gf1_mem_proc_free(snd_info_entry_t *entry) 81static void snd_gf1_mem_proc_free(struct snd_info_entry *entry)
82{ 82{
83 gus_proc_private_t *priv = entry->private_data; 83 struct gus_proc_private *priv = entry->private_data;
84 kfree(priv); 84 kfree(priv);
85} 85}
86 86
@@ -89,12 +89,12 @@ static struct snd_info_entry_ops snd_gf1_mem_proc_ops = {
89 .llseek = snd_gf1_mem_proc_llseek, 89 .llseek = snd_gf1_mem_proc_llseek,
90}; 90};
91 91
92int snd_gf1_mem_proc_init(snd_gus_card_t * gus) 92int snd_gf1_mem_proc_init(struct snd_gus_card * gus)
93{ 93{
94 int idx; 94 int idx;
95 char name[16]; 95 char name[16];
96 gus_proc_private_t *priv; 96 struct gus_proc_private *priv;
97 snd_info_entry_t *entry; 97 struct snd_info_entry *entry;
98 98
99 for (idx = 0; idx < 4; idx++) { 99 for (idx = 0; idx < 4; idx++) {
100 if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { 100 if (gus->gf1.mem_alloc.banks_8[idx].size > 0) {
diff --git a/sound/isa/gus/gus_mixer.c b/sound/isa/gus/gus_mixer.c
index a051094d510e..acc25a297200 100644
--- a/sound/isa/gus/gus_mixer.c
+++ b/sound/isa/gus/gus_mixer.c
@@ -36,7 +36,7 @@
36 .get = snd_gf1_get_single, .put = snd_gf1_put_single, \ 36 .get = snd_gf1_get_single, .put = snd_gf1_put_single, \
37 .private_value = shift | (invert << 8) } 37 .private_value = shift | (invert << 8) }
38 38
39static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 39static int snd_gf1_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
40{ 40{
41 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 41 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
42 uinfo->count = 1; 42 uinfo->count = 1;
@@ -45,9 +45,9 @@ static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
45 return 0; 45 return 0;
46} 46}
47 47
48static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 48static int snd_gf1_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
49{ 49{
50 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 50 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
51 int shift = kcontrol->private_value & 0xff; 51 int shift = kcontrol->private_value & 0xff;
52 int invert = (kcontrol->private_value >> 8) & 1; 52 int invert = (kcontrol->private_value >> 8) & 1;
53 53
@@ -57,9 +57,9 @@ static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
57 return 0; 57 return 0;
58} 58}
59 59
60static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 60static int snd_gf1_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
61{ 61{
62 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 62 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
63 unsigned long flags; 63 unsigned long flags;
64 int shift = kcontrol->private_value & 0xff; 64 int shift = kcontrol->private_value & 0xff;
65 int invert = (kcontrol->private_value >> 8) & 1; 65 int invert = (kcontrol->private_value >> 8) & 1;
@@ -86,7 +86,7 @@ static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
86 .get = snd_ics_get_double, .put = snd_ics_put_double, \ 86 .get = snd_ics_get_double, .put = snd_ics_put_double, \
87 .private_value = addr } 87 .private_value = addr }
88 88
89static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 89static int snd_ics_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
90{ 90{
91 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 91 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
92 uinfo->count = 2; 92 uinfo->count = 2;
@@ -95,9 +95,9 @@ static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
95 return 0; 95 return 0;
96} 96}
97 97
98static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 98static int snd_ics_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
99{ 99{
100 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 100 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
101 unsigned long flags; 101 unsigned long flags;
102 int addr = kcontrol->private_value & 0xff; 102 int addr = kcontrol->private_value & 0xff;
103 unsigned char left, right; 103 unsigned char left, right;
@@ -111,9 +111,9 @@ static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
111 return 0; 111 return 0;
112} 112}
113 113
114static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 114static int snd_ics_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
115{ 115{
116 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 116 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
117 unsigned long flags; 117 unsigned long flags;
118 int addr = kcontrol->private_value & 0xff; 118 int addr = kcontrol->private_value & 0xff;
119 int change; 119 int change;
@@ -146,13 +146,13 @@ static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
146 return change; 146 return change;
147} 147}
148 148
149static snd_kcontrol_new_t snd_gf1_controls[] = { 149static struct snd_kcontrol_new snd_gf1_controls[] = {
150GF1_SINGLE("Master Playback Switch", 0, 1, 1), 150GF1_SINGLE("Master Playback Switch", 0, 1, 1),
151GF1_SINGLE("Line Switch", 0, 0, 1), 151GF1_SINGLE("Line Switch", 0, 0, 1),
152GF1_SINGLE("Mic Switch", 0, 2, 0) 152GF1_SINGLE("Mic Switch", 0, 2, 0)
153}; 153};
154 154
155static snd_kcontrol_new_t snd_ics_controls[] = { 155static struct snd_kcontrol_new snd_ics_controls[] = {
156GF1_SINGLE("Master Playback Switch", 0, 1, 1), 156GF1_SINGLE("Master Playback Switch", 0, 1, 1),
157ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV), 157ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV),
158ICS_DOUBLE("Synth Playback Volume", 0, SNDRV_ICS_GF1_DEV), 158ICS_DOUBLE("Synth Playback Volume", 0, SNDRV_ICS_GF1_DEV),
@@ -163,9 +163,9 @@ ICS_DOUBLE("Mic Playback Volume", 0, SNDRV_ICS_MIC_DEV),
163ICS_DOUBLE("CD Playback Volume", 0, SNDRV_ICS_CD_DEV) 163ICS_DOUBLE("CD Playback Volume", 0, SNDRV_ICS_CD_DEV)
164}; 164};
165 165
166int snd_gf1_new_mixer(snd_gus_card_t * gus) 166int snd_gf1_new_mixer(struct snd_gus_card * gus)
167{ 167{
168 snd_card_t *card; 168 struct snd_card *card;
169 unsigned int idx, max; 169 unsigned int idx, max;
170 int err; 170 int err;
171 171
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index 1cc89fb67bf2..d0829393ec8a 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -42,12 +42,12 @@
42#define SNDRV_GF1_PCM_PFLG_ACTIVE (1<<0) 42#define SNDRV_GF1_PCM_PFLG_ACTIVE (1<<0)
43#define SNDRV_GF1_PCM_PFLG_NEUTRAL (2<<0) 43#define SNDRV_GF1_PCM_PFLG_NEUTRAL (2<<0)
44 44
45typedef struct { 45struct gus_pcm_private {
46 snd_gus_card_t * gus; 46 struct snd_gus_card * gus;
47 snd_pcm_substream_t * substream; 47 struct snd_pcm_substream *substream;
48 spinlock_t lock; 48 spinlock_t lock;
49 unsigned int voices; 49 unsigned int voices;
50 snd_gus_voice_t *pvoices[2]; 50 struct snd_gus_voice *pvoices[2];
51 unsigned int memory; 51 unsigned int memory;
52 unsigned short flags; 52 unsigned short flags;
53 unsigned char voice_ctrl, ramp_ctrl; 53 unsigned char voice_ctrl, ramp_ctrl;
@@ -58,13 +58,13 @@ typedef struct {
58 wait_queue_head_t sleep; 58 wait_queue_head_t sleep;
59 atomic_t dma_count; 59 atomic_t dma_count;
60 int final_volume; 60 int final_volume;
61} gus_pcm_private_t; 61};
62 62
63static int snd_gf1_pcm_use_dma = 1; 63static int snd_gf1_pcm_use_dma = 1;
64 64
65static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_data) 65static void snd_gf1_pcm_block_change_ack(struct snd_gus_card * gus, void *private_data)
66{ 66{
67 gus_pcm_private_t *pcmp = private_data; 67 struct gus_pcm_private *pcmp = private_data;
68 68
69 if (pcmp) { 69 if (pcmp) {
70 atomic_dec(&pcmp->dma_count); 70 atomic_dec(&pcmp->dma_count);
@@ -72,14 +72,14 @@ static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_dat
72 } 72 }
73} 73}
74 74
75static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream, 75static int snd_gf1_pcm_block_change(struct snd_pcm_substream *substream,
76 unsigned int offset, 76 unsigned int offset,
77 unsigned int addr, 77 unsigned int addr,
78 unsigned int count) 78 unsigned int count)
79{ 79{
80 snd_gf1_dma_block_t block; 80 struct snd_gf1_dma_block block;
81 snd_pcm_runtime_t *runtime = substream->runtime; 81 struct snd_pcm_runtime *runtime = substream->runtime;
82 gus_pcm_private_t *pcmp = runtime->private_data; 82 struct gus_pcm_private *pcmp = runtime->private_data;
83 83
84 count += offset & 31; 84 count += offset & 31;
85 offset &= ~31; 85 offset &= ~31;
@@ -101,11 +101,11 @@ static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream,
101 return 0; 101 return 0;
102} 102}
103 103
104static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream) 104static void snd_gf1_pcm_trigger_up(struct snd_pcm_substream *substream)
105{ 105{
106 snd_pcm_runtime_t *runtime = substream->runtime; 106 struct snd_pcm_runtime *runtime = substream->runtime;
107 gus_pcm_private_t *pcmp = runtime->private_data; 107 struct gus_pcm_private *pcmp = runtime->private_data;
108 snd_gus_card_t * gus = pcmp->gus; 108 struct snd_gus_card * gus = pcmp->gus;
109 unsigned long flags; 109 unsigned long flags;
110 unsigned char voice_ctrl, ramp_ctrl; 110 unsigned char voice_ctrl, ramp_ctrl;
111 unsigned short rate; 111 unsigned short rate;
@@ -179,10 +179,11 @@ static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream)
179 spin_unlock_irqrestore(&gus->reg_lock, flags); 179 spin_unlock_irqrestore(&gus->reg_lock, flags);
180} 180}
181 181
182static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pvoice) 182static void snd_gf1_pcm_interrupt_wave(struct snd_gus_card * gus,
183 struct snd_gus_voice *pvoice)
183{ 184{
184 gus_pcm_private_t * pcmp; 185 struct gus_pcm_private * pcmp;
185 snd_pcm_runtime_t * runtime; 186 struct snd_pcm_runtime *runtime;
186 unsigned char voice_ctrl, ramp_ctrl; 187 unsigned char voice_ctrl, ramp_ctrl;
187 unsigned int idx; 188 unsigned int idx;
188 unsigned int end, step; 189 unsigned int end, step;
@@ -261,11 +262,12 @@ static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pv
261#endif 262#endif
262} 263}
263 264
264static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t * pvoice) 265static void snd_gf1_pcm_interrupt_volume(struct snd_gus_card * gus,
266 struct snd_gus_voice * pvoice)
265{ 267{
266 unsigned short vol; 268 unsigned short vol;
267 int cvoice; 269 int cvoice;
268 gus_pcm_private_t *pcmp = pvoice->private_data; 270 struct gus_pcm_private *pcmp = pvoice->private_data;
269 271
270 /* stop ramp, but leave rollover bit untouched */ 272 /* stop ramp, but leave rollover bit untouched */
271 spin_lock(&gus->reg_lock); 273 spin_lock(&gus->reg_lock);
@@ -289,11 +291,11 @@ static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t *
289 spin_unlock(&gus->reg_lock); 291 spin_unlock(&gus->reg_lock);
290} 292}
291 293
292static void snd_gf1_pcm_volume_change(snd_gus_card_t * gus) 294static void snd_gf1_pcm_volume_change(struct snd_gus_card * gus)
293{ 295{
294} 296}
295 297
296static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, 298static int snd_gf1_pcm_poke_block(struct snd_gus_card *gus, unsigned char *buf,
297 unsigned int pos, unsigned int count, 299 unsigned int pos, unsigned int count,
298 int w16, int invert) 300 int w16, int invert)
299{ 301{
@@ -341,14 +343,14 @@ static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf,
341 return 0; 343 return 0;
342} 344}
343 345
344static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, 346static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream,
345 int voice, 347 int voice,
346 snd_pcm_uframes_t pos, 348 snd_pcm_uframes_t pos,
347 void __user *src, 349 void __user *src,
348 snd_pcm_uframes_t count) 350 snd_pcm_uframes_t count)
349{ 351{
350 snd_pcm_runtime_t *runtime = substream->runtime; 352 struct snd_pcm_runtime *runtime = substream->runtime;
351 gus_pcm_private_t *pcmp = runtime->private_data; 353 struct gus_pcm_private *pcmp = runtime->private_data;
352 unsigned int bpos, len; 354 unsigned int bpos, len;
353 355
354 bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); 356 bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2));
@@ -360,7 +362,7 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream,
360 if (snd_gf1_pcm_use_dma && len > 32) { 362 if (snd_gf1_pcm_use_dma && len > 32) {
361 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); 363 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len);
362 } else { 364 } else {
363 snd_gus_card_t *gus = pcmp->gus; 365 struct snd_gus_card *gus = pcmp->gus;
364 int err, w16, invert; 366 int err, w16, invert;
365 367
366 w16 = (snd_pcm_format_width(runtime->format) == 16); 368 w16 = (snd_pcm_format_width(runtime->format) == 16);
@@ -371,13 +373,13 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream,
371 return 0; 373 return 0;
372} 374}
373 375
374static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, 376static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream,
375 int voice, 377 int voice,
376 snd_pcm_uframes_t pos, 378 snd_pcm_uframes_t pos,
377 snd_pcm_uframes_t count) 379 snd_pcm_uframes_t count)
378{ 380{
379 snd_pcm_runtime_t *runtime = substream->runtime; 381 struct snd_pcm_runtime *runtime = substream->runtime;
380 gus_pcm_private_t *pcmp = runtime->private_data; 382 struct gus_pcm_private *pcmp = runtime->private_data;
381 unsigned int bpos, len; 383 unsigned int bpos, len;
382 384
383 bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); 385 bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2));
@@ -388,7 +390,7 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream,
388 if (snd_gf1_pcm_use_dma && len > 32) { 390 if (snd_gf1_pcm_use_dma && len > 32) {
389 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); 391 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len);
390 } else { 392 } else {
391 snd_gus_card_t *gus = pcmp->gus; 393 struct snd_gus_card *gus = pcmp->gus;
392 int err, w16, invert; 394 int err, w16, invert;
393 395
394 w16 = (snd_pcm_format_width(runtime->format) == 16); 396 w16 = (snd_pcm_format_width(runtime->format) == 16);
@@ -399,18 +401,18 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream,
399 return 0; 401 return 0;
400} 402}
401 403
402static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream, 404static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream,
403 snd_pcm_hw_params_t * hw_params) 405 struct snd_pcm_hw_params *hw_params)
404{ 406{
405 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 407 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
406 snd_pcm_runtime_t *runtime = substream->runtime; 408 struct snd_pcm_runtime *runtime = substream->runtime;
407 gus_pcm_private_t *pcmp = runtime->private_data; 409 struct gus_pcm_private *pcmp = runtime->private_data;
408 int err; 410 int err;
409 411
410 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 412 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
411 return err; 413 return err;
412 if (err > 0) { /* change */ 414 if (err > 0) { /* change */
413 snd_gf1_mem_block_t *block; 415 struct snd_gf1_mem_block *block;
414 if (pcmp->memory > 0) { 416 if (pcmp->memory > 0) {
415 snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory); 417 snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory);
416 pcmp->memory = 0; 418 pcmp->memory = 0;
@@ -448,10 +450,10 @@ static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream,
448 return 0; 450 return 0;
449} 451}
450 452
451static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream) 453static int snd_gf1_pcm_playback_hw_free(struct snd_pcm_substream *substream)
452{ 454{
453 snd_pcm_runtime_t *runtime = substream->runtime; 455 struct snd_pcm_runtime *runtime = substream->runtime;
454 gus_pcm_private_t *pcmp = runtime->private_data; 456 struct gus_pcm_private *pcmp = runtime->private_data;
455 457
456 snd_pcm_lib_free_pages(substream); 458 snd_pcm_lib_free_pages(substream);
457 if (pcmp->pvoices[0]) { 459 if (pcmp->pvoices[0]) {
@@ -469,10 +471,10 @@ static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream)
469 return 0; 471 return 0;
470} 472}
471 473
472static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream) 474static int snd_gf1_pcm_playback_prepare(struct snd_pcm_substream *substream)
473{ 475{
474 snd_pcm_runtime_t *runtime = substream->runtime; 476 struct snd_pcm_runtime *runtime = substream->runtime;
475 gus_pcm_private_t *pcmp = runtime->private_data; 477 struct gus_pcm_private *pcmp = runtime->private_data;
476 478
477 pcmp->bpos = 0; 479 pcmp->bpos = 0;
478 pcmp->dma_size = snd_pcm_lib_buffer_bytes(substream); 480 pcmp->dma_size = snd_pcm_lib_buffer_bytes(substream);
@@ -481,12 +483,12 @@ static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream)
481 return 0; 483 return 0;
482} 484}
483 485
484static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream, 486static int snd_gf1_pcm_playback_trigger(struct snd_pcm_substream *substream,
485 int cmd) 487 int cmd)
486{ 488{
487 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 489 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
488 snd_pcm_runtime_t *runtime = substream->runtime; 490 struct snd_pcm_runtime *runtime = substream->runtime;
489 gus_pcm_private_t *pcmp = runtime->private_data; 491 struct gus_pcm_private *pcmp = runtime->private_data;
490 int voice; 492 int voice;
491 493
492 if (cmd == SNDRV_PCM_TRIGGER_START) { 494 if (cmd == SNDRV_PCM_TRIGGER_START) {
@@ -507,11 +509,11 @@ static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream,
507 return 0; 509 return 0;
508} 510}
509 511
510static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * substream) 512static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(struct snd_pcm_substream *substream)
511{ 513{
512 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 514 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
513 snd_pcm_runtime_t *runtime = substream->runtime; 515 struct snd_pcm_runtime *runtime = substream->runtime;
514 gus_pcm_private_t *pcmp = runtime->private_data; 516 struct gus_pcm_private *pcmp = runtime->private_data;
515 unsigned int pos; 517 unsigned int pos;
516 unsigned char voice_ctrl; 518 unsigned char voice_ctrl;
517 519
@@ -529,22 +531,22 @@ static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * subs
529 return pos; 531 return pos;
530} 532}
531 533
532static ratnum_t clock = { 534static struct snd_ratnum clock = {
533 .num = 9878400/16, 535 .num = 9878400/16,
534 .den_min = 2, 536 .den_min = 2,
535 .den_max = 257, 537 .den_max = 257,
536 .den_step = 1, 538 .den_step = 1,
537}; 539};
538 540
539static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { 541static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
540 .nrats = 1, 542 .nrats = 1,
541 .rats = &clock, 543 .rats = &clock,
542}; 544};
543 545
544static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream, 546static int snd_gf1_pcm_capture_hw_params(struct snd_pcm_substream *substream,
545 snd_pcm_hw_params_t * hw_params) 547 struct snd_pcm_hw_params *hw_params)
546{ 548{
547 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 549 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
548 550
549 gus->c_dma_size = params_buffer_bytes(hw_params); 551 gus->c_dma_size = params_buffer_bytes(hw_params);
550 gus->c_period_size = params_period_bytes(hw_params); 552 gus->c_period_size = params_period_bytes(hw_params);
@@ -559,15 +561,15 @@ static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream,
559 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 561 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
560} 562}
561 563
562static int snd_gf1_pcm_capture_hw_free(snd_pcm_substream_t * substream) 564static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream)
563{ 565{
564 return snd_pcm_lib_free_pages(substream); 566 return snd_pcm_lib_free_pages(substream);
565} 567}
566 568
567static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream) 569static int snd_gf1_pcm_capture_prepare(struct snd_pcm_substream *substream)
568{ 570{
569 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 571 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
570 snd_pcm_runtime_t *runtime = substream->runtime; 572 struct snd_pcm_runtime *runtime = substream->runtime;
571 573
572 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RECORD_RATE, runtime->rate_den - 2); 574 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RECORD_RATE, runtime->rate_den - 2);
573 snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ 575 snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */
@@ -576,10 +578,10 @@ static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream)
576 return 0; 578 return 0;
577} 579}
578 580
579static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream, 581static int snd_gf1_pcm_capture_trigger(struct snd_pcm_substream *substream,
580 int cmd) 582 int cmd)
581{ 583{
582 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 584 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
583 int val; 585 int val;
584 586
585 if (cmd == SNDRV_PCM_TRIGGER_START) { 587 if (cmd == SNDRV_PCM_TRIGGER_START) {
@@ -597,15 +599,15 @@ static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream,
597 return 0; 599 return 0;
598} 600}
599 601
600static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(snd_pcm_substream_t * substream) 602static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(struct snd_pcm_substream *substream)
601{ 603{
602 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 604 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
603 int pos = snd_dma_pointer(gus->gf1.dma2, gus->c_period_size); 605 int pos = snd_dma_pointer(gus->gf1.dma2, gus->c_period_size);
604 pos = bytes_to_frames(substream->runtime, (gus->c_pos + pos) % gus->c_dma_size); 606 pos = bytes_to_frames(substream->runtime, (gus->c_pos + pos) % gus->c_dma_size);
605 return pos; 607 return pos;
606} 608}
607 609
608static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus) 610static void snd_gf1_pcm_interrupt_dma_read(struct snd_gus_card * gus)
609{ 611{
610 snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ 612 snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */
611 snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL); /* Sampling Control Register */ 613 snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL); /* Sampling Control Register */
@@ -617,7 +619,7 @@ static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus)
617 } 619 }
618} 620}
619 621
620static snd_pcm_hardware_t snd_gf1_pcm_playback = 622static struct snd_pcm_hardware snd_gf1_pcm_playback =
621{ 623{
622 .info = SNDRV_PCM_INFO_NONINTERLEAVED, 624 .info = SNDRV_PCM_INFO_NONINTERLEAVED,
623 .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | 625 .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
@@ -635,7 +637,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_playback =
635 .fifo_size = 0, 637 .fifo_size = 0,
636}; 638};
637 639
638static snd_pcm_hardware_t snd_gf1_pcm_capture = 640static struct snd_pcm_hardware snd_gf1_pcm_capture =
639{ 641{
640 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 642 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
641 SNDRV_PCM_INFO_MMAP_VALID), 643 SNDRV_PCM_INFO_MMAP_VALID),
@@ -653,16 +655,16 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture =
653 .fifo_size = 0, 655 .fifo_size = 0,
654}; 656};
655 657
656static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) 658static void snd_gf1_pcm_playback_free(struct snd_pcm_runtime *runtime)
657{ 659{
658 kfree(runtime->private_data); 660 kfree(runtime->private_data);
659} 661}
660 662
661static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) 663static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream)
662{ 664{
663 gus_pcm_private_t *pcmp; 665 struct gus_pcm_private *pcmp;
664 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 666 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
665 snd_pcm_runtime_t *runtime = substream->runtime; 667 struct snd_pcm_runtime *runtime = substream->runtime;
666 int err; 668 int err;
667 669
668 pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL); 670 pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL);
@@ -690,11 +692,11 @@ static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream)
690 return 0; 692 return 0;
691} 693}
692 694
693static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream) 695static int snd_gf1_pcm_playback_close(struct snd_pcm_substream *substream)
694{ 696{
695 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 697 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
696 snd_pcm_runtime_t *runtime = substream->runtime; 698 struct snd_pcm_runtime *runtime = substream->runtime;
697 gus_pcm_private_t *pcmp = runtime->private_data; 699 struct gus_pcm_private *pcmp = runtime->private_data;
698 700
699 if (!wait_event_timeout(pcmp->sleep, (atomic_read(&pcmp->dma_count) <= 0), 2*HZ)) 701 if (!wait_event_timeout(pcmp->sleep, (atomic_read(&pcmp->dma_count) <= 0), 2*HZ))
700 snd_printk(KERN_ERR "gf1 pcm - serious DMA problem\n"); 702 snd_printk(KERN_ERR "gf1 pcm - serious DMA problem\n");
@@ -703,10 +705,10 @@ static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream)
703 return 0; 705 return 0;
704} 706}
705 707
706static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream) 708static int snd_gf1_pcm_capture_open(struct snd_pcm_substream *substream)
707{ 709{
708 snd_pcm_runtime_t *runtime = substream->runtime; 710 struct snd_pcm_runtime *runtime = substream->runtime;
709 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 711 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
710 712
711 gus->gf1.interrupt_handler_dma_read = snd_gf1_pcm_interrupt_dma_read; 713 gus->gf1.interrupt_handler_dma_read = snd_gf1_pcm_interrupt_dma_read;
712 gus->pcm_cap_substream = substream; 714 gus->pcm_cap_substream = substream;
@@ -718,23 +720,16 @@ static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream)
718 return 0; 720 return 0;
719} 721}
720 722
721static int snd_gf1_pcm_capture_close(snd_pcm_substream_t * substream) 723static int snd_gf1_pcm_capture_close(struct snd_pcm_substream *substream)
722{ 724{
723 snd_gus_card_t *gus = snd_pcm_substream_chip(substream); 725 struct snd_gus_card *gus = snd_pcm_substream_chip(substream);
724 726
725 gus->pcm_cap_substream = NULL; 727 gus->pcm_cap_substream = NULL;
726 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_DMA_READ); 728 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_DMA_READ);
727 return 0; 729 return 0;
728} 730}
729 731
730static void snd_gf1_pcm_free(snd_pcm_t *pcm) 732static int snd_gf1_pcm_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
731{
732 snd_gus_card_t *gus = pcm->private_data;
733 gus->pcm = NULL;
734 snd_pcm_lib_preallocate_free_for_all(pcm);
735}
736
737static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
738{ 733{
739 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 734 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
740 uinfo->count = 2; 735 uinfo->count = 2;
@@ -743,9 +738,9 @@ static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
743 return 0; 738 return 0;
744} 739}
745 740
746static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 741static int snd_gf1_pcm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
747{ 742{
748 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 743 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
749 unsigned long flags; 744 unsigned long flags;
750 745
751 spin_lock_irqsave(&gus->pcm_volume_level_lock, flags); 746 spin_lock_irqsave(&gus->pcm_volume_level_lock, flags);
@@ -755,15 +750,15 @@ static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
755 return 0; 750 return 0;
756} 751}
757 752
758static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 753static int snd_gf1_pcm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
759{ 754{
760 snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); 755 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol);
761 unsigned long flags; 756 unsigned long flags;
762 int change; 757 int change;
763 unsigned int idx; 758 unsigned int idx;
764 unsigned short val1, val2, vol; 759 unsigned short val1, val2, vol;
765 gus_pcm_private_t *pcmp; 760 struct gus_pcm_private *pcmp;
766 snd_gus_voice_t *pvoice; 761 struct snd_gus_voice *pvoice;
767 762
768 val1 = ucontrol->value.integer.value[0] & 127; 763 val1 = ucontrol->value.integer.value[0] & 127;
769 val2 = ucontrol->value.integer.value[1] & 127; 764 val2 = ucontrol->value.integer.value[1] & 127;
@@ -797,7 +792,7 @@ static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
797 return change; 792 return change;
798} 793}
799 794
800static snd_kcontrol_new_t snd_gf1_pcm_volume_control = 795static struct snd_kcontrol_new snd_gf1_pcm_volume_control =
801{ 796{
802 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
803 .name = "PCM Playback Volume", 798 .name = "PCM Playback Volume",
@@ -806,7 +801,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control =
806 .put = snd_gf1_pcm_volume_put 801 .put = snd_gf1_pcm_volume_put
807}; 802};
808 803
809static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 = 804static struct snd_kcontrol_new snd_gf1_pcm_volume_control1 =
810{ 805{
811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
812 .name = "GPCM Playback Volume", 807 .name = "GPCM Playback Volume",
@@ -815,7 +810,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 =
815 .put = snd_gf1_pcm_volume_put 810 .put = snd_gf1_pcm_volume_put
816}; 811};
817 812
818static snd_pcm_ops_t snd_gf1_pcm_playback_ops = { 813static struct snd_pcm_ops snd_gf1_pcm_playback_ops = {
819 .open = snd_gf1_pcm_playback_open, 814 .open = snd_gf1_pcm_playback_open,
820 .close = snd_gf1_pcm_playback_close, 815 .close = snd_gf1_pcm_playback_close,
821 .ioctl = snd_pcm_lib_ioctl, 816 .ioctl = snd_pcm_lib_ioctl,
@@ -828,7 +823,7 @@ static snd_pcm_ops_t snd_gf1_pcm_playback_ops = {
828 .silence = snd_gf1_pcm_playback_silence, 823 .silence = snd_gf1_pcm_playback_silence,
829}; 824};
830 825
831static snd_pcm_ops_t snd_gf1_pcm_capture_ops = { 826static struct snd_pcm_ops snd_gf1_pcm_capture_ops = {
832 .open = snd_gf1_pcm_capture_open, 827 .open = snd_gf1_pcm_capture_open,
833 .close = snd_gf1_pcm_capture_close, 828 .close = snd_gf1_pcm_capture_close,
834 .ioctl = snd_pcm_lib_ioctl, 829 .ioctl = snd_pcm_lib_ioctl,
@@ -839,12 +834,12 @@ static snd_pcm_ops_t snd_gf1_pcm_capture_ops = {
839 .pointer = snd_gf1_pcm_capture_pointer, 834 .pointer = snd_gf1_pcm_capture_pointer,
840}; 835};
841 836
842int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pcm_t ** rpcm) 837int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm)
843{ 838{
844 snd_card_t *card; 839 struct snd_card *card;
845 snd_kcontrol_t *kctl; 840 struct snd_kcontrol *kctl;
846 snd_pcm_t *pcm; 841 struct snd_pcm *pcm;
847 snd_pcm_substream_t *substream; 842 struct snd_pcm_substream *substream;
848 int capture, err; 843 int capture, err;
849 844
850 if (rpcm) 845 if (rpcm)
@@ -860,7 +855,6 @@ int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pc
860 if (err < 0) 855 if (err < 0)
861 return err; 856 return err;
862 pcm->private_data = gus; 857 pcm->private_data = gus;
863 pcm->private_free = snd_gf1_pcm_free;
864 /* playback setup */ 858 /* playback setup */
865 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops); 859 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops);
866 860
diff --git a/sound/isa/gus/gus_reset.c b/sound/isa/gus/gus_reset.c
index 90710969ef7f..b263655c4116 100644
--- a/sound/isa/gus/gus_reset.c
+++ b/sound/isa/gus/gus_reset.c
@@ -25,52 +25,52 @@
25#include <sound/core.h> 25#include <sound/core.h>
26#include <sound/gus.h> 26#include <sound/gus.h>
27 27
28extern void snd_gf1_timers_init(snd_gus_card_t * gus); 28extern void snd_gf1_timers_init(struct snd_gus_card * gus);
29extern void snd_gf1_timers_done(snd_gus_card_t * gus); 29extern void snd_gf1_timers_done(struct snd_gus_card * gus);
30extern int snd_gf1_synth_init(snd_gus_card_t * gus); 30extern int snd_gf1_synth_init(struct snd_gus_card * gus);
31extern void snd_gf1_synth_done(snd_gus_card_t * gus); 31extern void snd_gf1_synth_done(struct snd_gus_card * gus);
32 32
33/* 33/*
34 * ok.. default interrupt handlers... 34 * ok.. default interrupt handlers...
35 */ 35 */
36 36
37static void snd_gf1_default_interrupt_handler_midi_out(snd_gus_card_t * gus) 37static void snd_gf1_default_interrupt_handler_midi_out(struct snd_gus_card * gus)
38{ 38{
39 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20); 39 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20);
40} 40}
41 41
42static void snd_gf1_default_interrupt_handler_midi_in(snd_gus_card_t * gus) 42static void snd_gf1_default_interrupt_handler_midi_in(struct snd_gus_card * gus)
43{ 43{
44 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80); 44 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80);
45} 45}
46 46
47static void snd_gf1_default_interrupt_handler_timer1(snd_gus_card_t * gus) 47static void snd_gf1_default_interrupt_handler_timer1(struct snd_gus_card * gus)
48{ 48{
49 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4); 49 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4);
50} 50}
51 51
52static void snd_gf1_default_interrupt_handler_timer2(snd_gus_card_t * gus) 52static void snd_gf1_default_interrupt_handler_timer2(struct snd_gus_card * gus)
53{ 53{
54 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8); 54 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8);
55} 55}
56 56
57static void snd_gf1_default_interrupt_handler_wave_and_volume(snd_gus_card_t * gus, snd_gus_voice_t * voice) 57static void snd_gf1_default_interrupt_handler_wave_and_volume(struct snd_gus_card * gus, struct snd_gus_voice * voice)
58{ 58{
59 snd_gf1_i_ctrl_stop(gus, 0x00); 59 snd_gf1_i_ctrl_stop(gus, 0x00);
60 snd_gf1_i_ctrl_stop(gus, 0x0d); 60 snd_gf1_i_ctrl_stop(gus, 0x0d);
61} 61}
62 62
63static void snd_gf1_default_interrupt_handler_dma_write(snd_gus_card_t * gus) 63static void snd_gf1_default_interrupt_handler_dma_write(struct snd_gus_card * gus)
64{ 64{
65 snd_gf1_i_write8(gus, 0x41, 0x00); 65 snd_gf1_i_write8(gus, 0x41, 0x00);
66} 66}
67 67
68static void snd_gf1_default_interrupt_handler_dma_read(snd_gus_card_t * gus) 68static void snd_gf1_default_interrupt_handler_dma_read(struct snd_gus_card * gus)
69{ 69{
70 snd_gf1_i_write8(gus, 0x49, 0x00); 70 snd_gf1_i_write8(gus, 0x49, 0x00);
71} 71}
72 72
73void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) 73void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what)
74{ 74{
75 if (what & SNDRV_GF1_HANDLER_MIDI_OUT) 75 if (what & SNDRV_GF1_HANDLER_MIDI_OUT)
76 gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out; 76 gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out;
@@ -81,7 +81,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what)
81 if (what & SNDRV_GF1_HANDLER_TIMER2) 81 if (what & SNDRV_GF1_HANDLER_TIMER2)
82 gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2; 82 gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2;
83 if (what & SNDRV_GF1_HANDLER_VOICE) { 83 if (what & SNDRV_GF1_HANDLER_VOICE) {
84 snd_gus_voice_t *voice; 84 struct snd_gus_voice *voice;
85 85
86 voice = &gus->gf1.voices[what & 0xffff]; 86 voice = &gus->gf1.voices[what & 0xffff];
87 voice->handler_wave = 87 voice->handler_wave =
@@ -99,7 +99,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what)
99 99
100 */ 100 */
101 101
102static void snd_gf1_clear_regs(snd_gus_card_t * gus) 102static void snd_gf1_clear_regs(struct snd_gus_card * gus)
103{ 103{
104 unsigned long flags; 104 unsigned long flags;
105 105
@@ -111,7 +111,7 @@ static void snd_gf1_clear_regs(snd_gus_card_t * gus)
111 spin_unlock_irqrestore(&gus->reg_lock, flags); 111 spin_unlock_irqrestore(&gus->reg_lock, flags);
112} 112}
113 113
114static void snd_gf1_look_regs(snd_gus_card_t * gus) 114static void snd_gf1_look_regs(struct snd_gus_card * gus)
115{ 115{
116 unsigned long flags; 116 unsigned long flags;
117 117
@@ -127,7 +127,7 @@ static void snd_gf1_look_regs(snd_gus_card_t * gus)
127 * put selected GF1 voices to initial stage... 127 * put selected GF1 voices to initial stage...
128 */ 128 */
129 129
130void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice) 130void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice)
131{ 131{
132 unsigned long flags; 132 unsigned long flags;
133 133
@@ -141,7 +141,7 @@ void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice)
141 spin_unlock_irqrestore(&gus->reg_lock, flags); 141 spin_unlock_irqrestore(&gus->reg_lock, flags);
142} 142}
143 143
144void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) 144void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice)
145{ 145{
146 unsigned long flags; 146 unsigned long flags;
147 147
@@ -161,7 +161,7 @@ void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice)
161#endif 161#endif
162} 162}
163 163
164static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, 164static void snd_gf1_clear_voices(struct snd_gus_card * gus, unsigned short v_min,
165 unsigned short v_max) 165 unsigned short v_max)
166{ 166{
167 unsigned long flags; 167 unsigned long flags;
@@ -203,7 +203,7 @@ static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min,
203 } 203 }
204} 204}
205 205
206void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max) 206void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max)
207{ 207{
208 unsigned long flags; 208 unsigned long flags;
209 short i, ramp_ok; 209 short i, ramp_ok;
@@ -232,8 +232,8 @@ void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned sh
232 snd_gf1_clear_voices(gus, v_min, v_max); 232 snd_gf1_clear_voices(gus, v_min, v_max);
233} 233}
234 234
235static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus, 235static void snd_gf1_alloc_voice_use(struct snd_gus_card * gus,
236 snd_gus_voice_t * pvoice, 236 struct snd_gus_voice * pvoice,
237 int type, int client, int port) 237 int type, int client, int port)
238{ 238{
239 pvoice->use = 1; 239 pvoice->use = 1;
@@ -255,9 +255,9 @@ static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus,
255 } 255 }
256} 256}
257 257
258snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port) 258struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port)
259{ 259{
260 snd_gus_voice_t *pvoice; 260 struct snd_gus_voice *pvoice;
261 unsigned long flags; 261 unsigned long flags;
262 int idx; 262 int idx;
263 263
@@ -289,10 +289,10 @@ snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client,
289 return NULL; 289 return NULL;
290} 290}
291 291
292void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice) 292void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice)
293{ 293{
294 unsigned long flags; 294 unsigned long flags;
295 void (*private_free)(snd_gus_voice_t *voice); 295 void (*private_free)(struct snd_gus_voice *voice);
296 void *private_data; 296 void *private_data;
297 297
298 if (voice == NULL || !voice->use) 298 if (voice == NULL || !voice->use)
@@ -317,7 +317,7 @@ void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice)
317 * call this function only by start of driver 317 * call this function only by start of driver
318 */ 318 */
319 319
320int snd_gf1_start(snd_gus_card_t * gus) 320int snd_gf1_start(struct snd_gus_card * gus)
321{ 321{
322 unsigned long flags; 322 unsigned long flags;
323 unsigned int i; 323 unsigned int i;
@@ -400,7 +400,7 @@ int snd_gf1_start(snd_gus_card_t * gus)
400 * call this function only by shutdown of driver 400 * call this function only by shutdown of driver
401 */ 401 */
402 402
403int snd_gf1_stop(snd_gus_card_t * gus) 403int snd_gf1_stop(struct snd_gus_card * gus)
404{ 404{
405 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */ 405 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */
406 snd_gf1_stop_voices(gus, 0, 31); /* stop all voices */ 406 snd_gf1_stop_voices(gus, 0, 31); /* stop all voices */
diff --git a/sound/isa/gus/gus_sample.c b/sound/isa/gus/gus_sample.c
index 4290e03acd51..9e0c55ab25b2 100644
--- a/sound/isa/gus/gus_sample.c
+++ b/sound/isa/gus/gus_sample.c
@@ -28,9 +28,9 @@
28 * 28 *
29 */ 29 */
30 30
31static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v) 31static void select_instrument(struct snd_gus_card * gus, struct snd_gus_voice * v)
32{ 32{
33 snd_seq_kinstr_t *instr; 33 struct snd_seq_kinstr *instr;
34 34
35#if 0 35#if 0
36 printk("select instrument: cluster = %li, std = 0x%x, bank = %i, prg = %i\n", 36 printk("select instrument: cluster = %li, std = 0x%x, bank = %i, prg = %i\n",
@@ -53,7 +53,8 @@ static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v)
53 * 53 *
54 */ 54 */
55 55
56static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 56static void event_sample(struct snd_seq_event *ev, struct snd_gus_port *p,
57 struct snd_gus_voice *v)
57{ 58{
58 if (v->sample_ops && v->sample_ops->sample_stop) 59 if (v->sample_ops && v->sample_ops->sample_stop)
59 v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); 60 v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY);
@@ -67,7 +68,8 @@ static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t
67 select_instrument(p->gus, v); 68 select_instrument(p->gus, v);
68} 69}
69 70
70static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 71static void event_cluster(struct snd_seq_event *ev, struct snd_gus_port *p,
72 struct snd_gus_voice *v)
71{ 73{
72 if (v->sample_ops && v->sample_ops->sample_stop) 74 if (v->sample_ops && v->sample_ops->sample_stop)
73 v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); 75 v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY);
@@ -75,50 +77,58 @@ static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_
75 select_instrument(p->gus, v); 77 select_instrument(p->gus, v);
76} 78}
77 79
78static void event_start(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 80static void event_start(struct snd_seq_event *ev, struct snd_gus_port *p,
81 struct snd_gus_voice *v)
79{ 82{
80 if (v->sample_ops && v->sample_ops->sample_start) 83 if (v->sample_ops && v->sample_ops->sample_start)
81 v->sample_ops->sample_start(p->gus, v, ev->data.sample.param.position); 84 v->sample_ops->sample_start(p->gus, v, ev->data.sample.param.position);
82} 85}
83 86
84static void event_stop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 87static void event_stop(struct snd_seq_event *ev, struct snd_gus_port *p,
88 struct snd_gus_voice *v)
85{ 89{
86 if (v->sample_ops && v->sample_ops->sample_stop) 90 if (v->sample_ops && v->sample_ops->sample_stop)
87 v->sample_ops->sample_stop(p->gus, v, ev->data.sample.param.stop_mode); 91 v->sample_ops->sample_stop(p->gus, v, ev->data.sample.param.stop_mode);
88} 92}
89 93
90static void event_freq(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 94static void event_freq(struct snd_seq_event *ev, struct snd_gus_port *p,
95 struct snd_gus_voice *v)
91{ 96{
92 if (v->sample_ops && v->sample_ops->sample_freq) 97 if (v->sample_ops && v->sample_ops->sample_freq)
93 v->sample_ops->sample_freq(p->gus, v, ev->data.sample.param.frequency); 98 v->sample_ops->sample_freq(p->gus, v, ev->data.sample.param.frequency);
94} 99}
95 100
96static void event_volume(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 101static void event_volume(struct snd_seq_event *ev, struct snd_gus_port *p,
102 struct snd_gus_voice *v)
97{ 103{
98 if (v->sample_ops && v->sample_ops->sample_volume) 104 if (v->sample_ops && v->sample_ops->sample_volume)
99 v->sample_ops->sample_volume(p->gus, v, &ev->data.sample.param.volume); 105 v->sample_ops->sample_volume(p->gus, v, &ev->data.sample.param.volume);
100} 106}
101 107
102static void event_loop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 108static void event_loop(struct snd_seq_event *ev, struct snd_gus_port *p,
109 struct snd_gus_voice *v)
103{ 110{
104 if (v->sample_ops && v->sample_ops->sample_loop) 111 if (v->sample_ops && v->sample_ops->sample_loop)
105 v->sample_ops->sample_loop(p->gus, v, &ev->data.sample.param.loop); 112 v->sample_ops->sample_loop(p->gus, v, &ev->data.sample.param.loop);
106} 113}
107 114
108static void event_position(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 115static void event_position(struct snd_seq_event *ev, struct snd_gus_port *p,
116 struct snd_gus_voice *v)
109{ 117{
110 if (v->sample_ops && v->sample_ops->sample_pos) 118 if (v->sample_ops && v->sample_ops->sample_pos)
111 v->sample_ops->sample_pos(p->gus, v, ev->data.sample.param.position); 119 v->sample_ops->sample_pos(p->gus, v, ev->data.sample.param.position);
112} 120}
113 121
114static void event_private1(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) 122static void event_private1(struct snd_seq_event *ev, struct snd_gus_port *p,
123 struct snd_gus_voice *v)
115{ 124{
116 if (v->sample_ops && v->sample_ops->sample_private1) 125 if (v->sample_ops && v->sample_ops->sample_private1)
117 v->sample_ops->sample_private1(p->gus, v, (unsigned char *)&ev->data.sample.param.raw8); 126 v->sample_ops->sample_private1(p->gus, v, (unsigned char *)&ev->data.sample.param.raw8);
118} 127}
119 128
120typedef void (gus_sample_event_handler_t)(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v); 129typedef void (gus_sample_event_handler_t)(struct snd_seq_event *ev,
121 130 struct snd_gus_port *p,
131 struct snd_gus_voice *v);
122static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { 132static gus_sample_event_handler_t *gus_sample_event_handlers[9] = {
123 event_sample, 133 event_sample,
124 event_cluster, 134 event_cluster,
@@ -131,11 +141,11 @@ static gus_sample_event_handler_t *gus_sample_event_handlers[9] = {
131 event_private1 141 event_private1
132}; 142};
133 143
134void snd_gus_sample_event(snd_seq_event_t *ev, snd_gus_port_t *p) 144void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p)
135{ 145{
136 int idx, voice; 146 int idx, voice;
137 snd_gus_card_t *gus = p->gus; 147 struct snd_gus_card *gus = p->gus;
138 snd_gus_voice_t *v; 148 struct snd_gus_voice *v;
139 unsigned long flags; 149 unsigned long flags;
140 150
141 idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE; 151 idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE;
diff --git a/sound/isa/gus/gus_simple.c b/sound/isa/gus/gus_simple.c
index dfed85b58b3a..dcad6ed0198c 100644
--- a/sound/isa/gus/gus_simple.c
+++ b/sound/isa/gus/gus_simple.c
@@ -29,19 +29,19 @@
29 * 29 *
30 */ 30 */
31 31
32static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice); 32static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice);
33static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice); 33static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice);
34static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice); 34static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice);
35 35
36static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position); 36static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position);
37static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode); 37static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode);
38static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq); 38static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq);
39static void sample_volume(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume); 39static void sample_volume(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume);
40static void sample_loop(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop); 40static void sample_loop(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop);
41static void sample_pos(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_position_t position); 41static void sample_pos(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position);
42static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data); 42static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data);
43 43
44static snd_gus_sample_ops_t sample_ops = { 44static struct snd_gus_sample_ops sample_ops = {
45 sample_start, 45 sample_start,
46 sample_stop, 46 sample_stop,
47 sample_freq, 47 sample_freq,
@@ -53,13 +53,13 @@ static snd_gus_sample_ops_t sample_ops = {
53 53
54#if 0 54#if 0
55 55
56static void note_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, int wait); 56static void note_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int wait);
57static void note_wait(snd_gus_card_t *gus, snd_gus_voice_t *voice); 57static void note_wait(struct snd_gus_card *gus, struct snd_gus_voice *voice);
58static void note_off(snd_gus_card_t *gus, snd_gus_voice_t *voice); 58static void note_off(struct snd_gus_card *gus, struct snd_gus_voice *voice);
59static void note_volume(snd_gus_card_t *card, snd_gus_voice_t *voice); 59static void note_volume(struct snd_gus_card *card, struct snd_gus_voice *voice);
60static void note_pitchbend(snd_gus_card_t *card, snd_gus_voice_t *voice); 60static void note_pitchbend(struct snd_gus_card *card, struct snd_gus_voice *voice);
61static void note_vibrato(snd_gus_card_t *card, snd_gus_voice_t *voice); 61static void note_vibrato(struct snd_gus_card *card, struct snd_gus_voice *voice);
62static void note_tremolo(snd_gus_card_t *card, snd_gus_voice_t *voice); 62static void note_tremolo(struct snd_gus_card *card, struct snd_gus_voice *voice);
63 63
64static struct snd_gus_note_handlers note_commands = { 64static struct snd_gus_note_handlers note_commands = {
65 note_stop, 65 note_stop,
@@ -71,7 +71,7 @@ static struct snd_gus_note_handlers note_commands = {
71 note_tremolo 71 note_tremolo
72}; 72};
73 73
74static void chn_trigger_down(snd_gus_card_t *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); 74static void chn_trigger_down(struct snd_gus_card *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority );
75static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note ); 75static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note );
76static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 ); 76static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 );
77 77
@@ -83,14 +83,14 @@ static struct ULTRA_STRU_INSTRUMENT_CHANNEL_COMMANDS channel_commands = {
83 83
84#endif 84#endif
85 85
86static void do_volume_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); 86static void do_volume_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice);
87static void do_pan_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); 87static void do_pan_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice);
88 88
89/* 89/*
90 * 90 *
91 */ 91 */
92 92
93static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice) 93static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice)
94{ 94{
95 spin_lock(&gus->event_lock); 95 spin_lock(&gus->event_lock);
96 snd_gf1_stop_voice(gus, voice->number); 96 snd_gf1_stop_voice(gus, voice->number);
@@ -102,7 +102,7 @@ static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice)
102 spin_unlock(&gus->event_lock); 102 spin_unlock(&gus->event_lock);
103} 103}
104 104
105static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice) 105static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice)
106{ 106{
107 spin_lock(&gus->event_lock); 107 spin_lock(&gus->event_lock);
108 if (voice->flags & SNDRV_GF1_VFLG_RUNNING) 108 if (voice->flags & SNDRV_GF1_VFLG_RUNNING)
@@ -112,7 +112,7 @@ static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice)
112 spin_unlock(&gus->event_lock); 112 spin_unlock(&gus->event_lock);
113} 113}
114 114
115static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice) 115static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice)
116{ 116{
117 spin_lock(&gus->event_lock); 117 spin_lock(&gus->event_lock);
118 if ((voice->flags & (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) == 118 if ((voice->flags & (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) ==
@@ -125,7 +125,7 @@ static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice)
125 * 125 *
126 */ 126 */
127 127
128static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) 128static void do_volume_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice)
129{ 129{
130 unsigned short next, rate, old_volume; 130 unsigned short next, rate, old_volume;
131 int program_next_ramp; 131 int program_next_ramp;
@@ -229,7 +229,7 @@ static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice)
229 } 229 }
230} 230}
231 231
232static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) 232static void do_pan_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice)
233{ 233{
234 unsigned long flags; 234 unsigned long flags;
235 unsigned char old_pan; 235 unsigned char old_pan;
@@ -276,7 +276,7 @@ static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice)
276#endif 276#endif
277} 277}
278 278
279static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsigned short pan) 279static void set_enhanced_pan(struct snd_gus_card *gus, struct snd_gus_voice *voice, unsigned short pan)
280{ 280{
281 unsigned long flags; 281 unsigned long flags;
282 unsigned short vlo, vro; 282 unsigned short vlo, vro;
@@ -307,13 +307,13 @@ static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsign
307 * 307 *
308 */ 308 */
309 309
310static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) 310static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position)
311{ 311{
312 unsigned long flags; 312 unsigned long flags;
313 unsigned int begin, addr, addr_end, addr_start; 313 unsigned int begin, addr, addr_end, addr_start;
314 int w_16; 314 int w_16;
315 simple_instrument_t *simple; 315 struct simple_instrument *simple;
316 snd_seq_kinstr_t *instr; 316 struct snd_seq_kinstr *instr;
317 317
318 instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); 318 instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1);
319 if (instr == NULL) 319 if (instr == NULL)
@@ -397,7 +397,7 @@ static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_po
397 snd_seq_instr_free_use(gus->gf1.ilist, instr); 397 snd_seq_instr_free_use(gus->gf1.ilist, instr);
398} 398}
399 399
400static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode) 400static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode)
401{ 401{
402 unsigned char control; 402 unsigned char control;
403 unsigned long flags; 403 unsigned long flags;
@@ -433,7 +433,7 @@ static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_sto
433 } 433 }
434} 434}
435 435
436static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq) 436static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq)
437{ 437{
438 unsigned long flags; 438 unsigned long flags;
439 439
@@ -444,7 +444,7 @@ static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_fre
444 spin_unlock_irqrestore(&gus->reg_lock, flags); 444 spin_unlock_irqrestore(&gus->reg_lock, flags);
445} 445}
446 446
447static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume) 447static void sample_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume)
448{ 448{
449 if (volume->volume >= 0) { 449 if (volume->volume >= 0) {
450 volume->volume &= 0x3fff; 450 volume->volume &= 0x3fff;
@@ -471,13 +471,13 @@ static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_e
471 } 471 }
472} 472}
473 473
474static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop) 474static void sample_loop(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop)
475{ 475{
476 unsigned long flags; 476 unsigned long flags;
477 int w_16 = voice->control & 0x04; 477 int w_16 = voice->control & 0x04;
478 unsigned int begin, addr_start, addr_end; 478 unsigned int begin, addr_start, addr_end;
479 simple_instrument_t *simple; 479 struct simple_instrument *simple;
480 snd_seq_kinstr_t *instr; 480 struct snd_seq_kinstr *instr;
481 481
482#if 0 482#if 0
483 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); 483 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end);
@@ -500,13 +500,13 @@ static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_
500 snd_seq_instr_free_use(gus->gf1.ilist, instr); 500 snd_seq_instr_free_use(gus->gf1.ilist, instr);
501} 501}
502 502
503static void sample_pos(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) 503static void sample_pos(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position)
504{ 504{
505 unsigned long flags; 505 unsigned long flags;
506 int w_16 = voice->control & 0x04; 506 int w_16 = voice->control & 0x04;
507 unsigned int begin, addr; 507 unsigned int begin, addr;
508 simple_instrument_t *simple; 508 struct simple_instrument *simple;
509 snd_seq_kinstr_t *instr; 509 struct snd_seq_kinstr *instr;
510 510
511#if 0 511#if 0
512 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); 512 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end);
@@ -537,7 +537,7 @@ static unsigned char get_effects_mask( ultra_card_t *card, int value )
537 537
538#endif 538#endif
539 539
540static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data) 540static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data)
541{ 541{
542#if 0 542#if 0
543 unsigned long flags; 543 unsigned long flags;
@@ -624,7 +624,7 @@ static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned
624 624
625#endif 625#endif
626 626
627void snd_gf1_simple_init(snd_gus_voice_t *voice) 627void snd_gf1_simple_init(struct snd_gus_voice *voice)
628{ 628{
629 voice->handler_wave = interrupt_wave; 629 voice->handler_wave = interrupt_wave;
630 voice->handler_volume = interrupt_volume; 630 voice->handler_volume = interrupt_volume;
diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c
index f51c386ee192..85a1b051f09a 100644
--- a/sound/isa/gus/gus_synth.c
+++ b/sound/isa/gus/gus_synth.c
@@ -34,10 +34,10 @@ MODULE_LICENSE("GPL");
34 * 34 *
35 */ 35 */
36 36
37static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port) 37static void snd_gus_synth_free_voices(struct snd_gus_card * gus, int client, int port)
38{ 38{
39 int idx; 39 int idx;
40 snd_gus_voice_t * voice; 40 struct snd_gus_voice * voice;
41 41
42 for (idx = 0; idx < 32; idx++) { 42 for (idx = 0; idx < 32; idx++) {
43 voice = &gus->gf1.voices[idx]; 43 voice = &gus->gf1.voices[idx];
@@ -46,11 +46,11 @@ static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port
46 } 46 }
47} 47}
48 48
49static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info) 49static int snd_gus_synth_use(void *private_data, struct snd_seq_port_subscribe *info)
50{ 50{
51 snd_gus_port_t * port = (snd_gus_port_t *)private_data; 51 struct snd_gus_port * port = private_data;
52 snd_gus_card_t * gus = port->gus; 52 struct snd_gus_card * gus = port->gus;
53 snd_gus_voice_t * voice; 53 struct snd_gus_voice * voice;
54 unsigned int idx; 54 unsigned int idx;
55 55
56 if (info->voices > 32) 56 if (info->voices > 32)
@@ -74,10 +74,10 @@ static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info)
74 return 0; 74 return 0;
75} 75}
76 76
77static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *info) 77static int snd_gus_synth_unuse(void *private_data, struct snd_seq_port_subscribe *info)
78{ 78{
79 snd_gus_port_t * port = (snd_gus_port_t *)private_data; 79 struct snd_gus_port * port = private_data;
80 snd_gus_card_t * gus = port->gus; 80 struct snd_gus_card * gus = port->gus;
81 81
82 down(&gus->register_mutex); 82 down(&gus->register_mutex);
83 snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port); 83 snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port);
@@ -90,19 +90,19 @@ static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *inf
90 * 90 *
91 */ 91 */
92 92
93static void snd_gus_synth_free_private_instruments(snd_gus_port_t *p, int client) 93static void snd_gus_synth_free_private_instruments(struct snd_gus_port *p, int client)
94{ 94{
95 snd_seq_instr_header_t ifree; 95 struct snd_seq_instr_header ifree;
96 96
97 memset(&ifree, 0, sizeof(ifree)); 97 memset(&ifree, 0, sizeof(ifree));
98 ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE; 98 ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE;
99 snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); 99 snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0);
100} 100}
101 101
102static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, 102static int snd_gus_synth_event_input(struct snd_seq_event *ev, int direct,
103 void *private_data, int atomic, int hop) 103 void *private_data, int atomic, int hop)
104{ 104{
105 snd_gus_port_t * p = (snd_gus_port_t *) private_data; 105 struct snd_gus_port * p = private_data;
106 106
107 snd_assert(p != NULL, return -EINVAL); 107 snd_assert(p != NULL, return -EINVAL);
108 if (ev->type >= SNDRV_SEQ_EVENT_SAMPLE && 108 if (ev->type >= SNDRV_SEQ_EVENT_SAMPLE &&
@@ -131,12 +131,12 @@ static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct,
131} 131}
132 132
133static void snd_gus_synth_instr_notify(void *private_data, 133static void snd_gus_synth_instr_notify(void *private_data,
134 snd_seq_kinstr_t *instr, 134 struct snd_seq_kinstr *instr,
135 int what) 135 int what)
136{ 136{
137 unsigned int idx; 137 unsigned int idx;
138 snd_gus_card_t *gus = private_data; 138 struct snd_gus_card *gus = private_data;
139 snd_gus_voice_t *pvoice; 139 struct snd_gus_voice *pvoice;
140 unsigned long flags; 140 unsigned long flags;
141 141
142 spin_lock_irqsave(&gus->event_lock, flags); 142 spin_lock_irqsave(&gus->event_lock, flags);
@@ -160,16 +160,16 @@ static void snd_gus_synth_instr_notify(void *private_data,
160 160
161static void snd_gus_synth_free_port(void *private_data) 161static void snd_gus_synth_free_port(void *private_data)
162{ 162{
163 snd_gus_port_t * p = (snd_gus_port_t *)private_data; 163 struct snd_gus_port * p = private_data;
164 164
165 if (p) 165 if (p)
166 snd_midi_channel_free_set(p->chset); 166 snd_midi_channel_free_set(p->chset);
167} 167}
168 168
169static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) 169static int snd_gus_synth_create_port(struct snd_gus_card * gus, int idx)
170{ 170{
171 snd_gus_port_t * p; 171 struct snd_gus_port * p;
172 snd_seq_port_callback_t callbacks; 172 struct snd_seq_port_callback callbacks;
173 char name[32]; 173 char name[32];
174 int result; 174 int result;
175 175
@@ -210,46 +210,28 @@ static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx)
210 * 210 *
211 */ 211 */
212 212
213static int snd_gus_synth_new_device(snd_seq_device_t *dev) 213static int snd_gus_synth_new_device(struct snd_seq_device *dev)
214{ 214{
215 snd_gus_card_t *gus; 215 struct snd_gus_card *gus;
216 int client, i; 216 int client, i;
217 snd_seq_client_callback_t callbacks; 217 struct snd_seq_port_subscribe sub;
218 snd_seq_client_info_t *cinfo; 218 struct snd_iwffff_ops *iwops;
219 snd_seq_port_subscribe_t sub; 219 struct snd_gf1_ops *gf1ops;
220 snd_iwffff_ops_t *iwops; 220 struct snd_simple_ops *simpleops;
221 snd_gf1_ops_t *gf1ops; 221
222 snd_simple_ops_t *simpleops; 222 gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev);
223
224 gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev);
225 if (gus == NULL) 223 if (gus == NULL)
226 return -EINVAL; 224 return -EINVAL;
227 225
228 init_MUTEX(&gus->register_mutex); 226 init_MUTEX(&gus->register_mutex);
229 gus->gf1.seq_client = -1; 227 gus->gf1.seq_client = -1;
230 228
231 cinfo = kmalloc(sizeof(*cinfo), GFP_KERNEL);
232 if (! cinfo)
233 return -ENOMEM;
234
235 /* allocate new client */ 229 /* allocate new client */
236 memset(&callbacks, 0, sizeof(callbacks));
237 callbacks.private_data = gus;
238 callbacks.allow_output = callbacks.allow_input = 1;
239 client = gus->gf1.seq_client = 230 client = gus->gf1.seq_client =
240 snd_seq_create_kernel_client(gus->card, 1, &callbacks); 231 snd_seq_create_kernel_client(gus->card, 1, gus->interwave ?
241 if (client < 0) { 232 "AMD InterWave" : "GF1");
242 kfree(cinfo); 233 if (client < 0)
243 return client; 234 return client;
244 }
245
246 /* change name of client */
247 memset(cinfo, 0, sizeof(*cinfo));
248 cinfo->client = client;
249 cinfo->type = KERNEL_CLIENT;
250 sprintf(cinfo->name, gus->interwave ? "AMD InterWave" : "GF1");
251 snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, cinfo);
252 kfree(cinfo);
253 235
254 for (i = 0; i < 4; i++) 236 for (i = 0; i < 4; i++)
255 snd_gus_synth_create_port(gus, i); 237 snd_gus_synth_create_port(gus, i);
@@ -293,11 +275,11 @@ static int snd_gus_synth_new_device(snd_seq_device_t *dev)
293 return 0; 275 return 0;
294} 276}
295 277
296static int snd_gus_synth_delete_device(snd_seq_device_t *dev) 278static int snd_gus_synth_delete_device(struct snd_seq_device *dev)
297{ 279{
298 snd_gus_card_t *gus; 280 struct snd_gus_card *gus;
299 281
300 gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); 282 gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev);
301 if (gus == NULL) 283 if (gus == NULL)
302 return -EINVAL; 284 return -EINVAL;
303 285
@@ -312,13 +294,13 @@ static int snd_gus_synth_delete_device(snd_seq_device_t *dev)
312 294
313static int __init alsa_gus_synth_init(void) 295static int __init alsa_gus_synth_init(void)
314{ 296{
315 static snd_seq_dev_ops_t ops = { 297 static struct snd_seq_dev_ops ops = {
316 snd_gus_synth_new_device, 298 snd_gus_synth_new_device,
317 snd_gus_synth_delete_device 299 snd_gus_synth_delete_device
318 }; 300 };
319 301
320 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_GUS, &ops, 302 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_GUS, &ops,
321 sizeof(snd_gus_card_t*)); 303 sizeof(struct snd_gus_card *));
322} 304}
323 305
324static void __exit alsa_gus_synth_exit(void) 306static void __exit alsa_gus_synth_exit(void)
diff --git a/sound/isa/gus/gus_timer.c b/sound/isa/gus/gus_timer.c
index 9876603ff6c1..a43b662f17c7 100644
--- a/sound/isa/gus/gus_timer.c
+++ b/sound/isa/gus/gus_timer.c
@@ -30,12 +30,12 @@
30 * Timer 1 - 80us 30 * Timer 1 - 80us
31 */ 31 */
32 32
33static int snd_gf1_timer1_start(snd_timer_t * timer) 33static int snd_gf1_timer1_start(struct snd_timer * timer)
34{ 34{
35 unsigned long flags; 35 unsigned long flags;
36 unsigned char tmp; 36 unsigned char tmp;
37 unsigned int ticks; 37 unsigned int ticks;
38 snd_gus_card_t *gus; 38 struct snd_gus_card *gus;
39 39
40 gus = snd_timer_chip(timer); 40 gus = snd_timer_chip(timer);
41 spin_lock_irqsave(&gus->reg_lock, flags); 41 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -48,11 +48,11 @@ static int snd_gf1_timer1_start(snd_timer_t * timer)
48 return 0; 48 return 0;
49} 49}
50 50
51static int snd_gf1_timer1_stop(snd_timer_t * timer) 51static int snd_gf1_timer1_stop(struct snd_timer * timer)
52{ 52{
53 unsigned long flags; 53 unsigned long flags;
54 unsigned char tmp; 54 unsigned char tmp;
55 snd_gus_card_t *gus; 55 struct snd_gus_card *gus;
56 56
57 gus = snd_timer_chip(timer); 57 gus = snd_timer_chip(timer);
58 spin_lock_irqsave(&gus->reg_lock, flags); 58 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -66,12 +66,12 @@ static int snd_gf1_timer1_stop(snd_timer_t * timer)
66 * Timer 2 - 320us 66 * Timer 2 - 320us
67 */ 67 */
68 68
69static int snd_gf1_timer2_start(snd_timer_t * timer) 69static int snd_gf1_timer2_start(struct snd_timer * timer)
70{ 70{
71 unsigned long flags; 71 unsigned long flags;
72 unsigned char tmp; 72 unsigned char tmp;
73 unsigned int ticks; 73 unsigned int ticks;
74 snd_gus_card_t *gus; 74 struct snd_gus_card *gus;
75 75
76 gus = snd_timer_chip(timer); 76 gus = snd_timer_chip(timer);
77 spin_lock_irqsave(&gus->reg_lock, flags); 77 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -84,11 +84,11 @@ static int snd_gf1_timer2_start(snd_timer_t * timer)
84 return 0; 84 return 0;
85} 85}
86 86
87static int snd_gf1_timer2_stop(snd_timer_t * timer) 87static int snd_gf1_timer2_stop(struct snd_timer * timer)
88{ 88{
89 unsigned long flags; 89 unsigned long flags;
90 unsigned char tmp; 90 unsigned char tmp;
91 snd_gus_card_t *gus; 91 struct snd_gus_card *gus;
92 92
93 gus = snd_timer_chip(timer); 93 gus = snd_timer_chip(timer);
94 spin_lock_irqsave(&gus->reg_lock, flags); 94 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -102,18 +102,18 @@ static int snd_gf1_timer2_stop(snd_timer_t * timer)
102 102
103 */ 103 */
104 104
105static void snd_gf1_interrupt_timer1(snd_gus_card_t * gus) 105static void snd_gf1_interrupt_timer1(struct snd_gus_card * gus)
106{ 106{
107 snd_timer_t *timer = gus->gf1.timer1; 107 struct snd_timer *timer = gus->gf1.timer1;
108 108
109 if (timer == NULL) 109 if (timer == NULL)
110 return; 110 return;
111 snd_timer_interrupt(timer, timer->sticks); 111 snd_timer_interrupt(timer, timer->sticks);
112} 112}
113 113
114static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus) 114static void snd_gf1_interrupt_timer2(struct snd_gus_card * gus)
115{ 115{
116 snd_timer_t *timer = gus->gf1.timer2; 116 struct snd_timer *timer = gus->gf1.timer2;
117 117
118 if (timer == NULL) 118 if (timer == NULL)
119 return; 119 return;
@@ -124,7 +124,7 @@ static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus)
124 124
125 */ 125 */
126 126
127static struct _snd_timer_hardware snd_gf1_timer1 = 127static struct snd_timer_hardware snd_gf1_timer1 =
128{ 128{
129 .flags = SNDRV_TIMER_HW_STOP, 129 .flags = SNDRV_TIMER_HW_STOP,
130 .resolution = 80000, 130 .resolution = 80000,
@@ -133,7 +133,7 @@ static struct _snd_timer_hardware snd_gf1_timer1 =
133 .stop = snd_gf1_timer1_stop, 133 .stop = snd_gf1_timer1_stop,
134}; 134};
135 135
136static struct _snd_timer_hardware snd_gf1_timer2 = 136static struct snd_timer_hardware snd_gf1_timer2 =
137{ 137{
138 .flags = SNDRV_TIMER_HW_STOP, 138 .flags = SNDRV_TIMER_HW_STOP,
139 .resolution = 320000, 139 .resolution = 320000,
@@ -142,22 +142,22 @@ static struct _snd_timer_hardware snd_gf1_timer2 =
142 .stop = snd_gf1_timer2_stop, 142 .stop = snd_gf1_timer2_stop,
143}; 143};
144 144
145static void snd_gf1_timer1_free(snd_timer_t *timer) 145static void snd_gf1_timer1_free(struct snd_timer *timer)
146{ 146{
147 snd_gus_card_t *gus = timer->private_data; 147 struct snd_gus_card *gus = timer->private_data;
148 gus->gf1.timer1 = NULL; 148 gus->gf1.timer1 = NULL;
149} 149}
150 150
151static void snd_gf1_timer2_free(snd_timer_t *timer) 151static void snd_gf1_timer2_free(struct snd_timer *timer)
152{ 152{
153 snd_gus_card_t *gus = timer->private_data; 153 struct snd_gus_card *gus = timer->private_data;
154 gus->gf1.timer2 = NULL; 154 gus->gf1.timer2 = NULL;
155} 155}
156 156
157void snd_gf1_timers_init(snd_gus_card_t * gus) 157void snd_gf1_timers_init(struct snd_gus_card * gus)
158{ 158{
159 snd_timer_t *timer; 159 struct snd_timer *timer;
160 snd_timer_id_t tid; 160 struct snd_timer_id tid;
161 161
162 if (gus->gf1.timer1 != NULL || gus->gf1.timer2 != NULL) 162 if (gus->gf1.timer1 != NULL || gus->gf1.timer2 != NULL)
163 return; 163 return;
@@ -190,7 +190,7 @@ void snd_gf1_timers_init(snd_gus_card_t * gus)
190 gus->gf1.timer2 = timer; 190 gus->gf1.timer2 = timer;
191} 191}
192 192
193void snd_gf1_timers_done(snd_gus_card_t * gus) 193void snd_gf1_timers_done(struct snd_gus_card * gus)
194{ 194{
195 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_TIMER1 | SNDRV_GF1_HANDLER_TIMER2); 195 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_TIMER1 | SNDRV_GF1_HANDLER_TIMER2);
196 if (gus->gf1.timer1) { 196 if (gus->gf1.timer1) {
diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c
index fbc95e99105c..654290a8b21c 100644
--- a/sound/isa/gus/gus_uart.c
+++ b/sound/isa/gus/gus_uart.c
@@ -26,7 +26,7 @@
26#include <sound/core.h> 26#include <sound/core.h>
27#include <sound/gus.h> 27#include <sound/gus.h>
28 28
29static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus) 29static void snd_gf1_interrupt_midi_in(struct snd_gus_card * gus)
30{ 30{
31 int count; 31 int count;
32 unsigned char stat, data, byte; 32 unsigned char stat, data, byte;
@@ -61,7 +61,7 @@ static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus)
61 } 61 }
62} 62}
63 63
64static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus) 64static void snd_gf1_interrupt_midi_out(struct snd_gus_card * gus)
65{ 65{
66 char byte; 66 char byte;
67 unsigned long flags; 67 unsigned long flags;
@@ -81,7 +81,7 @@ static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus)
81 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); 81 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags);
82} 82}
83 83
84static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close) 84static void snd_gf1_uart_reset(struct snd_gus_card * gus, int close)
85{ 85{
86 snd_gf1_uart_cmd(gus, 0x03); /* reset */ 86 snd_gf1_uart_cmd(gus, 0x03); /* reset */
87 if (!close && gus->uart_enable) { 87 if (!close && gus->uart_enable) {
@@ -90,10 +90,10 @@ static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close)
90 } 90 }
91} 91}
92 92
93static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream) 93static int snd_gf1_uart_output_open(struct snd_rawmidi_substream *substream)
94{ 94{
95 unsigned long flags; 95 unsigned long flags;
96 snd_gus_card_t *gus; 96 struct snd_gus_card *gus;
97 97
98 gus = substream->rmidi->private_data; 98 gus = substream->rmidi->private_data;
99 spin_lock_irqsave(&gus->uart_cmd_lock, flags); 99 spin_lock_irqsave(&gus->uart_cmd_lock, flags);
@@ -109,10 +109,10 @@ static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream)
109 return 0; 109 return 0;
110} 110}
111 111
112static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream) 112static int snd_gf1_uart_input_open(struct snd_rawmidi_substream *substream)
113{ 113{
114 unsigned long flags; 114 unsigned long flags;
115 snd_gus_card_t *gus; 115 struct snd_gus_card *gus;
116 int i; 116 int i;
117 117
118 gus = substream->rmidi->private_data; 118 gus = substream->rmidi->private_data;
@@ -136,10 +136,10 @@ static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream)
136 return 0; 136 return 0;
137} 137}
138 138
139static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream) 139static int snd_gf1_uart_output_close(struct snd_rawmidi_substream *substream)
140{ 140{
141 unsigned long flags; 141 unsigned long flags;
142 snd_gus_card_t *gus; 142 struct snd_gus_card *gus;
143 143
144 gus = substream->rmidi->private_data; 144 gus = substream->rmidi->private_data;
145 spin_lock_irqsave(&gus->uart_cmd_lock, flags); 145 spin_lock_irqsave(&gus->uart_cmd_lock, flags);
@@ -151,10 +151,10 @@ static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream)
151 return 0; 151 return 0;
152} 152}
153 153
154static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream) 154static int snd_gf1_uart_input_close(struct snd_rawmidi_substream *substream)
155{ 155{
156 unsigned long flags; 156 unsigned long flags;
157 snd_gus_card_t *gus; 157 struct snd_gus_card *gus;
158 158
159 gus = substream->rmidi->private_data; 159 gus = substream->rmidi->private_data;
160 spin_lock_irqsave(&gus->uart_cmd_lock, flags); 160 spin_lock_irqsave(&gus->uart_cmd_lock, flags);
@@ -166,9 +166,9 @@ static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream)
166 return 0; 166 return 0;
167} 167}
168 168
169static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int up) 169static void snd_gf1_uart_input_trigger(struct snd_rawmidi_substream *substream, int up)
170{ 170{
171 snd_gus_card_t *gus; 171 struct snd_gus_card *gus;
172 unsigned long flags; 172 unsigned long flags;
173 173
174 gus = substream->rmidi->private_data; 174 gus = substream->rmidi->private_data;
@@ -184,10 +184,10 @@ static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int
184 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); 184 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags);
185} 185}
186 186
187static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int up) 187static void snd_gf1_uart_output_trigger(struct snd_rawmidi_substream *substream, int up)
188{ 188{
189 unsigned long flags; 189 unsigned long flags;
190 snd_gus_card_t *gus; 190 struct snd_gus_card *gus;
191 char byte; 191 char byte;
192 int timeout; 192 int timeout;
193 193
@@ -222,23 +222,23 @@ static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int
222 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); 222 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags);
223} 223}
224 224
225static snd_rawmidi_ops_t snd_gf1_uart_output = 225static struct snd_rawmidi_ops snd_gf1_uart_output =
226{ 226{
227 .open = snd_gf1_uart_output_open, 227 .open = snd_gf1_uart_output_open,
228 .close = snd_gf1_uart_output_close, 228 .close = snd_gf1_uart_output_close,
229 .trigger = snd_gf1_uart_output_trigger, 229 .trigger = snd_gf1_uart_output_trigger,
230}; 230};
231 231
232static snd_rawmidi_ops_t snd_gf1_uart_input = 232static struct snd_rawmidi_ops snd_gf1_uart_input =
233{ 233{
234 .open = snd_gf1_uart_input_open, 234 .open = snd_gf1_uart_input_open,
235 .close = snd_gf1_uart_input_close, 235 .close = snd_gf1_uart_input_close,
236 .trigger = snd_gf1_uart_input_trigger, 236 .trigger = snd_gf1_uart_input_trigger,
237}; 237};
238 238
239int snd_gf1_rawmidi_new(snd_gus_card_t * gus, int device, snd_rawmidi_t ** rrawmidi) 239int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi ** rrawmidi)
240{ 240{
241 snd_rawmidi_t *rmidi; 241 struct snd_rawmidi *rmidi;
242 int err; 242 int err;
243 243
244 if (rrawmidi) 244 if (rrawmidi)
diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c
index b3382fec5298..dbbc0a6d7659 100644
--- a/sound/isa/gus/gus_volume.c
+++ b/sound/isa/gus/gus_volume.c
@@ -72,7 +72,7 @@ unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol)
72 return rvol | (m >> (8 - e)); 72 return rvol | (m >> (8 - e));
73} 73}
74 74
75unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, 75unsigned int snd_gf1_calc_ramp_rate(struct snd_gus_card * gus,
76 unsigned short start, 76 unsigned short start,
77 unsigned short end, 77 unsigned short end,
78 unsigned int us) 78 unsigned int us)
@@ -112,7 +112,7 @@ unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus,
112 112
113#endif /* 0 */ 113#endif /* 0 */
114 114
115unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) 115unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq16)
116{ 116{
117 freq16 >>= 3; 117 freq16 >>= 3;
118 if (freq16 < 50) 118 if (freq16 < 50)
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index 39cef38835ca..d1165b96fa3f 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -20,14 +20,15 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <asm/dma.h>
24#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/time.h> 27#include <linux/time.h>
27#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <asm/dma.h>
28#include <sound/core.h> 30#include <sound/core.h>
29#include <sound/gus.h> 31#include <sound/gus.h>
30#define SNDRV_LEGACY_AUTO_PROBE
31#define SNDRV_LEGACY_FIND_FREE_IRQ 32#define SNDRV_LEGACY_FIND_FREE_IRQ
32#define SNDRV_LEGACY_FIND_FREE_DMA 33#define SNDRV_LEGACY_FIND_FREE_DMA
33#include <sound/initval.h> 34#include <sound/initval.h>
@@ -70,11 +71,12 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver.");
70module_param_array(pcm_channels, int, NULL, 0444); 71module_param_array(pcm_channels, int, NULL, 0444);
71MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); 72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver.");
72 73
73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 74static struct platform_device *devices[SNDRV_CARDS];
75
74 76
75#define PFX "gusclassic: " 77#define PFX "gusclassic: "
76 78
77static int __init snd_gusclassic_detect(snd_gus_card_t * gus) 79static int __init snd_gusclassic_detect(struct snd_gus_card * gus)
78{ 80{
79 unsigned char d; 81 unsigned char d;
80 82
@@ -93,7 +95,7 @@ static int __init snd_gusclassic_detect(snd_gus_card_t * gus)
93 return 0; 95 return 0;
94} 96}
95 97
96static void __init snd_gusclassic_init(int dev, snd_gus_card_t * gus) 98static void __init snd_gusclassic_init(int dev, struct snd_gus_card * gus)
97{ 99{
98 gus->equal_irq = 0; 100 gus->equal_irq = 0;
99 gus->codec_flag = 0; 101 gus->codec_flag = 0;
@@ -101,20 +103,19 @@ static void __init snd_gusclassic_init(int dev, snd_gus_card_t * gus)
101 gus->joystick_dac = joystick_dac[dev]; 103 gus->joystick_dac = joystick_dac[dev];
102} 104}
103 105
104static int __init snd_gusclassic_probe(int dev) 106static int __init snd_gusclassic_probe(struct platform_device *pdev)
105{ 107{
108 int dev = pdev->id;
106 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; 109 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
107 static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; 110 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
108 int xirq, xdma1, xdma2; 111 int xirq, xdma1, xdma2;
109 snd_card_t *card; 112 struct snd_card *card;
110 struct snd_gusclassic *guscard; 113 struct snd_gus_card *gus = NULL;
111 snd_gus_card_t *gus = NULL;
112 int err; 114 int err;
113 115
114 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 116 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
115 if (card == NULL) 117 if (card == NULL)
116 return -ENOMEM; 118 return -ENOMEM;
117 guscard = (struct snd_gusclassic *)card->private_data;
118 if (pcm_channels[dev] < 2) 119 if (pcm_channels[dev] < 2)
119 pcm_channels[dev] = 2; 120 pcm_channels[dev] = 2;
120 121
@@ -143,12 +144,31 @@ static int __init snd_gusclassic_probe(int dev)
143 } 144 }
144 } 145 }
145 146
146 147 if (port[dev] != SNDRV_AUTO_PORT) {
147 if ((err = snd_gus_create(card, 148 err = snd_gus_create(card,
148 port[dev], 149 port[dev],
149 xirq, xdma1, xdma2, 150 xirq, xdma1, xdma2,
150 0, channels[dev], pcm_channels[dev], 151 0, channels[dev], pcm_channels[dev],
151 0, &gus)) < 0) 152 0, &gus);
153 } else {
154 /* auto-probe legacy ports */
155 static unsigned long possible_ports[] = {
156 0x220, 0x230, 0x240, 0x250, 0x260,
157 };
158 int i;
159 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
160 err = snd_gus_create(card,
161 possible_ports[i],
162 xirq, xdma1, xdma2,
163 0, channels[dev], pcm_channels[dev],
164 0, &gus);
165 if (err >= 0) {
166 port[dev] = possible_ports[i];
167 break;
168 }
169 }
170 }
171 if (err < 0)
152 goto _err; 172 goto _err;
153 173
154 if ((err = snd_gusclassic_detect(gus)) < 0) 174 if ((err = snd_gusclassic_detect(gus)) < 0)
@@ -178,13 +198,12 @@ static int __init snd_gusclassic_probe(int dev)
178 if (dma2 >= 0) 198 if (dma2 >= 0)
179 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 199 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
180 200
181 if ((err = snd_card_set_generic_dev(card)) < 0) 201 snd_card_set_dev(card, &pdev->dev);
182 goto _err;
183 202
184 if ((err = snd_card_register(card)) < 0) 203 if ((err = snd_card_register(card)) < 0)
185 goto _err; 204 goto _err;
186 205
187 snd_gusclassic_cards[dev] = card; 206 platform_set_drvdata(pdev, card);
188 return 0; 207 return 0;
189 208
190 _err: 209 _err:
@@ -192,53 +211,70 @@ static int __init snd_gusclassic_probe(int dev)
192 return err; 211 return err;
193} 212}
194 213
195static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) 214static int snd_gusclassic_remove(struct platform_device *devptr)
196{ 215{
197 static int dev; 216 snd_card_free(platform_get_drvdata(devptr));
198 int res; 217 platform_set_drvdata(devptr, NULL);
199 218 return 0;
200 for ( ; dev < SNDRV_CARDS; dev++) { 219}
201 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 220
202 continue; 221#define GUSCLASSIC_DRIVER "snd_gusclassic"
203 port[dev] = xport; 222
204 res = snd_gusclassic_probe(dev); 223static struct platform_driver snd_gusclassic_driver = {
205 if (res < 0) 224 .probe = snd_gusclassic_probe,
206 port[dev] = SNDRV_AUTO_PORT; 225 .remove = snd_gusclassic_remove,
207 return res; 226 /* FIXME: suspend/resume */
208 } 227 .driver = {
209 return -ENODEV; 228 .name = GUSCLASSIC_DRIVER
229 },
230};
231
232static void __init_or_module snd_gusclassic_unregister_all(void)
233{
234 int i;
235
236 for (i = 0; i < ARRAY_SIZE(devices); ++i)
237 platform_device_unregister(devices[i]);
238 platform_driver_unregister(&snd_gusclassic_driver);
210} 239}
211 240
212static int __init alsa_card_gusclassic_init(void) 241static int __init alsa_card_gusclassic_init(void)
213{ 242{
214 static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; 243 int i, cards, err;
215 int dev, cards, i; 244
216 245 err = platform_driver_register(&snd_gusclassic_driver);
217 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { 246 if (err < 0)
218 if (port[dev] == SNDRV_AUTO_PORT) 247 return err;
219 continue;
220 if (snd_gusclassic_probe(dev) >= 0)
221 cards++;
222 }
223 i = snd_legacy_auto_probe(possible_ports, snd_gusclassic_legacy_auto_probe);
224 if (i > 0)
225 cards += i;
226 248
249 cards = 0;
250 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
251 struct platform_device *device;
252 device = platform_device_register_simple(GUSCLASSIC_DRIVER,
253 i, NULL, 0);
254 if (IS_ERR(device)) {
255 err = PTR_ERR(device);
256 goto errout;
257 }
258 devices[i] = device;
259 cards++;
260 }
227 if (!cards) { 261 if (!cards) {
228#ifdef MODULE 262#ifdef MODULE
229 printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); 263 printk(KERN_ERR "GUS Classic soundcard not found or device busy\n");
230#endif 264#endif
231 return -ENODEV; 265 err = -ENODEV;
266 goto errout;
232 } 267 }
233 return 0; 268 return 0;
269
270 errout:
271 snd_gusclassic_unregister_all();
272 return err;
234} 273}
235 274
236static void __exit alsa_card_gusclassic_exit(void) 275static void __exit alsa_card_gusclassic_exit(void)
237{ 276{
238 int idx; 277 snd_gusclassic_unregister_all();
239
240 for (idx = 0; idx < SNDRV_CARDS; idx++)
241 snd_card_free(snd_gusclassic_cards[idx]);
242} 278}
243 279
244module_init(alsa_card_gusclassic_init) 280module_init(alsa_card_gusclassic_init)
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index d2e7cb1df537..239f16e6b9ee 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -20,11 +20,13 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <asm/dma.h>
24#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/time.h> 27#include <linux/time.h>
27#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <asm/dma.h>
28#include <sound/core.h> 30#include <sound/core.h>
29#include <sound/gus.h> 31#include <sound/gus.h>
30#include <sound/es1688.h> 32#include <sound/es1688.h>
@@ -85,14 +87,15 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver.");
85module_param_array(pcm_channels, int, NULL, 0444); 87module_param_array(pcm_channels, int, NULL, 0444);
86MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); 88MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver.");
87 89
88static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 90struct platform_device *devices[SNDRV_CARDS];
91
89 92
90#define PFX "gusextreme: " 93#define PFX "gusextreme: "
91 94
92static int __init snd_gusextreme_detect(int dev, 95static int __init snd_gusextreme_detect(int dev,
93 snd_card_t * card, 96 struct snd_card *card,
94 snd_gus_card_t * gus, 97 struct snd_gus_card * gus,
95 es1688_t *es1688) 98 struct snd_es1688 *es1688)
96{ 99{
97 unsigned long flags; 100 unsigned long flags;
98 unsigned char d; 101 unsigned char d;
@@ -139,15 +142,15 @@ static int __init snd_gusextreme_detect(int dev,
139 return 0; 142 return 0;
140} 143}
141 144
142static void __init snd_gusextreme_init(int dev, snd_gus_card_t * gus) 145static void __init snd_gusextreme_init(int dev, struct snd_gus_card * gus)
143{ 146{
144 gus->joystick_dac = joystick_dac[dev]; 147 gus->joystick_dac = joystick_dac[dev];
145} 148}
146 149
147static int __init snd_gusextreme_mixer(es1688_t *chip) 150static int __init snd_gusextreme_mixer(struct snd_es1688 *chip)
148{ 151{
149 snd_card_t *card = chip->card; 152 struct snd_card *card = chip->card;
150 snd_ctl_elem_id_t id1, id2; 153 struct snd_ctl_elem_id id1, id2;
151 int err; 154 int err;
152 155
153 memset(&id1, 0, sizeof(id1)); 156 memset(&id1, 0, sizeof(id1));
@@ -166,24 +169,23 @@ static int __init snd_gusextreme_mixer(es1688_t *chip)
166 return 0; 169 return 0;
167} 170}
168 171
169static int __init snd_gusextreme_probe(int dev) 172static int __init snd_gusextreme_probe(struct platform_device *pdev)
170{ 173{
174 int dev = pdev->id;
171 static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; 175 static int possible_ess_irqs[] = {5, 9, 10, 7, -1};
172 static int possible_ess_dmas[] = {1, 3, 0, -1}; 176 static int possible_ess_dmas[] = {1, 3, 0, -1};
173 static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 177 static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
174 static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; 178 static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1};
175 int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; 179 int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma;
176 snd_card_t *card; 180 struct snd_card *card;
177 struct snd_gusextreme *acard; 181 struct snd_gus_card *gus;
178 snd_gus_card_t *gus; 182 struct snd_es1688 *es1688;
179 es1688_t *es1688; 183 struct snd_opl3 *opl3;
180 opl3_t *opl3;
181 int err; 184 int err;
182 185
183 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 186 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
184 if (card == NULL) 187 if (card == NULL)
185 return -ENOMEM; 188 return -ENOMEM;
186 acard = (struct snd_gusextreme *)card->private_data;
187 189
188 xgf1_irq = gf1_irq[dev]; 190 xgf1_irq = gf1_irq[dev];
189 if (xgf1_irq == SNDRV_AUTO_IRQ) { 191 if (xgf1_irq == SNDRV_AUTO_IRQ) {
@@ -223,10 +225,29 @@ static int __init snd_gusextreme_probe(int dev)
223 } 225 }
224 } 226 }
225 227
226 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], 228 if (port[dev] != SNDRV_AUTO_PORT) {
227 xess_irq, xmpu_irq, xess_dma, 229 err = snd_es1688_create(card, port[dev], mpu_port[dev],
228 ES1688_HW_1688, &es1688)) < 0) 230 xess_irq, xmpu_irq, xess_dma,
231 ES1688_HW_1688, &es1688);
232 } else {
233 /* auto-probe legacy ports */
234 static unsigned long possible_ports[] = {0x220, 0x240, 0x260};
235 int i;
236 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
237 err = snd_es1688_create(card,
238 possible_ports[i],
239 mpu_port[dev],
240 xess_irq, xmpu_irq, xess_dma,
241 ES1688_HW_1688, &es1688);
242 if (err >= 0) {
243 port[dev] = possible_ports[i];
244 break;
245 }
246 }
247 }
248 if (err < 0)
229 goto out; 249 goto out;
250
230 if (gf1_port[dev] < 0) 251 if (gf1_port[dev] < 0)
231 gf1_port[dev] = port[dev] + 0x20; 252 gf1_port[dev] = port[dev] + 0x20;
232 if ((err = snd_gus_create(card, 253 if ((err = snd_gus_create(card,
@@ -287,13 +308,12 @@ static int __init snd_gusextreme_probe(int dev)
287 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", 308 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i",
288 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); 309 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma);
289 310
290 if ((err = snd_card_set_generic_dev(card)) < 0) 311 snd_card_set_dev(card, &pdev->dev);
291 goto out;
292 312
293 if ((err = snd_card_register(card)) < 0) 313 if ((err = snd_card_register(card)) < 0)
294 goto out; 314 goto out;
295 315
296 snd_gusextreme_cards[dev] = card; 316 platform_set_drvdata(pdev, card);
297 return 0; 317 return 0;
298 318
299 out: 319 out:
@@ -301,60 +321,70 @@ static int __init snd_gusextreme_probe(int dev)
301 return err; 321 return err;
302} 322}
303 323
304static int __init snd_gusextreme_legacy_auto_probe(unsigned long xport) 324static int snd_gusextreme_remove(struct platform_device *devptr)
325{
326 snd_card_free(platform_get_drvdata(devptr));
327 platform_set_drvdata(devptr, NULL);
328 return 0;
329}
330
331#define GUSEXTREME_DRIVER "snd_gusextreme"
332
333static struct platform_driver snd_gusextreme_driver = {
334 .probe = snd_gusextreme_probe,
335 .remove = snd_gusextreme_remove,
336 /* FIXME: suspend/resume */
337 .driver = {
338 .name = GUSEXTREME_DRIVER
339 },
340};
341
342static void __init_or_module snd_gusextreme_unregister_all(void)
305{ 343{
306 static int dev; 344 int i;
307 int res; 345
308 346 for (i = 0; i < ARRAY_SIZE(devices); ++i)
309 for ( ; dev < SNDRV_CARDS; dev++) { 347 platform_device_unregister(devices[i]);
310 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 348 platform_driver_unregister(&snd_gusextreme_driver);
311 continue;
312 port[dev] = xport;
313 res = snd_gusextreme_probe(dev);
314 if (res < 0)
315 port[dev] = SNDRV_AUTO_PORT;
316 return res;
317 }
318 return -ENODEV;
319} 349}
320 350
321static int __init alsa_card_gusextreme_init(void) 351static int __init alsa_card_gusextreme_init(void)
322{ 352{
323 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; 353 int i, cards, err;
324 int dev, cards, i; 354
325 355 err = platform_driver_register(&snd_gusextreme_driver);
326 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { 356 if (err < 0)
327 if (port[dev] == SNDRV_AUTO_PORT) 357 return err;
328 continue;
329 if (snd_gusextreme_probe(dev) >= 0)
330 cards++;
331 }
332 i = snd_legacy_auto_probe(possible_ports, snd_gusextreme_legacy_auto_probe);
333 if (i > 0)
334 cards += i;
335 358
359 cards = 0;
360 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
361 struct platform_device *device;
362 device = platform_device_register_simple(GUSEXTREME_DRIVER,
363 i, NULL, 0);
364 if (IS_ERR(device)) {
365 err = PTR_ERR(device);
366 goto errout;
367 }
368 devices[i] = device;
369 cards++;
370 }
336 if (!cards) { 371 if (!cards) {
337#ifdef MODULE 372#ifdef MODULE
338 printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); 373 printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n");
339#endif 374#endif
340 return -ENODEV; 375 err = -ENODEV;
376 goto errout;
341 } 377 }
342 return 0; 378 return 0;
379
380 errout:
381 snd_gusextreme_unregister_all();
382 return err;
343} 383}
344 384
345static void __exit alsa_card_gusextreme_exit(void) 385static void __exit alsa_card_gusextreme_exit(void)
346{ 386{
347 int idx; 387 snd_gusextreme_unregister_all();
348 snd_card_t *card;
349 struct snd_gusextreme *acard;
350
351 for (idx = 0; idx < SNDRV_CARDS; idx++) {
352 card = snd_gusextreme_cards[idx];
353 if (card == NULL)
354 continue;
355 acard = (struct snd_gusextreme *)card->private_data;
356 snd_card_free(snd_gusextreme_cards[idx]);
357 }
358} 388}
359 389
360module_init(alsa_card_gusextreme_init) 390module_init(alsa_card_gusextreme_init)
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index 0bb44b519340..d4d2b2a517d5 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -20,15 +20,16 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <asm/dma.h>
24#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/time.h> 27#include <linux/time.h>
27#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <asm/dma.h>
28#include <sound/core.h> 30#include <sound/core.h>
29#include <sound/gus.h> 31#include <sound/gus.h>
30#include <sound/cs4231.h> 32#include <sound/cs4231.h>
31#define SNDRV_LEGACY_AUTO_PROBE
32#define SNDRV_LEGACY_FIND_FREE_IRQ 33#define SNDRV_LEGACY_FIND_FREE_IRQ
33#define SNDRV_LEGACY_FIND_FREE_DMA 34#define SNDRV_LEGACY_FIND_FREE_DMA
34#include <sound/initval.h> 35#include <sound/initval.h>
@@ -71,20 +72,20 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
71module_param_array(pcm_channels, int, NULL, 0444); 72module_param_array(pcm_channels, int, NULL, 0444);
72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); 73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
73 74
75static struct platform_device *devices[SNDRV_CARDS];
76
74struct snd_gusmax { 77struct snd_gusmax {
75 int irq; 78 int irq;
76 snd_card_t *card; 79 struct snd_card *card;
77 snd_gus_card_t *gus; 80 struct snd_gus_card *gus;
78 cs4231_t *cs4231; 81 struct snd_cs4231 *cs4231;
79 unsigned short gus_status_reg; 82 unsigned short gus_status_reg;
80 unsigned short pcm_status_reg; 83 unsigned short pcm_status_reg;
81}; 84};
82 85
83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
84
85#define PFX "gusmax: " 86#define PFX "gusmax: "
86 87
87static int __init snd_gusmax_detect(snd_gus_card_t * gus) 88static int __init snd_gusmax_detect(struct snd_gus_card * gus)
88{ 89{
89 unsigned char d; 90 unsigned char d;
90 91
@@ -126,7 +127,7 @@ static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *r
126 return IRQ_RETVAL(handled); 127 return IRQ_RETVAL(handled);
127} 128}
128 129
129static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * gus) 130static void __init snd_gusmax_init(int dev, struct snd_card *card, struct snd_gus_card * gus)
130{ 131{
131 gus->equal_irq = 1; 132 gus->equal_irq = 1;
132 gus->codec_flag = 1; 133 gus->codec_flag = 1;
@@ -144,10 +145,10 @@ static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t *
144#define CS4231_PRIVATE( left, right, shift, mute ) \ 145#define CS4231_PRIVATE( left, right, shift, mute ) \
145 ((left << 24)|(right << 16)|(shift<<8)|mute) 146 ((left << 24)|(right << 16)|(shift<<8)|mute)
146 147
147static int __init snd_gusmax_mixer(cs4231_t *chip) 148static int __init snd_gusmax_mixer(struct snd_cs4231 *chip)
148{ 149{
149 snd_card_t *card = chip->card; 150 struct snd_card *card = chip->card;
150 snd_ctl_elem_id_t id1, id2; 151 struct snd_ctl_elem_id id1, id2;
151 int err; 152 int err;
152 153
153 memset(&id1, 0, sizeof(id1)); 154 memset(&id1, 0, sizeof(id1));
@@ -193,7 +194,7 @@ static int __init snd_gusmax_mixer(cs4231_t *chip)
193 return 0; 194 return 0;
194} 195}
195 196
196static void snd_gusmax_free(snd_card_t *card) 197static void snd_gusmax_free(struct snd_card *card)
197{ 198{
198 struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data; 199 struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data;
199 200
@@ -203,14 +204,15 @@ static void snd_gusmax_free(snd_card_t *card)
203 free_irq(maxcard->irq, (void *)maxcard); 204 free_irq(maxcard->irq, (void *)maxcard);
204} 205}
205 206
206static int __init snd_gusmax_probe(int dev) 207static int __init snd_gusmax_probe(struct platform_device *pdev)
207{ 208{
209 int dev = pdev->id;
208 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 210 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
209 static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; 211 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
210 int xirq, xdma1, xdma2, err; 212 int xirq, xdma1, xdma2, err;
211 snd_card_t *card; 213 struct snd_card *card;
212 snd_gus_card_t *gus = NULL; 214 struct snd_gus_card *gus = NULL;
213 cs4231_t *cs4231; 215 struct snd_cs4231 *cs4231;
214 struct snd_gusmax *maxcard; 216 struct snd_gusmax *maxcard;
215 217
216 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 218 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
@@ -247,12 +249,32 @@ static int __init snd_gusmax_probe(int dev)
247 } 249 }
248 } 250 }
249 251
250 if ((err = snd_gus_create(card, 252 if (port[dev] != SNDRV_AUTO_PORT) {
251 port[dev], 253 err = snd_gus_create(card,
252 -xirq, xdma1, xdma2, 254 port[dev],
253 0, channels[dev], 255 -xirq, xdma1, xdma2,
254 pcm_channels[dev], 256 0, channels[dev],
255 0, &gus)) < 0) 257 pcm_channels[dev],
258 0, &gus);
259 } else {
260 static unsigned long possible_ports[] = {
261 0x220, 0x230, 0x240, 0x250, 0x260
262 };
263 int i;
264 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
265 err = snd_gus_create(card,
266 possible_ports[i],
267 -xirq, xdma1, xdma2,
268 0, channels[dev],
269 pcm_channels[dev],
270 0, &gus);
271 if (err >= 0) {
272 port[dev] = possible_ports[i];
273 break;
274 }
275 }
276 }
277 if (err < 0)
256 goto _err; 278 goto _err;
257 279
258 if ((err = snd_gusmax_detect(gus)) < 0) 280 if ((err = snd_gusmax_detect(gus)) < 0)
@@ -310,15 +332,15 @@ static int __init snd_gusmax_probe(int dev)
310 if (xdma2 >= 0) 332 if (xdma2 >= 0)
311 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 333 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
312 334
313 if ((err = snd_card_set_generic_dev(card)) < 0) 335 snd_card_set_dev(card, &pdev->dev);
314 goto _err;
315 336
316 if ((err = snd_card_register(card)) < 0) 337 if ((err = snd_card_register(card)) < 0)
317 goto _err; 338 goto _err;
318 339
319 maxcard->gus = gus; 340 maxcard->gus = gus;
320 maxcard->cs4231 = cs4231; 341 maxcard->cs4231 = cs4231;
321 snd_gusmax_cards[dev] = card; 342
343 platform_set_drvdata(pdev, card);
322 return 0; 344 return 0;
323 345
324 _err: 346 _err:
@@ -326,53 +348,70 @@ static int __init snd_gusmax_probe(int dev)
326 return err; 348 return err;
327} 349}
328 350
329static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) 351static int snd_gusmax_remove(struct platform_device *devptr)
330{ 352{
331 static int dev; 353 snd_card_free(platform_get_drvdata(devptr));
332 int res; 354 platform_set_drvdata(devptr, NULL);
333 355 return 0;
334 for ( ; dev < SNDRV_CARDS; dev++) { 356}
335 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 357
336 continue; 358#define GUSMAX_DRIVER "snd_gusmax"
337 port[dev] = xport; 359
338 res = snd_gusmax_probe(dev); 360static struct platform_driver snd_gusmax_driver = {
339 if (res < 0) 361 .probe = snd_gusmax_probe,
340 port[dev] = SNDRV_AUTO_PORT; 362 .remove = snd_gusmax_remove,
341 return res; 363 /* FIXME: suspend/resume */
342 } 364 .driver = {
343 return -ENODEV; 365 .name = GUSMAX_DRIVER
366 },
367};
368
369static void __init_or_module snd_gusmax_unregister_all(void)
370{
371 int i;
372
373 for (i = 0; i < ARRAY_SIZE(devices); ++i)
374 platform_device_unregister(devices[i]);
375 platform_driver_unregister(&snd_gusmax_driver);
344} 376}
345 377
346static int __init alsa_card_gusmax_init(void) 378static int __init alsa_card_gusmax_init(void)
347{ 379{
348 static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; 380 int i, cards, err;
349 int dev, cards, i;
350
351 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) {
352 if (port[dev] == SNDRV_AUTO_PORT)
353 continue;
354 if (snd_gusmax_probe(dev) >= 0)
355 cards++;
356 }
357 i = snd_legacy_auto_probe(possible_ports, snd_gusmax_legacy_auto_probe);
358 if (i > 0)
359 cards += i;
360 381
382 err = platform_driver_register(&snd_gusmax_driver);
383 if (err < 0)
384 return err;
385
386 cards = 0;
387 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
388 struct platform_device *device;
389 device = platform_device_register_simple(GUSMAX_DRIVER,
390 i, NULL, 0);
391 if (IS_ERR(device)) {
392 err = PTR_ERR(device);
393 goto errout;
394 }
395 devices[i] = device;
396 cards++;
397 }
361 if (!cards) { 398 if (!cards) {
362#ifdef MODULE 399#ifdef MODULE
363 printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); 400 printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
364#endif 401#endif
365 return -ENODEV; 402 err = -ENODEV;
403 goto errout;
366 } 404 }
367 return 0; 405 return 0;
406
407 errout:
408 snd_gusmax_unregister_all();
409 return err;
368} 410}
369 411
370static void __exit alsa_card_gusmax_exit(void) 412static void __exit alsa_card_gusmax_exit(void)
371{ 413{
372 int idx; 414 snd_gusmax_unregister_all();
373
374 for (idx = 0; idx < SNDRV_CARDS; idx++)
375 snd_card_free(snd_gusmax_cards[idx]);
376} 415}
377 416
378module_init(alsa_card_gusmax_init) 417module_init(alsa_card_gusmax_init)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index f703a9f4257c..9838d992b101 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -23,19 +23,20 @@
23 */ 23 */
24 24
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <asm/dma.h>
27#include <linux/delay.h>
28#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h>
28#include <linux/platform_device.h>
29#include <linux/delay.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/pnp.h> 31#include <linux/pnp.h>
31#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <asm/dma.h>
32#include <sound/core.h> 34#include <sound/core.h>
33#include <sound/gus.h> 35#include <sound/gus.h>
34#include <sound/cs4231.h> 36#include <sound/cs4231.h>
35#ifdef SNDRV_STB 37#ifdef SNDRV_STB
36#include <sound/tea6330t.h> 38#include <sound/tea6330t.h>
37#endif 39#endif
38#define SNDRV_LEGACY_AUTO_PROBE
39#define SNDRV_LEGACY_FIND_FREE_IRQ 40#define SNDRV_LEGACY_FIND_FREE_IRQ
40#define SNDRV_LEGACY_FIND_FREE_DMA 41#define SNDRV_LEGACY_FIND_FREE_DMA
41#include <sound/initval.h> 42#include <sound/initval.h>
@@ -75,8 +76,12 @@ static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
75 76
76#ifdef SNDRV_STB 77#ifdef SNDRV_STB
77#define PFX "interwave-stb: " 78#define PFX "interwave-stb: "
79#define INTERWAVE_DRIVER "snd_interwave_stb"
80#define INTERWAVE_PNP_DRIVER "interwave-stb"
78#else 81#else
79#define PFX "interwave: " 82#define PFX "interwave: "
83#define INTERWAVE_DRIVER "snd_interwave"
84#define INTERWAVE_PNP_DRIVER "interwave"
80#endif 85#endif
81 86
82module_param_array(index, int, NULL, 0444); 87module_param_array(index, int, NULL, 0444);
@@ -110,11 +115,14 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
110module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
111MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
112 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
113struct snd_interwave { 121struct snd_interwave {
114 int irq; 122 int irq;
115 snd_card_t *card; 123 struct snd_card *card;
116 snd_gus_card_t *gus; 124 struct snd_gus_card *gus;
117 cs4231_t *cs4231; 125 struct snd_cs4231 *cs4231;
118#ifdef SNDRV_STB 126#ifdef SNDRV_STB
119 struct resource *i2c_res; 127 struct resource *i2c_res;
120#endif 128#endif
@@ -128,7 +136,6 @@ struct snd_interwave {
128#endif 136#endif
129}; 137};
130 138
131static snd_card_t *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
132 139
133#ifdef CONFIG_PNP 140#ifdef CONFIG_PNP
134 141
@@ -160,7 +167,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids);
160 167
161 168
162#ifdef SNDRV_STB 169#ifdef SNDRV_STB
163static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) 170static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int data)
164{ 171{
165 unsigned long port = bus->private_value; 172 unsigned long port = bus->private_value;
166 173
@@ -171,7 +178,7 @@ static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data)
171 udelay(10); 178 udelay(10);
172} 179}
173 180
174static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) 181static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus)
175{ 182{
176 unsigned long port = bus->private_value; 183 unsigned long port = bus->private_value;
177 unsigned char res; 184 unsigned char res;
@@ -183,7 +190,7 @@ static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus)
183 return res; 190 return res;
184} 191}
185 192
186static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) 193static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack)
187{ 194{
188 unsigned long port = bus->private_value; 195 unsigned long port = bus->private_value;
189 unsigned char res; 196 unsigned char res;
@@ -197,19 +204,19 @@ static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack)
197 return res; 204 return res;
198} 205}
199 206
200static snd_i2c_bit_ops_t snd_interwave_i2c_bit_ops = { 207static struct snd_i2c_bit_ops snd_interwave_i2c_bit_ops = {
201 .setlines = snd_interwave_i2c_setlines, 208 .setlines = snd_interwave_i2c_setlines,
202 .getclock = snd_interwave_i2c_getclockline, 209 .getclock = snd_interwave_i2c_getclockline,
203 .getdata = snd_interwave_i2c_getdataline, 210 .getdata = snd_interwave_i2c_getdataline,
204}; 211};
205 212
206static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, 213static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard,
207 snd_gus_card_t * gus, int dev, 214 struct snd_gus_card * gus, int dev,
208 snd_i2c_bus_t **rbus) 215 struct snd_i2c_bus **rbus)
209{ 216{
210 unsigned long port; 217 unsigned long port;
211 snd_i2c_bus_t *bus; 218 struct snd_i2c_bus *bus;
212 snd_card_t *card = iwcard->card; 219 struct snd_card *card = iwcard->card;
213 char name[32]; 220 char name[32];
214 int err; 221 int err;
215 222
@@ -246,10 +253,10 @@ static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard,
246#endif 253#endif
247 254
248static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, 255static int __devinit snd_interwave_detect(struct snd_interwave *iwcard,
249 snd_gus_card_t * gus, 256 struct snd_gus_card * gus,
250 int dev 257 int dev
251#ifdef SNDRV_STB 258#ifdef SNDRV_STB
252 , snd_i2c_bus_t **rbus 259 , struct snd_i2c_bus **rbus
253#endif 260#endif
254 ) 261 )
255{ 262{
@@ -314,7 +321,7 @@ static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs
314 return IRQ_RETVAL(handled); 321 return IRQ_RETVAL(handled);
315} 322}
316 323
317static void __devinit snd_interwave_reset(snd_gus_card_t * gus) 324static void __devinit snd_interwave_reset(struct snd_gus_card * gus)
318{ 325{
319 snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00); 326 snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00);
320 udelay(160); 327 udelay(160);
@@ -322,7 +329,7 @@ static void __devinit snd_interwave_reset(snd_gus_card_t * gus)
322 udelay(160); 329 udelay(160);
323} 330}
324 331
325static void __devinit snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes) 332static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *sizes)
326{ 333{
327 unsigned int idx; 334 unsigned int idx;
328 unsigned int local; 335 unsigned int local;
@@ -371,7 +378,7 @@ struct rom_hdr {
371 /* 511 */ unsigned char csum; 378 /* 511 */ unsigned char csum;
372}; 379};
373 380
374static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) 381static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus)
375{ 382{
376 static unsigned int lmc[13] = 383 static unsigned int lmc[13] =
377 { 384 {
@@ -470,7 +477,7 @@ static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus)
470 snd_interwave_reset(gus); 477 snd_interwave_reset(gus);
471} 478}
472 479
473static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) 480static void __devinit snd_interwave_init(int dev, struct snd_gus_card * gus)
474{ 481{
475 unsigned long flags; 482 unsigned long flags;
476 483
@@ -492,17 +499,17 @@ static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus)
492 499
493} 500}
494 501
495static snd_kcontrol_new_t snd_interwave_controls[] = { 502static struct snd_kcontrol_new snd_interwave_controls[] = {
496CS4231_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1), 503CS4231_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1),
497CS4231_DOUBLE("Master Playback Volume", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 0, 0, 31, 1), 504CS4231_DOUBLE("Master Playback Volume", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 0, 0, 31, 1),
498CS4231_DOUBLE("Mic Playback Switch", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 7, 7, 1, 1), 505CS4231_DOUBLE("Mic Playback Switch", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 7, 7, 1, 1),
499CS4231_DOUBLE("Mic Playback Volume", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 0, 0, 31, 1) 506CS4231_DOUBLE("Mic Playback Volume", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 0, 0, 31, 1)
500}; 507};
501 508
502static int __devinit snd_interwave_mixer(cs4231_t *chip) 509static int __devinit snd_interwave_mixer(struct snd_cs4231 *chip)
503{ 510{
504 snd_card_t *card = chip->card; 511 struct snd_card *card = chip->card;
505 snd_ctl_elem_id_t id1, id2; 512 struct snd_ctl_elem_id id1, id2;
506 unsigned int idx; 513 unsigned int idx;
507 int err; 514 int err;
508 515
@@ -631,9 +638,9 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
631} 638}
632#endif /* CONFIG_PNP */ 639#endif /* CONFIG_PNP */
633 640
634static void snd_interwave_free(snd_card_t *card) 641static void snd_interwave_free(struct snd_card *card)
635{ 642{
636 struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; 643 struct snd_interwave *iwcard = card->private_data;
637 644
638 if (iwcard == NULL) 645 if (iwcard == NULL)
639 return; 646 return;
@@ -644,76 +651,52 @@ static void snd_interwave_free(snd_card_t *card)
644 free_irq(iwcard->irq, (void *)iwcard); 651 free_irq(iwcard->irq, (void *)iwcard);
645} 652}
646 653
647static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, 654static struct snd_card *snd_interwave_card_new(int dev)
648 const struct pnp_card_device_id *pid)
649{ 655{
650 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 656 struct snd_card *card;
651 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
652 int xirq, xdma1, xdma2;
653 snd_card_t *card;
654 struct snd_interwave *iwcard; 657 struct snd_interwave *iwcard;
655 cs4231_t *cs4231;
656 snd_gus_card_t *gus;
657#ifdef SNDRV_STB
658 snd_i2c_bus_t *i2c_bus;
659#endif
660 snd_pcm_t *pcm;
661 char *str;
662 int err;
663 658
664 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 659 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
665 sizeof(struct snd_interwave)); 660 sizeof(struct snd_interwave));
666 if (card == NULL) 661 if (card == NULL)
667 return -ENOMEM; 662 return NULL;
668 iwcard = (struct snd_interwave *)card->private_data; 663 iwcard = card->private_data;
669 iwcard->card = card; 664 iwcard->card = card;
670 iwcard->irq = -1; 665 iwcard->irq = -1;
671 card->private_free = snd_interwave_free; 666 card->private_free = snd_interwave_free;
672#ifdef CONFIG_PNP 667 return card;
673 if (isapnp[dev]) { 668}
674 if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) 669
675 goto _err; 670static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
676 snd_card_set_dev(card, &pcard->card->dev); 671{
677 } 672 int xirq, xdma1, xdma2;
673 struct snd_interwave *iwcard = card->private_data;
674 struct snd_cs4231 *cs4231;
675 struct snd_gus_card *gus;
676#ifdef SNDRV_STB
677 struct snd_i2c_bus *i2c_bus;
678#endif 678#endif
679 struct snd_pcm *pcm;
680 char *str;
681 int err;
682
679 xirq = irq[dev]; 683 xirq = irq[dev];
680 if (xirq == SNDRV_AUTO_IRQ) {
681 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
682 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
683 err = -EBUSY;
684 goto _err;
685 }
686 }
687 xdma1 = dma1[dev]; 684 xdma1 = dma1[dev];
688 if (xdma1 == SNDRV_AUTO_DMA) {
689 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
690 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
691 err = -EBUSY;
692 goto _err;
693 }
694 }
695 xdma2 = dma2[dev]; 685 xdma2 = dma2[dev];
696 if (xdma2 == SNDRV_AUTO_DMA) {
697 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
698 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
699 err = -EBUSY;
700 goto _err;
701 }
702 }
703 686
704 if ((err = snd_gus_create(card, 687 if ((err = snd_gus_create(card,
705 port[dev], 688 port[dev],
706 -xirq, xdma1, xdma2, 689 -xirq, xdma1, xdma2,
707 0, 32, 690 0, 32,
708 pcm_channels[dev], effect[dev], &gus)) < 0) 691 pcm_channels[dev], effect[dev], &gus)) < 0)
709 goto _err; 692 return err;
710 693
711 if ((err = snd_interwave_detect(iwcard, gus, dev 694 if ((err = snd_interwave_detect(iwcard, gus, dev
712#ifdef SNDRV_STB 695#ifdef SNDRV_STB
713 , &i2c_bus 696 , &i2c_bus
714#endif 697#endif
715 )) < 0) 698 )) < 0)
716 goto _err; 699 return err;
717 700
718 iwcard->gus_status_reg = gus->gf1.reg_irqstat; 701 iwcard->gus_status_reg = gus->gf1.reg_irqstat;
719 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 702 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
@@ -721,12 +704,12 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
721 snd_interwave_init(dev, gus); 704 snd_interwave_init(dev, gus);
722 snd_interwave_detect_memory(gus); 705 snd_interwave_detect_memory(gus);
723 if ((err = snd_gus_initialize(gus)) < 0) 706 if ((err = snd_gus_initialize(gus)) < 0)
724 goto _err; 707 return err;
725 708
726 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { 709 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT,
710 "InterWave", iwcard)) {
727 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); 711 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
728 err = -EBUSY; 712 return -EBUSY;
729 goto _err;
730 } 713 }
731 iwcard->irq = xirq; 714 iwcard->irq = xirq;
732 715
@@ -738,30 +721,30 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
738 CS4231_HWSHARE_DMA1 | 721 CS4231_HWSHARE_DMA1 |
739 CS4231_HWSHARE_DMA2, 722 CS4231_HWSHARE_DMA2,
740 &cs4231)) < 0) 723 &cs4231)) < 0)
741 goto _err; 724 return err;
742 725
743 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) 726 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0)
744 goto _err; 727 return err;
745 728
746 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); 729 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
747 strcat(pcm->name, " (codec)"); 730 strcat(pcm->name, " (codec)");
748 731
749 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) 732 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
750 goto _err; 733 return err;
751 734
752 if ((err = snd_cs4231_mixer(cs4231)) < 0) 735 if ((err = snd_cs4231_mixer(cs4231)) < 0)
753 goto _err; 736 return err;
754 737
755 if (pcm_channels[dev] > 0) { 738 if (pcm_channels[dev] > 0) {
756 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) 739 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
757 goto _err; 740 return err;
758 } 741 }
759 if ((err = snd_interwave_mixer(cs4231)) < 0) 742 if ((err = snd_interwave_mixer(cs4231)) < 0)
760 goto _err; 743 return err;
761 744
762#ifdef SNDRV_STB 745#ifdef SNDRV_STB
763 { 746 {
764 snd_ctl_elem_id_t id1, id2; 747 struct snd_ctl_elem_id id1, id2;
765 memset(&id1, 0, sizeof(id1)); 748 memset(&id1, 0, sizeof(id1));
766 memset(&id2, 0, sizeof(id2)); 749 memset(&id2, 0, sizeof(id2));
767 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 750 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
@@ -769,19 +752,19 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
769 strcpy(id2.name, id1.name); 752 strcpy(id2.name, id1.name);
770 id2.index = 1; 753 id2.index = 1;
771 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 754 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
772 goto _err; 755 return err;
773 strcpy(id1.name, "Master Playback Volume"); 756 strcpy(id1.name, "Master Playback Volume");
774 strcpy(id2.name, id1.name); 757 strcpy(id2.name, id1.name);
775 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 758 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
776 goto _err; 759 return err;
777 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) 760 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0)
778 goto _err; 761 return err;
779 } 762 }
780#endif 763#endif
781 764
782 gus->uart_enable = midi[dev]; 765 gus->uart_enable = midi[dev];
783 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) 766 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
784 goto _err; 767 return err;
785 768
786#ifndef SNDRV_STB 769#ifndef SNDRV_STB
787 str = "AMD InterWave"; 770 str = "AMD InterWave";
@@ -800,139 +783,198 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
800 if (xdma2 >= 0) 783 if (xdma2 >= 0)
801 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 784 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
802 785
803 if ((err = snd_card_set_generic_dev(card)) < 0)
804 goto _err;
805
806 if ((err = snd_card_register(card)) < 0) 786 if ((err = snd_card_register(card)) < 0)
807 goto _err; 787 return err;
808 788
809 iwcard->cs4231 = cs4231; 789 iwcard->cs4231 = cs4231;
810 iwcard->gus = gus; 790 iwcard->gus = gus;
811 if (pcard)
812 pnp_set_card_drvdata(pcard, card);
813 else
814 snd_interwave_legacy[dev++] = card;
815 return 0; 791 return 0;
792}
816 793
817 _err: 794static int __init snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr)
818 snd_card_free(card); 795{
819 return err; 796 struct snd_card *card;
797 int err;
798
799 card = snd_interwave_card_new(dev);
800 if (! card)
801 return -ENOMEM;
802
803 snd_card_set_dev(card, &devptr->dev);
804 if ((err = snd_interwave_probe(card, dev)) < 0) {
805 snd_card_free(card);
806 return err;
807 }
808 platform_set_drvdata(devptr, card);
809 return 0;
820} 810}
821 811
822static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) 812static int __init snd_interwave_nonpnp_probe(struct platform_device *pdev)
823{ 813{
824 static int dev; 814 int dev = pdev->id;
825 int res; 815 int err;
816 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
817 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
826 818
827 for ( ; dev < SNDRV_CARDS; dev++) { 819 if (irq[dev] == SNDRV_AUTO_IRQ) {
828 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 820 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
829 continue; 821 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
830#ifdef CONFIG_PNP 822 return -EBUSY;
831 if (isapnp[dev]) 823 }
832 continue;
833#endif
834 port[dev] = xport;
835 res = snd_interwave_probe(dev, NULL, NULL);
836 if (res < 0)
837 port[dev] = SNDRV_AUTO_PORT;
838 return res;
839 } 824 }
840 return -ENODEV; 825 if (dma1[dev] == SNDRV_AUTO_DMA) {
826 if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
827 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
828 return -EBUSY;
829 }
830 }
831 if (dma2[dev] == SNDRV_AUTO_DMA) {
832 if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
833 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
834 return -EBUSY;
835 }
836 }
837
838 if (port[dev] != SNDRV_AUTO_PORT)
839 return snd_interwave_nonpnp_probe1(dev, pdev);
840 else {
841 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
842 int i;
843 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
844 port[dev] = possible_ports[i];
845 err = snd_interwave_nonpnp_probe1(dev, pdev);
846 if (! err)
847 return 0;
848 }
849 return err;
850 }
851}
852
853static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr)
854{
855 snd_card_free(platform_get_drvdata(devptr));
856 platform_set_drvdata(devptr, NULL);
857 return 0;
841} 858}
842 859
860static struct platform_driver snd_interwave_driver = {
861 .probe = snd_interwave_nonpnp_probe,
862 .remove = __devexit_p(snd_interwave_nonpnp_remove),
863 /* FIXME: suspend,resume */
864 .driver = {
865 .name = INTERWAVE_DRIVER
866 },
867};
868
843#ifdef CONFIG_PNP 869#ifdef CONFIG_PNP
844 870
845static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, 871static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
846 const struct pnp_card_device_id *id) 872 const struct pnp_card_device_id *pid)
847{ 873{
848 static int dev; 874 static int dev;
875 struct snd_card *card;
849 int res; 876 int res;
850 877
851 for ( ; dev < SNDRV_CARDS; dev++) { 878 for ( ; dev < SNDRV_CARDS; dev++) {
852 if (!enable[dev] || !isapnp[dev]) 879 if (enable[dev] && isapnp[dev])
853 continue; 880 break;
854 res = snd_interwave_probe(dev, card, id); 881 }
855 if (res < 0) 882 if (dev >= SNDRV_CARDS)
856 return res; 883 return -ENODEV;
857 dev++; 884
858 return 0; 885 card = snd_interwave_card_new(dev);
859 } 886 if (! card)
860 887 return -ENOMEM;
861 return -ENODEV; 888
889 if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) {
890 snd_card_free(card);
891 return res;
892 }
893 snd_card_set_dev(card, &pcard->card->dev);
894 if ((res = snd_interwave_probe(card, dev)) < 0) {
895 snd_card_free(card);
896 return res;
897 }
898 pnp_set_card_drvdata(pcard, card);
899 dev++;
900 return 0;
862} 901}
863 902
864static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) 903static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard)
865{ 904{
866 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 905 snd_card_free(pnp_get_card_drvdata(pcard));
867 906 pnp_set_card_drvdata(pcard, NULL);
868 snd_card_disconnect(card);
869 snd_card_free_in_thread(card);
870} 907}
871 908
872static struct pnp_card_driver interwave_pnpc_driver = { 909static struct pnp_card_driver interwave_pnpc_driver = {
873 .flags = PNP_DRIVER_RES_DISABLE, 910 .flags = PNP_DRIVER_RES_DISABLE,
874 .name = "interwave", 911 .name = INTERWAVE_PNP_DRIVER,
875 .id_table = snd_interwave_pnpids, 912 .id_table = snd_interwave_pnpids,
876 .probe = snd_interwave_pnp_detect, 913 .probe = snd_interwave_pnp_detect,
877 .remove = __devexit_p(snd_interwave_pnp_remove), 914 .remove = __devexit_p(snd_interwave_pnp_remove),
915 /* FIXME: suspend,resume */
878}; 916};
879 917
880#endif /* CONFIG_PNP */ 918#endif /* CONFIG_PNP */
881 919
920static void __init_or_module snd_interwave_unregister_all(void)
921{
922 int i;
923
924 if (pnp_registered)
925 pnp_unregister_card_driver(&interwave_pnpc_driver);
926 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
927 platform_device_unregister(platform_devices[i]);
928 platform_driver_unregister(&snd_interwave_driver);
929}
930
882static int __init alsa_card_interwave_init(void) 931static int __init alsa_card_interwave_init(void)
883{ 932{
884 int cards = 0, i; 933 int i, err, cards = 0;
885 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260, -1};
886 int dev;
887 934
888 for (dev = 0; dev < SNDRV_CARDS; dev++) { 935 if ((err = platform_driver_register(&snd_interwave_driver)) < 0)
889 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 936 return err;
890 continue; 937
938 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
939 struct platform_device *device;
891#ifdef CONFIG_PNP 940#ifdef CONFIG_PNP
892 if (isapnp[dev]) 941 if (isapnp[i])
893 continue; 942 continue;
894#endif 943#endif
895 if (!snd_interwave_probe(dev, NULL, NULL)) { 944 device = platform_device_register_simple(INTERWAVE_DRIVER,
896 cards++; 945 i, NULL, 0);
897 continue; 946 if (IS_ERR(device)) {
947 err = PTR_ERR(device);
948 goto errout;
898 } 949 }
899#ifdef MODULE 950 platform_devices[i] = device;
900 printk(KERN_ERR "InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); 951 cards++;
901#endif
902 } 952 }
903 /* legacy auto configured cards */ 953
904 i = snd_legacy_auto_probe(possible_ports, snd_interwave_probe_legacy_port);
905 if (i > 0)
906 cards += i;
907#ifdef CONFIG_PNP
908 /* ISA PnP cards */ 954 /* ISA PnP cards */
909 i = pnp_register_card_driver(&interwave_pnpc_driver); 955 i = pnp_register_card_driver(&interwave_pnpc_driver);
910 if (i > 0) 956 if (i >= 0) {
957 pnp_registered = 1;
911 cards += i; 958 cards += i;
912#endif 959 }
913 960
914 if (!cards) { 961 if (!cards) {
915#ifdef CONFIG_PNP
916 pnp_unregister_card_driver(&interwave_pnpc_driver);
917#endif
918#ifdef MODULE 962#ifdef MODULE
919 printk(KERN_ERR "InterWave soundcard not found or device busy\n"); 963 printk(KERN_ERR "InterWave soundcard not found or device busy\n");
920#endif 964#endif
921 return -ENODEV; 965 err = -ENODEV;
966 goto errout;
922 } 967 }
923 return 0; 968 return 0;
969
970 errout:
971 snd_interwave_unregister_all();
972 return err;
924} 973}
925 974
926static void __exit alsa_card_interwave_exit(void) 975static void __exit alsa_card_interwave_exit(void)
927{ 976{
928 int dev; 977 snd_interwave_unregister_all();
929
930#ifdef CONFIG_PNP
931 /* PnP cards first */
932 pnp_unregister_card_driver(&interwave_pnpc_driver);
933#endif
934 for (dev = 0; dev < SNDRV_CARDS; dev++)
935 snd_card_free(snd_interwave_legacy[dev]);
936} 978}
937 979
938module_init(alsa_card_interwave_init) 980module_init(alsa_card_interwave_init)
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 47cabda792b6..ca359e0c674b 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -21,6 +21,8 @@
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
24#include <linux/interrupt.h> 26#include <linux/interrupt.h>
25#include <linux/pm.h> 27#include <linux/pm.h>
26#include <linux/slab.h> 28#include <linux/slab.h>
@@ -88,6 +90,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
88module_param_array(opl3sa3_ymode, int, NULL, 0444); 90module_param_array(opl3sa3_ymode, int, NULL, 0444);
89MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 91MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
90 92
93static struct platform_device *platform_devices[SNDRV_CARDS];
94static int pnp_registered;
95static int pnpc_registered;
96
91/* control ports */ 97/* control ports */
92#define OPL3SA2_PM_CTRL 0x01 98#define OPL3SA2_PM_CTRL 0x01
93#define OPL3SA2_SYS_CTRL 0x02 99#define OPL3SA2_SYS_CTRL 0x02
@@ -115,34 +121,23 @@ MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode:
115#define OPL3SA2_PM_D0 0x00 121#define OPL3SA2_PM_D0 0x00
116#define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX) 122#define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX)
117 123
118typedef struct snd_opl3sa2 opl3sa2_t;
119
120struct snd_opl3sa2 { 124struct snd_opl3sa2 {
121 snd_card_t *card; 125 struct snd_card *card;
122 int version; /* 2 or 3 */ 126 int version; /* 2 or 3 */
123 unsigned long port; /* control port */ 127 unsigned long port; /* control port */
124 struct resource *res_port; /* control port resource */ 128 struct resource *res_port; /* control port resource */
125 int irq; 129 int irq;
126 int single_dma; 130 int single_dma;
127 spinlock_t reg_lock; 131 spinlock_t reg_lock;
128 snd_hwdep_t *synth; 132 struct snd_hwdep *synth;
129 snd_rawmidi_t *rmidi; 133 struct snd_rawmidi *rmidi;
130 cs4231_t *cs4231; 134 struct snd_cs4231 *cs4231;
131#ifdef CONFIG_PNP
132 struct pnp_dev *dev;
133#endif
134 unsigned char ctlregs[0x20]; 135 unsigned char ctlregs[0x20];
135 int ymode; /* SL added */ 136 int ymode; /* SL added */
136 snd_kcontrol_t *master_switch; 137 struct snd_kcontrol *master_switch;
137 snd_kcontrol_t *master_volume; 138 struct snd_kcontrol *master_volume;
138#ifdef CONFIG_PM
139 void (*cs4231_suspend)(cs4231_t *);
140 void (*cs4231_resume)(cs4231_t *);
141#endif
142}; 139};
143 140
144static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
145
146#define PFX "opl3sa2: " 141#define PFX "opl3sa2: "
147 142
148#ifdef CONFIG_PNP 143#ifdef CONFIG_PNP
@@ -176,7 +171,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids);
176 171
177 172
178/* read control port (w/o spinlock) */ 173/* read control port (w/o spinlock) */
179static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) 174static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg)
180{ 175{
181 unsigned char result; 176 unsigned char result;
182#if 0 177#if 0
@@ -192,7 +187,7 @@ static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg)
192} 187}
193 188
194/* read control port (with spinlock) */ 189/* read control port (with spinlock) */
195static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) 190static unsigned char snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg)
196{ 191{
197 unsigned long flags; 192 unsigned long flags;
198 unsigned char result; 193 unsigned char result;
@@ -204,7 +199,7 @@ static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg)
204} 199}
205 200
206/* write control port (w/o spinlock) */ 201/* write control port (w/o spinlock) */
207static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) 202static void __snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value)
208{ 203{
209#if 0 204#if 0
210 outb(0x1d, port); /* password */ 205 outb(0x1d, port); /* password */
@@ -215,7 +210,7 @@ static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned cha
215} 210}
216 211
217/* write control port (with spinlock) */ 212/* write control port (with spinlock) */
218static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) 213static void snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value)
219{ 214{
220 unsigned long flags; 215 unsigned long flags;
221 spin_lock_irqsave(&chip->reg_lock, flags); 216 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -223,9 +218,9 @@ static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char
223 spin_unlock_irqrestore(&chip->reg_lock, flags); 218 spin_unlock_irqrestore(&chip->reg_lock, flags);
224} 219}
225 220
226static int __init snd_opl3sa2_detect(opl3sa2_t *chip) 221static int __init snd_opl3sa2_detect(struct snd_opl3sa2 *chip)
227{ 222{
228 snd_card_t *card; 223 struct snd_card *card;
229 unsigned long port; 224 unsigned long port;
230 unsigned char tmp, tmp1; 225 unsigned char tmp, tmp1;
231 char str[2]; 226 char str[2];
@@ -298,7 +293,7 @@ static int __init snd_opl3sa2_detect(opl3sa2_t *chip)
298static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs) 293static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs)
299{ 294{
300 unsigned short status; 295 unsigned short status;
301 opl3sa2_t *chip = dev_id; 296 struct snd_opl3sa2 *chip = dev_id;
302 int handled = 0; 297 int handled = 0;
303 298
304 if (chip == NULL || chip->card == NULL) 299 if (chip == NULL || chip->card == NULL)
@@ -340,7 +335,7 @@ static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *
340 .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \ 335 .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \
341 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 336 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
342 337
343static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 338static int snd_opl3sa2_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
344{ 339{
345 int mask = (kcontrol->private_value >> 16) & 0xff; 340 int mask = (kcontrol->private_value >> 16) & 0xff;
346 341
@@ -351,9 +346,9 @@ static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
351 return 0; 346 return 0;
352} 347}
353 348
354static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 349static int snd_opl3sa2_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
355{ 350{
356 opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); 351 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
357 unsigned long flags; 352 unsigned long flags;
358 int reg = kcontrol->private_value & 0xff; 353 int reg = kcontrol->private_value & 0xff;
359 int shift = (kcontrol->private_value >> 8) & 0xff; 354 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -368,9 +363,9 @@ static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
368 return 0; 363 return 0;
369} 364}
370 365
371static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 366static int snd_opl3sa2_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
372{ 367{
373 opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); 368 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
374 unsigned long flags; 369 unsigned long flags;
375 int reg = kcontrol->private_value & 0xff; 370 int reg = kcontrol->private_value & 0xff;
376 int shift = (kcontrol->private_value >> 8) & 0xff; 371 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -398,7 +393,7 @@ static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
398 .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \ 393 .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \
399 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 394 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
400 395
401static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 396static int snd_opl3sa2_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
402{ 397{
403 int mask = (kcontrol->private_value >> 24) & 0xff; 398 int mask = (kcontrol->private_value >> 24) & 0xff;
404 399
@@ -409,9 +404,9 @@ static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
409 return 0; 404 return 0;
410} 405}
411 406
412static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 407static int snd_opl3sa2_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
413{ 408{
414 opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); 409 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
415 unsigned long flags; 410 unsigned long flags;
416 int left_reg = kcontrol->private_value & 0xff; 411 int left_reg = kcontrol->private_value & 0xff;
417 int right_reg = (kcontrol->private_value >> 8) & 0xff; 412 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -431,9 +426,9 @@ static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
431 return 0; 426 return 0;
432} 427}
433 428
434static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 429static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
435{ 430{
436 opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); 431 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
437 unsigned long flags; 432 unsigned long flags;
438 int left_reg = kcontrol->private_value & 0xff; 433 int left_reg = kcontrol->private_value & 0xff;
439 int right_reg = (kcontrol->private_value >> 8) & 0xff; 434 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -471,31 +466,31 @@ static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
471 return change; 466 return change;
472} 467}
473 468
474static snd_kcontrol_new_t snd_opl3sa2_controls[] = { 469static struct snd_kcontrol_new snd_opl3sa2_controls[] = {
475OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1), 470OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
476OPL3SA2_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1), 471OPL3SA2_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1),
477OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), 472OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
478OPL3SA2_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1) 473OPL3SA2_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1)
479}; 474};
480 475
481static snd_kcontrol_new_t snd_opl3sa2_tone_controls[] = { 476static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
482OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0), 477OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
483OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0), 478OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
484OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0) 479OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
485}; 480};
486 481
487static void snd_opl3sa2_master_free(snd_kcontrol_t *kcontrol) 482static void snd_opl3sa2_master_free(struct snd_kcontrol *kcontrol)
488{ 483{
489 opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); 484 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol);
490 chip->master_switch = NULL; 485 chip->master_switch = NULL;
491 chip->master_volume = NULL; 486 chip->master_volume = NULL;
492} 487}
493 488
494static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) 489static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip)
495{ 490{
496 snd_card_t *card = chip->card; 491 struct snd_card *card = chip->card;
497 snd_ctl_elem_id_t id1, id2; 492 struct snd_ctl_elem_id id1, id2;
498 snd_kcontrol_t *kctl; 493 struct snd_kcontrol *kctl;
499 unsigned int idx; 494 unsigned int idx;
500 int err; 495 int err;
501 496
@@ -505,21 +500,29 @@ static int __init snd_opl3sa2_mixer(opl3sa2_t *chip)
505 /* reassign AUX0 to CD */ 500 /* reassign AUX0 to CD */
506 strcpy(id1.name, "Aux Playback Switch"); 501 strcpy(id1.name, "Aux Playback Switch");
507 strcpy(id2.name, "CD Playback Switch"); 502 strcpy(id2.name, "CD Playback Switch");
508 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 503 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
504 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
509 return err; 505 return err;
506 }
510 strcpy(id1.name, "Aux Playback Volume"); 507 strcpy(id1.name, "Aux Playback Volume");
511 strcpy(id2.name, "CD Playback Volume"); 508 strcpy(id2.name, "CD Playback Volume");
512 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 509 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
510 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
513 return err; 511 return err;
512 }
514 /* reassign AUX1 to FM */ 513 /* reassign AUX1 to FM */
515 strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; 514 strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
516 strcpy(id2.name, "FM Playback Switch"); 515 strcpy(id2.name, "FM Playback Switch");
517 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 516 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
517 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
518 return err; 518 return err;
519 }
519 strcpy(id1.name, "Aux Playback Volume"); 520 strcpy(id1.name, "Aux Playback Volume");
520 strcpy(id2.name, "FM Playback Volume"); 521 strcpy(id2.name, "FM Playback Volume");
521 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 522 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) {
523 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
522 return err; 524 return err;
525 }
523 /* add OPL3SA2 controls */ 526 /* add OPL3SA2 controls */
524 for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { 527 for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) {
525 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0) 528 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0)
@@ -539,22 +542,21 @@ static int __init snd_opl3sa2_mixer(opl3sa2_t *chip)
539 542
540/* Power Management support functions */ 543/* Power Management support functions */
541#ifdef CONFIG_PM 544#ifdef CONFIG_PM
542static int snd_opl3sa2_suspend(snd_card_t *card, pm_message_t state) 545static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state)
543{ 546{
544 opl3sa2_t *chip = card->pm_private_data; 547 struct snd_opl3sa2 *chip = card->private_data;
545
546 snd_pcm_suspend_all(chip->cs4231->pcm); /* stop before saving regs */
547 chip->cs4231_suspend(chip->cs4231);
548 548
549 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
550 chip->cs4231->suspend(chip->cs4231);
549 /* power down */ 551 /* power down */
550 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3); 552 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
551 553
552 return 0; 554 return 0;
553} 555}
554 556
555static int snd_opl3sa2_resume(snd_card_t *card) 557static int snd_opl3sa2_resume(struct snd_card *card)
556{ 558{
557 opl3sa2_t *chip = card->pm_private_data; 559 struct snd_opl3sa2 *chip = card->private_data;
558 int i; 560 int i;
559 561
560 /* power up */ 562 /* power up */
@@ -570,26 +572,25 @@ static int snd_opl3sa2_resume(snd_card_t *card)
570 snd_opl3sa2_write(chip, i, chip->ctlregs[i]); 572 snd_opl3sa2_write(chip, i, chip->ctlregs[i]);
571 } 573 }
572 /* restore cs4231 */ 574 /* restore cs4231 */
573 chip->cs4231_resume(chip->cs4231); 575 chip->cs4231->resume(chip->cs4231);
574 576
577 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
575 return 0; 578 return 0;
576} 579}
577#endif /* CONFIG_PM */ 580#endif /* CONFIG_PM */
578 581
579#ifdef CONFIG_PNP 582#ifdef CONFIG_PNP
580static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, 583static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip,
581 struct pnp_dev *pdev, 584 struct pnp_dev *pdev)
582 int isapnp)
583{ 585{
584 struct pnp_resource_table * cfg; 586 struct pnp_resource_table * cfg;
585 int err; 587 int err;
586 588
587 if (!isapnp && pnp_device_is_isapnp(pdev))
588 return -ENOENT; /* we have another procedure - card */
589
590 cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 589 cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
591 if (!cfg) 590 if (!cfg) {
591 snd_printk(KERN_ERR PFX "cannot allocate pnp cfg\n");
592 return -ENOMEM; 592 return -ENOMEM;
593 }
593 /* PnP initialization */ 594 /* PnP initialization */
594 pnp_init_resource_table(cfg); 595 pnp_init_resource_table(cfg);
595 if (sb_port[dev] != SNDRV_AUTO_PORT) 596 if (sb_port[dev] != SNDRV_AUTO_PORT)
@@ -609,8 +610,8 @@ static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip,
609 if (irq[dev] != SNDRV_AUTO_IRQ) 610 if (irq[dev] != SNDRV_AUTO_IRQ)
610 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 611 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
611 err = pnp_manual_config_dev(pdev, cfg, 0); 612 err = pnp_manual_config_dev(pdev, cfg, 0);
612 if (err < 0 && isapnp) 613 if (err < 0)
613 snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); 614 snd_printk(KERN_WARNING "PnP manual resources are invalid, using auto config\n");
614 err = pnp_activate_dev(pdev); 615 err = pnp_activate_dev(pdev);
615 if (err < 0) { 616 if (err < 0) {
616 kfree(cfg); 617 kfree(cfg);
@@ -630,111 +631,47 @@ static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip,
630 snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", 631 snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n",
631 pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]); 632 pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]);
632 kfree(cfg); 633 kfree(cfg);
633 chip->dev = pdev;
634 return 0; 634 return 0;
635} 635}
636
637static int __init snd_opl3sa2_cpnp(int dev, opl3sa2_t *chip,
638 struct pnp_card_link *card,
639 const struct pnp_card_device_id *id)
640{
641 struct pnp_dev *pdev;
642 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
643
644 if (!cfg)
645 return -ENOMEM;
646 pdev = pnp_request_card_device(card, id->devs[0].id, NULL);
647 if (pdev == NULL) {
648 kfree(cfg);
649 return -EBUSY;
650 }
651 return snd_opl3sa2_pnp(dev, chip, pdev, 1);
652}
653#endif /* CONFIG_PNP */ 636#endif /* CONFIG_PNP */
654 637
655static int snd_opl3sa2_free(opl3sa2_t *chip) 638static void snd_opl3sa2_free(struct snd_card *card)
656{ 639{
640 struct snd_opl3sa2 *chip = card->private_data;
657 if (chip->irq >= 0) 641 if (chip->irq >= 0)
658 free_irq(chip->irq, (void *)chip); 642 free_irq(chip->irq, (void *)chip);
659 release_and_free_resource(chip->res_port); 643 release_and_free_resource(chip->res_port);
660 kfree(chip);
661 return 0;
662} 644}
663 645
664static int snd_opl3sa2_dev_free(snd_device_t *device) 646static struct snd_card *snd_opl3sa2_card_new(int dev)
665{
666 opl3sa2_t *chip = device->device_data;
667 return snd_opl3sa2_free(chip);
668}
669
670#ifdef CONFIG_PNP
671#define is_isapnp_selected(dev) isapnp[dev]
672#else
673#define is_isapnp_selected(dev) 0
674#endif
675
676static int __devinit snd_opl3sa2_probe(int dev,
677 struct pnp_dev *pdev,
678 struct pnp_card_link *pcard,
679 const struct pnp_card_device_id *pid)
680{ 647{
681 int xirq, xdma1, xdma2; 648 struct snd_card *card;
682 snd_card_t *card;
683 struct snd_opl3sa2 *chip; 649 struct snd_opl3sa2 *chip;
684 cs4231_t *cs4231;
685 opl3_t *opl3;
686 static snd_device_ops_t ops = {
687 .dev_free = snd_opl3sa2_dev_free,
688 };
689 int err;
690
691 if (! is_isapnp_selected(dev)) {
692 if (port[dev] == SNDRV_AUTO_PORT) {
693 snd_printk(KERN_ERR PFX "specify port\n");
694 return -EINVAL;
695 }
696 if (wss_port[dev] == SNDRV_AUTO_PORT) {
697 snd_printk(KERN_ERR PFX "specify wss_port\n");
698 return -EINVAL;
699 }
700 if (fm_port[dev] == SNDRV_AUTO_PORT) {
701 snd_printk(KERN_ERR PFX "specify fm_port\n");
702 return -EINVAL;
703 }
704 if (midi_port[dev] == SNDRV_AUTO_PORT) {
705 snd_printk(KERN_ERR PFX "specify midi_port\n");
706 return -EINVAL;
707 }
708 }
709 650
710 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 651 card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_opl3sa2));
711 if (card == NULL) 652 if (card == NULL)
712 return -ENOMEM; 653 return NULL;
713 strcpy(card->driver, "OPL3SA2"); 654 strcpy(card->driver, "OPL3SA2");
714 strcpy(card->shortname, "Yamaha OPL3-SA2"); 655 strcpy(card->shortname, "Yamaha OPL3-SA2");
715 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 656 chip = card->private_data;
716 if (chip == NULL) {
717 err = -ENOMEM;
718 goto __error;
719 }
720 spin_lock_init(&chip->reg_lock); 657 spin_lock_init(&chip->reg_lock);
721 chip->irq = -1; 658 chip->irq = -1;
722 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
723 goto __error;
724#ifdef CONFIG_PNP
725 if (pdev) {
726 if ((err = snd_opl3sa2_pnp(dev, chip, pdev, 0)) < 0)
727 goto __error;
728 snd_card_set_dev(card, &pdev->dev);
729 }
730 if (pcard) {
731 if ((err = snd_opl3sa2_cpnp(dev, chip, pcard, pid)) < 0)
732 goto __error;
733 snd_card_set_dev(card, &pcard->card->dev);
734 }
735#endif
736 chip->ymode = opl3sa3_ymode[dev] & 0x03 ; /* initialise this card from supplied (or default) parameter*/
737 chip->card = card; 659 chip->card = card;
660 card->private_free = snd_opl3sa2_free;
661 return card;
662}
663
664static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev)
665{
666 int xirq, xdma1, xdma2;
667 struct snd_opl3sa2 *chip;
668 struct snd_cs4231 *cs4231;
669 struct snd_opl3 *opl3;
670 int err;
671
672 /* initialise this card from supplied (or default) parameter*/
673 chip = card->private_data;
674 chip->ymode = opl3sa3_ymode[dev] & 0x03 ;
738 chip->port = port[dev]; 675 chip->port = port[dev];
739 xirq = irq[dev]; 676 xirq = irq[dev];
740 xdma1 = dma1[dev]; 677 xdma1 = dma1[dev];
@@ -742,11 +679,10 @@ static int __devinit snd_opl3sa2_probe(int dev,
742 if (xdma2 < 0) 679 if (xdma2 < 0)
743 chip->single_dma = 1; 680 chip->single_dma = 1;
744 if ((err = snd_opl3sa2_detect(chip)) < 0) 681 if ((err = snd_opl3sa2_detect(chip)) < 0)
745 goto __error; 682 return err;
746 if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) { 683 if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", chip)) {
747 snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq); 684 snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq);
748 err = -ENODEV; 685 return -ENODEV;
749 goto __error;
750 } 686 }
751 chip->irq = xirq; 687 chip->irq = xirq;
752 if ((err = snd_cs4231_create(card, 688 if ((err = snd_cs4231_create(card,
@@ -756,179 +692,303 @@ static int __devinit snd_opl3sa2_probe(int dev,
756 CS4231_HWSHARE_IRQ, 692 CS4231_HWSHARE_IRQ,
757 &cs4231)) < 0) { 693 &cs4231)) < 0) {
758 snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4); 694 snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4);
759 goto __error; 695 return err;
760 } 696 }
761 chip->cs4231 = cs4231; 697 chip->cs4231 = cs4231;
762 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) 698 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
763 goto __error; 699 return err;
764 if ((err = snd_cs4231_mixer(cs4231)) < 0) 700 if ((err = snd_cs4231_mixer(cs4231)) < 0)
765 goto __error; 701 return err;
766 if ((err = snd_opl3sa2_mixer(chip)) < 0) 702 if ((err = snd_opl3sa2_mixer(chip)) < 0)
767 goto __error; 703 return err;
768 if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0) 704 if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0)
769 goto __error; 705 return err;
770 if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { 706 if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) {
771 if ((err = snd_opl3_create(card, fm_port[dev], 707 if ((err = snd_opl3_create(card, fm_port[dev],
772 fm_port[dev] + 2, 708 fm_port[dev] + 2,
773 OPL3_HW_OPL3, 0, &opl3)) < 0) 709 OPL3_HW_OPL3, 0, &opl3)) < 0)
774 goto __error; 710 return err;
775 if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) 711 if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0)
776 goto __error; 712 return err;
777 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0) 713 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0)
778 goto __error; 714 return err;
779 } 715 }
780 if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) { 716 if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) {
781 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2, 717 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
782 midi_port[dev], 0, 718 midi_port[dev], 0,
783 xirq, 0, &chip->rmidi)) < 0) 719 xirq, 0, &chip->rmidi)) < 0)
784 goto __error; 720 return err;
785 } 721 }
786#ifdef CONFIG_PM
787 chip->cs4231_suspend = chip->cs4231->suspend;
788 chip->cs4231_resume = chip->cs4231->resume;
789 /* now clear callbacks for cs4231 */
790 chip->cs4231->suspend = NULL;
791 chip->cs4231->resume = NULL;
792 snd_card_set_isa_pm_callback(card, snd_opl3sa2_suspend, snd_opl3sa2_resume, chip);
793#endif
794
795 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 722 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
796 card->shortname, chip->port, xirq, xdma1); 723 card->shortname, chip->port, xirq, xdma1);
797 if (dma2 >= 0) 724 if (dma2 >= 0)
798 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 725 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
799 726
800 if ((err = snd_card_set_generic_dev(card)) < 0) 727 return snd_card_register(card);
801 goto __error;
802
803 if ((err = snd_card_register(card)) < 0)
804 goto __error;
805
806 if (pdev)
807 pnp_set_drvdata(pdev, card);
808 else if (pcard)
809 pnp_set_card_drvdata(pcard, card);
810 else
811 snd_opl3sa2_legacy[dev] = card;
812 return 0;
813
814 __error:
815 snd_card_free(card);
816 return err;
817} 728}
818 729
819#ifdef CONFIG_PNP 730#ifdef CONFIG_PNP
820static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, 731static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
821 const struct pnp_device_id *id) 732 const struct pnp_device_id *id)
822{ 733{
823 static int dev; 734 static int dev;
824 int res; 735 int err;
736 struct snd_card *card;
825 737
826 for ( ; dev < SNDRV_CARDS; dev++) { 738 if (pnp_device_is_isapnp(pdev))
827 if (!enable[dev] || !isapnp[dev]) 739 return -ENOENT; /* we have another procedure - card */
828 continue; 740 for (; dev < SNDRV_CARDS; dev++) {
829 res = snd_opl3sa2_probe(dev, pdev, NULL, NULL); 741 if (enable[dev] && isapnp[dev])
830 if (res < 0) 742 break;
831 return res; 743 }
832 dev++; 744 if (dev >= SNDRV_CARDS)
833 return 0; 745 return -ENODEV;
834 } 746
835 return -ENODEV; 747 card = snd_opl3sa2_card_new(dev);
748 if (! card)
749 return -ENOMEM;
750 if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
751 snd_card_free(card);
752 return err;
753 }
754 snd_card_set_dev(card, &pdev->dev);
755 if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
756 snd_card_free(card);
757 return err;
758 }
759 pnp_set_drvdata(pdev, card);
760 dev++;
761 return 0;
836} 762}
837 763
838static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev) 764static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev)
839{ 765{
840 snd_card_t *card = (snd_card_t *) pnp_get_drvdata(pdev); 766 snd_card_free(pnp_get_drvdata(pdev));
841 767 pnp_set_drvdata(pdev, NULL);
842 snd_card_disconnect(card); 768}
843 snd_card_free_in_thread(card); 769
770#ifdef CONFIG_PM
771static int snd_opl3sa2_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
772{
773 return snd_opl3sa2_suspend(pnp_get_drvdata(pdev), state);
844} 774}
775static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev)
776{
777 return snd_opl3sa2_resume(pnp_get_drvdata(pdev));
778}
779#endif
845 780
846static struct pnp_driver opl3sa2_pnp_driver = { 781static struct pnp_driver opl3sa2_pnp_driver = {
847 .name = "opl3sa2-pnpbios", 782 .name = "opl3sa2-pnpbios",
848 .id_table = snd_opl3sa2_pnpbiosids, 783 .id_table = snd_opl3sa2_pnpbiosids,
849 .probe = snd_opl3sa2_pnp_detect, 784 .probe = snd_opl3sa2_pnp_detect,
850 .remove = __devexit_p(snd_opl3sa2_pnp_remove), 785 .remove = __devexit_p(snd_opl3sa2_pnp_remove),
786#ifdef CONFIG_PM
787 .suspend = snd_opl3sa2_pnp_suspend,
788 .resume = snd_opl3sa2_pnp_resume,
789#endif
851}; 790};
852 791
853static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card, 792static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
854 const struct pnp_card_device_id *id) 793 const struct pnp_card_device_id *id)
855{ 794{
856 static int dev; 795 static int dev;
857 int res; 796 struct pnp_dev *pdev;
797 int err;
798 struct snd_card *card;
858 799
859 for ( ; dev < SNDRV_CARDS; dev++) { 800 pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL);
860 if (!enable[dev]) 801 if (pdev == NULL) {
861 continue; 802 snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n",
862 if (is_isapnp_selected(dev)) 803 id->devs[0].id);
863 continue; 804 return -EBUSY;
864 res = snd_opl3sa2_probe(dev, NULL, card, id); 805 }
865 if (res < 0) 806 for (; dev < SNDRV_CARDS; dev++) {
866 return res; 807 if (enable[dev] && isapnp[dev])
867 dev++; 808 break;
868 return 0; 809 }
869 } 810 if (dev >= SNDRV_CARDS)
870 return -ENODEV; 811 return -ENODEV;
812
813 card = snd_opl3sa2_card_new(dev);
814 if (! card)
815 return -ENOMEM;
816 if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) {
817 snd_card_free(card);
818 return err;
819 }
820 snd_card_set_dev(card, &pdev->dev);
821 if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
822 snd_card_free(card);
823 return err;
824 }
825 pnp_set_card_drvdata(pcard, card);
826 dev++;
827 return 0;
871} 828}
872 829
873static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard) 830static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard)
874{ 831{
875 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 832 snd_card_free(pnp_get_card_drvdata(pcard));
876 833 pnp_set_card_drvdata(pcard, NULL);
877 snd_card_disconnect(card);
878 snd_card_free_in_thread(card);
879} 834}
880 835
836#ifdef CONFIG_PM
837static int snd_opl3sa2_pnp_csuspend(struct pnp_card_link *pcard, pm_message_t state)
838{
839 return snd_opl3sa2_suspend(pnp_get_card_drvdata(pcard), state);
840}
841static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard)
842{
843 return snd_opl3sa2_resume(pnp_get_card_drvdata(pcard));
844}
845#endif
846
881static struct pnp_card_driver opl3sa2_pnpc_driver = { 847static struct pnp_card_driver opl3sa2_pnpc_driver = {
882 .flags = PNP_DRIVER_RES_DISABLE, 848 .flags = PNP_DRIVER_RES_DISABLE,
883 .name = "opl3sa2", 849 .name = "opl3sa2",
884 .id_table = snd_opl3sa2_pnpids, 850 .id_table = snd_opl3sa2_pnpids,
885 .probe = snd_opl3sa2_pnp_cdetect, 851 .probe = snd_opl3sa2_pnp_cdetect,
886 .remove = __devexit_p(snd_opl3sa2_pnp_cremove), 852 .remove = __devexit_p(snd_opl3sa2_pnp_cremove),
853#ifdef CONFIG_PM
854 .suspend = snd_opl3sa2_pnp_csuspend,
855 .resume = snd_opl3sa2_pnp_cresume,
856#endif
887}; 857};
888#endif /* CONFIG_PNP */ 858#endif /* CONFIG_PNP */
889 859
860static int __init snd_opl3sa2_nonpnp_probe(struct platform_device *pdev)
861{
862 struct snd_card *card;
863 int err;
864 int dev = pdev->id;
865
866 if (port[dev] == SNDRV_AUTO_PORT) {
867 snd_printk(KERN_ERR PFX "specify port\n");
868 return -EINVAL;
869 }
870 if (wss_port[dev] == SNDRV_AUTO_PORT) {
871 snd_printk(KERN_ERR PFX "specify wss_port\n");
872 return -EINVAL;
873 }
874 if (fm_port[dev] == SNDRV_AUTO_PORT) {
875 snd_printk(KERN_ERR PFX "specify fm_port\n");
876 return -EINVAL;
877 }
878 if (midi_port[dev] == SNDRV_AUTO_PORT) {
879 snd_printk(KERN_ERR PFX "specify midi_port\n");
880 return -EINVAL;
881 }
882
883 card = snd_opl3sa2_card_new(dev);
884 if (! card)
885 return -ENOMEM;
886 snd_card_set_dev(card, &pdev->dev);
887 if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
888 snd_card_free(card);
889 return err;
890 }
891 platform_set_drvdata(pdev, card);
892 return 0;
893}
894
895static int snd_opl3sa2_nonpnp_remove(struct platform_device *devptr)
896{
897 snd_card_free(platform_get_drvdata(devptr));
898 platform_set_drvdata(devptr, NULL);
899 return 0;
900}
901
902#ifdef CONFIG_PM
903static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state)
904{
905 return snd_opl3sa2_suspend(platform_get_drvdata(dev), state);
906}
907
908static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev)
909{
910 return snd_opl3sa2_resume(platform_get_drvdata(dev));
911}
912#endif
913
914#define OPL3SA2_DRIVER "snd_opl3sa2"
915
916static struct platform_driver snd_opl3sa2_nonpnp_driver = {
917 .probe = snd_opl3sa2_nonpnp_probe,
918 .remove = snd_opl3sa2_nonpnp_remove,
919#ifdef CONFIG_PM
920 .suspend = snd_opl3sa2_nonpnp_suspend,
921 .resume = snd_opl3sa2_nonpnp_resume,
922#endif
923 .driver = {
924 .name = OPL3SA2_DRIVER
925 },
926};
927
928static void __init_or_module snd_opl3sa2_unregister_all(void)
929{
930 int i;
931
932 if (pnpc_registered)
933 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
934 if (pnp_registered)
935 pnp_unregister_driver(&opl3sa2_pnp_driver);
936 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
937 platform_device_unregister(platform_devices[i]);
938 platform_driver_unregister(&snd_opl3sa2_nonpnp_driver);
939}
940
890static int __init alsa_card_opl3sa2_init(void) 941static int __init alsa_card_opl3sa2_init(void)
891{ 942{
892 int dev, cards = 0; 943 int i, err, cards = 0;
893 944
894 for (dev = 0; dev < SNDRV_CARDS; dev++) { 945 if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0)
895 if (!enable[dev]) 946 return err;
896 continue; 947
948 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
949 struct platform_device *device;
897#ifdef CONFIG_PNP 950#ifdef CONFIG_PNP
898 if (isapnp[dev]) 951 if (isapnp[i])
899 continue; 952 continue;
900#endif 953#endif
901 if (snd_opl3sa2_probe(dev, NULL, NULL, NULL) >= 0) 954 device = platform_device_register_simple(OPL3SA2_DRIVER,
902 cards++; 955 i, NULL, 0);
956 if (IS_ERR(device)) {
957 err = PTR_ERR(device);
958 goto errout;
959 }
960 platform_devices[i] = device;
961 cards++;
903 } 962 }
904#ifdef CONFIG_PNP 963
905 cards += pnp_register_driver(&opl3sa2_pnp_driver); 964 err = pnp_register_driver(&opl3sa2_pnp_driver);
906 cards += pnp_register_card_driver(&opl3sa2_pnpc_driver); 965 if (err >= 0) {
907#endif 966 pnp_registered = 1;
967 cards += err;
968 }
969 err = pnp_register_card_driver(&opl3sa2_pnpc_driver);
970 if (err >= 0) {
971 pnpc_registered = 1;
972 cards += err;
973 }
974
908 if (!cards) { 975 if (!cards) {
909#ifdef MODULE 976#ifdef MODULE
910 snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); 977 snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n");
911#endif 978#endif
912#ifdef CONFIG_PNP 979 err = -ENODEV;
913 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 980 goto errout;
914 pnp_unregister_driver(&opl3sa2_pnp_driver);
915#endif
916 return -ENODEV;
917 } 981 }
918 return 0; 982 return 0;
983
984 errout:
985 snd_opl3sa2_unregister_all();
986 return err;
919} 987}
920 988
921static void __exit alsa_card_opl3sa2_exit(void) 989static void __exit alsa_card_opl3sa2_exit(void)
922{ 990{
923 int idx; 991 snd_opl3sa2_unregister_all();
924
925#ifdef CONFIG_PNP
926 /* PnP cards first */
927 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
928 pnp_unregister_driver(&opl3sa2_pnp_driver);
929#endif
930 for (idx = 0; idx < SNDRV_CARDS; idx++)
931 snd_card_free(snd_opl3sa2_legacy[idx]);
932} 992}
933 993
934module_init(alsa_card_opl3sa2_init) 994module_init(alsa_card_opl3sa2_init)
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index b94339f8306f..1ea3944ef7ab 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -24,13 +24,15 @@
24 24
25 25
26#include <sound/driver.h> 26#include <sound/driver.h>
27#include <asm/io.h>
28#include <asm/dma.h>
29#include <linux/delay.h>
30#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/err.h>
29#include <linux/platform_device.h>
30#include <linux/delay.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pnp.h> 32#include <linux/pnp.h>
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <asm/io.h>
35#include <asm/dma.h>
34#include <sound/core.h> 36#include <sound/core.h>
35#ifdef CS4231 37#ifdef CS4231
36#include <sound/cs4231.h> 38#include <sound/cs4231.h>
@@ -120,8 +122,6 @@ MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver.");
120 122
121#define OPTi9XX_MC_REG(n) n 123#define OPTi9XX_MC_REG(n) n
122 124
123typedef struct _snd_opti9xx opti9xx_t;
124
125#ifdef OPTi93X 125#ifdef OPTi93X
126 126
127#define OPTi93X_INDEX 0x00 127#define OPTi93X_INDEX 0x00
@@ -193,16 +193,14 @@ typedef struct _snd_opti9xx opti9xx_t;
193#define OPTi93X_IRQ_CAPTURE 0x08 193#define OPTi93X_IRQ_CAPTURE 0x08
194 194
195 195
196typedef struct _snd_opti93x opti93x_t; 196struct snd_opti93x {
197
198struct _snd_opti93x {
199 unsigned long port; 197 unsigned long port;
200 struct resource *res_port; 198 struct resource *res_port;
201 int irq; 199 int irq;
202 int dma1; 200 int dma1;
203 int dma2; 201 int dma2;
204 202
205 opti9xx_t *chip; 203 struct snd_opti9xx *chip;
206 unsigned short hardware; 204 unsigned short hardware;
207 unsigned char image[32]; 205 unsigned char image[32];
208 206
@@ -212,10 +210,10 @@ struct _snd_opti93x {
212 210
213 spinlock_t lock; 211 spinlock_t lock;
214 212
215 snd_card_t *card; 213 struct snd_card *card;
216 snd_pcm_t *pcm; 214 struct snd_pcm *pcm;
217 snd_pcm_substream_t *playback_substream; 215 struct snd_pcm_substream *playback_substream;
218 snd_pcm_substream_t *capture_substream; 216 struct snd_pcm_substream *capture_substream;
219 unsigned int p_dma_size; 217 unsigned int p_dma_size;
220 unsigned int c_dma_size; 218 unsigned int c_dma_size;
221}; 219};
@@ -227,7 +225,7 @@ struct _snd_opti93x {
227 225
228#endif /* OPTi93X */ 226#endif /* OPTi93X */
229 227
230struct _snd_opti9xx { 228struct snd_opti9xx {
231 unsigned short hardware; 229 unsigned short hardware;
232 unsigned char password; 230 unsigned char password;
233 char name[7]; 231 char name[7];
@@ -260,8 +258,8 @@ struct _snd_opti9xx {
260#endif /* CONFIG_PNP */ 258#endif /* CONFIG_PNP */
261}; 259};
262 260
263static int snd_opti9xx_first_hit = 1; 261static int snd_opti9xx_pnp_is_probed;
264static snd_card_t *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; 262static struct platform_device *snd_opti9xx_platform_device;
265 263
266#ifdef CONFIG_PNP 264#ifdef CONFIG_PNP
267 265
@@ -296,7 +294,7 @@ static char * snd_opti9xx_names[] = {
296}; 294};
297 295
298 296
299static long snd_legacy_find_free_ioport(long *port_table, long size) 297static long __init snd_legacy_find_free_ioport(long *port_table, long size)
300{ 298{
301 while (*port_table != -1) { 299 while (*port_table != -1) {
302 if (request_region(*port_table, size, "ALSA test")) { 300 if (request_region(*port_table, size, "ALSA test")) {
@@ -308,7 +306,7 @@ static long snd_legacy_find_free_ioport(long *port_table, long size)
308 return -1; 306 return -1;
309} 307}
310 308
311static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) 309static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware)
312{ 310{
313 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
314 312
@@ -363,7 +361,7 @@ static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware)
363 return 0; 361 return 0;
364} 362}
365 363
366static unsigned char snd_opti9xx_read(opti9xx_t *chip, 364static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip,
367 unsigned char reg) 365 unsigned char reg)
368{ 366{
369 unsigned long flags; 367 unsigned long flags;
@@ -406,7 +404,7 @@ static unsigned char snd_opti9xx_read(opti9xx_t *chip,
406 return retval; 404 return retval;
407} 405}
408 406
409static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg, 407static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
410 unsigned char value) 408 unsigned char value)
411{ 409{
412 unsigned long flags; 410 unsigned long flags;
@@ -453,7 +451,7 @@ static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg,
453 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
454 452
455 453
456static int __devinit snd_opti9xx_configure(opti9xx_t *chip) 454static int __init snd_opti9xx_configure(struct snd_opti9xx *chip)
457{ 455{
458 unsigned char wss_base_bits; 456 unsigned char wss_base_bits;
459 unsigned char irq_bits; 457 unsigned char irq_bits;
@@ -684,7 +682,7 @@ static unsigned char snd_opti93x_default_image[32] =
684}; 682};
685 683
686 684
687static int snd_opti93x_busy_wait(opti93x_t *chip) 685static int snd_opti93x_busy_wait(struct snd_opti93x *chip)
688{ 686{
689 int timeout; 687 int timeout;
690 688
@@ -696,14 +694,14 @@ static int snd_opti93x_busy_wait(opti93x_t *chip)
696 return -EBUSY; 694 return -EBUSY;
697} 695}
698 696
699static unsigned char snd_opti93x_in(opti93x_t *chip, unsigned char reg) 697static unsigned char snd_opti93x_in(struct snd_opti93x *chip, unsigned char reg)
700{ 698{
701 snd_opti93x_busy_wait(chip); 699 snd_opti93x_busy_wait(chip);
702 outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX)); 700 outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX));
703 return inb(OPTi93X_PORT(chip, DATA)); 701 return inb(OPTi93X_PORT(chip, DATA));
704} 702}
705 703
706static void snd_opti93x_out(opti93x_t *chip, unsigned char reg, 704static void snd_opti93x_out(struct snd_opti93x *chip, unsigned char reg,
707 unsigned char value) 705 unsigned char value)
708{ 706{
709 snd_opti93x_busy_wait(chip); 707 snd_opti93x_busy_wait(chip);
@@ -711,13 +709,13 @@ static void snd_opti93x_out(opti93x_t *chip, unsigned char reg,
711 outb(value, OPTi93X_PORT(chip, DATA)); 709 outb(value, OPTi93X_PORT(chip, DATA));
712} 710}
713 711
714static void snd_opti93x_out_image(opti93x_t *chip, unsigned char reg, 712static void snd_opti93x_out_image(struct snd_opti93x *chip, unsigned char reg,
715 unsigned char value) 713 unsigned char value)
716{ 714{
717 snd_opti93x_out(chip, reg, chip->image[reg] = value); 715 snd_opti93x_out(chip, reg, chip->image[reg] = value);
718} 716}
719 717
720static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg, 718static void snd_opti93x_out_mask(struct snd_opti93x *chip, unsigned char reg,
721 unsigned char mask, unsigned char value) 719 unsigned char mask, unsigned char value)
722{ 720{
723 snd_opti93x_out_image(chip, reg, 721 snd_opti93x_out_image(chip, reg,
@@ -725,7 +723,7 @@ static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg,
725} 723}
726 724
727 725
728static void snd_opti93x_mce_up(opti93x_t *chip) 726static void snd_opti93x_mce_up(struct snd_opti93x *chip)
729{ 727{
730 snd_opti93x_busy_wait(chip); 728 snd_opti93x_busy_wait(chip);
731 729
@@ -734,7 +732,7 @@ static void snd_opti93x_mce_up(opti93x_t *chip)
734 outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX)); 732 outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX));
735} 733}
736 734
737static void snd_opti93x_mce_down(opti93x_t *chip) 735static void snd_opti93x_mce_down(struct snd_opti93x *chip)
738{ 736{
739 snd_opti93x_busy_wait(chip); 737 snd_opti93x_busy_wait(chip);
740 738
@@ -746,7 +744,7 @@ static void snd_opti93x_mce_down(opti93x_t *chip)
746#define snd_opti93x_mute_reg(chip, reg, mute) \ 744#define snd_opti93x_mute_reg(chip, reg, mute) \
747 snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]); 745 snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]);
748 746
749static void snd_opti93x_mute(opti93x_t *chip, int mute) 747static void snd_opti93x_mute(struct snd_opti93x *chip, int mute)
750{ 748{
751 mute = mute ? 1 : 0; 749 mute = mute ? 1 : 0;
752 if (chip->mute == mute) 750 if (chip->mute == mute)
@@ -798,7 +796,7 @@ static unsigned int rates[] = { 5512, 6615, 8000, 9600, 11025, 16000,
798 44100, 48000 }; 796 44100, 48000 };
799#define RATES ARRAY_SIZE(rates) 797#define RATES ARRAY_SIZE(rates)
800 798
801static snd_pcm_hw_constraint_list_t hw_constraints_rates = { 799static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
802 .count = RATES, 800 .count = RATES,
803 .list = rates, 801 .list = rates,
804 .mask = 0, 802 .mask = 0,
@@ -820,7 +818,7 @@ static unsigned char snd_opti93x_get_freq(unsigned int rate)
820 return bits[RATES-1]; 818 return bits[RATES-1];
821} 819}
822 820
823static unsigned char snd_opti93x_get_format(opti93x_t *chip, 821static unsigned char snd_opti93x_get_format(struct snd_opti93x *chip,
824 unsigned int format, int channels) 822 unsigned int format, int channels)
825{ 823{
826 unsigned char retval = OPTi93X_LINEAR_8; 824 unsigned char retval = OPTi93X_LINEAR_8;
@@ -845,7 +843,7 @@ static unsigned char snd_opti93x_get_format(opti93x_t *chip,
845} 843}
846 844
847 845
848static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) 846static void snd_opti93x_playback_format(struct snd_opti93x *chip, unsigned char fmt)
849{ 847{
850 unsigned char mask; 848 unsigned char mask;
851 849
@@ -859,7 +857,7 @@ static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt)
859 snd_opti93x_mute(chip, 0); 857 snd_opti93x_mute(chip, 0);
860} 858}
861 859
862static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) 860static void snd_opti93x_capture_format(struct snd_opti93x *chip, unsigned char fmt)
863{ 861{
864 snd_opti93x_mute(chip, 1); 862 snd_opti93x_mute(chip, 1);
865 863
@@ -875,7 +873,7 @@ static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt)
875} 873}
876 874
877 875
878static int snd_opti93x_open(opti93x_t *chip, unsigned int mode) 876static int snd_opti93x_open(struct snd_opti93x *chip, unsigned int mode)
879{ 877{
880 unsigned long flags; 878 unsigned long flags;
881 879
@@ -899,7 +897,7 @@ static int snd_opti93x_open(opti93x_t *chip, unsigned int mode)
899 return 0; 897 return 0;
900} 898}
901 899
902static void snd_opti93x_close(opti93x_t *chip, unsigned int mode) 900static void snd_opti93x_close(struct snd_opti93x *chip, unsigned int mode)
903{ 901{
904 unsigned long flags; 902 unsigned long flags;
905 903
@@ -926,10 +924,10 @@ static void snd_opti93x_close(opti93x_t *chip, unsigned int mode)
926 spin_unlock_irqrestore(&chip->lock, flags); 924 spin_unlock_irqrestore(&chip->lock, flags);
927} 925}
928 926
929static int snd_opti93x_trigger(snd_pcm_substream_t *substream, 927static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
930 unsigned char what, int cmd) 928 unsigned char what, int cmd)
931{ 929{
932 opti93x_t *chip = snd_pcm_substream_chip(substream); 930 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
933 931
934 switch (cmd) { 932 switch (cmd) {
935 case SNDRV_PCM_TRIGGER_START: 933 case SNDRV_PCM_TRIGGER_START:
@@ -937,7 +935,7 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream,
937 { 935 {
938 unsigned int what = 0; 936 unsigned int what = 0;
939 struct list_head *pos; 937 struct list_head *pos;
940 snd_pcm_substream_t *s; 938 struct snd_pcm_substream *s;
941 snd_pcm_group_for_each(pos, substream) { 939 snd_pcm_group_for_each(pos, substream) {
942 s = snd_pcm_group_substream_entry(pos); 940 s = snd_pcm_group_substream_entry(pos);
943 if (s == chip->playback_substream) { 941 if (s == chip->playback_substream) {
@@ -964,36 +962,36 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream,
964 return 0; 962 return 0;
965} 963}
966 964
967static int snd_opti93x_playback_trigger(snd_pcm_substream_t *substream, int cmd) 965static int snd_opti93x_playback_trigger(struct snd_pcm_substream *substream, int cmd)
968{ 966{
969 return snd_opti93x_trigger(substream, 967 return snd_opti93x_trigger(substream,
970 OPTi93X_PLAYBACK_ENABLE, cmd); 968 OPTi93X_PLAYBACK_ENABLE, cmd);
971} 969}
972 970
973static int snd_opti93x_capture_trigger(snd_pcm_substream_t * substream, int cmd) 971static int snd_opti93x_capture_trigger(struct snd_pcm_substream *substream, int cmd)
974{ 972{
975 return snd_opti93x_trigger(substream, 973 return snd_opti93x_trigger(substream,
976 OPTi93X_CAPTURE_ENABLE, cmd); 974 OPTi93X_CAPTURE_ENABLE, cmd);
977} 975}
978 976
979static int snd_opti93x_hw_params(snd_pcm_substream_t * substream, 977static int snd_opti93x_hw_params(struct snd_pcm_substream *substream,
980 snd_pcm_hw_params_t * hw_params) 978 struct snd_pcm_hw_params *hw_params)
981{ 979{
982 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 980 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
983} 981}
984 982
985 983
986static int snd_opti93x_hw_free(snd_pcm_substream_t * substream) 984static int snd_opti93x_hw_free(struct snd_pcm_substream *substream)
987{ 985{
988 snd_pcm_lib_free_pages(substream); 986 snd_pcm_lib_free_pages(substream);
989 return 0; 987 return 0;
990} 988}
991 989
992 990
993static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream) 991static int snd_opti93x_playback_prepare(struct snd_pcm_substream *substream)
994{ 992{
995 opti93x_t *chip = snd_pcm_substream_chip(substream); 993 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
996 snd_pcm_runtime_t *runtime = substream->runtime; 994 struct snd_pcm_runtime *runtime = substream->runtime;
997 unsigned long flags; 995 unsigned long flags;
998 unsigned char format; 996 unsigned char format;
999 unsigned int count = snd_pcm_lib_period_bytes(substream); 997 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -1023,10 +1021,10 @@ static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream)
1023 return 0; 1021 return 0;
1024} 1022}
1025 1023
1026static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) 1024static int snd_opti93x_capture_prepare(struct snd_pcm_substream *substream)
1027{ 1025{
1028 opti93x_t *chip = snd_pcm_substream_chip(substream); 1026 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1029 snd_pcm_runtime_t *runtime = substream->runtime; 1027 struct snd_pcm_runtime *runtime = substream->runtime;
1030 unsigned long flags; 1028 unsigned long flags;
1031 unsigned char format; 1029 unsigned char format;
1032 unsigned int count = snd_pcm_lib_period_bytes(substream); 1030 unsigned int count = snd_pcm_lib_period_bytes(substream);
@@ -1055,9 +1053,9 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream)
1055 return 0; 1053 return 0;
1056} 1054}
1057 1055
1058static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *substream) 1056static snd_pcm_uframes_t snd_opti93x_playback_pointer(struct snd_pcm_substream *substream)
1059{ 1057{
1060 opti93x_t *chip = snd_pcm_substream_chip(substream); 1058 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1061 size_t ptr; 1059 size_t ptr;
1062 1060
1063 if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE)) 1061 if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE))
@@ -1067,9 +1065,9 @@ static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *subst
1067 return bytes_to_frames(substream->runtime, ptr); 1065 return bytes_to_frames(substream->runtime, ptr);
1068} 1066}
1069 1067
1070static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substream) 1068static snd_pcm_uframes_t snd_opti93x_capture_pointer(struct snd_pcm_substream *substream)
1071{ 1069{
1072 opti93x_t *chip = snd_pcm_substream_chip(substream); 1070 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1073 size_t ptr; 1071 size_t ptr;
1074 1072
1075 if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE)) 1073 if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE))
@@ -1080,7 +1078,7 @@ static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substr
1080} 1078}
1081 1079
1082 1080
1083static void snd_opti93x_overrange(opti93x_t *chip) 1081static void snd_opti93x_overrange(struct snd_opti93x *chip)
1084{ 1082{
1085 unsigned long flags; 1083 unsigned long flags;
1086 1084
@@ -1094,7 +1092,7 @@ static void snd_opti93x_overrange(opti93x_t *chip)
1094 1092
1095static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1093static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1096{ 1094{
1097 opti93x_t *codec = dev_id; 1095 struct snd_opti93x *codec = dev_id;
1098 unsigned char status; 1096 unsigned char status;
1099 1097
1100 status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11)); 1098 status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11));
@@ -1109,7 +1107,7 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *
1109} 1107}
1110 1108
1111 1109
1112static snd_pcm_hardware_t snd_opti93x_playback = { 1110static struct snd_pcm_hardware snd_opti93x_playback = {
1113 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1111 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1114 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), 1112 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
1115 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | 1113 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
@@ -1127,7 +1125,7 @@ static snd_pcm_hardware_t snd_opti93x_playback = {
1127 .fifo_size = 0, 1125 .fifo_size = 0,
1128}; 1126};
1129 1127
1130static snd_pcm_hardware_t snd_opti93x_capture = { 1128static struct snd_pcm_hardware snd_opti93x_capture = {
1131 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1129 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1132 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), 1130 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
1133 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | 1131 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM |
@@ -1145,11 +1143,11 @@ static snd_pcm_hardware_t snd_opti93x_capture = {
1145 .fifo_size = 0, 1143 .fifo_size = 0,
1146}; 1144};
1147 1145
1148static int snd_opti93x_playback_open(snd_pcm_substream_t *substream) 1146static int snd_opti93x_playback_open(struct snd_pcm_substream *substream)
1149{ 1147{
1150 int error; 1148 int error;
1151 opti93x_t *chip = snd_pcm_substream_chip(substream); 1149 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1152 snd_pcm_runtime_t *runtime = substream->runtime; 1150 struct snd_pcm_runtime *runtime = substream->runtime;
1153 1151
1154 if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0) 1152 if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0)
1155 return error; 1153 return error;
@@ -1161,11 +1159,11 @@ static int snd_opti93x_playback_open(snd_pcm_substream_t *substream)
1161 return error; 1159 return error;
1162} 1160}
1163 1161
1164static int snd_opti93x_capture_open(snd_pcm_substream_t *substream) 1162static int snd_opti93x_capture_open(struct snd_pcm_substream *substream)
1165{ 1163{
1166 int error; 1164 int error;
1167 opti93x_t *chip = snd_pcm_substream_chip(substream); 1165 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1168 snd_pcm_runtime_t *runtime = substream->runtime; 1166 struct snd_pcm_runtime *runtime = substream->runtime;
1169 1167
1170 if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0) 1168 if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0)
1171 return error; 1169 return error;
@@ -1177,18 +1175,18 @@ static int snd_opti93x_capture_open(snd_pcm_substream_t *substream)
1177 return error; 1175 return error;
1178} 1176}
1179 1177
1180static int snd_opti93x_playback_close(snd_pcm_substream_t *substream) 1178static int snd_opti93x_playback_close(struct snd_pcm_substream *substream)
1181{ 1179{
1182 opti93x_t *chip = snd_pcm_substream_chip(substream); 1180 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1183 1181
1184 chip->playback_substream = NULL; 1182 chip->playback_substream = NULL;
1185 snd_opti93x_close(chip, OPTi93X_MODE_PLAY); 1183 snd_opti93x_close(chip, OPTi93X_MODE_PLAY);
1186 return 0; 1184 return 0;
1187} 1185}
1188 1186
1189static int snd_opti93x_capture_close(snd_pcm_substream_t *substream) 1187static int snd_opti93x_capture_close(struct snd_pcm_substream *substream)
1190{ 1188{
1191 opti93x_t *chip = snd_pcm_substream_chip(substream); 1189 struct snd_opti93x *chip = snd_pcm_substream_chip(substream);
1192 1190
1193 chip->capture_substream = NULL; 1191 chip->capture_substream = NULL;
1194 snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE); 1192 snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE);
@@ -1196,7 +1194,7 @@ static int snd_opti93x_capture_close(snd_pcm_substream_t *substream)
1196} 1194}
1197 1195
1198 1196
1199static void snd_opti93x_init(opti93x_t *chip) 1197static void snd_opti93x_init(struct snd_opti93x *chip)
1200{ 1198{
1201 unsigned long flags; 1199 unsigned long flags;
1202 int i; 1200 int i;
@@ -1211,7 +1209,7 @@ static void snd_opti93x_init(opti93x_t *chip)
1211 spin_unlock_irqrestore(&chip->lock, flags); 1209 spin_unlock_irqrestore(&chip->lock, flags);
1212} 1210}
1213 1211
1214static int snd_opti93x_probe(opti93x_t *chip) 1212static int snd_opti93x_probe(struct snd_opti93x *chip)
1215{ 1213{
1216 unsigned long flags; 1214 unsigned long flags;
1217 unsigned char val; 1215 unsigned char val;
@@ -1223,7 +1221,7 @@ static int snd_opti93x_probe(opti93x_t *chip)
1223 return (val == 0x0a) ? 0 : -ENODEV; 1221 return (val == 0x0a) ? 0 : -ENODEV;
1224} 1222}
1225 1223
1226static int snd_opti93x_free(opti93x_t *chip) 1224static int snd_opti93x_free(struct snd_opti93x *chip)
1227{ 1225{
1228 release_and_free_resource(chip->res_port); 1226 release_and_free_resource(chip->res_port);
1229 if (chip->dma1 >= 0) { 1227 if (chip->dma1 >= 0) {
@@ -1241,13 +1239,13 @@ static int snd_opti93x_free(opti93x_t *chip)
1241 return 0; 1239 return 0;
1242} 1240}
1243 1241
1244static int snd_opti93x_dev_free(snd_device_t *device) 1242static int snd_opti93x_dev_free(struct snd_device *device)
1245{ 1243{
1246 opti93x_t *chip = device->device_data; 1244 struct snd_opti93x *chip = device->device_data;
1247 return snd_opti93x_free(chip); 1245 return snd_opti93x_free(chip);
1248} 1246}
1249 1247
1250static const char *snd_opti93x_chip_id(opti93x_t *codec) 1248static const char *snd_opti93x_chip_id(struct snd_opti93x *codec)
1251{ 1249{
1252 switch (codec->hardware) { 1250 switch (codec->hardware) {
1253 case OPTi9XX_HW_82C930: return "82C930"; 1251 case OPTi9XX_HW_82C930: return "82C930";
@@ -1257,15 +1255,15 @@ static const char *snd_opti93x_chip_id(opti93x_t *codec)
1257 } 1255 }
1258} 1256}
1259 1257
1260static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, 1258static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
1261 int dma1, int dma2, 1259 int dma1, int dma2,
1262 opti93x_t **rcodec) 1260 struct snd_opti93x **rcodec)
1263{ 1261{
1264 static snd_device_ops_t ops = { 1262 static struct snd_device_ops ops = {
1265 .dev_free = snd_opti93x_dev_free, 1263 .dev_free = snd_opti93x_dev_free,
1266 }; 1264 };
1267 int error; 1265 int error;
1268 opti93x_t *codec; 1266 struct snd_opti93x *codec;
1269 1267
1270 *rcodec = NULL; 1268 *rcodec = NULL;
1271 codec = kzalloc(sizeof(*codec), GFP_KERNEL); 1269 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
@@ -1324,7 +1322,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip,
1324 return 0; 1322 return 0;
1325} 1323}
1326 1324
1327static snd_pcm_ops_t snd_opti93x_playback_ops = { 1325static struct snd_pcm_ops snd_opti93x_playback_ops = {
1328 .open = snd_opti93x_playback_open, 1326 .open = snd_opti93x_playback_open,
1329 .close = snd_opti93x_playback_close, 1327 .close = snd_opti93x_playback_close,
1330 .ioctl = snd_pcm_lib_ioctl, 1328 .ioctl = snd_pcm_lib_ioctl,
@@ -1335,7 +1333,7 @@ static snd_pcm_ops_t snd_opti93x_playback_ops = {
1335 .pointer = snd_opti93x_playback_pointer, 1333 .pointer = snd_opti93x_playback_pointer,
1336}; 1334};
1337 1335
1338static snd_pcm_ops_t snd_opti93x_capture_ops = { 1336static struct snd_pcm_ops snd_opti93x_capture_ops = {
1339 .open = snd_opti93x_capture_open, 1337 .open = snd_opti93x_capture_open,
1340 .close = snd_opti93x_capture_close, 1338 .close = snd_opti93x_capture_close,
1341 .ioctl = snd_pcm_lib_ioctl, 1339 .ioctl = snd_pcm_lib_ioctl,
@@ -1346,17 +1344,10 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = {
1346 .pointer = snd_opti93x_capture_pointer, 1344 .pointer = snd_opti93x_capture_pointer,
1347}; 1345};
1348 1346
1349static void snd_opti93x_pcm_free(snd_pcm_t *pcm) 1347static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm **rpcm)
1350{
1351 opti93x_t *codec = pcm->private_data;
1352 codec->pcm = NULL;
1353 snd_pcm_lib_preallocate_free_for_all(pcm);
1354}
1355
1356static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
1357{ 1348{
1358 int error; 1349 int error;
1359 snd_pcm_t *pcm; 1350 struct snd_pcm *pcm;
1360 1351
1361 if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm))) 1352 if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm)))
1362 return error; 1353 return error;
@@ -1365,7 +1356,6 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
1365 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops); 1356 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops);
1366 1357
1367 pcm->private_data = codec; 1358 pcm->private_data = codec;
1368 pcm->private_free = snd_opti93x_pcm_free;
1369 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; 1359 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
1370 1360
1371 strcpy(pcm->name, snd_opti93x_chip_id(codec)); 1361 strcpy(pcm->name, snd_opti93x_chip_id(codec));
@@ -1384,7 +1374,7 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm)
1384 * MIXER part 1374 * MIXER part
1385 */ 1375 */
1386 1376
1387static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1377static int snd_opti93x_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1388{ 1378{
1389 static char *texts[4] = { 1379 static char *texts[4] = {
1390 "Line1", "Aux", "Mic", "Mix" 1380 "Line1", "Aux", "Mic", "Mix"
@@ -1399,9 +1389,9 @@ static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
1399 return 0; 1389 return 0;
1400} 1390}
1401 1391
1402static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1392static int snd_opti93x_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1403{ 1393{
1404 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1394 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1405 unsigned long flags; 1395 unsigned long flags;
1406 1396
1407 spin_lock_irqsave(&chip->lock, flags); 1397 spin_lock_irqsave(&chip->lock, flags);
@@ -1411,9 +1401,9 @@ static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1411 return 0; 1401 return 0;
1412} 1402}
1413 1403
1414static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1404static int snd_opti93x_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1415{ 1405{
1416 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1406 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1417 unsigned long flags; 1407 unsigned long flags;
1418 unsigned short left, right; 1408 unsigned short left, right;
1419 int change; 1409 int change;
@@ -1442,7 +1432,7 @@ static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
1442 .get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \ 1432 .get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \
1443 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 1433 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
1444 1434
1445static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1435static int snd_opti93x_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1446{ 1436{
1447 int mask = (kcontrol->private_value >> 16) & 0xff; 1437 int mask = (kcontrol->private_value >> 16) & 0xff;
1448 1438
@@ -1453,9 +1443,9 @@ static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1453 return 0; 1443 return 0;
1454} 1444}
1455 1445
1456static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1446static int snd_opti93x_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1457{ 1447{
1458 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1448 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1459 unsigned long flags; 1449 unsigned long flags;
1460 int reg = kcontrol->private_value & 0xff; 1450 int reg = kcontrol->private_value & 0xff;
1461 int shift = (kcontrol->private_value >> 8) & 0xff; 1451 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1470,9 +1460,9 @@ static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
1470 return 0; 1460 return 0;
1471} 1461}
1472 1462
1473static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1463static int snd_opti93x_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1474{ 1464{
1475 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1465 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1476 unsigned long flags; 1466 unsigned long flags;
1477 int reg = kcontrol->private_value & 0xff; 1467 int reg = kcontrol->private_value & 0xff;
1478 int shift = (kcontrol->private_value >> 8) & 0xff; 1468 int shift = (kcontrol->private_value >> 8) & 0xff;
@@ -1507,7 +1497,7 @@ static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
1507 do { xctl.private_value &= ~0x0000ffff; \ 1497 do { xctl.private_value &= ~0x0000ffff; \
1508 xctl.private_value |= left_reg | (right_reg << 8); } while (0) 1498 xctl.private_value |= left_reg | (right_reg << 8); } while (0)
1509 1499
1510static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1500static int snd_opti93x_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1511{ 1501{
1512 int mask = (kcontrol->private_value >> 24) & 0xff; 1502 int mask = (kcontrol->private_value >> 24) & 0xff;
1513 1503
@@ -1518,9 +1508,9 @@ static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
1518 return 0; 1508 return 0;
1519} 1509}
1520 1510
1521static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1511static int snd_opti93x_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1522{ 1512{
1523 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1513 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1524 unsigned long flags; 1514 unsigned long flags;
1525 int left_reg = kcontrol->private_value & 0xff; 1515 int left_reg = kcontrol->private_value & 0xff;
1526 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1516 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1540,9 +1530,9 @@ static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
1540 return 0; 1530 return 0;
1541} 1531}
1542 1532
1543static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1533static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1544{ 1534{
1545 opti93x_t *chip = snd_kcontrol_chip(kcontrol); 1535 struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol);
1546 unsigned long flags; 1536 unsigned long flags;
1547 int left_reg = kcontrol->private_value & 0xff; 1537 int left_reg = kcontrol->private_value & 0xff;
1548 int right_reg = (kcontrol->private_value >> 8) & 0xff; 1538 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -1571,7 +1561,7 @@ static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
1571 return change; 1561 return change;
1572} 1562}
1573 1563
1574static snd_kcontrol_new_t snd_opti93x_controls[] = { 1564static struct snd_kcontrol_new snd_opti93x_controls[] = {
1575OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 1565OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
1576OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), 1566OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
1577OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), 1567OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
@@ -1597,10 +1587,10 @@ OPTi93X_DOUBLE("Capture Volume", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 0
1597} 1587}
1598}; 1588};
1599 1589
1600static int snd_opti93x_mixer(opti93x_t *chip) 1590static int snd_opti93x_mixer(struct snd_opti93x *chip)
1601{ 1591{
1602 snd_card_t *card; 1592 struct snd_card *card;
1603 snd_kcontrol_new_t knew; 1593 struct snd_kcontrol_new knew;
1604 int err; 1594 int err;
1605 unsigned int idx; 1595 unsigned int idx;
1606 1596
@@ -1632,7 +1622,7 @@ static int snd_opti93x_mixer(opti93x_t *chip)
1632 1622
1633#endif /* OPTi93X */ 1623#endif /* OPTi93X */
1634 1624
1635static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) 1625static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip)
1636{ 1626{
1637 int i, err; 1627 int i, err;
1638 1628
@@ -1686,8 +1676,8 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)
1686} 1676}
1687 1677
1688#ifdef CONFIG_PNP 1678#ifdef CONFIG_PNP
1689static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link *card, 1679static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card,
1690 const struct pnp_card_device_id *pid) 1680 const struct pnp_card_device_id *pid)
1691{ 1681{
1692 struct pnp_dev *pdev; 1682 struct pnp_dev *pdev;
1693 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -1778,195 +1768,35 @@ static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link
1778} 1768}
1779#endif /* CONFIG_PNP */ 1769#endif /* CONFIG_PNP */
1780 1770
1781#if 0 1771static void snd_card_opti9xx_free(struct snd_card *card)
1782static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip,
1783 snd_card_t *card)
1784{
1785 int error, i, pnp = 0;
1786
1787#ifdef CONFIG_PNP
1788 pnp = chip->dev != NULL;
1789#endif /* CONFIG_PNP */
1790
1791#ifndef OPTi93X
1792 if (chip->chip->hardware == OPTi9XX_HW_82C928)
1793 mpu_port = -1;
1794#endif /* OPTi93X */
1795 error = 0;
1796 if (!pnp && (mpu_port == SNDRV_DEFAULT_PORT1)) {
1797 for (i = 0; possible_mpu_ports[i] != -1; i++)
1798 if (!snd_register_ioport(card, possible_mpu_ports[i], 2,
1799 DRIVER_NAME" - MPU-401", NULL)) {
1800 mpu_port = possible_mpu_ports[i];
1801 break;
1802 }
1803 if (mpu_port == SNDRV_DEFAULT_PORT1)
1804 error = -EBUSY;
1805 }
1806 else
1807 error = (mpu_port == -1) ? -ENODEV :
1808 snd_register_ioport(card, mpu_port, 2,
1809 DRIVER_NAME" - MPU-401", NULL);
1810 if (error)
1811 chip->chip->mpu_port = -1;
1812 else if (pnp && (irq == mpu_irq))
1813 chip->chip->mpu_irq = mpu_irq;
1814 else if (!snd_register_interrupt(card,
1815 DRIVER_NAME" - MPU-401",
1816 mpu_irq, SNDRV_IRQ_TYPE_ISA,
1817 snd_card_opti9xx_mpu_interrupt, chip,
1818 pnp ? no_alternatives : possible_mpu_irqs,
1819 &chip->mpuirqptr)) {
1820 chip->chip->mpu_port = mpu_port;
1821 chip->chip->mpu_irq = chip->mpuirqptr->irq;
1822 }
1823 else
1824 chip->chip->mpu_port = -1;
1825
1826 if (!pnp && (port == SNDRV_DEFAULT_PORT1)) {
1827 for (i = 0; possible_ports[i] != -1; i++)
1828 if (!snd_register_ioport(card, possible_ports[i], 8,
1829 DRIVER_NAME" - WSS", NULL)) {
1830 port = possible_ports[i];
1831 break;
1832 }
1833 if (port == SNDRV_DEFAULT_PORT1)
1834 return -EBUSY;
1835 }
1836 else if ((error = snd_register_ioport(card, port, 8,
1837 DRIVER_NAME" - WSS", NULL)) < 0)
1838 return error;
1839 chip->chip->wss_base = port;
1840 if ((error = snd_register_interrupt(card, DRIVER_NAME" - WSS",
1841 irq, SNDRV_IRQ_TYPE_ISA,
1842 snd_card_opti9xx_interrupt, chip,
1843 pnp ? no_alternatives : possible_irqs,
1844 &chip->irqptr)) < 0)
1845 return error;
1846 chip->chip->irq = chip->irqptr->irq;
1847 if ((error = snd_register_dma_channel(card,
1848#if defined(CS4231) || defined(OPTi93X)
1849 DRIVER_NAME" - WSS playback",
1850#else
1851 DRIVER_NAME" - WSS",
1852#endif /* CS4231 || OPTi93X */
1853 dma1, SNDRV_DMA_TYPE_ISA, dma1_size,
1854 pnp ? no_alternatives : possible_dma1s,
1855 &chip->dma1ptr)) < 0)
1856 return error;
1857 chip->chip->dma1 = chip->dma1ptr->dma;
1858#if defined(CS4231) || defined(OPTi93X)
1859 if ((error = snd_register_dma_channel(card, DRIVER_NAME" - WSS capture",
1860 dma2, SNDRV_DMA_TYPE_ISA, dma2_size,
1861 pnp ? no_alternatives :
1862 possible_dma2s[chip->dma1ptr->dma],
1863 &chip->dma2ptr)) < 0)
1864 return error;
1865 chip->chip->dma2 = chip->dma2ptr->dma;
1866#endif /* CS4231 || OPTi93X */
1867
1868 if (snd_register_ioport(card,
1869 pnp ? fm_port : fm_port = 0x388, 4,
1870 DRIVER_NAME" - OPL", NULL) < 0)
1871 fm_port = -1;
1872 chip->chip->fm_port = fm_port;
1873
1874 return 0;
1875}
1876#endif
1877
1878static void snd_card_opti9xx_free(snd_card_t *card)
1879{ 1772{
1880 opti9xx_t *chip = (opti9xx_t *)card->private_data; 1773 struct snd_opti9xx *chip = card->private_data;
1881 1774
1882 if (chip) 1775 if (chip)
1883 release_and_free_resource(chip->res_mc_base); 1776 release_and_free_resource(chip->res_mc_base);
1884} 1777}
1885 1778
1886static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, 1779static int __init snd_opti9xx_probe(struct snd_card *card)
1887 const struct pnp_card_device_id *pid)
1888{ 1780{
1889 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1781 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1890 static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
1891#ifdef OPTi93X
1892 static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
1893#else
1894 static int possible_irqs[] = {9, 10, 11, 7, -1};
1895#endif /* OPTi93X */
1896 static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
1897 static int possible_dma1s[] = {3, 1, 0, -1};
1898#if defined(CS4231) || defined(OPTi93X)
1899 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
1900#endif /* CS4231 || OPTi93X */
1901 int error; 1782 int error;
1902 opti9xx_t *chip; 1783 struct snd_opti9xx *chip = card->private_data;
1903#if defined(OPTi93X) 1784#if defined(OPTi93X)
1904 opti93x_t *codec; 1785 struct snd_opti93x *codec;
1905#elif defined(CS4231) 1786#elif defined(CS4231)
1906 cs4231_t *codec; 1787 struct snd_cs4231 *codec;
1907 snd_timer_t *timer; 1788 struct snd_timer *timer;
1908#else 1789#else
1909 ad1848_t *codec; 1790 struct snd_ad1848 *codec;
1910#endif 1791#endif
1911 snd_card_t *card; 1792 struct snd_pcm *pcm;
1912 snd_pcm_t *pcm; 1793 struct snd_rawmidi *rmidi;
1913 snd_rawmidi_t *rmidi; 1794 struct snd_hwdep *synth;
1914 snd_hwdep_t *synth;
1915#ifdef CONFIG_PNP
1916 int hw;
1917#endif /* CONFIG_PNP */
1918
1919 if (pcard && !snd_opti9xx_first_hit)
1920 return -EBUSY;
1921 if (!(card = snd_card_new(index, id, THIS_MODULE,
1922 sizeof(opti9xx_t))))
1923 return -ENOMEM;
1924 card->private_free = snd_card_opti9xx_free;
1925 chip = (opti9xx_t *)card->private_data;
1926
1927#ifdef CONFIG_PNP
1928 if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) {
1929 switch (hw) {
1930 case 0x0924:
1931 hw = OPTi9XX_HW_82C924;
1932 break;
1933 case 0x0925:
1934 hw = OPTi9XX_HW_82C925;
1935 break;
1936 case 0x0931:
1937 hw = OPTi9XX_HW_82C931;
1938 break;
1939 default:
1940 snd_card_free(card);
1941 return -ENODEV;
1942 }
1943
1944 if ((error = snd_opti9xx_init(chip, hw))) {
1945 snd_card_free(card);
1946 return error;
1947 }
1948 if (hw <= OPTi9XX_HW_82C930)
1949 chip->mc_base -= 0x80;
1950 snd_card_set_dev(card, &pcard->card->dev);
1951 } else {
1952#endif /* CONFIG_PNP */
1953 if ((error = snd_card_opti9xx_detect(card, chip)) < 0) {
1954 snd_card_free(card);
1955 return error;
1956 }
1957 if ((error = snd_card_set_generic_dev(card)) < 0) {
1958 snd_card_free(card);
1959 return error;
1960 }
1961#ifdef CONFIG_PNP
1962 }
1963#endif /* CONFIG_PNP */
1964 1795
1965 if (! chip->res_mc_base && 1796 if (! chip->res_mc_base &&
1966 (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) { 1797 (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
1967 snd_card_free(card); 1798 "OPTi9xx MC")) == NULL)
1968 return -ENOMEM; 1799 return -ENOMEM;
1969 }
1970 1800
1971 chip->wss_base = port; 1801 chip->wss_base = port;
1972 chip->fm_port = fm_port; 1802 chip->fm_port = fm_port;
@@ -1980,110 +1810,42 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
1980 1810
1981 if (chip->wss_base == SNDRV_AUTO_PORT) { 1811 if (chip->wss_base == SNDRV_AUTO_PORT) {
1982 if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { 1812 if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) {
1983 snd_card_free(card);
1984 snd_printk("unable to find a free WSS port\n"); 1813 snd_printk("unable to find a free WSS port\n");
1985 return -EBUSY; 1814 return -EBUSY;
1986 } 1815 }
1987 } 1816 }
1988#ifdef CONFIG_PNP 1817 if ((error = snd_opti9xx_configure(chip)))
1989 if (!isapnp) {
1990#endif
1991 if (chip->mpu_port == SNDRV_AUTO_PORT) {
1992 if ((chip->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
1993 snd_card_free(card);
1994 snd_printk("unable to find a free MPU401 port\n");
1995 return -EBUSY;
1996 }
1997 }
1998 if (chip->irq == SNDRV_AUTO_IRQ) {
1999 if ((chip->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
2000 snd_card_free(card);
2001 snd_printk("unable to find a free IRQ\n");
2002 return -EBUSY;
2003 }
2004 }
2005 if (chip->mpu_irq == SNDRV_AUTO_IRQ) {
2006 if ((chip->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) {
2007 snd_card_free(card);
2008 snd_printk("unable to find a free MPU401 IRQ\n");
2009 return -EBUSY;
2010 }
2011 }
2012 if (chip->dma1 == SNDRV_AUTO_DMA) {
2013 if ((chip->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) {
2014 snd_card_free(card);
2015 snd_printk("unable to find a free DMA1\n");
2016 return -EBUSY;
2017 }
2018 }
2019#if defined(CS4231) || defined(OPTi93X)
2020 if (chip->dma2 == SNDRV_AUTO_DMA) {
2021 if ((chip->dma2 = snd_legacy_find_free_dma(possible_dma2s[chip->dma1 % 4])) < 0) {
2022 snd_card_free(card);
2023 snd_printk("unable to find a free DMA2\n");
2024 return -EBUSY;
2025 }
2026 }
2027#endif
2028
2029#ifdef CONFIG_PNP
2030 }
2031#endif
2032
2033 if ((error = snd_opti9xx_configure(chip))) {
2034 snd_card_free(card);
2035 return error; 1818 return error;
2036 }
2037 1819
2038#if defined(OPTi93X) 1820#if defined(OPTi93X)
2039 if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) { 1821 if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec)))
2040 snd_card_free(card);
2041 return error; 1822 return error;
2042 } 1823 if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0)
2043 if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) {
2044 snd_card_free(card);
2045 return error; 1824 return error;
2046 } 1825 if ((error = snd_opti93x_mixer(codec)) < 0)
2047 if ((error = snd_opti93x_mixer(codec)) < 0) {
2048 snd_card_free(card);
2049 return error; 1826 return error;
2050 }
2051#elif defined(CS4231) 1827#elif defined(CS4231)
2052 if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1, 1828 if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1,
2053 chip->irq, chip->dma1, chip->dma2, 1829 chip->irq, chip->dma1, chip->dma2,
2054 CS4231_HW_DETECT, 1830 CS4231_HW_DETECT,
2055 0, 1831 0,
2056 &codec)) < 0) { 1832 &codec)) < 0)
2057 snd_card_free(card);
2058 return error; 1833 return error;
2059 } 1834 if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0)
2060 if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) {
2061 snd_card_free(card);
2062 return error; 1835 return error;
2063 } 1836 if ((error = snd_cs4231_mixer(codec)) < 0)
2064 if ((error = snd_cs4231_mixer(codec)) < 0) {
2065 snd_card_free(card);
2066 return error; 1837 return error;
2067 } 1838 if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0)
2068 if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) {
2069 snd_card_free(card);
2070 return error; 1839 return error;
2071 }
2072#else 1840#else
2073 if ((error = snd_ad1848_create(card, chip->wss_base + 4, 1841 if ((error = snd_ad1848_create(card, chip->wss_base + 4,
2074 chip->irq, chip->dma1, 1842 chip->irq, chip->dma1,
2075 AD1848_HW_DETECT, &codec)) < 0) { 1843 AD1848_HW_DETECT, &codec)) < 0)
2076 snd_card_free(card);
2077 return error; 1844 return error;
2078 } 1845 if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0)
2079 if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) {
2080 snd_card_free(card);
2081 return error; 1846 return error;
2082 } 1847 if ((error = snd_ad1848_mixer(codec)) < 0)
2083 if ((error = snd_ad1848_mixer(codec)) < 0) {
2084 snd_card_free(card);
2085 return error; 1848 return error;
2086 }
2087#endif 1849#endif
2088 strcpy(card->driver, chip->name); 1850 strcpy(card->driver, chip->name);
2089 sprintf(card->shortname, "OPTi %s", card->driver); 1851 sprintf(card->shortname, "OPTi %s", card->driver);
@@ -2103,15 +1865,16 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
2103 if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, 1865 if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
2104 chip->mpu_port, 0, chip->mpu_irq, SA_INTERRUPT, 1866 chip->mpu_port, 0, chip->mpu_irq, SA_INTERRUPT,
2105 &rmidi))) 1867 &rmidi)))
2106 snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port); 1868 snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
1869 chip->mpu_port);
2107 1870
2108 if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { 1871 if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) {
2109 opl3_t *opl3 = NULL; 1872 struct snd_opl3 *opl3 = NULL;
2110#ifndef OPTi93X 1873#ifndef OPTi93X
2111 if (chip->hardware == OPTi9XX_HW_82C928 || 1874 if (chip->hardware == OPTi9XX_HW_82C928 ||
2112 chip->hardware == OPTi9XX_HW_82C929 || 1875 chip->hardware == OPTi9XX_HW_82C929 ||
2113 chip->hardware == OPTi9XX_HW_82C924) { 1876 chip->hardware == OPTi9XX_HW_82C924) {
2114 opl4_t *opl4; 1877 struct snd_opl4 *opl4;
2115 /* assume we have an OPL4 */ 1878 /* assume we have an OPL4 */
2116 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 1879 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
2117 0x20, 0x20); 1880 0x20, 0x20);
@@ -2129,89 +1892,230 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard,
2129 chip->fm_port, 1892 chip->fm_port,
2130 chip->fm_port + 2, 1893 chip->fm_port + 2,
2131 OPL3_HW_AUTO, 0, &opl3) < 0) { 1894 OPL3_HW_AUTO, 0, &opl3) < 0) {
2132 snd_printk("no OPL device at 0x%lx-0x%lx\n", 1895 snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
2133 chip->fm_port, chip->fm_port + 4 - 1); 1896 chip->fm_port, chip->fm_port + 4 - 1);
2134 } 1897 }
2135 if (opl3) { 1898 if (opl3) {
2136 if ((error = snd_opl3_timer_new(opl3,
2137#ifdef CS4231 1899#ifdef CS4231
2138 1, 2)) < 0) { 1900 const int t1dev = 1;
2139#else 1901#else
2140 0, 1)) < 0) { 1902 const int t1dev = 0;
2141#endif /* CS4231 */ 1903#endif
2142 snd_card_free(card); 1904 if ((error = snd_opl3_timer_new(opl3, t1dev, t1dev+1)) < 0)
2143 return error; 1905 return error;
2144 } 1906 if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0)
2145 if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) {
2146 snd_card_free(card);
2147 return error; 1907 return error;
2148 }
2149 } 1908 }
2150 } 1909 }
2151 1910
2152 if ((error = snd_card_register(card))) { 1911 return snd_card_register(card);
1912}
1913
1914static struct snd_card *snd_opti9xx_card_new(void)
1915{
1916 struct snd_card *card;
1917
1918 card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx));
1919 if (! card)
1920 return NULL;
1921 card->private_free = snd_card_opti9xx_free;
1922 return card;
1923}
1924
1925static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1926{
1927 struct snd_card *card;
1928 int error;
1929 static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
1930#ifdef OPTi93X
1931 static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
1932#else
1933 static int possible_irqs[] = {9, 10, 11, 7, -1};
1934#endif /* OPTi93X */
1935 static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
1936 static int possible_dma1s[] = {3, 1, 0, -1};
1937#if defined(CS4231) || defined(OPTi93X)
1938 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
1939#endif /* CS4231 || OPTi93X */
1940
1941 if (snd_opti9xx_pnp_is_probed)
1942 return -EBUSY;
1943
1944 if (mpu_port == SNDRV_AUTO_PORT) {
1945 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
1946 snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
1947 return -EBUSY;
1948 }
1949 }
1950 if (irq == SNDRV_AUTO_IRQ) {
1951 if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
1952 snd_printk(KERN_ERR "unable to find a free IRQ\n");
1953 return -EBUSY;
1954 }
1955 }
1956 if (mpu_irq == SNDRV_AUTO_IRQ) {
1957 if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) {
1958 snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n");
1959 return -EBUSY;
1960 }
1961 }
1962 if (dma1 == SNDRV_AUTO_DMA) {
1963 if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) {
1964 snd_printk(KERN_ERR "unable to find a free DMA1\n");
1965 return -EBUSY;
1966 }
1967 }
1968#if defined(CS4231) || defined(OPTi93X)
1969 if (dma2 == SNDRV_AUTO_DMA) {
1970 if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) {
1971 snd_printk("unable to find a free DMA2\n");
1972 return -EBUSY;
1973 }
1974 }
1975#endif
1976
1977 card = snd_opti9xx_card_new();
1978 if (! card)
1979 return -ENOMEM;
1980
1981 if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) {
2153 snd_card_free(card); 1982 snd_card_free(card);
2154 return error; 1983 return error;
2155 } 1984 }
2156 snd_opti9xx_first_hit = 0; 1985 snd_card_set_dev(card, &devptr->dev);
2157 if (pcard) 1986 if ((error = snd_opti9xx_probe(card)) < 0) {
2158 pnp_set_card_drvdata(pcard, card); 1987 snd_card_free(card);
2159 else 1988 return error;
2160 snd_opti9xx_legacy = card; 1989 }
1990 platform_set_drvdata(devptr, card);
1991 return 0;
1992}
1993
1994static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr)
1995{
1996 snd_card_free(platform_get_drvdata(devptr));
1997 platform_set_drvdata(devptr, NULL);
2161 return 0; 1998 return 0;
2162} 1999}
2163 2000
2001static struct platform_driver snd_opti9xx_driver = {
2002 .probe = snd_opti9xx_nonpnp_probe,
2003 .remove = __devexit_p(snd_opti9xx_nonpnp_remove),
2004 /* FIXME: suspend/resume */
2005 .driver = {
2006 .name = DRIVER_NAME
2007 },
2008};
2009
2164#ifdef CONFIG_PNP 2010#ifdef CONFIG_PNP
2165static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) 2011static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
2012 const struct pnp_card_device_id *pid)
2166{ 2013{
2167 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 2014 struct snd_card *card;
2015 int error, hw;
2016 struct snd_opti9xx *chip;
2168 2017
2169 snd_card_disconnect(card); 2018 if (snd_opti9xx_pnp_is_probed)
2170 snd_card_free_in_thread(card); 2019 return -EBUSY;
2171 snd_opti9xx_first_hit = 0; 2020 if (! isapnp)
2021 return -ENODEV;
2022 card = snd_opti9xx_card_new();
2023 if (! card)
2024 return -ENOMEM;
2025 chip = card->private_data;
2026
2027 hw = snd_card_opti9xx_pnp(chip, pcard, pid);
2028 switch (hw) {
2029 case 0x0924:
2030 hw = OPTi9XX_HW_82C924;
2031 break;
2032 case 0x0925:
2033 hw = OPTi9XX_HW_82C925;
2034 break;
2035 case 0x0931:
2036 hw = OPTi9XX_HW_82C931;
2037 break;
2038 default:
2039 snd_card_free(card);
2040 return -ENODEV;
2041 }
2042
2043 if ((error = snd_opti9xx_init(chip, hw))) {
2044 snd_card_free(card);
2045 return error;
2046 }
2047 if (hw <= OPTi9XX_HW_82C930)
2048 chip->mc_base -= 0x80;
2049 snd_card_set_dev(card, &pcard->card->dev);
2050 if ((error = snd_opti9xx_probe(card)) < 0) {
2051 snd_card_free(card);
2052 return error;
2053 }
2054 pnp_set_card_drvdata(pcard, card);
2055 snd_opti9xx_pnp_is_probed = 1;
2056 return 0;
2057}
2058
2059static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
2060{
2061 snd_card_free(pnp_get_card_drvdata(pcard));
2062 pnp_set_card_drvdata(pcard, NULL);
2063 snd_opti9xx_pnp_is_probed = 0;
2172} 2064}
2173 2065
2174static struct pnp_card_driver opti9xx_pnpc_driver = { 2066static struct pnp_card_driver opti9xx_pnpc_driver = {
2175 .flags = PNP_DRIVER_RES_DISABLE, 2067 .flags = PNP_DRIVER_RES_DISABLE,
2176 .name = "opti9xx", 2068 .name = "opti9xx",
2177 .id_table = snd_opti9xx_pnpids, 2069 .id_table = snd_opti9xx_pnpids,
2178 .probe = snd_card_opti9xx_probe, 2070 .probe = snd_opti9xx_pnp_probe,
2179 .remove = __devexit_p(snd_opti9xx_pnp_remove), 2071 .remove = __devexit_p(snd_opti9xx_pnp_remove),
2180}; 2072};
2181#endif 2073#endif
2182 2074
2183static int __init alsa_card_opti9xx_init(void)
2184{
2185 int cards, error;
2186
2187#ifdef CONFIG_PNP 2075#ifdef CONFIG_PNP
2188 cards = pnp_register_card_driver(&opti9xx_pnpc_driver); 2076#define is_isapnp_selected() isapnp
2189#else 2077#else
2190 cards = 0; 2078#define is_isapnp_selected() 0
2191#endif
2192 if (cards == 0 && (error = snd_card_opti9xx_probe(NULL, NULL)) < 0) {
2193#ifdef CONFIG_PNP
2194 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2195#endif 2079#endif
2196#ifdef MODULE
2197#ifdef OPTi93X 2080#ifdef OPTi93X
2198 printk(KERN_ERR "no OPTi 82C93x soundcard found\n"); 2081#define CHIP_NAME "82C93x"
2199#else 2082#else
2200 printk(KERN_ERR "no OPTi 82C92x soundcard found\n"); 2083#define CHIP_NAME "82C92x"
2201#endif /* OPTi93X */
2202#endif 2084#endif
2203 return error; 2085
2086static int __init alsa_card_opti9xx_init(void)
2087{
2088 int error;
2089 struct platform_device *device;
2090
2091 pnp_register_card_driver(&opti9xx_pnpc_driver);
2092 if (snd_opti9xx_pnp_is_probed)
2093 return 0;
2094 if (! is_isapnp_selected()) {
2095 error = platform_driver_register(&snd_opti9xx_driver);
2096 if (error < 0)
2097 return error;
2098 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
2099 if (!IS_ERR(device)) {
2100 snd_opti9xx_platform_device = device;
2101 return 0;
2102 }
2103 platform_driver_unregister(&snd_opti9xx_driver);
2204 } 2104 }
2205 return 0; 2105 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2106#ifdef MODULE
2107 printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n");
2108#endif
2109 return -ENODEV;
2206} 2110}
2207 2111
2208static void __exit alsa_card_opti9xx_exit(void) 2112static void __exit alsa_card_opti9xx_exit(void)
2209{ 2113{
2210#ifdef CONFIG_PNP 2114 if (!snd_opti9xx_pnp_is_probed) {
2115 platform_device_unregister(snd_opti9xx_platform_device);
2116 platform_driver_unregister(&snd_opti9xx_driver);
2117 }
2211 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2118 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2212#endif
2213 if (snd_opti9xx_legacy)
2214 snd_card_free(snd_opti9xx_legacy);
2215} 2119}
2216 2120
2217module_init(alsa_card_opti9xx_init) 2121module_init(alsa_card_opti9xx_init)
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c
index b09c6575e01a..c0b8d61b75e7 100644
--- a/sound/isa/sb/emu8000.c
+++ b/sound/isa/sb/emu8000.c
@@ -45,7 +45,7 @@
45 * directly. The macros handle the port number and command word. 45 * directly. The macros handle the port number and command word.
46 */ 46 */
47/* Write a word */ 47/* Write a word */
48void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) 48void snd_emu8000_poke(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val)
49{ 49{
50 unsigned long flags; 50 unsigned long flags;
51 spin_lock_irqsave(&emu->reg_lock, flags); 51 spin_lock_irqsave(&emu->reg_lock, flags);
@@ -58,7 +58,7 @@ void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsig
58} 58}
59 59
60/* Read a word */ 60/* Read a word */
61unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int reg) 61unsigned short snd_emu8000_peek(struct snd_emu8000 *emu, unsigned int port, unsigned int reg)
62{ 62{
63 unsigned short res; 63 unsigned short res;
64 unsigned long flags; 64 unsigned long flags;
@@ -73,7 +73,7 @@ unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int
73} 73}
74 74
75/* Write a double word */ 75/* Write a double word */
76void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) 76void snd_emu8000_poke_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val)
77{ 77{
78 unsigned long flags; 78 unsigned long flags;
79 spin_lock_irqsave(&emu->reg_lock, flags); 79 spin_lock_irqsave(&emu->reg_lock, flags);
@@ -87,7 +87,7 @@ void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, un
87} 87}
88 88
89/* Read a double word */ 89/* Read a double word */
90unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int reg) 90unsigned int snd_emu8000_peek_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg)
91{ 91{
92 unsigned short low; 92 unsigned short low;
93 unsigned int res; 93 unsigned int res;
@@ -107,7 +107,7 @@ unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int
107 * Set up / close a channel to be used for DMA. 107 * Set up / close a channel to be used for DMA.
108 */ 108 */
109/*exported*/ void 109/*exported*/ void
110snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode) 110snd_emu8000_dma_chan(struct snd_emu8000 *emu, int ch, int mode)
111{ 111{
112 unsigned right_bit = (mode & EMU8000_RAM_RIGHT) ? 0x01000000 : 0; 112 unsigned right_bit = (mode & EMU8000_RAM_RIGHT) ? 0x01000000 : 0;
113 mode &= EMU8000_RAM_MODE_MASK; 113 mode &= EMU8000_RAM_MODE_MASK;
@@ -132,7 +132,7 @@ snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode)
132/* 132/*
133 */ 133 */
134static void __init 134static void __init
135snd_emu8000_read_wait(emu8000_t *emu) 135snd_emu8000_read_wait(struct snd_emu8000 *emu)
136{ 136{
137 while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) { 137 while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) {
138 schedule_timeout_interruptible(1); 138 schedule_timeout_interruptible(1);
@@ -144,7 +144,7 @@ snd_emu8000_read_wait(emu8000_t *emu)
144/* 144/*
145 */ 145 */
146static void __init 146static void __init
147snd_emu8000_write_wait(emu8000_t *emu) 147snd_emu8000_write_wait(struct snd_emu8000 *emu)
148{ 148{
149 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { 149 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
150 schedule_timeout_interruptible(1); 150 schedule_timeout_interruptible(1);
@@ -157,7 +157,7 @@ snd_emu8000_write_wait(emu8000_t *emu)
157 * detect a card at the given port 157 * detect a card at the given port
158 */ 158 */
159static int __init 159static int __init
160snd_emu8000_detect(emu8000_t *emu) 160snd_emu8000_detect(struct snd_emu8000 *emu)
161{ 161{
162 /* Initialise */ 162 /* Initialise */
163 EMU8000_HWCF1_WRITE(emu, 0x0059); 163 EMU8000_HWCF1_WRITE(emu, 0x0059);
@@ -183,7 +183,7 @@ snd_emu8000_detect(emu8000_t *emu)
183 * intiailize audio channels 183 * intiailize audio channels
184 */ 184 */
185static void __init 185static void __init
186init_audio(emu8000_t *emu) 186init_audio(struct snd_emu8000 *emu)
187{ 187{
188 int ch; 188 int ch;
189 189
@@ -224,7 +224,7 @@ init_audio(emu8000_t *emu)
224 * initialize DMA address 224 * initialize DMA address
225 */ 225 */
226static void __init 226static void __init
227init_dma(emu8000_t *emu) 227init_dma(struct snd_emu8000 *emu)
228{ 228{
229 EMU8000_SMALR_WRITE(emu, 0); 229 EMU8000_SMALR_WRITE(emu, 0);
230 EMU8000_SMARR_WRITE(emu, 0); 230 EMU8000_SMARR_WRITE(emu, 0);
@@ -328,7 +328,7 @@ static unsigned short init4[128] /*__devinitdata*/ = {
328 * is meant to work 328 * is meant to work
329 */ 329 */
330static void __init 330static void __init
331send_array(emu8000_t *emu, unsigned short *data, int size) 331send_array(struct snd_emu8000 *emu, unsigned short *data, int size)
332{ 332{
333 int i; 333 int i;
334 unsigned short *p; 334 unsigned short *p;
@@ -350,7 +350,7 @@ send_array(emu8000_t *emu, unsigned short *data, int size)
350 * initialisation sequence in the adip. 350 * initialisation sequence in the adip.
351 */ 351 */
352static void __init 352static void __init
353init_arrays(emu8000_t *emu) 353init_arrays(struct snd_emu8000 *emu)
354{ 354{
355 send_array(emu, init1, ARRAY_SIZE(init1)/4); 355 send_array(emu, init1, ARRAY_SIZE(init1)/4);
356 356
@@ -376,7 +376,7 @@ init_arrays(emu8000_t *emu)
376 * reallocating between read and write. 376 * reallocating between read and write.
377 */ 377 */
378static void __init 378static void __init
379size_dram(emu8000_t *emu) 379size_dram(struct snd_emu8000 *emu)
380{ 380{
381 int i, size; 381 int i, size;
382 382
@@ -455,7 +455,7 @@ size_dram(emu8000_t *emu)
455 * and therefore lose 2 voices. 455 * and therefore lose 2 voices.
456 */ 456 */
457/*exported*/ void 457/*exported*/ void
458snd_emu8000_init_fm(emu8000_t *emu) 458snd_emu8000_init_fm(struct snd_emu8000 *emu)
459{ 459{
460 unsigned long flags; 460 unsigned long flags;
461 461
@@ -501,7 +501,7 @@ snd_emu8000_init_fm(emu8000_t *emu)
501 * The main initialization routine. 501 * The main initialization routine.
502 */ 502 */
503static void __init 503static void __init
504snd_emu8000_init_hw(emu8000_t *emu) 504snd_emu8000_init_hw(struct snd_emu8000 *emu)
505{ 505{
506 int i; 506 int i;
507 507
@@ -585,7 +585,7 @@ static unsigned short treble_parm[12][9] = {
585 * set Emu8000 digital equalizer; from 0 to 11 [-12dB - 12dB] 585 * set Emu8000 digital equalizer; from 0 to 11 [-12dB - 12dB]
586 */ 586 */
587/*exported*/ void 587/*exported*/ void
588snd_emu8000_update_equalizer(emu8000_t *emu) 588snd_emu8000_update_equalizer(struct snd_emu8000 *emu)
589{ 589{
590 unsigned short w; 590 unsigned short w;
591 int bass = emu->bass_level; 591 int bass = emu->bass_level;
@@ -628,17 +628,17 @@ snd_emu8000_update_equalizer(emu8000_t *emu)
628/* user can define chorus modes up to 32 */ 628/* user can define chorus modes up to 32 */
629#define SNDRV_EMU8000_CHORUS_NUMBERS 32 629#define SNDRV_EMU8000_CHORUS_NUMBERS 32
630 630
631typedef struct soundfont_chorus_fx_t { 631struct soundfont_chorus_fx {
632 unsigned short feedback; /* feedback level (0xE600-0xE6FF) */ 632 unsigned short feedback; /* feedback level (0xE600-0xE6FF) */
633 unsigned short delay_offset; /* delay (0-0x0DA3) [1/44100 sec] */ 633 unsigned short delay_offset; /* delay (0-0x0DA3) [1/44100 sec] */
634 unsigned short lfo_depth; /* LFO depth (0xBC00-0xBCFF) */ 634 unsigned short lfo_depth; /* LFO depth (0xBC00-0xBCFF) */
635 unsigned int delay; /* right delay (0-0xFFFFFFFF) [1/256/44100 sec] */ 635 unsigned int delay; /* right delay (0-0xFFFFFFFF) [1/256/44100 sec] */
636 unsigned int lfo_freq; /* LFO freq LFO freq (0-0xFFFFFFFF) */ 636 unsigned int lfo_freq; /* LFO freq LFO freq (0-0xFFFFFFFF) */
637} soundfont_chorus_fx_t; 637};
638 638
639/* 5 parameters for each chorus mode; 3 x 16bit, 2 x 32bit */ 639/* 5 parameters for each chorus mode; 3 x 16bit, 2 x 32bit */
640static char chorus_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; 640static char chorus_defined[SNDRV_EMU8000_CHORUS_NUMBERS];
641static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { 641static struct soundfont_chorus_fx chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = {
642 {0xE600, 0x03F6, 0xBC2C ,0x00000000, 0x0000006D}, /* chorus 1 */ 642 {0xE600, 0x03F6, 0xBC2C ,0x00000000, 0x0000006D}, /* chorus 1 */
643 {0xE608, 0x031A, 0xBC6E, 0x00000000, 0x0000017C}, /* chorus 2 */ 643 {0xE608, 0x031A, 0xBC6E, 0x00000000, 0x0000017C}, /* chorus 2 */
644 {0xE610, 0x031A, 0xBC84, 0x00000000, 0x00000083}, /* chorus 3 */ 644 {0xE610, 0x031A, 0xBC84, 0x00000000, 0x00000083}, /* chorus 3 */
@@ -650,9 +650,9 @@ static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = {
650}; 650};
651 651
652/*exported*/ int 652/*exported*/ int
653snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, long len) 653snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len)
654{ 654{
655 soundfont_chorus_fx_t rec; 655 struct soundfont_chorus_fx rec;
656 if (mode < SNDRV_EMU8000_CHORUS_PREDEFINED || mode >= SNDRV_EMU8000_CHORUS_NUMBERS) { 656 if (mode < SNDRV_EMU8000_CHORUS_PREDEFINED || mode >= SNDRV_EMU8000_CHORUS_NUMBERS) {
657 snd_printk(KERN_WARNING "invalid chorus mode %d for uploading\n", mode); 657 snd_printk(KERN_WARNING "invalid chorus mode %d for uploading\n", mode);
658 return -EINVAL; 658 return -EINVAL;
@@ -665,7 +665,7 @@ snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, lon
665} 665}
666 666
667/*exported*/ void 667/*exported*/ void
668snd_emu8000_update_chorus_mode(emu8000_t *emu) 668snd_emu8000_update_chorus_mode(struct snd_emu8000 *emu)
669{ 669{
670 int effect = emu->chorus_mode; 670 int effect = emu->chorus_mode;
671 if (effect < 0 || effect >= SNDRV_EMU8000_CHORUS_NUMBERS || 671 if (effect < 0 || effect >= SNDRV_EMU8000_CHORUS_NUMBERS ||
@@ -699,15 +699,15 @@ snd_emu8000_update_chorus_mode(emu8000_t *emu)
699/* user can define reverb modes up to 32 */ 699/* user can define reverb modes up to 32 */
700#define SNDRV_EMU8000_REVERB_NUMBERS 32 700#define SNDRV_EMU8000_REVERB_NUMBERS 32
701 701
702typedef struct soundfont_reverb_fx_t { 702struct soundfont_reverb_fx {
703 unsigned short parms[28]; 703 unsigned short parms[28];
704} soundfont_reverb_fx_t; 704};
705 705
706/* reverb mode settings; write the following 28 data of 16 bit length 706/* reverb mode settings; write the following 28 data of 16 bit length
707 * on the corresponding ports in the reverb_cmds array 707 * on the corresponding ports in the reverb_cmds array
708 */ 708 */
709static char reverb_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; 709static char reverb_defined[SNDRV_EMU8000_CHORUS_NUMBERS];
710static soundfont_reverb_fx_t reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = { 710static struct soundfont_reverb_fx reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = {
711{{ /* room 1 */ 711{{ /* room 1 */
712 0xB488, 0xA450, 0x9550, 0x84B5, 0x383A, 0x3EB5, 0x72F4, 712 0xB488, 0xA450, 0x9550, 0x84B5, 0x383A, 0x3EB5, 0x72F4,
713 0x72A4, 0x7254, 0x7204, 0x7204, 0x7204, 0x4416, 0x4516, 713 0x72A4, 0x7254, 0x7204, 0x7204, 0x7204, 0x4416, 0x4516,
@@ -777,9 +777,9 @@ static struct reverb_cmd_pair {
777}; 777};
778 778
779/*exported*/ int 779/*exported*/ int
780snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, long len) 780snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len)
781{ 781{
782 soundfont_reverb_fx_t rec; 782 struct soundfont_reverb_fx rec;
783 783
784 if (mode < SNDRV_EMU8000_REVERB_PREDEFINED || mode >= SNDRV_EMU8000_REVERB_NUMBERS) { 784 if (mode < SNDRV_EMU8000_REVERB_PREDEFINED || mode >= SNDRV_EMU8000_REVERB_NUMBERS) {
785 snd_printk(KERN_WARNING "invalid reverb mode %d for uploading\n", mode); 785 snd_printk(KERN_WARNING "invalid reverb mode %d for uploading\n", mode);
@@ -793,7 +793,7 @@ snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, lon
793} 793}
794 794
795/*exported*/ void 795/*exported*/ void
796snd_emu8000_update_reverb_mode(emu8000_t *emu) 796snd_emu8000_update_reverb_mode(struct snd_emu8000 *emu)
797{ 797{
798 int effect = emu->reverb_mode; 798 int effect = emu->reverb_mode;
799 int i; 799 int i;
@@ -819,7 +819,7 @@ snd_emu8000_update_reverb_mode(emu8000_t *emu)
819/* 819/*
820 * bass/treble 820 * bass/treble
821 */ 821 */
822static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 822static int mixer_bass_treble_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
823{ 823{
824 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 824 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
825 uinfo->count = 1; 825 uinfo->count = 1;
@@ -828,17 +828,17 @@ static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
828 return 0; 828 return 0;
829} 829}
830 830
831static int mixer_bass_treble_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 831static int mixer_bass_treble_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
832{ 832{
833 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 833 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
834 834
835 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->treble_level : emu->bass_level; 835 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->treble_level : emu->bass_level;
836 return 0; 836 return 0;
837} 837}
838 838
839static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 839static int mixer_bass_treble_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
840{ 840{
841 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 841 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
842 unsigned long flags; 842 unsigned long flags;
843 int change; 843 int change;
844 unsigned short val1; 844 unsigned short val1;
@@ -857,7 +857,7 @@ static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
857 return change; 857 return change;
858} 858}
859 859
860static snd_kcontrol_new_t mixer_bass_control = 860static struct snd_kcontrol_new mixer_bass_control =
861{ 861{
862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
863 .name = "Synth Tone Control - Bass", 863 .name = "Synth Tone Control - Bass",
@@ -867,7 +867,7 @@ static snd_kcontrol_new_t mixer_bass_control =
867 .private_value = 0, 867 .private_value = 0,
868}; 868};
869 869
870static snd_kcontrol_new_t mixer_treble_control = 870static struct snd_kcontrol_new mixer_treble_control =
871{ 871{
872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
873 .name = "Synth Tone Control - Treble", 873 .name = "Synth Tone Control - Treble",
@@ -880,7 +880,7 @@ static snd_kcontrol_new_t mixer_treble_control =
880/* 880/*
881 * chorus/reverb mode 881 * chorus/reverb mode
882 */ 882 */
883static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 883static int mixer_chorus_reverb_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
884{ 884{
885 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 885 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
886 uinfo->count = 1; 886 uinfo->count = 1;
@@ -889,17 +889,17 @@ static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
889 return 0; 889 return 0;
890} 890}
891 891
892static int mixer_chorus_reverb_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 892static int mixer_chorus_reverb_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
893{ 893{
894 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 894 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
895 895
896 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->chorus_mode : emu->reverb_mode; 896 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->chorus_mode : emu->reverb_mode;
897 return 0; 897 return 0;
898} 898}
899 899
900static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 900static int mixer_chorus_reverb_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
901{ 901{
902 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 902 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
903 unsigned long flags; 903 unsigned long flags;
904 int change; 904 int change;
905 unsigned short val1; 905 unsigned short val1;
@@ -924,7 +924,7 @@ static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
924 return change; 924 return change;
925} 925}
926 926
927static snd_kcontrol_new_t mixer_chorus_mode_control = 927static struct snd_kcontrol_new mixer_chorus_mode_control =
928{ 928{
929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
930 .name = "Chorus Mode", 930 .name = "Chorus Mode",
@@ -934,7 +934,7 @@ static snd_kcontrol_new_t mixer_chorus_mode_control =
934 .private_value = 1, 934 .private_value = 1,
935}; 935};
936 936
937static snd_kcontrol_new_t mixer_reverb_mode_control = 937static struct snd_kcontrol_new mixer_reverb_mode_control =
938{ 938{
939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
940 .name = "Reverb Mode", 940 .name = "Reverb Mode",
@@ -947,7 +947,7 @@ static snd_kcontrol_new_t mixer_reverb_mode_control =
947/* 947/*
948 * FM OPL3 chorus/reverb depth 948 * FM OPL3 chorus/reverb depth
949 */ 949 */
950static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 950static int mixer_fm_depth_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
951{ 951{
952 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 952 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
953 uinfo->count = 1; 953 uinfo->count = 1;
@@ -956,17 +956,17 @@ static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
956 return 0; 956 return 0;
957} 957}
958 958
959static int mixer_fm_depth_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 959static int mixer_fm_depth_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
960{ 960{
961 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 961 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
962 962
963 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->fm_chorus_depth : emu->fm_reverb_depth; 963 ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->fm_chorus_depth : emu->fm_reverb_depth;
964 return 0; 964 return 0;
965} 965}
966 966
967static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 967static int mixer_fm_depth_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
968{ 968{
969 emu8000_t *emu = snd_kcontrol_chip(kcontrol); 969 struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol);
970 unsigned long flags; 970 unsigned long flags;
971 int change; 971 int change;
972 unsigned short val1; 972 unsigned short val1;
@@ -986,7 +986,7 @@ static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
986 return change; 986 return change;
987} 987}
988 988
989static snd_kcontrol_new_t mixer_fm_chorus_depth_control = 989static struct snd_kcontrol_new mixer_fm_chorus_depth_control =
990{ 990{
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
992 .name = "FM Chorus Depth", 992 .name = "FM Chorus Depth",
@@ -996,7 +996,7 @@ static snd_kcontrol_new_t mixer_fm_chorus_depth_control =
996 .private_value = 1, 996 .private_value = 1,
997}; 997};
998 998
999static snd_kcontrol_new_t mixer_fm_reverb_depth_control = 999static struct snd_kcontrol_new mixer_fm_reverb_depth_control =
1000{ 1000{
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1002 .name = "FM Reverb Depth", 1002 .name = "FM Reverb Depth",
@@ -1007,7 +1007,7 @@ static snd_kcontrol_new_t mixer_fm_reverb_depth_control =
1007}; 1007};
1008 1008
1009 1009
1010static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = { 1010static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {
1011 &mixer_bass_control, 1011 &mixer_bass_control,
1012 &mixer_treble_control, 1012 &mixer_treble_control,
1013 &mixer_chorus_mode_control, 1013 &mixer_chorus_mode_control,
@@ -1020,7 +1020,7 @@ static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = {
1020 * create and attach mixer elements for WaveTable treble/bass controls 1020 * create and attach mixer elements for WaveTable treble/bass controls
1021 */ 1021 */
1022static int __init 1022static int __init
1023snd_emu8000_create_mixer(snd_card_t *card, emu8000_t *emu) 1023snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
1024{ 1024{
1025 int i, err = 0; 1025 int i, err = 0;
1026 1026
@@ -1049,7 +1049,7 @@ __error:
1049/* 1049/*
1050 * free resources 1050 * free resources
1051 */ 1051 */
1052static int snd_emu8000_free(emu8000_t *hw) 1052static int snd_emu8000_free(struct snd_emu8000 *hw)
1053{ 1053{
1054 release_and_free_resource(hw->res_port1); 1054 release_and_free_resource(hw->res_port1);
1055 release_and_free_resource(hw->res_port2); 1055 release_and_free_resource(hw->res_port2);
@@ -1060,9 +1060,9 @@ static int snd_emu8000_free(emu8000_t *hw)
1060 1060
1061/* 1061/*
1062 */ 1062 */
1063static int snd_emu8000_dev_free(snd_device_t *device) 1063static int snd_emu8000_dev_free(struct snd_device *device)
1064{ 1064{
1065 emu8000_t *hw = device->device_data; 1065 struct snd_emu8000 *hw = device->device_data;
1066 return snd_emu8000_free(hw); 1066 return snd_emu8000_free(hw);
1067} 1067}
1068 1068
@@ -1070,12 +1070,13 @@ static int snd_emu8000_dev_free(snd_device_t *device)
1070 * initialize and register emu8000 synth device. 1070 * initialize and register emu8000 synth device.
1071 */ 1071 */
1072int __init 1072int __init
1073snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_device_t **awe_ret) 1073snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports,
1074 struct snd_seq_device **awe_ret)
1074{ 1075{
1075 snd_seq_device_t *awe; 1076 struct snd_seq_device *awe;
1076 emu8000_t *hw; 1077 struct snd_emu8000 *hw;
1077 int err; 1078 int err;
1078 static snd_device_ops_t ops = { 1079 static struct snd_device_ops ops = {
1079 .dev_free = snd_emu8000_dev_free, 1080 .dev_free = snd_emu8000_dev_free,
1080 }; 1081 };
1081 1082
@@ -1127,9 +1128,9 @@ snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_d
1127 } 1128 }
1128#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) 1129#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
1129 if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000, 1130 if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000,
1130 sizeof(emu8000_t*), &awe) >= 0) { 1131 sizeof(struct snd_emu8000*), &awe) >= 0) {
1131 strcpy(awe->name, "EMU-8000"); 1132 strcpy(awe->name, "EMU-8000");
1132 *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; 1133 *(struct snd_emu8000 **)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw;
1133 } 1134 }
1134#else 1135#else
1135 awe = NULL; 1136 awe = NULL;
diff --git a/sound/isa/sb/emu8000_callback.c b/sound/isa/sb/emu8000_callback.c
index 1cc4101a17a4..9a3c71cc2e07 100644
--- a/sound/isa/sb/emu8000_callback.c
+++ b/sound/isa/sb/emu8000_callback.c
@@ -25,27 +25,30 @@
25/* 25/*
26 * prototypes 26 * prototypes
27 */ 27 */
28static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port); 28static struct snd_emux_voice *get_voice(struct snd_emux *emu,
29static int start_voice(snd_emux_voice_t *vp); 29 struct snd_emux_port *port);
30static void trigger_voice(snd_emux_voice_t *vp); 30static int start_voice(struct snd_emux_voice *vp);
31static void release_voice(snd_emux_voice_t *vp); 31static void trigger_voice(struct snd_emux_voice *vp);
32static void update_voice(snd_emux_voice_t *vp, int update); 32static void release_voice(struct snd_emux_voice *vp);
33static void reset_voice(snd_emux_t *emu, int ch); 33static void update_voice(struct snd_emux_voice *vp, int update);
34static void terminate_voice(snd_emux_voice_t *vp); 34static void reset_voice(struct snd_emux *emu, int ch);
35static void sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset); 35static void terminate_voice(struct snd_emux_voice *vp);
36static void sysex(struct snd_emux *emu, char *buf, int len, int parsed,
37 struct snd_midi_channel_set *chset);
36#ifdef CONFIG_SND_SEQUENCER_OSS 38#ifdef CONFIG_SND_SEQUENCER_OSS
37static int oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2); 39static int oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2);
38#endif 40#endif
39static int load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len); 41static int load_fx(struct snd_emux *emu, int type, int mode,
40 42 const void __user *buf, long len);
41static void set_pitch(emu8000_t *hw, snd_emux_voice_t *vp); 43
42static void set_volume(emu8000_t *hw, snd_emux_voice_t *vp); 44static void set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
43static void set_pan(emu8000_t *hw, snd_emux_voice_t *vp); 45static void set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
44static void set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp); 46static void set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
45static void set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp); 47static void set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
46static void set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp); 48static void set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
47static void set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp); 49static void set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
48static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch); 50static void set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp);
51static void snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int ch);
49 52
50/* 53/*
51 * Ensure a value is between two points 54 * Ensure a value is between two points
@@ -58,7 +61,7 @@ static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch);
58/* 61/*
59 * set up operators 62 * set up operators
60 */ 63 */
61static snd_emux_operators_t emu8000_ops = { 64static struct snd_emux_operators emu8000_ops = {
62 .owner = THIS_MODULE, 65 .owner = THIS_MODULE,
63 .get_voice = get_voice, 66 .get_voice = get_voice,
64 .prepare = start_voice, 67 .prepare = start_voice,
@@ -78,7 +81,7 @@ static snd_emux_operators_t emu8000_ops = {
78}; 81};
79 82
80void 83void
81snd_emu8000_ops_setup(emu8000_t *hw) 84snd_emu8000_ops_setup(struct snd_emu8000 *hw)
82{ 85{
83 hw->emu->ops = emu8000_ops; 86 hw->emu->ops = emu8000_ops;
84} 87}
@@ -89,10 +92,10 @@ snd_emu8000_ops_setup(emu8000_t *hw)
89 * Terminate a voice 92 * Terminate a voice
90 */ 93 */
91static void 94static void
92release_voice(snd_emux_voice_t *vp) 95release_voice(struct snd_emux_voice *vp)
93{ 96{
94 int dcysusv; 97 int dcysusv;
95 emu8000_t *hw; 98 struct snd_emu8000 *hw;
96 99
97 hw = vp->hw; 100 hw = vp->hw;
98 dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease; 101 dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease;
@@ -105,9 +108,9 @@ release_voice(snd_emux_voice_t *vp)
105/* 108/*
106 */ 109 */
107static void 110static void
108terminate_voice(snd_emux_voice_t *vp) 111terminate_voice(struct snd_emux_voice *vp)
109{ 112{
110 emu8000_t *hw; 113 struct snd_emu8000 *hw;
111 114
112 hw = vp->hw; 115 hw = vp->hw;
113 EMU8000_DCYSUSV_WRITE(hw, vp->ch, 0x807F); 116 EMU8000_DCYSUSV_WRITE(hw, vp->ch, 0x807F);
@@ -117,9 +120,9 @@ terminate_voice(snd_emux_voice_t *vp)
117/* 120/*
118 */ 121 */
119static void 122static void
120update_voice(snd_emux_voice_t *vp, int update) 123update_voice(struct snd_emux_voice *vp, int update)
121{ 124{
122 emu8000_t *hw; 125 struct snd_emu8000 *hw;
123 126
124 hw = vp->hw; 127 hw = vp->hw;
125 if (update & SNDRV_EMUX_UPDATE_VOLUME) 128 if (update & SNDRV_EMUX_UPDATE_VOLUME)
@@ -149,12 +152,12 @@ update_voice(snd_emux_voice_t *vp, int update)
149 * The channel index (vp->ch) must be initialized in this routine. 152 * The channel index (vp->ch) must be initialized in this routine.
150 * In Emu8k, it is identical with the array index. 153 * In Emu8k, it is identical with the array index.
151 */ 154 */
152static snd_emux_voice_t * 155static struct snd_emux_voice *
153get_voice(snd_emux_t *emu, snd_emux_port_t *port) 156get_voice(struct snd_emux *emu, struct snd_emux_port *port)
154{ 157{
155 int i; 158 int i;
156 snd_emux_voice_t *vp; 159 struct snd_emux_voice *vp;
157 emu8000_t *hw; 160 struct snd_emu8000 *hw;
158 161
159 /* what we are looking for, in order of preference */ 162 /* what we are looking for, in order of preference */
160 enum { 163 enum {
@@ -227,13 +230,13 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port)
227/* 230/*
228 */ 231 */
229static int 232static int
230start_voice(snd_emux_voice_t *vp) 233start_voice(struct snd_emux_voice *vp)
231{ 234{
232 unsigned int temp; 235 unsigned int temp;
233 int ch; 236 int ch;
234 int addr; 237 int addr;
235 snd_midi_channel_t *chan; 238 struct snd_midi_channel *chan;
236 emu8000_t *hw; 239 struct snd_emu8000 *hw;
237 240
238 hw = vp->hw; 241 hw = vp->hw;
239 ch = vp->ch; 242 ch = vp->ch;
@@ -307,11 +310,11 @@ start_voice(snd_emux_voice_t *vp)
307 * Start envelope 310 * Start envelope
308 */ 311 */
309static void 312static void
310trigger_voice(snd_emux_voice_t *vp) 313trigger_voice(struct snd_emux_voice *vp)
311{ 314{
312 int ch = vp->ch; 315 int ch = vp->ch;
313 unsigned int temp; 316 unsigned int temp;
314 emu8000_t *hw; 317 struct snd_emu8000 *hw;
315 318
316 hw = vp->hw; 319 hw = vp->hw;
317 320
@@ -329,9 +332,9 @@ trigger_voice(snd_emux_voice_t *vp)
329 * reset voice parameters 332 * reset voice parameters
330 */ 333 */
331static void 334static void
332reset_voice(snd_emux_t *emu, int ch) 335reset_voice(struct snd_emux *emu, int ch)
333{ 336{
334 emu8000_t *hw; 337 struct snd_emu8000 *hw;
335 338
336 hw = emu->hw; 339 hw = emu->hw;
337 EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); 340 EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F);
@@ -342,7 +345,7 @@ reset_voice(snd_emux_t *emu, int ch)
342 * Set the pitch of a possibly playing note. 345 * Set the pitch of a possibly playing note.
343 */ 346 */
344static void 347static void
345set_pitch(emu8000_t *hw, snd_emux_voice_t *vp) 348set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
346{ 349{
347 EMU8000_IP_WRITE(hw, vp->ch, vp->apitch); 350 EMU8000_IP_WRITE(hw, vp->ch, vp->apitch);
348} 351}
@@ -351,7 +354,7 @@ set_pitch(emu8000_t *hw, snd_emux_voice_t *vp)
351 * Set the volume of a possibly already playing note 354 * Set the volume of a possibly already playing note
352 */ 355 */
353static void 356static void
354set_volume(emu8000_t *hw, snd_emux_voice_t *vp) 357set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
355{ 358{
356 int ifatn; 359 int ifatn;
357 360
@@ -365,7 +368,7 @@ set_volume(emu8000_t *hw, snd_emux_voice_t *vp)
365 * Set pan and loop start address. 368 * Set pan and loop start address.
366 */ 369 */
367static void 370static void
368set_pan(emu8000_t *hw, snd_emux_voice_t *vp) 371set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
369{ 372{
370 unsigned int temp; 373 unsigned int temp;
371 374
@@ -376,7 +379,7 @@ set_pan(emu8000_t *hw, snd_emux_voice_t *vp)
376#define MOD_SENSE 18 379#define MOD_SENSE 18
377 380
378static void 381static void
379set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp) 382set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
380{ 383{
381 unsigned short fmmod; 384 unsigned short fmmod;
382 short pitch; 385 short pitch;
@@ -394,14 +397,14 @@ set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp)
394 397
395/* set tremolo (lfo1) volume & frequency */ 398/* set tremolo (lfo1) volume & frequency */
396static void 399static void
397set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp) 400set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
398{ 401{
399 EMU8000_TREMFRQ_WRITE(hw, vp->ch, vp->reg.parm.tremfrq); 402 EMU8000_TREMFRQ_WRITE(hw, vp->ch, vp->reg.parm.tremfrq);
400} 403}
401 404
402/* set lfo2 pitch & frequency */ 405/* set lfo2 pitch & frequency */
403static void 406static void
404set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp) 407set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
405{ 408{
406 unsigned short fm2frq2; 409 unsigned short fm2frq2;
407 short pitch; 410 short pitch;
@@ -419,7 +422,7 @@ set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp)
419 422
420/* set filterQ */ 423/* set filterQ */
421static void 424static void
422set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp) 425set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp)
423{ 426{
424 unsigned int addr; 427 unsigned int addr;
425 addr = EMU8000_CCCA_READ(hw, vp->ch) & 0xffffff; 428 addr = EMU8000_CCCA_READ(hw, vp->ch) & 0xffffff;
@@ -431,7 +434,7 @@ set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp)
431 * set the envelope & LFO parameters to the default values 434 * set the envelope & LFO parameters to the default values
432 */ 435 */
433static void 436static void
434snd_emu8000_tweak_voice(emu8000_t *emu, int i) 437snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int i)
435{ 438{
436 /* set all mod/vol envelope shape to minimum */ 439 /* set all mod/vol envelope shape to minimum */
437 EMU8000_ENVVOL_WRITE(emu, i, 0x8000); 440 EMU8000_ENVVOL_WRITE(emu, i, 0x8000);
@@ -453,9 +456,9 @@ snd_emu8000_tweak_voice(emu8000_t *emu, int i)
453 * sysex callback 456 * sysex callback
454 */ 457 */
455static void 458static void
456sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset) 459sysex(struct snd_emux *emu, char *buf, int len, int parsed, struct snd_midi_channel_set *chset)
457{ 460{
458 emu8000_t *hw; 461 struct snd_emu8000 *hw;
459 462
460 hw = emu->hw; 463 hw = emu->hw;
461 464
@@ -478,9 +481,9 @@ sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *c
478 * OSS ioctl callback 481 * OSS ioctl callback
479 */ 482 */
480static int 483static int
481oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2) 484oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2)
482{ 485{
483 emu8000_t *hw; 486 struct snd_emu8000 *hw;
484 487
485 hw = emu->hw; 488 hw = emu->hw;
486 489
@@ -523,9 +526,9 @@ oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2)
523 */ 526 */
524 527
525static int 528static int
526load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len) 529load_fx(struct snd_emux *emu, int type, int mode, const void __user *buf, long len)
527{ 530{
528 emu8000_t *hw; 531 struct snd_emu8000 *hw;
529 hw = emu->hw; 532 hw = emu->hw;
530 533
531 /* skip header */ 534 /* skip header */
diff --git a/sound/isa/sb/emu8000_local.h b/sound/isa/sb/emu8000_local.h
index ea4996a895fc..2ac77f10bb4e 100644
--- a/sound/isa/sb/emu8000_local.h
+++ b/sound/isa/sb/emu8000_local.h
@@ -30,14 +30,17 @@
30#include <sound/emu8000_reg.h> 30#include <sound/emu8000_reg.h>
31 31
32/* emu8000_patch.c */ 32/* emu8000_patch.c */
33int snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *data, long count); 33int snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
34int snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); 34 struct snd_util_memhdr *hdr,
35void snd_emu8000_sample_reset(snd_emux_t *rec); 35 const void __user *data, long count);
36int snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp,
37 struct snd_util_memhdr *hdr);
38void snd_emu8000_sample_reset(struct snd_emux *rec);
36 39
37/* emu8000_callback.c */ 40/* emu8000_callback.c */
38void snd_emu8000_ops_setup(emu8000_t *emu); 41void snd_emu8000_ops_setup(struct snd_emu8000 *emu);
39 42
40/* emu8000_pcm.c */ 43/* emu8000_pcm.c */
41int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index); 44int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index);
42 45
43#endif /* __EMU8000_LOCAL_H */ 46#endif /* __EMU8000_LOCAL_H */
diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c
index 2fea67e71c78..80b1cf84a1ae 100644
--- a/sound/isa/sb/emu8000_patch.c
+++ b/sound/isa/sb/emu8000_patch.c
@@ -32,7 +32,7 @@ MODULE_PARM_DESC(emu8000_reset_addr, "reset write address at each time (makes sl
32 * Open up channels. 32 * Open up channels.
33 */ 33 */
34static int 34static int
35snd_emu8000_open_dma(emu8000_t *emu, int write) 35snd_emu8000_open_dma(struct snd_emu8000 *emu, int write)
36{ 36{
37 int i; 37 int i;
38 38
@@ -59,7 +59,7 @@ snd_emu8000_open_dma(emu8000_t *emu, int write)
59 * Close all dram channels. 59 * Close all dram channels.
60 */ 60 */
61static void 61static void
62snd_emu8000_close_dma(emu8000_t *emu) 62snd_emu8000_close_dma(struct snd_emu8000 *emu)
63{ 63{
64 int i; 64 int i;
65 65
@@ -106,7 +106,7 @@ read_word(const void __user *buf, int offset, int mode)
106/* 106/*
107 */ 107 */
108static void 108static void
109snd_emu8000_write_wait(emu8000_t *emu) 109snd_emu8000_write_wait(struct snd_emu8000 *emu)
110{ 110{
111 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { 111 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
112 schedule_timeout_interruptible(1); 112 schedule_timeout_interruptible(1);
@@ -128,7 +128,7 @@ snd_emu8000_write_wait(emu8000_t *emu)
128 * working. 128 * working.
129 */ 129 */
130static inline void 130static inline void
131write_word(emu8000_t *emu, int *offset, unsigned short data) 131write_word(struct snd_emu8000 *emu, int *offset, unsigned short data)
132{ 132{
133 if (emu8000_reset_addr) { 133 if (emu8000_reset_addr) {
134 if (emu8000_reset_addr > 1) 134 if (emu8000_reset_addr > 1)
@@ -144,15 +144,16 @@ write_word(emu8000_t *emu, int *offset, unsigned short data)
144 * the generic soundfont routines as a callback. 144 * the generic soundfont routines as a callback.
145 */ 145 */
146int 146int
147snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, 147snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
148 snd_util_memhdr_t *hdr, const void __user *data, long count) 148 struct snd_util_memhdr *hdr,
149 const void __user *data, long count)
149{ 150{
150 int i; 151 int i;
151 int rc; 152 int rc;
152 int offset; 153 int offset;
153 int truesize; 154 int truesize;
154 int dram_offset, dram_start; 155 int dram_offset, dram_start;
155 emu8000_t *emu; 156 struct snd_emu8000 *emu;
156 157
157 emu = rec->hw; 158 emu = rec->hw;
158 snd_assert(sp != NULL, return -EINVAL); 159 snd_assert(sp != NULL, return -EINVAL);
@@ -282,7 +283,8 @@ snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp,
282 * free a sample block 283 * free a sample block
283 */ 284 */
284int 285int
285snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr) 286snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp,
287 struct snd_util_memhdr *hdr)
286{ 288{
287 if (sp->block) { 289 if (sp->block) {
288 snd_util_mem_free(hdr, sp->block); 290 snd_util_mem_free(hdr, sp->block);
@@ -296,7 +298,7 @@ snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t
296 * sample_reset callback - terminate voices 298 * sample_reset callback - terminate voices
297 */ 299 */
298void 300void
299snd_emu8000_sample_reset(snd_emux_t *rec) 301snd_emu8000_sample_reset(struct snd_emux *rec)
300{ 302{
301 snd_emux_terminate_all(rec); 303 snd_emux_terminate_all(rec);
302} 304}
diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c
index b323beeeda15..91dc3d83e2cf 100644
--- a/sound/isa/sb/emu8000_pcm.c
+++ b/sound/isa/sb/emu8000_pcm.c
@@ -46,14 +46,12 @@
46 */ 46 */
47 47
48 48
49typedef struct snd_emu8k_pcm emu8k_pcm_t;
50
51struct snd_emu8k_pcm { 49struct snd_emu8k_pcm {
52 emu8000_t *emu; 50 struct snd_emu8000 *emu;
53 snd_pcm_substream_t *substream; 51 struct snd_pcm_substream *substream;
54 52
55 unsigned int allocated_bytes; 53 unsigned int allocated_bytes;
56 snd_util_memblk_t *block; 54 struct snd_util_memblk *block;
57 unsigned int offset; 55 unsigned int offset;
58 unsigned int buf_size; 56 unsigned int buf_size;
59 unsigned int period_size; 57 unsigned int period_size;
@@ -77,7 +75,7 @@ struct snd_emu8k_pcm {
77 * open up channels for the simultaneous data transfer and playback 75 * open up channels for the simultaneous data transfer and playback
78 */ 76 */
79static int 77static int
80emu8k_open_dram_for_pcm(emu8000_t *emu, int channels) 78emu8k_open_dram_for_pcm(struct snd_emu8000 *emu, int channels)
81{ 79{
82 int i; 80 int i;
83 81
@@ -113,7 +111,7 @@ emu8k_open_dram_for_pcm(emu8000_t *emu, int channels)
113/* 111/*
114 */ 112 */
115static void 113static void
116snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) 114snd_emu8000_write_wait(struct snd_emu8000 *emu, int can_schedule)
117{ 115{
118 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { 116 while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
119 if (can_schedule) { 117 if (can_schedule) {
@@ -128,7 +126,7 @@ snd_emu8000_write_wait(emu8000_t *emu, int can_schedule)
128 * close all channels 126 * close all channels
129 */ 127 */
130static void 128static void
131emu8k_close_dram(emu8000_t *emu) 129emu8k_close_dram(struct snd_emu8000 *emu)
132{ 130{
133 int i; 131 int i;
134 132
@@ -156,7 +154,7 @@ static int calc_rate_offset(int hz)
156/* 154/*
157 */ 155 */
158 156
159static snd_pcm_hardware_t emu8k_pcm_hw = { 157static struct snd_pcm_hardware emu8k_pcm_hw = {
160#ifdef USE_NONINTERLEAVE 158#ifdef USE_NONINTERLEAVE
161 .info = SNDRV_PCM_INFO_NONINTERLEAVED, 159 .info = SNDRV_PCM_INFO_NONINTERLEAVED,
162#else 160#else
@@ -180,7 +178,7 @@ static snd_pcm_hardware_t emu8k_pcm_hw = {
180/* 178/*
181 * get the current position at the given channel from CCCA register 179 * get the current position at the given channel from CCCA register
182 */ 180 */
183static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch) 181static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch)
184{ 182{
185 int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff; 183 int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff;
186 val -= rec->loop_start[ch] - 1; 184 val -= rec->loop_start[ch] - 1;
@@ -194,7 +192,7 @@ static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch)
194 */ 192 */
195static void emu8k_pcm_timer_func(unsigned long data) 193static void emu8k_pcm_timer_func(unsigned long data)
196{ 194{
197 emu8k_pcm_t *rec = (emu8k_pcm_t *)data; 195 struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data;
198 int ptr, delta; 196 int ptr, delta;
199 197
200 spin_lock(&rec->timer_lock); 198 spin_lock(&rec->timer_lock);
@@ -226,11 +224,11 @@ static void emu8k_pcm_timer_func(unsigned long data)
226 * open pcm 224 * open pcm
227 * creating an instance here 225 * creating an instance here
228 */ 226 */
229static int emu8k_pcm_open(snd_pcm_substream_t *subs) 227static int emu8k_pcm_open(struct snd_pcm_substream *subs)
230{ 228{
231 emu8000_t *emu = snd_pcm_substream_chip(subs); 229 struct snd_emu8000 *emu = snd_pcm_substream_chip(subs);
232 emu8k_pcm_t *rec; 230 struct snd_emu8k_pcm *rec;
233 snd_pcm_runtime_t *runtime = subs->runtime; 231 struct snd_pcm_runtime *runtime = subs->runtime;
234 232
235 rec = kzalloc(sizeof(*rec), GFP_KERNEL); 233 rec = kzalloc(sizeof(*rec), GFP_KERNEL);
236 if (! rec) 234 if (! rec)
@@ -256,9 +254,9 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs)
256 return 0; 254 return 0;
257} 255}
258 256
259static int emu8k_pcm_close(snd_pcm_substream_t *subs) 257static int emu8k_pcm_close(struct snd_pcm_substream *subs)
260{ 258{
261 emu8k_pcm_t *rec = subs->runtime->private_data; 259 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
262 kfree(rec); 260 kfree(rec);
263 subs->runtime->private_data = NULL; 261 subs->runtime->private_data = NULL;
264 return 0; 262 return 0;
@@ -281,9 +279,9 @@ static int calc_pitch_target(int pitch)
281/* 279/*
282 * set up the voice 280 * set up the voice
283 */ 281 */
284static void setup_voice(emu8k_pcm_t *rec, int ch) 282static void setup_voice(struct snd_emu8k_pcm *rec, int ch)
285{ 283{
286 emu8000_t *hw = rec->emu; 284 struct snd_emu8000 *hw = rec->emu;
287 unsigned int temp; 285 unsigned int temp;
288 286
289 /* channel to be silent and idle */ 287 /* channel to be silent and idle */
@@ -334,10 +332,10 @@ static void setup_voice(emu8k_pcm_t *rec, int ch)
334/* 332/*
335 * trigger the voice 333 * trigger the voice
336 */ 334 */
337static void start_voice(emu8k_pcm_t *rec, int ch) 335static void start_voice(struct snd_emu8k_pcm *rec, int ch)
338{ 336{
339 unsigned long flags; 337 unsigned long flags;
340 emu8000_t *hw = rec->emu; 338 struct snd_emu8000 *hw = rec->emu;
341 unsigned int temp, aux; 339 unsigned int temp, aux;
342 int pt = calc_pitch_target(rec->pitch); 340 int pt = calc_pitch_target(rec->pitch);
343 341
@@ -370,10 +368,10 @@ static void start_voice(emu8k_pcm_t *rec, int ch)
370/* 368/*
371 * stop the voice immediately 369 * stop the voice immediately
372 */ 370 */
373static void stop_voice(emu8k_pcm_t *rec, int ch) 371static void stop_voice(struct snd_emu8k_pcm *rec, int ch)
374{ 372{
375 unsigned long flags; 373 unsigned long flags;
376 emu8000_t *hw = rec->emu; 374 struct snd_emu8000 *hw = rec->emu;
377 375
378 EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); 376 EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F);
379 377
@@ -386,9 +384,9 @@ static void stop_voice(emu8k_pcm_t *rec, int ch)
386 spin_unlock_irqrestore(&rec->timer_lock, flags); 384 spin_unlock_irqrestore(&rec->timer_lock, flags);
387} 385}
388 386
389static int emu8k_pcm_trigger(snd_pcm_substream_t *subs, int cmd) 387static int emu8k_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
390{ 388{
391 emu8k_pcm_t *rec = subs->runtime->private_data; 389 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
392 int ch; 390 int ch;
393 391
394 switch (cmd) { 392 switch (cmd) {
@@ -428,7 +426,7 @@ do { \
428 426
429#ifdef USE_NONINTERLEAVE 427#ifdef USE_NONINTERLEAVE
430/* copy one channel block */ 428/* copy one channel block */
431static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, int count) 429static int emu8k_transfer_block(struct snd_emu8000 *emu, int offset, unsigned short *buf, int count)
432{ 430{
433 EMU8000_SMALW_WRITE(emu, offset); 431 EMU8000_SMALW_WRITE(emu, offset);
434 while (count > 0) { 432 while (count > 0) {
@@ -442,14 +440,14 @@ static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf,
442 return 0; 440 return 0;
443} 441}
444 442
445static int emu8k_pcm_copy(snd_pcm_substream_t *subs, 443static int emu8k_pcm_copy(struct snd_pcm_substream *subs,
446 int voice, 444 int voice,
447 snd_pcm_uframes_t pos, 445 snd_pcm_uframes_t pos,
448 void *src, 446 void *src,
449 snd_pcm_uframes_t count) 447 snd_pcm_uframes_t count)
450{ 448{
451 emu8k_pcm_t *rec = subs->runtime->private_data; 449 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
452 emu8000_t *emu = rec->emu; 450 struct snd_emu8000 *emu = rec->emu;
453 451
454 snd_emu8000_write_wait(emu, 1); 452 snd_emu8000_write_wait(emu, 1);
455 if (voice == -1) { 453 if (voice == -1) {
@@ -469,7 +467,7 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
469} 467}
470 468
471/* make a channel block silence */ 469/* make a channel block silence */
472static int emu8k_silence_block(emu8000_t *emu, int offset, int count) 470static int emu8k_silence_block(struct snd_emu8000 *emu, int offset, int count)
473{ 471{
474 EMU8000_SMALW_WRITE(emu, offset); 472 EMU8000_SMALW_WRITE(emu, offset);
475 while (count > 0) { 473 while (count > 0) {
@@ -480,13 +478,13 @@ static int emu8k_silence_block(emu8000_t *emu, int offset, int count)
480 return 0; 478 return 0;
481} 479}
482 480
483static int emu8k_pcm_silence(snd_pcm_substream_t *subs, 481static int emu8k_pcm_silence(struct snd_pcm_substream *subs,
484 int voice, 482 int voice,
485 snd_pcm_uframes_t pos, 483 snd_pcm_uframes_t pos,
486 snd_pcm_uframes_t count) 484 snd_pcm_uframes_t count)
487{ 485{
488 emu8k_pcm_t *rec = subs->runtime->private_data; 486 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
489 emu8000_t *emu = rec->emu; 487 struct snd_emu8000 *emu = rec->emu;
490 488
491 snd_emu8000_write_wait(emu, 1); 489 snd_emu8000_write_wait(emu, 1);
492 if (voice == -1 && rec->voices == 1) 490 if (voice == -1 && rec->voices == 1)
@@ -508,14 +506,14 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
508 * copy the interleaved data can be done easily by using 506 * copy the interleaved data can be done easily by using
509 * DMA "left" and "right" channels on emu8k engine. 507 * DMA "left" and "right" channels on emu8k engine.
510 */ 508 */
511static int emu8k_pcm_copy(snd_pcm_substream_t *subs, 509static int emu8k_pcm_copy(struct snd_pcm_substream *subs,
512 int voice, 510 int voice,
513 snd_pcm_uframes_t pos, 511 snd_pcm_uframes_t pos,
514 void __user *src, 512 void __user *src,
515 snd_pcm_uframes_t count) 513 snd_pcm_uframes_t count)
516{ 514{
517 emu8k_pcm_t *rec = subs->runtime->private_data; 515 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
518 emu8000_t *emu = rec->emu; 516 struct snd_emu8000 *emu = rec->emu;
519 unsigned short __user *buf = src; 517 unsigned short __user *buf = src;
520 518
521 snd_emu8000_write_wait(emu, 1); 519 snd_emu8000_write_wait(emu, 1);
@@ -539,13 +537,13 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
539 return 0; 537 return 0;
540} 538}
541 539
542static int emu8k_pcm_silence(snd_pcm_substream_t *subs, 540static int emu8k_pcm_silence(struct snd_pcm_substream *subs,
543 int voice, 541 int voice,
544 snd_pcm_uframes_t pos, 542 snd_pcm_uframes_t pos,
545 snd_pcm_uframes_t count) 543 snd_pcm_uframes_t count)
546{ 544{
547 emu8k_pcm_t *rec = subs->runtime->private_data; 545 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
548 emu8000_t *emu = rec->emu; 546 struct snd_emu8000 *emu = rec->emu;
549 547
550 snd_emu8000_write_wait(emu, 1); 548 snd_emu8000_write_wait(emu, 1);
551 EMU8000_SMALW_WRITE(emu, rec->loop_start[0] + pos); 549 EMU8000_SMALW_WRITE(emu, rec->loop_start[0] + pos);
@@ -567,10 +565,10 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
567/* 565/*
568 * allocate a memory block 566 * allocate a memory block
569 */ 567 */
570static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs, 568static int emu8k_pcm_hw_params(struct snd_pcm_substream *subs,
571 snd_pcm_hw_params_t *hw_params) 569 struct snd_pcm_hw_params *hw_params)
572{ 570{
573 emu8k_pcm_t *rec = subs->runtime->private_data; 571 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
574 572
575 if (rec->block) { 573 if (rec->block) {
576 /* reallocation - release the old block */ 574 /* reallocation - release the old block */
@@ -592,9 +590,9 @@ static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs,
592/* 590/*
593 * free the memory block 591 * free the memory block
594 */ 592 */
595static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs) 593static int emu8k_pcm_hw_free(struct snd_pcm_substream *subs)
596{ 594{
597 emu8k_pcm_t *rec = subs->runtime->private_data; 595 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
598 596
599 if (rec->block) { 597 if (rec->block) {
600 int ch; 598 int ch;
@@ -610,9 +608,9 @@ static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs)
610 608
611/* 609/*
612 */ 610 */
613static int emu8k_pcm_prepare(snd_pcm_substream_t *subs) 611static int emu8k_pcm_prepare(struct snd_pcm_substream *subs)
614{ 612{
615 emu8k_pcm_t *rec = subs->runtime->private_data; 613 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
616 614
617 rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate); 615 rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate);
618 rec->last_ptr = 0; 616 rec->last_ptr = 0;
@@ -656,16 +654,16 @@ static int emu8k_pcm_prepare(snd_pcm_substream_t *subs)
656 return 0; 654 return 0;
657} 655}
658 656
659static snd_pcm_uframes_t emu8k_pcm_pointer(snd_pcm_substream_t *subs) 657static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs)
660{ 658{
661 emu8k_pcm_t *rec = subs->runtime->private_data; 659 struct snd_emu8k_pcm *rec = subs->runtime->private_data;
662 if (rec->running) 660 if (rec->running)
663 return emu8k_get_curpos(rec, 0); 661 return emu8k_get_curpos(rec, 0);
664 return 0; 662 return 0;
665} 663}
666 664
667 665
668static snd_pcm_ops_t emu8k_pcm_ops = { 666static struct snd_pcm_ops emu8k_pcm_ops = {
669 .open = emu8k_pcm_open, 667 .open = emu8k_pcm_open,
670 .close = emu8k_pcm_close, 668 .close = emu8k_pcm_close,
671 .ioctl = snd_pcm_lib_ioctl, 669 .ioctl = snd_pcm_lib_ioctl,
@@ -679,15 +677,15 @@ static snd_pcm_ops_t emu8k_pcm_ops = {
679}; 677};
680 678
681 679
682static void snd_emu8000_pcm_free(snd_pcm_t *pcm) 680static void snd_emu8000_pcm_free(struct snd_pcm *pcm)
683{ 681{
684 emu8000_t *emu = pcm->private_data; 682 struct snd_emu8000 *emu = pcm->private_data;
685 emu->pcm = NULL; 683 emu->pcm = NULL;
686} 684}
687 685
688int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index) 686int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index)
689{ 687{
690 snd_pcm_t *pcm; 688 struct snd_pcm *pcm;
691 int err; 689 int err;
692 690
693 if ((err = snd_pcm_new(card, "Emu8000 PCM", index, 1, 0, &pcm)) < 0) 691 if ((err = snd_pcm_new(card, "Emu8000 PCM", index, 1, 0, &pcm)) < 0)
diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
index f68e217416a6..3d72742b342f 100644
--- a/sound/isa/sb/emu8000_synth.c
+++ b/sound/isa/sb/emu8000_synth.c
@@ -33,12 +33,12 @@ MODULE_LICENSE("GPL");
33/* 33/*
34 * create a new hardware dependent device for Emu8000 34 * create a new hardware dependent device for Emu8000
35 */ 35 */
36static int snd_emu8000_new_device(snd_seq_device_t *dev) 36static int snd_emu8000_new_device(struct snd_seq_device *dev)
37{ 37{
38 emu8000_t *hw; 38 struct snd_emu8000 *hw;
39 snd_emux_t *emu; 39 struct snd_emux *emu;
40 40
41 hw = *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); 41 hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev);
42 if (hw == NULL) 42 if (hw == NULL)
43 return -EINVAL; 43 return -EINVAL;
44 44
@@ -92,9 +92,9 @@ static int snd_emu8000_new_device(snd_seq_device_t *dev)
92/* 92/*
93 * free all resources 93 * free all resources
94 */ 94 */
95static int snd_emu8000_delete_device(snd_seq_device_t *dev) 95static int snd_emu8000_delete_device(struct snd_seq_device *dev)
96{ 96{
97 emu8000_t *hw; 97 struct snd_emu8000 *hw;
98 98
99 if (dev->driver_data == NULL) 99 if (dev->driver_data == NULL)
100 return 0; /* no synth was allocated actually */ 100 return 0; /* no synth was allocated actually */
@@ -118,11 +118,12 @@ static int snd_emu8000_delete_device(snd_seq_device_t *dev)
118static int __init alsa_emu8000_init(void) 118static int __init alsa_emu8000_init(void)
119{ 119{
120 120
121 static snd_seq_dev_ops_t ops = { 121 static struct snd_seq_dev_ops ops = {
122 snd_emu8000_new_device, 122 snd_emu8000_new_device,
123 snd_emu8000_delete_device, 123 snd_emu8000_delete_device,
124 }; 124 };
125 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops, sizeof(emu8000_t*)); 125 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops,
126 sizeof(struct snd_emu8000*));
126} 127}
127 128
128static void __exit alsa_emu8000_exit(void) 129static void __exit alsa_emu8000_exit(void)
diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c
index c859917c14db..9da80bfa3027 100644
--- a/sound/isa/sb/es968.c
+++ b/sound/isa/sb/es968.c
@@ -58,6 +58,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver.");
58 58
59struct snd_card_es968 { 59struct snd_card_es968 {
60 struct pnp_dev *dev; 60 struct pnp_dev *dev;
61 struct snd_sb *chip;
61}; 62};
62 63
63static struct pnp_card_device_id snd_es968_pnpids[] = { 64static struct pnp_card_device_id snd_es968_pnpids[] = {
@@ -72,7 +73,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids);
72static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id, 73static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id,
73 struct pt_regs *regs) 74 struct pt_regs *regs)
74{ 75{
75 sb_t *chip = dev_id; 76 struct snd_sb *chip = dev_id;
76 77
77 if (chip->open & SB_OPEN_PCM) { 78 if (chip->open & SB_OPEN_PCM) {
78 return snd_sb8dsp_interrupt(chip); 79 return snd_sb8dsp_interrupt(chip);
@@ -128,14 +129,14 @@ static int __init snd_card_es968_probe(int dev,
128 const struct pnp_card_device_id *pid) 129 const struct pnp_card_device_id *pid)
129{ 130{
130 int error; 131 int error;
131 sb_t *chip; 132 struct snd_sb *chip;
132 snd_card_t *card; 133 struct snd_card *card;
133 struct snd_card_es968 *acard; 134 struct snd_card_es968 *acard;
134 135
135 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 136 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
136 sizeof(struct snd_card_es968))) == NULL) 137 sizeof(struct snd_card_es968))) == NULL)
137 return -ENOMEM; 138 return -ENOMEM;
138 acard = (struct snd_card_es968 *)card->private_data; 139 acard = card->private_data;
139 if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { 140 if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) {
140 snd_card_free(card); 141 snd_card_free(card);
141 return error; 142 return error;
@@ -151,6 +152,7 @@ static int __init snd_card_es968_probe(int dev,
151 snd_card_free(card); 152 snd_card_free(card);
152 return error; 153 return error;
153 } 154 }
155 acard->chip = chip;
154 156
155 if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { 157 if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) {
156 snd_card_free(card); 158 snd_card_free(card);
@@ -200,30 +202,59 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card,
200 202
201static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) 203static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
202{ 204{
203 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 205 snd_card_free(pnp_get_card_drvdata(pcard));
206 pnp_set_card_drvdata(pcard, NULL);
207}
208
209#ifdef CONFIG_PM
210static int snd_es968_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
211{
212 struct snd_card *card = pnp_get_card_drvdata(pcard);
213 struct snd_card_es968 *acard = card->private_data;
214 struct snd_sb *chip = acard->chip;
204 215
205 snd_card_disconnect(card); 216 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
206 snd_card_free_in_thread(card); 217 snd_pcm_suspend_all(chip->pcm);
218 snd_sbmixer_suspend(chip);
219 return 0;
207} 220}
208 221
222static int snd_es968_pnp_resume(struct pnp_card_link *pcard)
223{
224 struct snd_card *card = pnp_get_card_drvdata(pcard);
225 struct snd_card_es968 *acard = card->private_data;
226 struct snd_sb *chip = acard->chip;
227
228 snd_sbdsp_reset(chip);
229 snd_sbmixer_resume(chip);
230 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
231 return 0;
232}
233#endif
234
209static struct pnp_card_driver es968_pnpc_driver = { 235static struct pnp_card_driver es968_pnpc_driver = {
210 .flags = PNP_DRIVER_RES_DISABLE, 236 .flags = PNP_DRIVER_RES_DISABLE,
211 .name = "es968", 237 .name = "es968",
212 .id_table = snd_es968_pnpids, 238 .id_table = snd_es968_pnpids,
213 .probe = snd_es968_pnp_detect, 239 .probe = snd_es968_pnp_detect,
214 .remove = __devexit_p(snd_es968_pnp_remove), 240 .remove = __devexit_p(snd_es968_pnp_remove),
241#ifdef CONFIG_PM
242 .suspend = snd_es968_pnp_suspend,
243 .resume = snd_es968_pnp_resume,
244#endif
215}; 245};
216 246
217static int __init alsa_card_es968_init(void) 247static int __init alsa_card_es968_init(void)
218{ 248{
219 int cards = pnp_register_card_driver(&es968_pnpc_driver); 249 int cards = pnp_register_card_driver(&es968_pnpc_driver);
220#ifdef MODULE 250 if (cards <= 0) {
221 if (cards == 0) {
222 pnp_unregister_card_driver(&es968_pnpc_driver); 251 pnp_unregister_card_driver(&es968_pnpc_driver);
252#ifdef MODULE
223 snd_printk(KERN_ERR "no ES968 based soundcards found\n"); 253 snd_printk(KERN_ERR "no ES968 based soundcards found\n");
224 }
225#endif 254#endif
226 return cards ? 0 : -ENODEV; 255 return -ENODEV;
256 }
257 return 0;
227} 258}
228 259
229static void __exit alsa_card_es968_exit(void) 260static void __exit alsa_card_es968_exit(void)
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index c2fa451bc8f0..c0be7a5a3425 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -24,6 +24,8 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27#include <linux/err.h>
28#include <linux/platform_device.h>
27#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
28#include <sound/core.h> 30#include <sound/core.h>
29#include <sound/sb.h> 31#include <sound/sb.h>
@@ -32,7 +34,6 @@
32#include <sound/opl3.h> 34#include <sound/opl3.h>
33#include <sound/emu8000.h> 35#include <sound/emu8000.h>
34#include <sound/seq_device.h> 36#include <sound/seq_device.h>
35#define SNDRV_LEGACY_AUTO_PROBE
36#define SNDRV_LEGACY_FIND_FREE_IRQ 37#define SNDRV_LEGACY_FIND_FREE_IRQ
37#define SNDRV_LEGACY_FIND_FREE_DMA 38#define SNDRV_LEGACY_FIND_FREE_DMA
38#include <sound/initval.h> 39#include <sound/initval.h>
@@ -127,8 +128,14 @@ module_param_array(seq_ports, int, NULL, 0444);
127MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); 128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
128#endif 129#endif
129 130
131static struct platform_device *platform_devices[SNDRV_CARDS];
132#ifdef CONFIG_PNP
133static int pnp_registered;
134#endif
135
130struct snd_card_sb16 { 136struct snd_card_sb16 {
131 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 137 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
138 struct snd_sb *chip;
132#ifdef CONFIG_PNP 139#ifdef CONFIG_PNP
133 int dev_no; 140 int dev_no;
134 struct pnp_dev *dev; 141 struct pnp_dev *dev;
@@ -138,8 +145,6 @@ struct snd_card_sb16 {
138#endif 145#endif
139}; 146};
140 147
141static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
142
143#ifdef CONFIG_PNP 148#ifdef CONFIG_PNP
144 149
145static struct pnp_card_device_id snd_sb16_pnpids[] = { 150static struct pnp_card_device_id snd_sb16_pnpids[] = {
@@ -339,9 +344,9 @@ __wt_error:
339 344
340#endif /* CONFIG_PNP */ 345#endif /* CONFIG_PNP */
341 346
342static void snd_sb16_free(snd_card_t *card) 347static void snd_sb16_free(struct snd_card *card)
343{ 348{
344 struct snd_card_sb16 *acard = (struct snd_card_sb16 *)card->private_data; 349 struct snd_card_sb16 *acard = card->private_data;
345 350
346 if (acard == NULL) 351 if (acard == NULL)
347 return; 352 return;
@@ -354,73 +359,32 @@ static void snd_sb16_free(snd_card_t *card)
354#define is_isapnp_selected(dev) 0 359#define is_isapnp_selected(dev) 0
355#endif 360#endif
356 361
357static int __init snd_sb16_probe(int dev, 362static struct snd_card *snd_sb16_card_new(int dev)
358 struct pnp_card_link *pcard, 363{
359 const struct pnp_card_device_id *pid) 364 struct snd_card *card = snd_card_new(index[dev], id[dev], THIS_MODULE,
365 sizeof(struct snd_card_sb16));
366 if (card == NULL)
367 return NULL;
368 card->private_free = snd_sb16_free;
369 return card;
370}
371
372static int __init snd_sb16_probe(struct snd_card *card, int dev)
360{ 373{
361 static int possible_irqs[] = {5, 9, 10, 7, -1};
362 static int possible_dmas8[] = {1, 3, 0, -1};
363 static int possible_dmas16[] = {5, 6, 7, -1};
364 int xirq, xdma8, xdma16; 374 int xirq, xdma8, xdma16;
365 sb_t *chip; 375 struct snd_sb *chip;
366 snd_card_t *card; 376 struct snd_card_sb16 *acard = card->private_data;
367 struct snd_card_sb16 *acard; 377 struct snd_opl3 *opl3;
368 opl3_t *opl3; 378 struct snd_hwdep *synth = NULL;
369 snd_hwdep_t *synth = NULL;
370#ifdef CONFIG_SND_SB16_CSP 379#ifdef CONFIG_SND_SB16_CSP
371 snd_hwdep_t *xcsp = NULL; 380 struct snd_hwdep *xcsp = NULL;
372#endif 381#endif
373 unsigned long flags; 382 unsigned long flags;
374 int err; 383 int err;
375 384
376 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
377 sizeof(struct snd_card_sb16));
378 if (card == NULL)
379 return -ENOMEM;
380 acard = (struct snd_card_sb16 *) card->private_data;
381 card->private_free = snd_sb16_free;
382#ifdef CONFIG_PNP
383 if (isapnp[dev]) {
384 if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid)))
385 goto _err;
386 snd_card_set_dev(card, &pcard->card->dev);
387 }
388#endif
389
390 xirq = irq[dev]; 385 xirq = irq[dev];
391 xdma8 = dma8[dev]; 386 xdma8 = dma8[dev];
392 xdma16 = dma16[dev]; 387 xdma16 = dma16[dev];
393 if (! is_isapnp_selected(dev)) {
394 if (xirq == SNDRV_AUTO_IRQ) {
395 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
396 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
397 err = -EBUSY;
398 goto _err;
399 }
400 }
401 if (xdma8 == SNDRV_AUTO_DMA) {
402 if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
403 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");
404 err = -EBUSY;
405 goto _err;
406 }
407 }
408 if (xdma16 == SNDRV_AUTO_DMA) {
409 if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
410 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");
411 err = -EBUSY;
412 goto _err;
413 }
414 }
415 /* non-PnP FM port address is hardwired with base port address */
416 fm_port[dev] = port[dev];
417 /* block the 0x388 port to avoid PnP conflicts */
418 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
419#ifdef SNDRV_SBAWE_EMU8000
420 /* non-PnP AWE port address is hardwired with base port address */
421 awe_port[dev] = port[dev] + 0x400;
422#endif
423 }
424 388
425 if ((err = snd_sbdsp_create(card, 389 if ((err = snd_sbdsp_create(card,
426 port[dev], 390 port[dev],
@@ -430,19 +394,19 @@ static int __init snd_sb16_probe(int dev,
430 xdma16, 394 xdma16,
431 SB_HW_AUTO, 395 SB_HW_AUTO,
432 &chip)) < 0) 396 &chip)) < 0)
433 goto _err; 397 return err;
434 398
399 acard->chip = chip;
435 if (chip->hardware != SB_HW_16) { 400 if (chip->hardware != SB_HW_16) {
436 snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]); 401 snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]);
437 err = -ENODEV; 402 return -ENODEV;
438 goto _err;
439 } 403 }
440 chip->mpu_port = mpu_port[dev]; 404 chip->mpu_port = mpu_port[dev];
441 if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) 405 if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0)
442 goto _err; 406 return err;
443 407
444 if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) 408 if ((err = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0)
445 goto _err; 409 return err;
446 410
447 strcpy(card->driver, 411 strcpy(card->driver,
448#ifdef SNDRV_SBAWE_EMU8000 412#ifdef SNDRV_SBAWE_EMU8000
@@ -464,7 +428,7 @@ static int __init snd_sb16_probe(int dev,
464 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, 428 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
465 chip->mpu_port, 0, 429 chip->mpu_port, 0,
466 xirq, 0, &chip->rmidi)) < 0) 430 xirq, 0, &chip->rmidi)) < 0)
467 goto _err; 431 return err;
468 chip->rmidi_callback = snd_mpu401_uart_interrupt; 432 chip->rmidi_callback = snd_mpu401_uart_interrupt;
469 } 433 }
470 434
@@ -487,12 +451,12 @@ static int __init snd_sb16_probe(int dev,
487 int seqdev = 1; 451 int seqdev = 1;
488#endif 452#endif
489 if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) 453 if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0)
490 goto _err; 454 return err;
491 } 455 }
492 } 456 }
493 457
494 if ((err = snd_sbmixer_new(chip)) < 0) 458 if ((err = snd_sbmixer_new(chip)) < 0)
495 goto _err; 459 return err;
496 460
497#ifdef CONFIG_SND_SB16_CSP 461#ifdef CONFIG_SND_SB16_CSP
498 /* CSP chip on SB16ASP/AWE32 */ 462 /* CSP chip on SB16ASP/AWE32 */
@@ -512,7 +476,7 @@ static int __init snd_sb16_probe(int dev,
512 seq_ports[dev], NULL)) < 0) { 476 seq_ports[dev], NULL)) < 0) {
513 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); 477 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]);
514 478
515 goto _err; 479 return err;
516 } 480 }
517 } 481 }
518#endif 482#endif
@@ -524,56 +488,168 @@ static int __init snd_sb16_probe(int dev,
524 (mic_agc[dev] ? 0x00 : 0x01)); 488 (mic_agc[dev] ? 0x00 : 0x01));
525 spin_unlock_irqrestore(&chip->mixer_lock, flags); 489 spin_unlock_irqrestore(&chip->mixer_lock, flags);
526 490
527 if ((err = snd_card_set_generic_dev(card)) < 0)
528 goto _err;
529
530 if ((err = snd_card_register(card)) < 0) 491 if ((err = snd_card_register(card)) < 0)
531 goto _err; 492 return err;
532 493
533 if (pcard)
534 pnp_set_card_drvdata(pcard, card);
535 else
536 snd_sb16_legacy[dev] = card;
537 return 0; 494 return 0;
495}
538 496
539 _err: 497#ifdef CONFIG_PM
540 snd_card_free(card); 498static int snd_sb16_suspend(struct snd_card *card, pm_message_t state)
541 return err; 499{
500 struct snd_card_sb16 *acard = card->private_data;
501 struct snd_sb *chip = acard->chip;
502
503 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
504 snd_pcm_suspend_all(chip->pcm);
505 snd_sbmixer_suspend(chip);
506 return 0;
542} 507}
543 508
544static int __init snd_sb16_probe_legacy_port(unsigned long xport) 509static int snd_sb16_resume(struct snd_card *card)
545{ 510{
546 static int dev; 511 struct snd_card_sb16 *acard = card->private_data;
547 int res; 512 struct snd_sb *chip = acard->chip;
548 513
549 for ( ; dev < SNDRV_CARDS; dev++) { 514 snd_sbdsp_reset(chip);
550 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 515 snd_sbmixer_resume(chip);
551 continue; 516 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
552 if (is_isapnp_selected(dev)) 517 return 0;
553 continue; 518}
554 port[dev] = xport; 519#endif
555 res = snd_sb16_probe(dev, NULL, NULL); 520
556 if (res < 0) 521static int __init snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr)
557 port[dev] = SNDRV_AUTO_PORT; 522{
558 return res; 523 struct snd_card_sb16 *acard;
524 struct snd_card *card;
525 int err;
526
527 card = snd_sb16_card_new(dev);
528 if (! card)
529 return -ENOMEM;
530
531 acard = card->private_data;
532 /* non-PnP FM port address is hardwired with base port address */
533 fm_port[dev] = port[dev];
534 /* block the 0x388 port to avoid PnP conflicts */
535 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
536#ifdef SNDRV_SBAWE_EMU8000
537 /* non-PnP AWE port address is hardwired with base port address */
538 awe_port[dev] = port[dev] + 0x400;
539#endif
540
541 snd_card_set_dev(card, &devptr->dev);
542 if ((err = snd_sb16_probe(card, dev)) < 0) {
543 snd_card_free(card);
544 return err;
559 } 545 }
560 return -ENODEV; 546 platform_set_drvdata(devptr, card);
547 return 0;
561} 548}
562 549
550
551static int __init snd_sb16_nonpnp_probe(struct platform_device *pdev)
552{
553 int dev = pdev->id;
554 int err;
555 static int possible_irqs[] = {5, 9, 10, 7, -1};
556 static int possible_dmas8[] = {1, 3, 0, -1};
557 static int possible_dmas16[] = {5, 6, 7, -1};
558
559 if (irq[dev] == SNDRV_AUTO_IRQ) {
560 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
561 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
562 return -EBUSY;
563 }
564 }
565 if (dma8[dev] == SNDRV_AUTO_DMA) {
566 if ((dma8[dev] = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
567 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");
568 return -EBUSY;
569 }
570 }
571 if (dma16[dev] == SNDRV_AUTO_DMA) {
572 if ((dma16[dev] = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
573 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");
574 return -EBUSY;
575 }
576 }
577
578 if (port[dev] != SNDRV_AUTO_PORT)
579 return snd_sb16_nonpnp_probe1(dev, pdev);
580 else {
581 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280};
582 int i;
583 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
584 port[dev] = possible_ports[i];
585 err = snd_sb16_nonpnp_probe1(dev, pdev);
586 if (! err)
587 return 0;
588 }
589 return err;
590 }
591}
592
593static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr)
594{
595 snd_card_free(platform_get_drvdata(devptr));
596 platform_set_drvdata(devptr, NULL);
597 return 0;
598}
599
600#ifdef CONFIG_PM
601static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state)
602{
603 return snd_sb16_suspend(platform_get_drvdata(dev), state);
604}
605
606static int snd_sb16_nonpnp_resume(struct platform_device *dev)
607{
608 return snd_sb16_resume(platform_get_drvdata(dev));
609}
610#endif
611
612#ifdef SNDRV_SBAWE
613#define SND_SB16_DRIVER "snd_sbawe"
614#else
615#define SND_SB16_DRIVER "snd_sb16"
616#endif
617
618static struct platform_driver snd_sb16_nonpnp_driver = {
619 .probe = snd_sb16_nonpnp_probe,
620 .remove = __devexit_p(snd_sb16_nonpnp_remove),
621#ifdef CONFIG_PM
622 .suspend = snd_sb16_nonpnp_suspend,
623 .resume = snd_sb16_nonpnp_resume,
624#endif
625 .driver = {
626 .name = SND_SB16_DRIVER
627 },
628};
629
630
563#ifdef CONFIG_PNP 631#ifdef CONFIG_PNP
564 632
565static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, 633static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
566 const struct pnp_card_device_id *id) 634 const struct pnp_card_device_id *pid)
567{ 635{
568 static int dev; 636 static int dev;
637 struct snd_card *card;
569 int res; 638 int res;
570 639
571 for ( ; dev < SNDRV_CARDS; dev++) { 640 for ( ; dev < SNDRV_CARDS; dev++) {
572 if (!enable[dev] || !isapnp[dev]) 641 if (!enable[dev] || !isapnp[dev])
573 continue; 642 continue;
574 res = snd_sb16_probe(dev, card, id); 643 card = snd_sb16_card_new(dev);
575 if (res < 0) 644 if (! card)
645 return -ENOMEM;
646 snd_card_set_dev(card, &pcard->card->dev);
647 if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 ||
648 (res = snd_sb16_probe(card, dev)) < 0) {
649 snd_card_free(card);
576 return res; 650 return res;
651 }
652 pnp_set_card_drvdata(pcard, card);
577 dev++; 653 dev++;
578 return 0; 654 return 0;
579 } 655 }
@@ -583,57 +659,82 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card,
583 659
584static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard) 660static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard)
585{ 661{
586 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 662 snd_card_free(pnp_get_card_drvdata(pcard));
663 pnp_set_card_drvdata(pcard, NULL);
664}
587 665
588 snd_card_disconnect(card); 666#ifdef CONFIG_PM
589 snd_card_free_in_thread(card); 667static int snd_sb16_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
668{
669 return snd_sb16_suspend(pnp_get_card_drvdata(pcard), state);
590} 670}
671static int snd_sb16_pnp_resume(struct pnp_card_link *pcard)
672{
673 return snd_sb16_resume(pnp_get_card_drvdata(pcard));
674}
675#endif
591 676
592static struct pnp_card_driver sb16_pnpc_driver = { 677static struct pnp_card_driver sb16_pnpc_driver = {
593 .flags = PNP_DRIVER_RES_DISABLE, 678 .flags = PNP_DRIVER_RES_DISABLE,
679#ifdef SNDRV_SBAWE
680 .name = "sbawe",
681#else
594 .name = "sb16", 682 .name = "sb16",
683#endif
595 .id_table = snd_sb16_pnpids, 684 .id_table = snd_sb16_pnpids,
596 .probe = snd_sb16_pnp_detect, 685 .probe = snd_sb16_pnp_detect,
597 .remove = __devexit_p(snd_sb16_pnp_remove), 686 .remove = __devexit_p(snd_sb16_pnp_remove),
687#ifdef CONFIG_PM
688 .suspend = snd_sb16_pnp_suspend,
689 .resume = snd_sb16_pnp_resume,
690#endif
598}; 691};
599 692
600#endif /* CONFIG_PNP */ 693#endif /* CONFIG_PNP */
601 694
695static void __init_or_module snd_sb16_unregister_all(void)
696{
697 int i;
698
699#ifdef CONFIG_PNP
700 if (pnp_registered)
701 pnp_unregister_card_driver(&sb16_pnpc_driver);
702#endif
703 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
704 platform_device_unregister(platform_devices[i]);
705 platform_driver_unregister(&snd_sb16_nonpnp_driver);
706}
707
602static int __init alsa_card_sb16_init(void) 708static int __init alsa_card_sb16_init(void)
603{ 709{
604 int dev, cards = 0, i; 710 int i, err, cards = 0;
605 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1};
606 711
607 /* legacy non-auto cards at first */ 712 if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0)
608 for (dev = 0; dev < SNDRV_CARDS; dev++) { 713 return err;
609 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 714
610 continue; 715 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
611 if (is_isapnp_selected(dev)) 716 struct platform_device *device;
612 continue; 717 if (is_isapnp_selected(i))
613 if (!snd_sb16_probe(dev, NULL, NULL)) {
614 cards++;
615 continue; 718 continue;
719 device = platform_device_register_simple(SND_SB16_DRIVER,
720 i, NULL, 0);
721 if (IS_ERR(device)) {
722 err = PTR_ERR(device);
723 goto errout;
616 } 724 }
617#ifdef MODULE 725 platform_devices[i] = device;
618 snd_printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); 726 cards++;
619#endif
620 } 727 }
621 /* legacy auto configured cards */
622 i = snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port);
623 if (i > 0)
624 cards += i;
625
626#ifdef CONFIG_PNP 728#ifdef CONFIG_PNP
627 /* PnP cards at last */ 729 /* PnP cards at last */
628 i = pnp_register_card_driver(&sb16_pnpc_driver); 730 i = pnp_register_card_driver(&sb16_pnpc_driver);
629 if (i >0) 731 if (i >= 0) {
732 pnp_registered = 1;
630 cards += i; 733 cards += i;
734 }
631#endif 735#endif
632 736
633 if (!cards) { 737 if (!cards) {
634#ifdef CONFIG_PNP
635 pnp_unregister_card_driver(&sb16_pnpc_driver);
636#endif
637#ifdef MODULE 738#ifdef MODULE
638 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); 739 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");
639#ifdef SNDRV_SBAWE_EMU8000 740#ifdef SNDRV_SBAWE_EMU8000
@@ -642,21 +743,19 @@ static int __init alsa_card_sb16_init(void)
642 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); 743 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");
643#endif 744#endif
644#endif 745#endif
645 return -ENODEV; 746 err = -ENODEV;
747 goto errout;
646 } 748 }
647 return 0; 749 return 0;
750
751 errout:
752 snd_sb16_unregister_all();
753 return err;
648} 754}
649 755
650static void __exit alsa_card_sb16_exit(void) 756static void __exit alsa_card_sb16_exit(void)
651{ 757{
652 int dev; 758 snd_sb16_unregister_all();
653
654#ifdef CONFIG_PNP
655 /* PnP cards first */
656 pnp_unregister_card_driver(&sb16_pnpc_driver);
657#endif
658 for (dev = 0; dev < SNDRV_CARDS; dev++)
659 snd_card_free(snd_sb16_legacy[dev]);
660} 759}
661 760
662module_init(alsa_card_sb16_init) 761module_init(alsa_card_sb16_init)
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index 7192d4c758e6..9c2b5efbacbf 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -72,46 +72,47 @@ struct desc_header {
72/* 72/*
73 * prototypes 73 * prototypes
74 */ 74 */
75static void snd_sb_csp_free(snd_hwdep_t *hw); 75static void snd_sb_csp_free(struct snd_hwdep *hw);
76static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file); 76static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file);
77static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg); 77static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg);
78static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file); 78static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file);
79 79
80static int csp_detect(sb_t *chip, int *version); 80static int csp_detect(struct snd_sb *chip, int *version);
81static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val); 81static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val);
82static int set_register(sb_t *chip, unsigned char reg, unsigned char val); 82static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val);
83static int read_register(sb_t *chip, unsigned char reg); 83static int read_register(struct snd_sb *chip, unsigned char reg);
84static int set_mode_register(sb_t *chip, unsigned char mode); 84static int set_mode_register(struct snd_sb *chip, unsigned char mode);
85static int get_version(sb_t *chip); 85static int get_version(struct snd_sb *chip);
86 86
87static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * code); 87static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
88static int snd_sb_csp_unload(snd_sb_csp_t * p); 88 struct snd_sb_csp_microcode __user * code);
89static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags); 89static int snd_sb_csp_unload(struct snd_sb_csp * p);
90static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode); 90static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags);
91static int snd_sb_csp_check_version(snd_sb_csp_t * p); 91static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode);
92 92static int snd_sb_csp_check_version(struct snd_sb_csp * p);
93static int snd_sb_csp_use(snd_sb_csp_t * p); 93
94static int snd_sb_csp_unuse(snd_sb_csp_t * p); 94static int snd_sb_csp_use(struct snd_sb_csp * p);
95static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels); 95static int snd_sb_csp_unuse(struct snd_sb_csp * p);
96static int snd_sb_csp_stop(snd_sb_csp_t * p); 96static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels);
97static int snd_sb_csp_pause(snd_sb_csp_t * p); 97static int snd_sb_csp_stop(struct snd_sb_csp * p);
98static int snd_sb_csp_restart(snd_sb_csp_t * p); 98static int snd_sb_csp_pause(struct snd_sb_csp * p);
99 99static int snd_sb_csp_restart(struct snd_sb_csp * p);
100static int snd_sb_qsound_build(snd_sb_csp_t * p); 100
101static void snd_sb_qsound_destroy(snd_sb_csp_t * p); 101static int snd_sb_qsound_build(struct snd_sb_csp * p);
102static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p); 102static void snd_sb_qsound_destroy(struct snd_sb_csp * p);
103 103static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p);
104static int init_proc_entry(snd_sb_csp_t * p, int device); 104
105static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); 105static int init_proc_entry(struct snd_sb_csp * p, int device);
106static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer);
106 107
107/* 108/*
108 * Detect CSP chip and create a new instance 109 * Detect CSP chip and create a new instance
109 */ 110 */
110int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) 111int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
111{ 112{
112 snd_sb_csp_t *p; 113 struct snd_sb_csp *p;
113 int version, err; 114 int version, err;
114 snd_hwdep_t *hw; 115 struct snd_hwdep *hw;
115 116
116 if (rhwdep) 117 if (rhwdep)
117 *rhwdep = NULL; 118 *rhwdep = NULL;
@@ -158,9 +159,9 @@ int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep)
158/* 159/*
159 * free_private for hwdep instance 160 * free_private for hwdep instance
160 */ 161 */
161static void snd_sb_csp_free(snd_hwdep_t *hwdep) 162static void snd_sb_csp_free(struct snd_hwdep *hwdep)
162{ 163{
163 snd_sb_csp_t *p = hwdep->private_data; 164 struct snd_sb_csp *p = hwdep->private_data;
164 if (p) { 165 if (p) {
165 if (p->running & SNDRV_SB_CSP_ST_RUNNING) 166 if (p->running & SNDRV_SB_CSP_ST_RUNNING)
166 snd_sb_csp_stop(p); 167 snd_sb_csp_stop(p);
@@ -173,20 +174,20 @@ static void snd_sb_csp_free(snd_hwdep_t *hwdep)
173/* 174/*
174 * open the device exclusively 175 * open the device exclusively
175 */ 176 */
176static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file) 177static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file)
177{ 178{
178 snd_sb_csp_t *p = hw->private_data; 179 struct snd_sb_csp *p = hw->private_data;
179 return (snd_sb_csp_use(p)); 180 return (snd_sb_csp_use(p));
180} 181}
181 182
182/* 183/*
183 * ioctl for hwdep device: 184 * ioctl for hwdep device:
184 */ 185 */
185static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) 186static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg)
186{ 187{
187 snd_sb_csp_t *p = hw->private_data; 188 struct snd_sb_csp *p = hw->private_data;
188 snd_sb_csp_info_t info; 189 struct snd_sb_csp_info info;
189 snd_sb_csp_start_t start_info; 190 struct snd_sb_csp_start start_info;
190 int err; 191 int err;
191 192
192 snd_assert(p != NULL, return -EINVAL); 193 snd_assert(p != NULL, return -EINVAL);
@@ -217,7 +218,7 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm
217 /* load CSP microcode */ 218 /* load CSP microcode */
218 case SNDRV_SB_CSP_IOCTL_LOAD_CODE: 219 case SNDRV_SB_CSP_IOCTL_LOAD_CODE:
219 err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? 220 err = (p->running & SNDRV_SB_CSP_ST_RUNNING ?
220 -EBUSY : snd_sb_csp_riff_load(p, (snd_sb_csp_microcode_t __user *) arg)); 221 -EBUSY : snd_sb_csp_riff_load(p, (struct snd_sb_csp_microcode __user *) arg));
221 break; 222 break;
222 case SNDRV_SB_CSP_IOCTL_UNLOAD_CODE: 223 case SNDRV_SB_CSP_IOCTL_UNLOAD_CODE:
223 err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? 224 err = (p->running & SNDRV_SB_CSP_ST_RUNNING ?
@@ -251,9 +252,9 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm
251/* 252/*
252 * close the device 253 * close the device
253 */ 254 */
254static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file) 255static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file)
255{ 256{
256 snd_sb_csp_t *p = hw->private_data; 257 struct snd_sb_csp *p = hw->private_data;
257 return (snd_sb_csp_unuse(p)); 258 return (snd_sb_csp_unuse(p));
258} 259}
259 260
@@ -262,7 +263,7 @@ static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file)
262/* 263/*
263 * acquire device 264 * acquire device
264 */ 265 */
265static int snd_sb_csp_use(snd_sb_csp_t * p) 266static int snd_sb_csp_use(struct snd_sb_csp * p)
266{ 267{
267 down(&p->access_mutex); 268 down(&p->access_mutex);
268 if (p->used) { 269 if (p->used) {
@@ -279,7 +280,7 @@ static int snd_sb_csp_use(snd_sb_csp_t * p)
279/* 280/*
280 * release device 281 * release device
281 */ 282 */
282static int snd_sb_csp_unuse(snd_sb_csp_t * p) 283static int snd_sb_csp_unuse(struct snd_sb_csp * p)
283{ 284{
284 down(&p->access_mutex); 285 down(&p->access_mutex);
285 p->used--; 286 p->used--;
@@ -292,9 +293,10 @@ static int snd_sb_csp_unuse(snd_sb_csp_t * p)
292 * load microcode via ioctl: 293 * load microcode via ioctl:
293 * code is user-space pointer 294 * code is user-space pointer
294 */ 295 */
295static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * mcode) 296static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
297 struct snd_sb_csp_microcode __user * mcode)
296{ 298{
297 snd_sb_csp_mc_header_t info; 299 struct snd_sb_csp_mc_header info;
298 300
299 unsigned char __user *data_ptr; 301 unsigned char __user *data_ptr;
300 unsigned char __user *data_end; 302 unsigned char __user *data_end;
@@ -449,7 +451,7 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user
449/* 451/*
450 * unload CSP microcode 452 * unload CSP microcode
451 */ 453 */
452static int snd_sb_csp_unload(snd_sb_csp_t * p) 454static int snd_sb_csp_unload(struct snd_sb_csp * p)
453{ 455{
454 if (p->running & SNDRV_SB_CSP_ST_RUNNING) 456 if (p->running & SNDRV_SB_CSP_ST_RUNNING)
455 return -EBUSY; 457 return -EBUSY;
@@ -472,7 +474,7 @@ static int snd_sb_csp_unload(snd_sb_csp_t * p)
472/* 474/*
473 * send command sequence to DSP 475 * send command sequence to DSP
474 */ 476 */
475static inline int command_seq(sb_t *chip, const unsigned char *seq, int size) 477static inline int command_seq(struct snd_sb *chip, const unsigned char *seq, int size)
476{ 478{
477 int i; 479 int i;
478 for (i = 0; i < size; i++) { 480 for (i = 0; i < size; i++) {
@@ -485,7 +487,7 @@ static inline int command_seq(sb_t *chip, const unsigned char *seq, int size)
485/* 487/*
486 * set CSP codec parameter 488 * set CSP codec parameter
487 */ 489 */
488static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val) 490static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val)
489{ 491{
490 unsigned char dsp_cmd[3]; 492 unsigned char dsp_cmd[3];
491 493
@@ -502,7 +504,7 @@ static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val)
502/* 504/*
503 * set CSP register 505 * set CSP register
504 */ 506 */
505static int set_register(sb_t *chip, unsigned char reg, unsigned char val) 507static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val)
506{ 508{
507 unsigned char dsp_cmd[3]; 509 unsigned char dsp_cmd[3];
508 510
@@ -516,7 +518,7 @@ static int set_register(sb_t *chip, unsigned char reg, unsigned char val)
516 * read CSP register 518 * read CSP register
517 * return < 0 -> error 519 * return < 0 -> error
518 */ 520 */
519static int read_register(sb_t *chip, unsigned char reg) 521static int read_register(struct snd_sb *chip, unsigned char reg)
520{ 522{
521 unsigned char dsp_cmd[2]; 523 unsigned char dsp_cmd[2];
522 524
@@ -529,7 +531,7 @@ static int read_register(sb_t *chip, unsigned char reg)
529/* 531/*
530 * set CSP mode register 532 * set CSP mode register
531 */ 533 */
532static int set_mode_register(sb_t *chip, unsigned char mode) 534static int set_mode_register(struct snd_sb *chip, unsigned char mode)
533{ 535{
534 unsigned char dsp_cmd[2]; 536 unsigned char dsp_cmd[2];
535 537
@@ -542,7 +544,7 @@ static int set_mode_register(sb_t *chip, unsigned char mode)
542 * Detect CSP 544 * Detect CSP
543 * return 0 if CSP exists. 545 * return 0 if CSP exists.
544 */ 546 */
545static int csp_detect(sb_t *chip, int *version) 547static int csp_detect(struct snd_sb *chip, int *version)
546{ 548{
547 unsigned char csp_test1, csp_test2; 549 unsigned char csp_test1, csp_test2;
548 unsigned long flags; 550 unsigned long flags;
@@ -579,7 +581,7 @@ static int csp_detect(sb_t *chip, int *version)
579/* 581/*
580 * get CSP version number 582 * get CSP version number
581 */ 583 */
582static int get_version(sb_t *chip) 584static int get_version(struct snd_sb *chip)
583{ 585{
584 unsigned char dsp_cmd[2]; 586 unsigned char dsp_cmd[2];
585 587
@@ -593,7 +595,7 @@ static int get_version(sb_t *chip)
593/* 595/*
594 * check if the CSP version is valid 596 * check if the CSP version is valid
595 */ 597 */
596static int snd_sb_csp_check_version(snd_sb_csp_t * p) 598static int snd_sb_csp_check_version(struct snd_sb_csp * p)
597{ 599{
598 if (p->version < 0x10 || p->version > 0x1f) { 600 if (p->version < 0x10 || p->version > 0x1f) {
599 snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version); 601 snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version);
@@ -605,7 +607,7 @@ static int snd_sb_csp_check_version(snd_sb_csp_t * p)
605/* 607/*
606 * download microcode to CSP (microcode should have one "main" block). 608 * download microcode to CSP (microcode should have one "main" block).
607 */ 609 */
608static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size, int load_flags) 610static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int size, int load_flags)
609{ 611{
610 int status, i; 612 int status, i;
611 int err; 613 int err;
@@ -671,7 +673,7 @@ static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size,
671 return result; 673 return result;
672} 674}
673 675
674static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags) 676static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags)
675{ 677{
676 int err = -ENOMEM; 678 int err = -ENOMEM;
677 unsigned char *kbuf = kmalloc(size, GFP_KERNEL); 679 unsigned char *kbuf = kmalloc(size, GFP_KERNEL);
@@ -691,7 +693,7 @@ static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *bu
691 * autoload hardware codec if necessary 693 * autoload hardware codec if necessary
692 * return 0 if CSP is loaded and ready to run (p->running != 0) 694 * return 0 if CSP is loaded and ready to run (p->running != 0)
693 */ 695 */
694static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode) 696static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode)
695{ 697{
696 unsigned long flags; 698 unsigned long flags;
697 int err = 0; 699 int err = 0;
@@ -763,7 +765,7 @@ static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode
763/* 765/*
764 * start CSP 766 * start CSP
765 */ 767 */
766static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels) 768static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels)
767{ 769{
768 unsigned char s_type; /* sample type */ 770 unsigned char s_type; /* sample type */
769 unsigned char mixL, mixR; 771 unsigned char mixL, mixR;
@@ -842,7 +844,7 @@ static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels)
842/* 844/*
843 * stop CSP 845 * stop CSP
844 */ 846 */
845static int snd_sb_csp_stop(snd_sb_csp_t * p) 847static int snd_sb_csp_stop(struct snd_sb_csp * p)
846{ 848{
847 int result; 849 int result;
848 unsigned char mixL, mixR; 850 unsigned char mixL, mixR;
@@ -883,7 +885,7 @@ static int snd_sb_csp_stop(snd_sb_csp_t * p)
883/* 885/*
884 * pause CSP codec and hold DMA transfer 886 * pause CSP codec and hold DMA transfer
885 */ 887 */
886static int snd_sb_csp_pause(snd_sb_csp_t * p) 888static int snd_sb_csp_pause(struct snd_sb_csp * p)
887{ 889{
888 int result; 890 int result;
889 unsigned long flags; 891 unsigned long flags;
@@ -903,7 +905,7 @@ static int snd_sb_csp_pause(snd_sb_csp_t * p)
903/* 905/*
904 * restart CSP codec and resume DMA transfer 906 * restart CSP codec and resume DMA transfer
905 */ 907 */
906static int snd_sb_csp_restart(snd_sb_csp_t * p) 908static int snd_sb_csp_restart(struct snd_sb_csp * p)
907{ 909{
908 int result; 910 int result;
909 unsigned long flags; 911 unsigned long flags;
@@ -926,7 +928,7 @@ static int snd_sb_csp_restart(snd_sb_csp_t * p)
926 * QSound mixer control for PCM 928 * QSound mixer control for PCM
927 */ 929 */
928 930
929static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 931static int snd_sb_qsound_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
930{ 932{
931 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 933 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
932 uinfo->count = 1; 934 uinfo->count = 1;
@@ -935,17 +937,17 @@ static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
935 return 0; 937 return 0;
936} 938}
937 939
938static int snd_sb_qsound_switch_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 940static int snd_sb_qsound_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
939{ 941{
940 snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); 942 struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol);
941 943
942 ucontrol->value.integer.value[0] = p->q_enabled ? 1 : 0; 944 ucontrol->value.integer.value[0] = p->q_enabled ? 1 : 0;
943 return 0; 945 return 0;
944} 946}
945 947
946static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 948static int snd_sb_qsound_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
947{ 949{
948 snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); 950 struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol);
949 unsigned long flags; 951 unsigned long flags;
950 int change; 952 int change;
951 unsigned char nval; 953 unsigned char nval;
@@ -958,7 +960,7 @@ static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu
958 return change; 960 return change;
959} 961}
960 962
961static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 963static int snd_sb_qsound_space_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
962{ 964{
963 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 965 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
964 uinfo->count = 2; 966 uinfo->count = 2;
@@ -967,9 +969,9 @@ static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
967 return 0; 969 return 0;
968} 970}
969 971
970static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 972static int snd_sb_qsound_space_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
971{ 973{
972 snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); 974 struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol);
973 unsigned long flags; 975 unsigned long flags;
974 976
975 spin_lock_irqsave(&p->q_lock, flags); 977 spin_lock_irqsave(&p->q_lock, flags);
@@ -979,9 +981,9 @@ static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
979 return 0; 981 return 0;
980} 982}
981 983
982static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 984static int snd_sb_qsound_space_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
983{ 985{
984 snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); 986 struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol);
985 unsigned long flags; 987 unsigned long flags;
986 int change; 988 int change;
987 unsigned char nval1, nval2; 989 unsigned char nval1, nval2;
@@ -1001,7 +1003,7 @@ static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
1001 return change; 1003 return change;
1002} 1004}
1003 1005
1004static snd_kcontrol_new_t snd_sb_qsound_switch = { 1006static struct snd_kcontrol_new snd_sb_qsound_switch = {
1005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1006 .name = "3D Control - Switch", 1008 .name = "3D Control - Switch",
1007 .info = snd_sb_qsound_switch_info, 1009 .info = snd_sb_qsound_switch_info,
@@ -1009,7 +1011,7 @@ static snd_kcontrol_new_t snd_sb_qsound_switch = {
1009 .put = snd_sb_qsound_switch_put 1011 .put = snd_sb_qsound_switch_put
1010}; 1012};
1011 1013
1012static snd_kcontrol_new_t snd_sb_qsound_space = { 1014static struct snd_kcontrol_new snd_sb_qsound_space = {
1013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1014 .name = "3D Control - Space", 1016 .name = "3D Control - Space",
1015 .info = snd_sb_qsound_space_info, 1017 .info = snd_sb_qsound_space_info,
@@ -1017,9 +1019,9 @@ static snd_kcontrol_new_t snd_sb_qsound_space = {
1017 .put = snd_sb_qsound_space_put 1019 .put = snd_sb_qsound_space_put
1018}; 1020};
1019 1021
1020static int snd_sb_qsound_build(snd_sb_csp_t * p) 1022static int snd_sb_qsound_build(struct snd_sb_csp * p)
1021{ 1023{
1022 snd_card_t * card; 1024 struct snd_card *card;
1023 int err; 1025 int err;
1024 1026
1025 snd_assert(p != NULL, return -EINVAL); 1027 snd_assert(p != NULL, return -EINVAL);
@@ -1042,9 +1044,9 @@ static int snd_sb_qsound_build(snd_sb_csp_t * p)
1042 return err; 1044 return err;
1043} 1045}
1044 1046
1045static void snd_sb_qsound_destroy(snd_sb_csp_t * p) 1047static void snd_sb_qsound_destroy(struct snd_sb_csp * p)
1046{ 1048{
1047 snd_card_t * card; 1049 struct snd_card *card;
1048 unsigned long flags; 1050 unsigned long flags;
1049 1051
1050 snd_assert(p != NULL, return); 1052 snd_assert(p != NULL, return);
@@ -1068,7 +1070,7 @@ static void snd_sb_qsound_destroy(snd_sb_csp_t * p)
1068 * Transfer qsound parameters to CSP, 1070 * Transfer qsound parameters to CSP,
1069 * function should be called from interrupt routine 1071 * function should be called from interrupt routine
1070 */ 1072 */
1071static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p) 1073static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p)
1072{ 1074{
1073 int err = -ENXIO; 1075 int err = -ENXIO;
1074 1076
@@ -1093,19 +1095,19 @@ static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p)
1093/* 1095/*
1094 * proc interface 1096 * proc interface
1095 */ 1097 */
1096static int init_proc_entry(snd_sb_csp_t * p, int device) 1098static int init_proc_entry(struct snd_sb_csp * p, int device)
1097{ 1099{
1098 char name[16]; 1100 char name[16];
1099 snd_info_entry_t *entry; 1101 struct snd_info_entry *entry;
1100 sprintf(name, "cspD%d", device); 1102 sprintf(name, "cspD%d", device);
1101 if (! snd_card_proc_new(p->chip->card, name, &entry)) 1103 if (! snd_card_proc_new(p->chip->card, name, &entry))
1102 snd_info_set_text_ops(entry, p, 1024, info_read); 1104 snd_info_set_text_ops(entry, p, 1024, info_read);
1103 return 0; 1105 return 0;
1104} 1106}
1105 1107
1106static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) 1108static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
1107{ 1109{
1108 snd_sb_csp_t *p = entry->private_data; 1110 struct snd_sb_csp *p = entry->private_data;
1109 1111
1110 snd_iprintf(buffer, "Creative Signal Processor [v%d.%d]\n", (p->version >> 4), (p->version & 0x0f)); 1112 snd_iprintf(buffer, "Creative Signal Processor [v%d.%d]\n", (p->version >> 4), (p->version & 0x0f));
1111 snd_iprintf(buffer, "State: %cx%c%c%c\n", ((p->running & SNDRV_SB_CSP_ST_QSOUND) ? 'Q' : '-'), 1113 snd_iprintf(buffer, "State: %cx%c%c%c\n", ((p->running & SNDRV_SB_CSP_ST_QSOUND) ? 'Q' : '-'),
diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c
index 556b95e3e22f..f183f1845a36 100644
--- a/sound/isa/sb/sb16_main.c
+++ b/sound/isa/sb/sb16_main.c
@@ -50,10 +50,10 @@ MODULE_DESCRIPTION("Routines for control of 16-bit SoundBlaster cards and clones
50MODULE_LICENSE("GPL"); 50MODULE_LICENSE("GPL");
51 51
52#ifdef CONFIG_SND_SB16_CSP 52#ifdef CONFIG_SND_SB16_CSP
53static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) 53static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
54{ 54{
55 if (chip->hardware == SB_HW_16CSP) { 55 if (chip->hardware == SB_HW_16CSP) {
56 snd_sb_csp_t *csp = chip->csp; 56 struct snd_sb_csp *csp = chip->csp;
57 57
58 if (csp->running & SNDRV_SB_CSP_ST_LOADED) { 58 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
59 /* manually loaded codec */ 59 /* manually loaded codec */
@@ -98,10 +98,10 @@ static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime
98 } 98 }
99} 99}
100 100
101static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) 101static void snd_sb16_csp_capture_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
102{ 102{
103 if (chip->hardware == SB_HW_16CSP) { 103 if (chip->hardware == SB_HW_16CSP) {
104 snd_sb_csp_t *csp = chip->csp; 104 struct snd_sb_csp *csp = chip->csp;
105 105
106 if (csp->running & SNDRV_SB_CSP_ST_LOADED) { 106 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
107 /* manually loaded codec */ 107 /* manually loaded codec */
@@ -136,10 +136,10 @@ static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime)
136 } 136 }
137} 137}
138 138
139static void snd_sb16_csp_update(sb_t *chip) 139static void snd_sb16_csp_update(struct snd_sb *chip)
140{ 140{
141 if (chip->hardware == SB_HW_16CSP) { 141 if (chip->hardware == SB_HW_16CSP) {
142 snd_sb_csp_t *csp = chip->csp; 142 struct snd_sb_csp *csp = chip->csp;
143 143
144 if (csp->qpos_changed) { 144 if (csp->qpos_changed) {
145 spin_lock(&chip->reg_lock); 145 spin_lock(&chip->reg_lock);
@@ -149,11 +149,11 @@ static void snd_sb16_csp_update(sb_t *chip)
149 } 149 }
150} 150}
151 151
152static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime) 152static void snd_sb16_csp_playback_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
153{ 153{
154 /* CSP decoders (QSound excluded) support only 16bit transfers */ 154 /* CSP decoders (QSound excluded) support only 16bit transfers */
155 if (chip->hardware == SB_HW_16CSP) { 155 if (chip->hardware == SB_HW_16CSP) {
156 snd_sb_csp_t *csp = chip->csp; 156 struct snd_sb_csp *csp = chip->csp;
157 157
158 if (csp->running & SNDRV_SB_CSP_ST_LOADED) { 158 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
159 /* manually loaded codec */ 159 /* manually loaded codec */
@@ -168,10 +168,10 @@ static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime)
168 } 168 }
169} 169}
170 170
171static void snd_sb16_csp_playback_close(sb_t *chip) 171static void snd_sb16_csp_playback_close(struct snd_sb *chip)
172{ 172{
173 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) { 173 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) {
174 snd_sb_csp_t *csp = chip->csp; 174 struct snd_sb_csp *csp = chip->csp;
175 175
176 if (csp->ops.csp_stop(csp) == 0) { 176 if (csp->ops.csp_stop(csp) == 0) {
177 csp->ops.csp_unuse(csp); 177 csp->ops.csp_unuse(csp);
@@ -180,11 +180,11 @@ static void snd_sb16_csp_playback_close(sb_t *chip)
180 } 180 }
181} 181}
182 182
183static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime) 183static void snd_sb16_csp_capture_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
184{ 184{
185 /* CSP coders support only 16bit transfers */ 185 /* CSP coders support only 16bit transfers */
186 if (chip->hardware == SB_HW_16CSP) { 186 if (chip->hardware == SB_HW_16CSP) {
187 snd_sb_csp_t *csp = chip->csp; 187 struct snd_sb_csp *csp = chip->csp;
188 188
189 if (csp->running & SNDRV_SB_CSP_ST_LOADED) { 189 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
190 /* manually loaded codec */ 190 /* manually loaded codec */
@@ -199,10 +199,10 @@ static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime)
199 } 199 }
200} 200}
201 201
202static void snd_sb16_csp_capture_close(sb_t *chip) 202static void snd_sb16_csp_capture_close(struct snd_sb *chip)
203{ 203{
204 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) { 204 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) {
205 snd_sb_csp_t *csp = chip->csp; 205 struct snd_sb_csp *csp = chip->csp;
206 206
207 if (csp->ops.csp_stop(csp) == 0) { 207 if (csp->ops.csp_stop(csp) == 0) {
208 csp->ops.csp_unuse(csp); 208 csp->ops.csp_unuse(csp);
@@ -221,7 +221,7 @@ static void snd_sb16_csp_capture_close(sb_t *chip)
221#endif 221#endif
222 222
223 223
224static void snd_sb16_setup_rate(sb_t *chip, 224static void snd_sb16_setup_rate(struct snd_sb *chip,
225 unsigned short rate, 225 unsigned short rate,
226 int channel) 226 int channel)
227{ 227{
@@ -244,23 +244,23 @@ static void snd_sb16_setup_rate(sb_t *chip,
244 spin_unlock_irqrestore(&chip->reg_lock, flags); 244 spin_unlock_irqrestore(&chip->reg_lock, flags);
245} 245}
246 246
247static int snd_sb16_hw_params(snd_pcm_substream_t * substream, 247static int snd_sb16_hw_params(struct snd_pcm_substream *substream,
248 snd_pcm_hw_params_t * hw_params) 248 struct snd_pcm_hw_params *hw_params)
249{ 249{
250 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 250 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
251} 251}
252 252
253static int snd_sb16_hw_free(snd_pcm_substream_t * substream) 253static int snd_sb16_hw_free(struct snd_pcm_substream *substream)
254{ 254{
255 snd_pcm_lib_free_pages(substream); 255 snd_pcm_lib_free_pages(substream);
256 return 0; 256 return 0;
257} 257}
258 258
259static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream) 259static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream)
260{ 260{
261 unsigned long flags; 261 unsigned long flags;
262 sb_t *chip = snd_pcm_substream_chip(substream); 262 struct snd_sb *chip = snd_pcm_substream_chip(substream);
263 snd_pcm_runtime_t *runtime = substream->runtime; 263 struct snd_pcm_runtime *runtime = substream->runtime;
264 unsigned char format; 264 unsigned char format;
265 unsigned int size, count, dma; 265 unsigned int size, count, dma;
266 266
@@ -298,19 +298,21 @@ static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream)
298 return 0; 298 return 0;
299} 299}
300 300
301static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream, 301static int snd_sb16_playback_trigger(struct snd_pcm_substream *substream,
302 int cmd) 302 int cmd)
303{ 303{
304 sb_t *chip = snd_pcm_substream_chip(substream); 304 struct snd_sb *chip = snd_pcm_substream_chip(substream);
305 int result = 0; 305 int result = 0;
306 306
307 spin_lock(&chip->reg_lock); 307 spin_lock(&chip->reg_lock);
308 switch (cmd) { 308 switch (cmd) {
309 case SNDRV_PCM_TRIGGER_START: 309 case SNDRV_PCM_TRIGGER_START:
310 case SNDRV_PCM_TRIGGER_RESUME:
310 chip->mode |= SB_RATE_LOCK_PLAYBACK; 311 chip->mode |= SB_RATE_LOCK_PLAYBACK;
311 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); 312 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
312 break; 313 break;
313 case SNDRV_PCM_TRIGGER_STOP: 314 case SNDRV_PCM_TRIGGER_STOP:
315 case SNDRV_PCM_TRIGGER_SUSPEND:
314 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); 316 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
315 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ 317 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */
316 if (chip->mode & SB_RATE_LOCK_CAPTURE) 318 if (chip->mode & SB_RATE_LOCK_CAPTURE)
@@ -324,11 +326,11 @@ static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream,
324 return result; 326 return result;
325} 327}
326 328
327static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream) 329static int snd_sb16_capture_prepare(struct snd_pcm_substream *substream)
328{ 330{
329 unsigned long flags; 331 unsigned long flags;
330 sb_t *chip = snd_pcm_substream_chip(substream); 332 struct snd_sb *chip = snd_pcm_substream_chip(substream);
331 snd_pcm_runtime_t *runtime = substream->runtime; 333 struct snd_pcm_runtime *runtime = substream->runtime;
332 unsigned char format; 334 unsigned char format;
333 unsigned int size, count, dma; 335 unsigned int size, count, dma;
334 336
@@ -365,19 +367,21 @@ static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream)
365 return 0; 367 return 0;
366} 368}
367 369
368static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream, 370static int snd_sb16_capture_trigger(struct snd_pcm_substream *substream,
369 int cmd) 371 int cmd)
370{ 372{
371 sb_t *chip = snd_pcm_substream_chip(substream); 373 struct snd_sb *chip = snd_pcm_substream_chip(substream);
372 int result = 0; 374 int result = 0;
373 375
374 spin_lock(&chip->reg_lock); 376 spin_lock(&chip->reg_lock);
375 switch (cmd) { 377 switch (cmd) {
376 case SNDRV_PCM_TRIGGER_START: 378 case SNDRV_PCM_TRIGGER_START:
379 case SNDRV_PCM_TRIGGER_RESUME:
377 chip->mode |= SB_RATE_LOCK_CAPTURE; 380 chip->mode |= SB_RATE_LOCK_CAPTURE;
378 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); 381 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
379 break; 382 break;
380 case SNDRV_PCM_TRIGGER_STOP: 383 case SNDRV_PCM_TRIGGER_STOP:
384 case SNDRV_PCM_TRIGGER_SUSPEND:
381 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); 385 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
382 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ 386 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */
383 if (chip->mode & SB_RATE_LOCK_PLAYBACK) 387 if (chip->mode & SB_RATE_LOCK_PLAYBACK)
@@ -393,7 +397,7 @@ static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream,
393 397
394irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 398irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
395{ 399{
396 sb_t *chip = dev_id; 400 struct snd_sb *chip = dev_id;
397 unsigned char status; 401 unsigned char status;
398 int ok; 402 int ok;
399 403
@@ -443,9 +447,9 @@ irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
443 447
444 */ 448 */
445 449
446static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substream) 450static snd_pcm_uframes_t snd_sb16_playback_pointer(struct snd_pcm_substream *substream)
447{ 451{
448 sb_t *chip = snd_pcm_substream_chip(substream); 452 struct snd_sb *chip = snd_pcm_substream_chip(substream);
449 unsigned int dma; 453 unsigned int dma;
450 size_t ptr; 454 size_t ptr;
451 455
@@ -454,9 +458,9 @@ static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substre
454 return bytes_to_frames(substream->runtime, ptr); 458 return bytes_to_frames(substream->runtime, ptr);
455} 459}
456 460
457static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substream) 461static snd_pcm_uframes_t snd_sb16_capture_pointer(struct snd_pcm_substream *substream)
458{ 462{
459 sb_t *chip = snd_pcm_substream_chip(substream); 463 struct snd_sb *chip = snd_pcm_substream_chip(substream);
460 unsigned int dma; 464 unsigned int dma;
461 size_t ptr; 465 size_t ptr;
462 466
@@ -469,7 +473,7 @@ static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substrea
469 473
470 */ 474 */
471 475
472static snd_pcm_hardware_t snd_sb16_playback = 476static struct snd_pcm_hardware snd_sb16_playback =
473{ 477{
474 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 478 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
475 SNDRV_PCM_INFO_MMAP_VALID), 479 SNDRV_PCM_INFO_MMAP_VALID),
@@ -487,7 +491,7 @@ static snd_pcm_hardware_t snd_sb16_playback =
487 .fifo_size = 0, 491 .fifo_size = 0,
488}; 492};
489 493
490static snd_pcm_hardware_t snd_sb16_capture = 494static struct snd_pcm_hardware snd_sb16_capture =
491{ 495{
492 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 496 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
493 SNDRV_PCM_INFO_MMAP_VALID), 497 SNDRV_PCM_INFO_MMAP_VALID),
@@ -509,11 +513,11 @@ static snd_pcm_hardware_t snd_sb16_capture =
509 * open/close 513 * open/close
510 */ 514 */
511 515
512static int snd_sb16_playback_open(snd_pcm_substream_t * substream) 516static int snd_sb16_playback_open(struct snd_pcm_substream *substream)
513{ 517{
514 unsigned long flags; 518 unsigned long flags;
515 sb_t *chip = snd_pcm_substream_chip(substream); 519 struct snd_sb *chip = snd_pcm_substream_chip(substream);
516 snd_pcm_runtime_t *runtime = substream->runtime; 520 struct snd_pcm_runtime *runtime = substream->runtime;
517 521
518 spin_lock_irqsave(&chip->open_lock, flags); 522 spin_lock_irqsave(&chip->open_lock, flags);
519 if (chip->mode & SB_MODE_PLAYBACK) { 523 if (chip->mode & SB_MODE_PLAYBACK) {
@@ -566,10 +570,10 @@ static int snd_sb16_playback_open(snd_pcm_substream_t * substream)
566 return 0; 570 return 0;
567} 571}
568 572
569static int snd_sb16_playback_close(snd_pcm_substream_t * substream) 573static int snd_sb16_playback_close(struct snd_pcm_substream *substream)
570{ 574{
571 unsigned long flags; 575 unsigned long flags;
572 sb_t *chip = snd_pcm_substream_chip(substream); 576 struct snd_sb *chip = snd_pcm_substream_chip(substream);
573 577
574 snd_sb16_csp_playback_close(chip); 578 snd_sb16_csp_playback_close(chip);
575 spin_lock_irqsave(&chip->open_lock, flags); 579 spin_lock_irqsave(&chip->open_lock, flags);
@@ -579,11 +583,11 @@ static int snd_sb16_playback_close(snd_pcm_substream_t * substream)
579 return 0; 583 return 0;
580} 584}
581 585
582static int snd_sb16_capture_open(snd_pcm_substream_t * substream) 586static int snd_sb16_capture_open(struct snd_pcm_substream *substream)
583{ 587{
584 unsigned long flags; 588 unsigned long flags;
585 sb_t *chip = snd_pcm_substream_chip(substream); 589 struct snd_sb *chip = snd_pcm_substream_chip(substream);
586 snd_pcm_runtime_t *runtime = substream->runtime; 590 struct snd_pcm_runtime *runtime = substream->runtime;
587 591
588 spin_lock_irqsave(&chip->open_lock, flags); 592 spin_lock_irqsave(&chip->open_lock, flags);
589 if (chip->mode & SB_MODE_CAPTURE) { 593 if (chip->mode & SB_MODE_CAPTURE) {
@@ -636,10 +640,10 @@ static int snd_sb16_capture_open(snd_pcm_substream_t * substream)
636 return 0; 640 return 0;
637} 641}
638 642
639static int snd_sb16_capture_close(snd_pcm_substream_t * substream) 643static int snd_sb16_capture_close(struct snd_pcm_substream *substream)
640{ 644{
641 unsigned long flags; 645 unsigned long flags;
642 sb_t *chip = snd_pcm_substream_chip(substream); 646 struct snd_sb *chip = snd_pcm_substream_chip(substream);
643 647
644 snd_sb16_csp_capture_close(chip); 648 snd_sb16_csp_capture_close(chip);
645 spin_lock_irqsave(&chip->open_lock, flags); 649 spin_lock_irqsave(&chip->open_lock, flags);
@@ -653,7 +657,7 @@ static int snd_sb16_capture_close(snd_pcm_substream_t * substream)
653 * DMA control interface 657 * DMA control interface
654 */ 658 */
655 659
656static int snd_sb16_set_dma_mode(sb_t *chip, int what) 660static int snd_sb16_set_dma_mode(struct snd_sb *chip, int what)
657{ 661{
658 if (chip->dma8 < 0 || chip->dma16 < 0) { 662 if (chip->dma8 < 0 || chip->dma16 < 0) {
659 snd_assert(what == 0, return -EINVAL); 663 snd_assert(what == 0, return -EINVAL);
@@ -671,7 +675,7 @@ static int snd_sb16_set_dma_mode(sb_t *chip, int what)
671 return 0; 675 return 0;
672} 676}
673 677
674static int snd_sb16_get_dma_mode(sb_t *chip) 678static int snd_sb16_get_dma_mode(struct snd_sb *chip)
675{ 679{
676 if (chip->dma8 < 0 || chip->dma16 < 0) 680 if (chip->dma8 < 0 || chip->dma16 < 0)
677 return 0; 681 return 0;
@@ -685,7 +689,7 @@ static int snd_sb16_get_dma_mode(sb_t *chip)
685 } 689 }
686} 690}
687 691
688static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 692static int snd_sb16_dma_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
689{ 693{
690 static char *texts[3] = { 694 static char *texts[3] = {
691 "Auto", "Playback", "Capture" 695 "Auto", "Playback", "Capture"
@@ -700,9 +704,9 @@ static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
700 return 0; 704 return 0;
701} 705}
702 706
703static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 707static int snd_sb16_dma_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
704{ 708{
705 sb_t *chip = snd_kcontrol_chip(kcontrol); 709 struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
706 unsigned long flags; 710 unsigned long flags;
707 711
708 spin_lock_irqsave(&chip->reg_lock, flags); 712 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -711,9 +715,9 @@ static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu
711 return 0; 715 return 0;
712} 716}
713 717
714static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 718static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
715{ 719{
716 sb_t *chip = snd_kcontrol_chip(kcontrol); 720 struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
717 unsigned long flags; 721 unsigned long flags;
718 unsigned char nval, oval; 722 unsigned char nval, oval;
719 int change; 723 int change;
@@ -728,7 +732,7 @@ static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu
728 return change; 732 return change;
729} 733}
730 734
731static snd_kcontrol_new_t snd_sb16_dma_control = { 735static struct snd_kcontrol_new snd_sb16_dma_control = {
732 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 736 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
733 .name = "16-bit DMA Allocation", 737 .name = "16-bit DMA Allocation",
734 .info = snd_sb16_dma_control_info, 738 .info = snd_sb16_dma_control_info,
@@ -740,7 +744,7 @@ static snd_kcontrol_new_t snd_sb16_dma_control = {
740 * Initialization part 744 * Initialization part
741 */ 745 */
742 746
743int snd_sb16dsp_configure(sb_t * chip) 747int snd_sb16dsp_configure(struct snd_sb * chip)
744{ 748{
745 unsigned long flags; 749 unsigned long flags;
746 unsigned char irqreg = 0, dmareg = 0, mpureg; 750 unsigned char irqreg = 0, dmareg = 0, mpureg;
@@ -829,7 +833,7 @@ int snd_sb16dsp_configure(sb_t * chip)
829 return 0; 833 return 0;
830} 834}
831 835
832static snd_pcm_ops_t snd_sb16_playback_ops = { 836static struct snd_pcm_ops snd_sb16_playback_ops = {
833 .open = snd_sb16_playback_open, 837 .open = snd_sb16_playback_open,
834 .close = snd_sb16_playback_close, 838 .close = snd_sb16_playback_close,
835 .ioctl = snd_pcm_lib_ioctl, 839 .ioctl = snd_pcm_lib_ioctl,
@@ -840,7 +844,7 @@ static snd_pcm_ops_t snd_sb16_playback_ops = {
840 .pointer = snd_sb16_playback_pointer, 844 .pointer = snd_sb16_playback_pointer,
841}; 845};
842 846
843static snd_pcm_ops_t snd_sb16_capture_ops = { 847static struct snd_pcm_ops snd_sb16_capture_ops = {
844 .open = snd_sb16_capture_open, 848 .open = snd_sb16_capture_open,
845 .close = snd_sb16_capture_close, 849 .close = snd_sb16_capture_close,
846 .ioctl = snd_pcm_lib_ioctl, 850 .ioctl = snd_pcm_lib_ioctl,
@@ -851,15 +855,10 @@ static snd_pcm_ops_t snd_sb16_capture_ops = {
851 .pointer = snd_sb16_capture_pointer, 855 .pointer = snd_sb16_capture_pointer,
852}; 856};
853 857
854static void snd_sb16dsp_pcm_free(snd_pcm_t *pcm) 858int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm)
855{ 859{
856 snd_pcm_lib_preallocate_free_for_all(pcm); 860 struct snd_card *card = chip->card;
857} 861 struct snd_pcm *pcm;
858
859int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm)
860{
861 snd_card_t *card = chip->card;
862 snd_pcm_t *pcm;
863 int err; 862 int err;
864 863
865 if (rpcm) 864 if (rpcm)
@@ -869,7 +868,6 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm)
869 sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); 868 sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff);
870 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; 869 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
871 pcm->private_data = chip; 870 pcm->private_data = chip;
872 pcm->private_free = snd_sb16dsp_pcm_free;
873 871
874 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops); 872 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops);
875 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops); 873 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops);
@@ -888,7 +886,7 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm)
888 return 0; 886 return 0;
889} 887}
890 888
891const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction) 889const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction)
892{ 890{
893 return direction == SNDRV_PCM_STREAM_PLAYBACK ? 891 return direction == SNDRV_PCM_STREAM_PLAYBACK ?
894 &snd_sb16_playback_ops : &snd_sb16_capture_ops; 892 &snd_sb16_playback_ops : &snd_sb16_capture_ops;
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index 0bc0a3afdabc..60ee79cd14a3 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -21,13 +21,14 @@
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h>
25#include <linux/platform_device.h>
24#include <linux/slab.h> 26#include <linux/slab.h>
25#include <linux/ioport.h> 27#include <linux/ioport.h>
26#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
27#include <sound/core.h> 29#include <sound/core.h>
28#include <sound/sb.h> 30#include <sound/sb.h>
29#include <sound/opl3.h> 31#include <sound/opl3.h>
30#define SNDRV_LEGACY_AUTO_PROBE
31#include <sound/initval.h> 32#include <sound/initval.h>
32 33
33MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 34MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -55,15 +56,16 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
55module_param_array(dma8, int, NULL, 0444); 56module_param_array(dma8, int, NULL, 0444);
56MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); 57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
57 58
59static struct platform_device *devices[SNDRV_CARDS];
60
58struct snd_sb8 { 61struct snd_sb8 {
59 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 62 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
63 struct snd_sb *chip;
60}; 64};
61 65
62static snd_card_t *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
63
64static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs) 66static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs)
65{ 67{
66 sb_t *chip = dev_id; 68 struct snd_sb *chip = dev_id;
67 69
68 if (chip->open & SB_OPEN_PCM) { 70 if (chip->open & SB_OPEN_PCM) {
69 return snd_sb8dsp_interrupt(chip); 71 return snd_sb8dsp_interrupt(chip);
@@ -72,7 +74,7 @@ static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs
72 } 74 }
73} 75}
74 76
75static void snd_sb8_free(snd_card_t *card) 77static void snd_sb8_free(struct snd_card *card)
76{ 78{
77 struct snd_sb8 *acard = (struct snd_sb8 *)card->private_data; 79 struct snd_sb8 *acard = (struct snd_sb8 *)card->private_data;
78 80
@@ -81,32 +83,57 @@ static void snd_sb8_free(snd_card_t *card)
81 release_and_free_resource(acard->fm_res); 83 release_and_free_resource(acard->fm_res);
82} 84}
83 85
84static int __init snd_sb8_probe(int dev) 86static int __init snd_sb8_probe(struct platform_device *pdev)
85{ 87{
86 sb_t *chip; 88 int dev = pdev->id;
87 snd_card_t *card; 89 struct snd_sb *chip;
90 struct snd_card *card;
88 struct snd_sb8 *acard; 91 struct snd_sb8 *acard;
89 opl3_t *opl3; 92 struct snd_opl3 *opl3;
90 int err; 93 int err;
91 94
92 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 95 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
93 sizeof(struct snd_sb8)); 96 sizeof(struct snd_sb8));
94 if (card == NULL) 97 if (card == NULL)
95 return -ENOMEM; 98 return -ENOMEM;
96 acard = (struct snd_sb8 *)card->private_data; 99 acard = card->private_data;
97 card->private_free = snd_sb8_free; 100 card->private_free = snd_sb8_free;
98 101
99 /* block the 0x388 port to avoid PnP conflicts */ 102 /* block the 0x388 port to avoid PnP conflicts */
100 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); 103 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
101 104
102 if ((err = snd_sbdsp_create(card, port[dev], irq[dev], 105 if (port[dev] != SNDRV_AUTO_PORT) {
103 snd_sb8_interrupt, 106 if ((err = snd_sbdsp_create(card, port[dev], irq[dev],
104 dma8[dev], 107 snd_sb8_interrupt,
105 -1, 108 dma8[dev],
106 SB_HW_AUTO, 109 -1,
107 &chip)) < 0) 110 SB_HW_AUTO,
108 goto _err; 111 &chip)) < 0)
109 112 goto _err;
113 } else {
114 /* auto-probe legacy ports */
115 static unsigned long possible_ports[] = {
116 0x220, 0x240, 0x260,
117 };
118 int i;
119 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
120 err = snd_sbdsp_create(card, possible_ports[i],
121 irq[dev],
122 snd_sb8_interrupt,
123 dma8[dev],
124 -1,
125 SB_HW_AUTO,
126 &chip);
127 if (err >= 0) {
128 port[dev] = possible_ports[i];
129 break;
130 }
131 }
132 if (i >= ARRAY_SIZE(possible_ports))
133 goto _err;
134 }
135 acard->chip = chip;
136
110 if (chip->hardware >= SB_HW_16) { 137 if (chip->hardware >= SB_HW_16) {
111 if (chip->hardware == SB_HW_ALS100) 138 if (chip->hardware == SB_HW_ALS100)
112 snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n", 139 snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n",
@@ -153,13 +180,12 @@ static int __init snd_sb8_probe(int dev)
153 chip->port, 180 chip->port,
154 irq[dev], dma8[dev]); 181 irq[dev], dma8[dev]);
155 182
156 if ((err = snd_card_set_generic_dev(card)) < 0) 183 snd_card_set_dev(card, &pdev->dev);
157 goto _err;
158 184
159 if ((err = snd_card_register(card)) < 0) 185 if ((err = snd_card_register(card)) < 0)
160 goto _err; 186 goto _err;
161 187
162 snd_sb8_cards[dev] = card; 188 platform_set_drvdata(pdev, card);
163 return 0; 189 return 0;
164 190
165 _err: 191 _err:
@@ -167,53 +193,99 @@ static int __init snd_sb8_probe(int dev)
167 return err; 193 return err;
168} 194}
169 195
170static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport) 196static int snd_sb8_remove(struct platform_device *pdev)
197{
198 snd_card_free(platform_get_drvdata(pdev));
199 platform_set_drvdata(pdev, NULL);
200 return 0;
201}
202
203#ifdef CONFIG_PM
204static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state)
205{
206 struct snd_card *card = platform_get_drvdata(dev);
207 struct snd_sb8 *acard = card->private_data;
208 struct snd_sb *chip = acard->chip;
209
210 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
211 snd_pcm_suspend_all(chip->pcm);
212 snd_sbmixer_suspend(chip);
213 return 0;
214}
215
216static int snd_sb8_resume(struct platform_device *dev)
217{
218 struct snd_card *card = platform_get_drvdata(dev);
219 struct snd_sb8 *acard = card->private_data;
220 struct snd_sb *chip = acard->chip;
221
222 snd_sbdsp_reset(chip);
223 snd_sbmixer_resume(chip);
224 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
225 return 0;
226}
227#endif
228
229#define SND_SB8_DRIVER "snd_sb8"
230
231static struct platform_driver snd_sb8_driver = {
232 .probe = snd_sb8_probe,
233 .remove = snd_sb8_remove,
234#ifdef CONFIG_PM
235 .suspend = snd_sb8_suspend,
236 .resume = snd_sb8_resume,
237#endif
238 .driver = {
239 .name = SND_SB8_DRIVER
240 },
241};
242
243static void __init_or_module snd_sb8_unregister_all(void)
171{ 244{
172 static int dev; 245 int i;
173 int res; 246
174 247 for (i = 0; i < ARRAY_SIZE(devices); ++i)
175 for ( ; dev < SNDRV_CARDS; dev++) { 248 platform_device_unregister(devices[i]);
176 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 249 platform_driver_unregister(&snd_sb8_driver);
177 continue;
178 port[dev] = xport;
179 res = snd_sb8_probe(dev);
180 if (res < 0)
181 port[dev] = SNDRV_AUTO_PORT;
182 return res;
183 }
184 return -ENODEV;
185} 250}
186 251
187static int __init alsa_card_sb8_init(void) 252static int __init alsa_card_sb8_init(void)
188{ 253{
189 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; 254 int i, cards, err;
190 int dev, cards, i; 255
191 256 err = platform_driver_register(&snd_sb8_driver);
192 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { 257 if (err < 0)
193 if (port[dev] == SNDRV_AUTO_PORT) 258 return err;
194 continue; 259
195 if (snd_sb8_probe(dev) >= 0) 260 cards = 0;
196 cards++; 261 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
262 struct platform_device *device;
263 device = platform_device_register_simple(SND_SB8_DRIVER,
264 i, NULL, 0);
265 if (IS_ERR(device)) {
266 err = PTR_ERR(device);
267 goto errout;
268 }
269 devices[i] = device;
270 cards++;
197 } 271 }
198 i = snd_legacy_auto_probe(possible_ports, snd_card_sb8_legacy_auto_probe);
199 if (i > 0)
200 cards += i;
201
202 if (!cards) { 272 if (!cards) {
203#ifdef MODULE 273#ifdef MODULE
204 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); 274 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
205#endif 275#endif
206 return -ENODEV; 276 err = -ENODEV;
277 goto errout;
207 } 278 }
208 return 0; 279 return 0;
280
281 errout:
282 snd_sb8_unregister_all();
283 return err;
209} 284}
210 285
211static void __exit alsa_card_sb8_exit(void) 286static void __exit alsa_card_sb8_exit(void)
212{ 287{
213 int idx; 288 snd_sb8_unregister_all();
214
215 for (idx = 0; idx < SNDRV_CARDS; idx++)
216 snd_card_free(snd_sb8_cards[idx]);
217} 289}
218 290
219module_init(alsa_card_sb8_init) 291module_init(alsa_card_sb8_init)
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c
index 5ddc6e41d909..aea9e5ec7b36 100644
--- a/sound/isa/sb/sb8_main.c
+++ b/sound/isa/sb/sb8_main.c
@@ -46,19 +46,19 @@ MODULE_LICENSE("GPL");
46#define SB8_DEN(v) ((SB8_CLOCK + (v) / 2) / (v)) 46#define SB8_DEN(v) ((SB8_CLOCK + (v) / 2) / (v))
47#define SB8_RATE(v) (SB8_CLOCK / SB8_DEN(v)) 47#define SB8_RATE(v) (SB8_CLOCK / SB8_DEN(v))
48 48
49static ratnum_t clock = { 49static struct snd_ratnum clock = {
50 .num = SB8_CLOCK, 50 .num = SB8_CLOCK,
51 .den_min = 1, 51 .den_min = 1,
52 .den_max = 256, 52 .den_max = 256,
53 .den_step = 1, 53 .den_step = 1,
54}; 54};
55 55
56static snd_pcm_hw_constraint_ratnums_t hw_constraints_clock = { 56static struct snd_pcm_hw_constraint_ratnums hw_constraints_clock = {
57 .nrats = 1, 57 .nrats = 1,
58 .rats = &clock, 58 .rats = &clock,
59}; 59};
60 60
61static ratnum_t stereo_clocks[] = { 61static struct snd_ratnum stereo_clocks[] = {
62 { 62 {
63 .num = SB8_CLOCK, 63 .num = SB8_CLOCK,
64 .den_min = SB8_DEN(22050), 64 .den_min = SB8_DEN(22050),
@@ -73,10 +73,10 @@ static ratnum_t stereo_clocks[] = {
73 } 73 }
74}; 74};
75 75
76static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params, 76static int snd_sb8_hw_constraint_rate_channels(struct snd_pcm_hw_params *params,
77 snd_pcm_hw_rule_t *rule) 77 struct snd_pcm_hw_rule *rule)
78{ 78{
79 snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 79 struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
80 if (c->min > 1) { 80 if (c->min > 1) {
81 unsigned int num = 0, den = 0; 81 unsigned int num = 0, den = 0;
82 int err = snd_interval_ratnum(hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE), 82 int err = snd_interval_ratnum(hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE),
@@ -90,22 +90,22 @@ static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params,
90 return 0; 90 return 0;
91} 91}
92 92
93static int snd_sb8_hw_constraint_channels_rate(snd_pcm_hw_params_t *params, 93static int snd_sb8_hw_constraint_channels_rate(struct snd_pcm_hw_params *params,
94 snd_pcm_hw_rule_t *rule) 94 struct snd_pcm_hw_rule *rule)
95{ 95{
96 snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 96 struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
97 if (r->min > SB8_RATE(22050) || r->max <= SB8_RATE(11025)) { 97 if (r->min > SB8_RATE(22050) || r->max <= SB8_RATE(11025)) {
98 snd_interval_t t = { .min = 1, .max = 1 }; 98 struct snd_interval t = { .min = 1, .max = 1 };
99 return snd_interval_refine(hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS), &t); 99 return snd_interval_refine(hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS), &t);
100 } 100 }
101 return 0; 101 return 0;
102} 102}
103 103
104static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream) 104static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream)
105{ 105{
106 unsigned long flags; 106 unsigned long flags;
107 sb_t *chip = snd_pcm_substream_chip(substream); 107 struct snd_sb *chip = snd_pcm_substream_chip(substream);
108 snd_pcm_runtime_t *runtime = substream->runtime; 108 struct snd_pcm_runtime *runtime = substream->runtime;
109 unsigned int mixreg, rate, size, count; 109 unsigned int mixreg, rate, size, count;
110 110
111 rate = runtime->rate; 111 rate = runtime->rate;
@@ -178,11 +178,11 @@ static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream)
178 return 0; 178 return 0;
179} 179}
180 180
181static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, 181static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream,
182 int cmd) 182 int cmd)
183{ 183{
184 unsigned long flags; 184 unsigned long flags;
185 sb_t *chip = snd_pcm_substream_chip(substream); 185 struct snd_sb *chip = snd_pcm_substream_chip(substream);
186 unsigned int count; 186 unsigned int count;
187 187
188 spin_lock_irqsave(&chip->reg_lock, flags); 188 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -197,7 +197,7 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream,
197 break; 197 break;
198 case SNDRV_PCM_TRIGGER_STOP: 198 case SNDRV_PCM_TRIGGER_STOP:
199 if (chip->playback_format == SB_DSP_HI_OUTPUT_AUTO) { 199 if (chip->playback_format == SB_DSP_HI_OUTPUT_AUTO) {
200 snd_pcm_runtime_t *runtime = substream->runtime; 200 struct snd_pcm_runtime *runtime = substream->runtime;
201 snd_sbdsp_reset(chip); 201 snd_sbdsp_reset(chip);
202 if (runtime->channels > 1) { 202 if (runtime->channels > 1) {
203 spin_lock(&chip->mixer_lock); 203 spin_lock(&chip->mixer_lock);
@@ -215,23 +215,23 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream,
215 return 0; 215 return 0;
216} 216}
217 217
218static int snd_sb8_hw_params(snd_pcm_substream_t * substream, 218static int snd_sb8_hw_params(struct snd_pcm_substream *substream,
219 snd_pcm_hw_params_t * hw_params) 219 struct snd_pcm_hw_params *hw_params)
220{ 220{
221 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 221 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
222} 222}
223 223
224static int snd_sb8_hw_free(snd_pcm_substream_t * substream) 224static int snd_sb8_hw_free(struct snd_pcm_substream *substream)
225{ 225{
226 snd_pcm_lib_free_pages(substream); 226 snd_pcm_lib_free_pages(substream);
227 return 0; 227 return 0;
228} 228}
229 229
230static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream) 230static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream)
231{ 231{
232 unsigned long flags; 232 unsigned long flags;
233 sb_t *chip = snd_pcm_substream_chip(substream); 233 struct snd_sb *chip = snd_pcm_substream_chip(substream);
234 snd_pcm_runtime_t *runtime = substream->runtime; 234 struct snd_pcm_runtime *runtime = substream->runtime;
235 unsigned int mixreg, rate, size, count; 235 unsigned int mixreg, rate, size, count;
236 236
237 rate = runtime->rate; 237 rate = runtime->rate;
@@ -290,11 +290,11 @@ static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream)
290 return 0; 290 return 0;
291} 291}
292 292
293static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, 293static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream,
294 int cmd) 294 int cmd)
295{ 295{
296 unsigned long flags; 296 unsigned long flags;
297 sb_t *chip = snd_pcm_substream_chip(substream); 297 struct snd_sb *chip = snd_pcm_substream_chip(substream);
298 unsigned int count; 298 unsigned int count;
299 299
300 spin_lock_irqsave(&chip->reg_lock, flags); 300 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -309,7 +309,7 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream,
309 break; 309 break;
310 case SNDRV_PCM_TRIGGER_STOP: 310 case SNDRV_PCM_TRIGGER_STOP:
311 if (chip->capture_format == SB_DSP_HI_INPUT_AUTO) { 311 if (chip->capture_format == SB_DSP_HI_INPUT_AUTO) {
312 snd_pcm_runtime_t *runtime = substream->runtime; 312 struct snd_pcm_runtime *runtime = substream->runtime;
313 snd_sbdsp_reset(chip); 313 snd_sbdsp_reset(chip);
314 if (runtime->channels > 1) { 314 if (runtime->channels > 1) {
315 /* restore input filter status */ 315 /* restore input filter status */
@@ -329,10 +329,10 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream,
329 return 0; 329 return 0;
330} 330}
331 331
332irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) 332irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip)
333{ 333{
334 snd_pcm_substream_t *substream; 334 struct snd_pcm_substream *substream;
335 snd_pcm_runtime_t *runtime; 335 struct snd_pcm_runtime *runtime;
336 336
337 snd_sb_ack_8bit(chip); 337 snd_sb_ack_8bit(chip);
338 switch (chip->mode) { 338 switch (chip->mode) {
@@ -354,9 +354,9 @@ irqreturn_t snd_sb8dsp_interrupt(sb_t *chip)
354 return IRQ_HANDLED; 354 return IRQ_HANDLED;
355} 355}
356 356
357static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substream) 357static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *substream)
358{ 358{
359 sb_t *chip = snd_pcm_substream_chip(substream); 359 struct snd_sb *chip = snd_pcm_substream_chip(substream);
360 size_t ptr; 360 size_t ptr;
361 361
362 if (chip->mode != SB_MODE_PLAYBACK_8) 362 if (chip->mode != SB_MODE_PLAYBACK_8)
@@ -365,9 +365,9 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substrea
365 return bytes_to_frames(substream->runtime, ptr); 365 return bytes_to_frames(substream->runtime, ptr);
366} 366}
367 367
368static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream) 368static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *substream)
369{ 369{
370 sb_t *chip = snd_pcm_substream_chip(substream); 370 struct snd_sb *chip = snd_pcm_substream_chip(substream);
371 size_t ptr; 371 size_t ptr;
372 372
373 if (chip->mode != SB_MODE_CAPTURE_8) 373 if (chip->mode != SB_MODE_CAPTURE_8)
@@ -380,7 +380,7 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream
380 380
381 */ 381 */
382 382
383static snd_pcm_hardware_t snd_sb8_playback = 383static struct snd_pcm_hardware snd_sb8_playback =
384{ 384{
385 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 385 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
386 SNDRV_PCM_INFO_MMAP_VALID), 386 SNDRV_PCM_INFO_MMAP_VALID),
@@ -399,7 +399,7 @@ static snd_pcm_hardware_t snd_sb8_playback =
399 .fifo_size = 0, 399 .fifo_size = 0,
400}; 400};
401 401
402static snd_pcm_hardware_t snd_sb8_capture = 402static struct snd_pcm_hardware snd_sb8_capture =
403{ 403{
404 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 404 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
405 SNDRV_PCM_INFO_MMAP_VALID), 405 SNDRV_PCM_INFO_MMAP_VALID),
@@ -422,10 +422,10 @@ static snd_pcm_hardware_t snd_sb8_capture =
422 * 422 *
423 */ 423 */
424 424
425static int snd_sb8_open(snd_pcm_substream_t *substream) 425static int snd_sb8_open(struct snd_pcm_substream *substream)
426{ 426{
427 sb_t *chip = snd_pcm_substream_chip(substream); 427 struct snd_sb *chip = snd_pcm_substream_chip(substream);
428 snd_pcm_runtime_t *runtime = substream->runtime; 428 struct snd_pcm_runtime *runtime = substream->runtime;
429 unsigned long flags; 429 unsigned long flags;
430 430
431 spin_lock_irqsave(&chip->open_lock, flags); 431 spin_lock_irqsave(&chip->open_lock, flags);
@@ -468,10 +468,10 @@ static int snd_sb8_open(snd_pcm_substream_t *substream)
468 return 0; 468 return 0;
469} 469}
470 470
471static int snd_sb8_close(snd_pcm_substream_t *substream) 471static int snd_sb8_close(struct snd_pcm_substream *substream)
472{ 472{
473 unsigned long flags; 473 unsigned long flags;
474 sb_t *chip = snd_pcm_substream_chip(substream); 474 struct snd_sb *chip = snd_pcm_substream_chip(substream);
475 475
476 chip->playback_substream = NULL; 476 chip->playback_substream = NULL;
477 chip->capture_substream = NULL; 477 chip->capture_substream = NULL;
@@ -485,7 +485,7 @@ static int snd_sb8_close(snd_pcm_substream_t *substream)
485 * Initialization part 485 * Initialization part
486 */ 486 */
487 487
488static snd_pcm_ops_t snd_sb8_playback_ops = { 488static struct snd_pcm_ops snd_sb8_playback_ops = {
489 .open = snd_sb8_open, 489 .open = snd_sb8_open,
490 .close = snd_sb8_close, 490 .close = snd_sb8_close,
491 .ioctl = snd_pcm_lib_ioctl, 491 .ioctl = snd_pcm_lib_ioctl,
@@ -496,7 +496,7 @@ static snd_pcm_ops_t snd_sb8_playback_ops = {
496 .pointer = snd_sb8_playback_pointer, 496 .pointer = snd_sb8_playback_pointer,
497}; 497};
498 498
499static snd_pcm_ops_t snd_sb8_capture_ops = { 499static struct snd_pcm_ops snd_sb8_capture_ops = {
500 .open = snd_sb8_open, 500 .open = snd_sb8_open,
501 .close = snd_sb8_close, 501 .close = snd_sb8_close,
502 .ioctl = snd_pcm_lib_ioctl, 502 .ioctl = snd_pcm_lib_ioctl,
@@ -507,15 +507,10 @@ static snd_pcm_ops_t snd_sb8_capture_ops = {
507 .pointer = snd_sb8_capture_pointer, 507 .pointer = snd_sb8_capture_pointer,
508}; 508};
509 509
510static void snd_sb8dsp_pcm_free(snd_pcm_t *pcm) 510int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm)
511{ 511{
512 snd_pcm_lib_preallocate_free_for_all(pcm); 512 struct snd_card *card = chip->card;
513} 513 struct snd_pcm *pcm;
514
515int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm)
516{
517 snd_card_t *card = chip->card;
518 snd_pcm_t *pcm;
519 int err; 514 int err;
520 515
521 if (rpcm) 516 if (rpcm)
@@ -525,7 +520,6 @@ int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm)
525 sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); 520 sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff);
526 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; 521 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
527 pcm->private_data = chip; 522 pcm->private_data = chip;
528 pcm->private_free = snd_sb8dsp_pcm_free;
529 523
530 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); 524 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops);
531 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); 525 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops);
diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c
index d2c633a40e74..c549aceea294 100644
--- a/sound/isa/sb/sb8_midi.c
+++ b/sound/isa/sb/sb8_midi.c
@@ -36,9 +36,9 @@
36 36
37 */ 37 */
38 38
39irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) 39irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb * chip)
40{ 40{
41 snd_rawmidi_t *rmidi; 41 struct snd_rawmidi *rmidi;
42 int max = 64; 42 int max = 64;
43 char byte; 43 char byte;
44 44
@@ -63,10 +63,10 @@ irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip)
63 63
64 */ 64 */
65 65
66static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream) 66static int snd_sb8dsp_midi_input_open(struct snd_rawmidi_substream *substream)
67{ 67{
68 unsigned long flags; 68 unsigned long flags;
69 sb_t *chip; 69 struct snd_sb *chip;
70 unsigned int valid_open_flags; 70 unsigned int valid_open_flags;
71 71
72 chip = substream->rmidi->private_data; 72 chip = substream->rmidi->private_data;
@@ -90,10 +90,10 @@ static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream)
90 return 0; 90 return 0;
91} 91}
92 92
93static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream) 93static int snd_sb8dsp_midi_output_open(struct snd_rawmidi_substream *substream)
94{ 94{
95 unsigned long flags; 95 unsigned long flags;
96 sb_t *chip; 96 struct snd_sb *chip;
97 unsigned int valid_open_flags; 97 unsigned int valid_open_flags;
98 98
99 chip = substream->rmidi->private_data; 99 chip = substream->rmidi->private_data;
@@ -117,10 +117,10 @@ static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream)
117 return 0; 117 return 0;
118} 118}
119 119
120static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream) 120static int snd_sb8dsp_midi_input_close(struct snd_rawmidi_substream *substream)
121{ 121{
122 unsigned long flags; 122 unsigned long flags;
123 sb_t *chip; 123 struct snd_sb *chip;
124 124
125 chip = substream->rmidi->private_data; 125 chip = substream->rmidi->private_data;
126 spin_lock_irqsave(&chip->open_lock, flags); 126 spin_lock_irqsave(&chip->open_lock, flags);
@@ -135,10 +135,10 @@ static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream)
135 return 0; 135 return 0;
136} 136}
137 137
138static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream) 138static int snd_sb8dsp_midi_output_close(struct snd_rawmidi_substream *substream)
139{ 139{
140 unsigned long flags; 140 unsigned long flags;
141 sb_t *chip; 141 struct snd_sb *chip;
142 142
143 chip = substream->rmidi->private_data; 143 chip = substream->rmidi->private_data;
144 spin_lock_irqsave(&chip->open_lock, flags); 144 spin_lock_irqsave(&chip->open_lock, flags);
@@ -153,10 +153,10 @@ static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream)
153 return 0; 153 return 0;
154} 154}
155 155
156static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) 156static void snd_sb8dsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
157{ 157{
158 unsigned long flags; 158 unsigned long flags;
159 sb_t *chip; 159 struct snd_sb *chip;
160 160
161 chip = substream->rmidi->private_data; 161 chip = substream->rmidi->private_data;
162 spin_lock_irqsave(&chip->open_lock, flags); 162 spin_lock_irqsave(&chip->open_lock, flags);
@@ -176,10 +176,10 @@ static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, i
176 spin_unlock_irqrestore(&chip->open_lock, flags); 176 spin_unlock_irqrestore(&chip->open_lock, flags);
177} 177}
178 178
179static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream) 179static void snd_sb8dsp_midi_output_write(struct snd_rawmidi_substream *substream)
180{ 180{
181 unsigned long flags; 181 unsigned long flags;
182 sb_t *chip; 182 struct snd_sb *chip;
183 char byte; 183 char byte;
184 int max = 32; 184 int max = 32;
185 185
@@ -214,8 +214,8 @@ static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream)
214 214
215static void snd_sb8dsp_midi_output_timer(unsigned long data) 215static void snd_sb8dsp_midi_output_timer(unsigned long data)
216{ 216{
217 snd_rawmidi_substream_t * substream = (snd_rawmidi_substream_t *) data; 217 struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data;
218 sb_t * chip = substream->rmidi->private_data; 218 struct snd_sb * chip = substream->rmidi->private_data;
219 unsigned long flags; 219 unsigned long flags;
220 220
221 spin_lock_irqsave(&chip->open_lock, flags); 221 spin_lock_irqsave(&chip->open_lock, flags);
@@ -225,10 +225,10 @@ static void snd_sb8dsp_midi_output_timer(unsigned long data)
225 snd_sb8dsp_midi_output_write(substream); 225 snd_sb8dsp_midi_output_write(substream);
226} 226}
227 227
228static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) 228static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
229{ 229{
230 unsigned long flags; 230 unsigned long flags;
231 sb_t *chip; 231 struct snd_sb *chip;
232 232
233 chip = substream->rmidi->private_data; 233 chip = substream->rmidi->private_data;
234 spin_lock_irqsave(&chip->open_lock, flags); 234 spin_lock_irqsave(&chip->open_lock, flags);
@@ -256,23 +256,23 @@ static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream,
256 256
257 */ 257 */
258 258
259static snd_rawmidi_ops_t snd_sb8dsp_midi_output = 259static struct snd_rawmidi_ops snd_sb8dsp_midi_output =
260{ 260{
261 .open = snd_sb8dsp_midi_output_open, 261 .open = snd_sb8dsp_midi_output_open,
262 .close = snd_sb8dsp_midi_output_close, 262 .close = snd_sb8dsp_midi_output_close,
263 .trigger = snd_sb8dsp_midi_output_trigger, 263 .trigger = snd_sb8dsp_midi_output_trigger,
264}; 264};
265 265
266static snd_rawmidi_ops_t snd_sb8dsp_midi_input = 266static struct snd_rawmidi_ops snd_sb8dsp_midi_input =
267{ 267{
268 .open = snd_sb8dsp_midi_input_open, 268 .open = snd_sb8dsp_midi_input_open,
269 .close = snd_sb8dsp_midi_input_close, 269 .close = snd_sb8dsp_midi_input_close,
270 .trigger = snd_sb8dsp_midi_input_trigger, 270 .trigger = snd_sb8dsp_midi_input_trigger,
271}; 271};
272 272
273int snd_sb8dsp_midi(sb_t *chip, int device, snd_rawmidi_t ** rrawmidi) 273int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi)
274{ 274{
275 snd_rawmidi_t *rmidi; 275 struct snd_rawmidi *rmidi;
276 int err; 276 int err;
277 277
278 if (rrawmidi) 278 if (rrawmidi)
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 603e923b5d2f..f343a8211d2d 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -41,7 +41,7 @@ MODULE_LICENSE("GPL");
41 41
42#undef IO_DEBUG 42#undef IO_DEBUG
43 43
44int snd_sbdsp_command(sb_t *chip, unsigned char val) 44int snd_sbdsp_command(struct snd_sb *chip, unsigned char val)
45{ 45{
46 int i; 46 int i;
47#ifdef IO_DEBUG 47#ifdef IO_DEBUG
@@ -56,7 +56,7 @@ int snd_sbdsp_command(sb_t *chip, unsigned char val)
56 return 0; 56 return 0;
57} 57}
58 58
59int snd_sbdsp_get_byte(sb_t *chip) 59int snd_sbdsp_get_byte(struct snd_sb *chip)
60{ 60{
61 int val; 61 int val;
62 int i; 62 int i;
@@ -73,7 +73,7 @@ int snd_sbdsp_get_byte(sb_t *chip)
73 return -ENODEV; 73 return -ENODEV;
74} 74}
75 75
76int snd_sbdsp_reset(sb_t *chip) 76int snd_sbdsp_reset(struct snd_sb *chip)
77{ 77{
78 int i; 78 int i;
79 79
@@ -92,7 +92,7 @@ int snd_sbdsp_reset(sb_t *chip)
92 return -ENODEV; 92 return -ENODEV;
93} 93}
94 94
95static int snd_sbdsp_version(sb_t * chip) 95static int snd_sbdsp_version(struct snd_sb * chip)
96{ 96{
97 unsigned int result = -ENODEV; 97 unsigned int result = -ENODEV;
98 98
@@ -102,7 +102,7 @@ static int snd_sbdsp_version(sb_t * chip)
102 return result; 102 return result;
103} 103}
104 104
105static int snd_sbdsp_probe(sb_t * chip) 105static int snd_sbdsp_probe(struct snd_sb * chip)
106{ 106{
107 int version; 107 int version;
108 int major, minor; 108 int major, minor;
@@ -176,7 +176,7 @@ static int snd_sbdsp_probe(sb_t * chip)
176 return 0; 176 return 0;
177} 177}
178 178
179static int snd_sbdsp_free(sb_t *chip) 179static int snd_sbdsp_free(struct snd_sb *chip)
180{ 180{
181 if (chip->res_port) 181 if (chip->res_port)
182 release_and_free_resource(chip->res_port); 182 release_and_free_resource(chip->res_port);
@@ -196,24 +196,24 @@ static int snd_sbdsp_free(sb_t *chip)
196 return 0; 196 return 0;
197} 197}
198 198
199static int snd_sbdsp_dev_free(snd_device_t *device) 199static int snd_sbdsp_dev_free(struct snd_device *device)
200{ 200{
201 sb_t *chip = device->device_data; 201 struct snd_sb *chip = device->device_data;
202 return snd_sbdsp_free(chip); 202 return snd_sbdsp_free(chip);
203} 203}
204 204
205int snd_sbdsp_create(snd_card_t *card, 205int snd_sbdsp_create(struct snd_card *card,
206 unsigned long port, 206 unsigned long port,
207 int irq, 207 int irq,
208 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *), 208 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *),
209 int dma8, 209 int dma8,
210 int dma16, 210 int dma16,
211 unsigned short hardware, 211 unsigned short hardware,
212 sb_t **r_chip) 212 struct snd_sb **r_chip)
213{ 213{
214 sb_t *chip; 214 struct snd_sb *chip;
215 int err; 215 int err;
216 static snd_device_ops_t ops = { 216 static struct snd_device_ops ops = {
217 .dev_free = snd_sbdsp_dev_free, 217 .dev_free = snd_sbdsp_dev_free,
218 }; 218 };
219 219
@@ -293,6 +293,10 @@ EXPORT_SYMBOL(snd_sbmixer_write);
293EXPORT_SYMBOL(snd_sbmixer_read); 293EXPORT_SYMBOL(snd_sbmixer_read);
294EXPORT_SYMBOL(snd_sbmixer_new); 294EXPORT_SYMBOL(snd_sbmixer_new);
295EXPORT_SYMBOL(snd_sbmixer_add_ctl); 295EXPORT_SYMBOL(snd_sbmixer_add_ctl);
296#ifdef CONFIG_PM
297EXPORT_SYMBOL(snd_sbmixer_suspend);
298EXPORT_SYMBOL(snd_sbmixer_resume);
299#endif
296 300
297/* 301/*
298 * INIT part 302 * INIT part
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c
index 5a926a452d38..1a6ee344dddb 100644
--- a/sound/isa/sb/sb_mixer.c
+++ b/sound/isa/sb/sb_mixer.c
@@ -29,7 +29,7 @@
29 29
30#undef IO_DEBUG 30#undef IO_DEBUG
31 31
32void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data) 32void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data)
33{ 33{
34 outb(reg, SBP(chip, MIXER_ADDR)); 34 outb(reg, SBP(chip, MIXER_ADDR));
35 udelay(10); 35 udelay(10);
@@ -40,7 +40,7 @@ void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data)
40#endif 40#endif
41} 41}
42 42
43unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg) 43unsigned char snd_sbmixer_read(struct snd_sb *chip, unsigned char reg)
44{ 44{
45 unsigned char result; 45 unsigned char result;
46 46
@@ -58,7 +58,7 @@ unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg)
58 * Single channel mixer element 58 * Single channel mixer element
59 */ 59 */
60 60
61static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 61static int snd_sbmixer_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
62{ 62{
63 int mask = (kcontrol->private_value >> 24) & 0xff; 63 int mask = (kcontrol->private_value >> 24) & 0xff;
64 64
@@ -69,9 +69,9 @@ static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
69 return 0; 69 return 0;
70} 70}
71 71
72static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 72static int snd_sbmixer_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
73{ 73{
74 sb_t *sb = snd_kcontrol_chip(kcontrol); 74 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
75 unsigned long flags; 75 unsigned long flags;
76 int reg = kcontrol->private_value & 0xff; 76 int reg = kcontrol->private_value & 0xff;
77 int shift = (kcontrol->private_value >> 16) & 0xff; 77 int shift = (kcontrol->private_value >> 16) & 0xff;
@@ -85,9 +85,9 @@ static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
85 return 0; 85 return 0;
86} 86}
87 87
88static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 88static int snd_sbmixer_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
89{ 89{
90 sb_t *sb = snd_kcontrol_chip(kcontrol); 90 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
91 unsigned long flags; 91 unsigned long flags;
92 int reg = kcontrol->private_value & 0xff; 92 int reg = kcontrol->private_value & 0xff;
93 int shift = (kcontrol->private_value >> 16) & 0x07; 93 int shift = (kcontrol->private_value >> 16) & 0x07;
@@ -110,7 +110,7 @@ static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
110 * Double channel mixer element 110 * Double channel mixer element
111 */ 111 */
112 112
113static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 113static int snd_sbmixer_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
114{ 114{
115 int mask = (kcontrol->private_value >> 24) & 0xff; 115 int mask = (kcontrol->private_value >> 24) & 0xff;
116 116
@@ -121,9 +121,9 @@ static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
121 return 0; 121 return 0;
122} 122}
123 123
124static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 124static int snd_sbmixer_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
125{ 125{
126 sb_t *sb = snd_kcontrol_chip(kcontrol); 126 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
127 unsigned long flags; 127 unsigned long flags;
128 int left_reg = kcontrol->private_value & 0xff; 128 int left_reg = kcontrol->private_value & 0xff;
129 int right_reg = (kcontrol->private_value >> 8) & 0xff; 129 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -141,9 +141,9 @@ static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
141 return 0; 141 return 0;
142} 142}
143 143
144static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 144static int snd_sbmixer_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
145{ 145{
146 sb_t *sb = snd_kcontrol_chip(kcontrol); 146 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
147 unsigned long flags; 147 unsigned long flags;
148 int left_reg = kcontrol->private_value & 0xff; 148 int left_reg = kcontrol->private_value & 0xff;
149 int right_reg = (kcontrol->private_value >> 8) & 0xff; 149 int right_reg = (kcontrol->private_value >> 8) & 0xff;
@@ -181,7 +181,7 @@ static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
181 * DT-019x / ALS-007 capture/input switch 181 * DT-019x / ALS-007 capture/input switch
182 */ 182 */
183 183
184static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 184static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
185{ 185{
186 static char *texts[5] = { 186 static char *texts[5] = {
187 "CD", "Mic", "Line", "Synth", "Master" 187 "CD", "Mic", "Line", "Synth", "Master"
@@ -196,9 +196,9 @@ static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
196 return 0; 196 return 0;
197} 197}
198 198
199static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 199static int snd_dt019x_input_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
200{ 200{
201 sb_t *sb = snd_kcontrol_chip(kcontrol); 201 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
202 unsigned long flags; 202 unsigned long flags;
203 unsigned char oval; 203 unsigned char oval;
204 204
@@ -232,9 +232,9 @@ static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
232 return 0; 232 return 0;
233} 233}
234 234
235static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 235static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
236{ 236{
237 sb_t *sb = snd_kcontrol_chip(kcontrol); 237 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
238 unsigned long flags; 238 unsigned long flags;
239 int change; 239 int change;
240 unsigned char nval, oval; 240 unsigned char nval, oval;
@@ -273,7 +273,7 @@ static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
273 * SBPRO input multiplexer 273 * SBPRO input multiplexer
274 */ 274 */
275 275
276static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 276static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
277{ 277{
278 static char *texts[3] = { 278 static char *texts[3] = {
279 "Mic", "CD", "Line" 279 "Mic", "CD", "Line"
@@ -289,9 +289,9 @@ static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
289} 289}
290 290
291 291
292static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 292static int snd_sb8mixer_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
293{ 293{
294 sb_t *sb = snd_kcontrol_chip(kcontrol); 294 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
295 unsigned long flags; 295 unsigned long flags;
296 unsigned char oval; 296 unsigned char oval;
297 297
@@ -312,9 +312,9 @@ static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
312 return 0; 312 return 0;
313} 313}
314 314
315static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 315static int snd_sb8mixer_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
316{ 316{
317 sb_t *sb = snd_kcontrol_chip(kcontrol); 317 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
318 unsigned long flags; 318 unsigned long flags;
319 int change; 319 int change;
320 unsigned char nval, oval; 320 unsigned char nval, oval;
@@ -346,7 +346,7 @@ static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
346 * SB16 input switch 346 * SB16 input switch
347 */ 347 */
348 348
349static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) 349static int snd_sb16mixer_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
350{ 350{
351 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 351 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
352 uinfo->count = 4; 352 uinfo->count = 4;
@@ -355,9 +355,9 @@ static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_i
355 return 0; 355 return 0;
356} 356}
357 357
358static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 358static int snd_sb16mixer_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
359{ 359{
360 sb_t *sb = snd_kcontrol_chip(kcontrol); 360 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
361 unsigned long flags; 361 unsigned long flags;
362 int reg1 = kcontrol->private_value & 0xff; 362 int reg1 = kcontrol->private_value & 0xff;
363 int reg2 = (kcontrol->private_value >> 8) & 0xff; 363 int reg2 = (kcontrol->private_value >> 8) & 0xff;
@@ -376,9 +376,9 @@ static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
376 return 0; 376 return 0;
377} 377}
378 378
379static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 379static int snd_sb16mixer_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
380{ 380{
381 sb_t *sb = snd_kcontrol_chip(kcontrol); 381 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
382 unsigned long flags; 382 unsigned long flags;
383 int reg1 = kcontrol->private_value & 0xff; 383 int reg1 = kcontrol->private_value & 0xff;
384 int reg2 = (kcontrol->private_value >> 8) & 0xff; 384 int reg2 = (kcontrol->private_value >> 8) & 0xff;
@@ -410,9 +410,9 @@ static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
410 */ 410 */
411/* 411/*
412 */ 412 */
413int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsigned long value) 413int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value)
414{ 414{
415 static snd_kcontrol_new_t newctls[] = { 415 static struct snd_kcontrol_new newctls[] = {
416 [SB_MIX_SINGLE] = { 416 [SB_MIX_SINGLE] = {
417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
418 .info = snd_sbmixer_info_single, 418 .info = snd_sbmixer_info_single,
@@ -444,7 +444,7 @@ int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsig
444 .put = snd_dt019x_input_sw_put, 444 .put = snd_dt019x_input_sw_put,
445 }, 445 },
446 }; 446 };
447 snd_kcontrol_t *ctl; 447 struct snd_kcontrol *ctl;
448 int err; 448 int err;
449 449
450 ctl = snd_ctl_new1(&newctls[type], chip); 450 ctl = snd_ctl_new1(&newctls[type], chip);
@@ -669,25 +669,34 @@ static unsigned char snd_dt019x_init_values[][2] = {
669/* 669/*
670 * ALS4000 specific mixer elements 670 * ALS4000 specific mixer elements
671 */ 671 */
672/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl ! */ 672/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl! */
673static struct sbmix_elem snd_als4000_ctl_mono_output_switch = 673static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch =
674 SB_SINGLE("Mono Output Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); 674 SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1);
675/* FIXME: mono input switch also available on DT019X ? */ 675static struct sbmix_elem snd_als4000_ctl_master_mono_capture_route =
676static struct sbmix_elem snd_als4000_ctl_mono_input_switch = 676 SB_SINGLE("Master Mono Capture Route", SB_ALS4000_MONO_IO_CTRL, 6, 0x03);
677 SB_SINGLE("Mono Input Switch", SB_DT019X_OUTPUT_SW2, 0, 1); 677/* FIXME: mono playback switch also available on DT019X? */
678static struct sbmix_elem snd_als4000_ctl_mono_playback_switch =
679 SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1);
678static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = 680static struct sbmix_elem snd_als4000_ctl_mic_20db_boost =
679 SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); 681 SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03);
680static struct sbmix_elem snd_als4000_ctl_mixer_out_to_in = 682static struct sbmix_elem snd_als4000_ctl_mixer_loopback =
681 SB_SINGLE("Mixer Out To In", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); 683 SB_SINGLE("Analog Loopback", SB_ALS4000_MIC_IN_GAIN, 7, 0x01);
682/* FIXME: 3D needs much more sophisticated controls, many more features ! */ 684/* FIXME: functionality of 3D controls might be swapped, I didn't find
683static struct sbmix_elem snd_als4000_ctl_3d_output_switch = 685 * a description of how to identify what is supposed to be what */
684 SB_SINGLE("3D Output Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); 686static struct sbmix_elem snd_als4000_3d_control_switch =
685static struct sbmix_elem snd_als4000_ctl_3d_output_ratio = 687 SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01);
686 SB_SINGLE("3D Output Ratio", SB_ALS4000_3D_SND_FX, 0, 0x07); 688static struct sbmix_elem snd_als4000_3d_control_ratio =
687static struct sbmix_elem snd_als4000_ctl_3d_poweroff_switch = 689 SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07);
690static struct sbmix_elem snd_als4000_3d_control_freq =
691 /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */
692 SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03);
693static struct sbmix_elem snd_als4000_3d_control_delay =
694 /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay,
695 * but what ALSA 3D attribute is that actually? "Center", "Depth",
696 * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */
697 SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f);
698static struct sbmix_elem snd_als4000_3d_control_poweroff_switch =
688 SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); 699 SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01);
689static struct sbmix_elem snd_als4000_ctl_3d_delay =
690 SB_SINGLE("3D Delay", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f);
691#ifdef NOT_AVAILABLE 700#ifdef NOT_AVAILABLE
692static struct sbmix_elem snd_als4000_ctl_fmdac = 701static struct sbmix_elem snd_als4000_ctl_fmdac =
693 SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); 702 SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01);
@@ -716,13 +725,15 @@ static struct sbmix_elem *snd_als4000_controls[] = {
716 &snd_sb16_ctl_pc_speaker_vol, 725 &snd_sb16_ctl_pc_speaker_vol,
717 &snd_sb16_ctl_capture_vol, 726 &snd_sb16_ctl_capture_vol,
718 &snd_sb16_ctl_play_vol, 727 &snd_sb16_ctl_play_vol,
719 &snd_als4000_ctl_mono_output_switch, 728 &snd_als4000_ctl_master_mono_playback_switch,
720 &snd_als4000_ctl_mono_input_switch, 729 &snd_als4000_ctl_master_mono_capture_route,
721 &snd_als4000_ctl_mixer_out_to_in, 730 &snd_als4000_ctl_mono_playback_switch,
722 &snd_als4000_ctl_3d_output_switch, 731 &snd_als4000_ctl_mixer_loopback,
723 &snd_als4000_ctl_3d_output_ratio, 732 &snd_als4000_3d_control_switch,
724 &snd_als4000_ctl_3d_delay, 733 &snd_als4000_3d_control_ratio,
725 &snd_als4000_ctl_3d_poweroff_switch, 734 &snd_als4000_3d_control_freq,
735 &snd_als4000_3d_control_delay,
736 &snd_als4000_3d_control_poweroff_switch,
726#ifdef NOT_AVAILABLE 737#ifdef NOT_AVAILABLE
727 &snd_als4000_ctl_fmdac, 738 &snd_als4000_ctl_fmdac,
728 &snd_als4000_ctl_qsound, 739 &snd_als4000_ctl_qsound,
@@ -747,7 +758,7 @@ static unsigned char snd_als4000_init_values[][2] = {
747 758
748/* 759/*
749 */ 760 */
750static int snd_sbmixer_init(sb_t *chip, 761static int snd_sbmixer_init(struct snd_sb *chip,
751 struct sbmix_elem **controls, 762 struct sbmix_elem **controls,
752 int controls_count, 763 int controls_count,
753 unsigned char map[][2], 764 unsigned char map[][2],
@@ -755,7 +766,7 @@ static int snd_sbmixer_init(sb_t *chip,
755 char *name) 766 char *name)
756{ 767{
757 unsigned long flags; 768 unsigned long flags;
758 snd_card_t *card = chip->card; 769 struct snd_card *card = chip->card;
759 int idx, err; 770 int idx, err;
760 771
761 /* mixer reset */ 772 /* mixer reset */
@@ -779,9 +790,9 @@ static int snd_sbmixer_init(sb_t *chip,
779 return 0; 790 return 0;
780} 791}
781 792
782int snd_sbmixer_new(sb_t *chip) 793int snd_sbmixer_new(struct snd_sb *chip)
783{ 794{
784 snd_card_t * card; 795 struct snd_card *card;
785 int err; 796 int err;
786 797
787 snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); 798 snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
@@ -842,3 +853,140 @@ int snd_sbmixer_new(sb_t *chip)
842 } 853 }
843 return 0; 854 return 0;
844} 855}
856
857#ifdef CONFIG_PM
858static unsigned char sb20_saved_regs[] = {
859 SB_DSP20_MASTER_DEV,
860 SB_DSP20_PCM_DEV,
861 SB_DSP20_FM_DEV,
862 SB_DSP20_CD_DEV,
863};
864
865static unsigned char sbpro_saved_regs[] = {
866 SB_DSP_MASTER_DEV,
867 SB_DSP_PCM_DEV,
868 SB_DSP_PLAYBACK_FILT,
869 SB_DSP_FM_DEV,
870 SB_DSP_CD_DEV,
871 SB_DSP_LINE_DEV,
872 SB_DSP_MIC_DEV,
873 SB_DSP_CAPTURE_SOURCE,
874 SB_DSP_CAPTURE_FILT,
875};
876
877static unsigned char sb16_saved_regs[] = {
878 SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1,
879 SB_DSP4_3DSE,
880 SB_DSP4_BASS_DEV, SB_DSP4_BASS_DEV + 1,
881 SB_DSP4_TREBLE_DEV, SB_DSP4_TREBLE_DEV + 1,
882 SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1,
883 SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT,
884 SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1,
885 SB_DSP4_OUTPUT_SW,
886 SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1,
887 SB_DSP4_LINE_DEV, SB_DSP4_LINE_DEV + 1,
888 SB_DSP4_MIC_DEV,
889 SB_DSP4_SPEAKER_DEV,
890 SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1,
891 SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1,
892 SB_DSP4_MIC_AGC
893};
894
895static unsigned char dt019x_saved_regs[] = {
896 SB_DT019X_MASTER_DEV,
897 SB_DT019X_PCM_DEV,
898 SB_DT019X_SYNTH_DEV,
899 SB_DT019X_CD_DEV,
900 SB_DT019X_MIC_DEV,
901 SB_DT019X_SPKR_DEV,
902 SB_DT019X_LINE_DEV,
903 SB_DSP4_OUTPUT_SW,
904 SB_DT019X_OUTPUT_SW2,
905 SB_DT019X_CAPTURE_SW,
906};
907
908static unsigned char als4000_saved_regs[] = {
909 SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1,
910 SB_DSP4_OUTPUT_SW,
911 SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1,
912 SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT,
913 SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1,
914 SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1,
915 SB_DSP4_MIC_AGC,
916 SB_DSP4_MIC_DEV,
917 SB_DSP4_SPEAKER_DEV,
918 SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1,
919 SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1,
920 SB_DT019X_OUTPUT_SW2,
921 SB_ALS4000_MONO_IO_CTRL,
922 SB_ALS4000_MIC_IN_GAIN,
923 SB_ALS4000_3D_SND_FX,
924 SB_ALS4000_3D_TIME_DELAY,
925};
926
927static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs)
928{
929 unsigned char *val = chip->saved_regs;
930 snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return);
931 for (; num_regs; num_regs--)
932 *val++ = snd_sbmixer_read(chip, *regs++);
933}
934
935static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs)
936{
937 unsigned char *val = chip->saved_regs;
938 snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return);
939 for (; num_regs; num_regs--)
940 snd_sbmixer_write(chip, *regs++, *val++);
941}
942
943void snd_sbmixer_suspend(struct snd_sb *chip)
944{
945 switch (chip->hardware) {
946 case SB_HW_20:
947 case SB_HW_201:
948 save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs));
949 break;
950 case SB_HW_PRO:
951 save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs));
952 break;
953 case SB_HW_16:
954 case SB_HW_ALS100:
955 save_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs));
956 break;
957 case SB_HW_ALS4000:
958 save_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs));
959 break;
960 case SB_HW_DT019X:
961 save_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs));
962 break;
963 default:
964 break;
965 }
966}
967
968void snd_sbmixer_resume(struct snd_sb *chip)
969{
970 switch (chip->hardware) {
971 case SB_HW_20:
972 case SB_HW_201:
973 restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs));
974 break;
975 case SB_HW_PRO:
976 restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs));
977 break;
978 case SB_HW_16:
979 case SB_HW_ALS100:
980 restore_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs));
981 break;
982 case SB_HW_ALS4000:
983 restore_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs));
984 break;
985 case SB_HW_DT019X:
986 restore_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs));
987 break;
988 default:
989 break;
990 }
991}
992#endif
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
index 52f2294da62b..0dbbb35b242c 100644
--- a/sound/isa/sgalaxy.c
+++ b/sound/isa/sgalaxy.c
@@ -22,12 +22,14 @@
22 */ 22 */
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <asm/dma.h>
26#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h>
27#include <linux/platform_device.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/time.h> 29#include <linux/time.h>
29#include <linux/interrupt.h> 30#include <linux/interrupt.h>
30#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <asm/dma.h>
31#include <sound/core.h> 33#include <sound/core.h>
32#include <sound/sb.h> 34#include <sound/sb.h>
33#include <sound/ad1848.h> 35#include <sound/ad1848.h>
@@ -62,11 +64,11 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver.");
62module_param_array(dma1, int, NULL, 0444); 64module_param_array(dma1, int, NULL, 0444);
63MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); 65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
64 66
67static struct platform_device *devices[SNDRV_CARDS];
68
65#define SGALAXY_AUXC_LEFT 18 69#define SGALAXY_AUXC_LEFT 18
66#define SGALAXY_AUXC_RIGHT 19 70#define SGALAXY_AUXC_RIGHT 19
67 71
68static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
69
70#define PFX "sgalaxy: " 72#define PFX "sgalaxy: "
71 73
72/* 74/*
@@ -75,7 +77,7 @@ static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
75 77
76#define AD1848P1( port, x ) ( port + c_d_c_AD1848##x ) 78#define AD1848P1( port, x ) ( port + c_d_c_AD1848##x )
77 79
78/* from lowlevel/sb/sb.c - to avoid having to allocate a sb_t for the */ 80/* from lowlevel/sb/sb.c - to avoid having to allocate a struct snd_sb for the */
79/* short time we actually need it.. */ 81/* short time we actually need it.. */
80 82
81static int snd_sgalaxy_sbdsp_reset(unsigned long port) 83static int snd_sgalaxy_sbdsp_reset(unsigned long port)
@@ -180,10 +182,10 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7
180AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) 182AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0)
181}; 183};
182 184
183static int __init snd_sgalaxy_mixer(ad1848_t *chip) 185static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip)
184{ 186{
185 snd_card_t *card = chip->card; 187 struct snd_card *card = chip->card;
186 snd_ctl_elem_id_t id1, id2; 188 struct snd_ctl_elem_id id1, id2;
187 unsigned int idx; 189 unsigned int idx;
188 int err; 190 int err;
189 191
@@ -216,13 +218,14 @@ static int __init snd_sgalaxy_mixer(ad1848_t *chip)
216 return 0; 218 return 0;
217} 219}
218 220
219static int __init snd_sgalaxy_probe(int dev) 221static int __init snd_sgalaxy_probe(struct platform_device *devptr)
220{ 222{
223 int dev = devptr->id;
221 static int possible_irqs[] = {7, 9, 10, 11, -1}; 224 static int possible_irqs[] = {7, 9, 10, 11, -1};
222 static int possible_dmas[] = {1, 3, 0, -1}; 225 static int possible_dmas[] = {1, 3, 0, -1};
223 int err, xirq, xdma1; 226 int err, xirq, xdma1;
224 snd_card_t *card; 227 struct snd_card *card;
225 ad1848_t *chip; 228 struct snd_ad1848 *chip;
226 229
227 if (sbport[dev] == SNDRV_AUTO_PORT) { 230 if (sbport[dev] == SNDRV_AUTO_PORT) {
228 snd_printk(KERN_ERR PFX "specify SB port\n"); 231 snd_printk(KERN_ERR PFX "specify SB port\n");
@@ -260,6 +263,7 @@ static int __init snd_sgalaxy_probe(int dev)
260 xirq, xdma1, 263 xirq, xdma1,
261 AD1848_HW_DETECT, &chip)) < 0) 264 AD1848_HW_DETECT, &chip)) < 0)
262 goto _err; 265 goto _err;
266 card->private_data = chip;
263 267
264 if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { 268 if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) {
265 snd_printdd(PFX "error creating new ad1848 PCM device\n"); 269 snd_printdd(PFX "error creating new ad1848 PCM device\n");
@@ -279,13 +283,12 @@ static int __init snd_sgalaxy_probe(int dev)
279 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", 283 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d",
280 wssport[dev], xirq, xdma1); 284 wssport[dev], xirq, xdma1);
281 285
282 if ((err = snd_card_set_generic_dev(card)) < 0) 286 snd_card_set_dev(card, &devptr->dev);
283 goto _err;
284 287
285 if ((err = snd_card_register(card)) < 0) 288 if ((err = snd_card_register(card)) < 0)
286 goto _err; 289 goto _err;
287 290
288 snd_sgalaxy_cards[dev] = card; 291 platform_set_drvdata(devptr, card);
289 return 0; 292 return 0;
290 293
291 _err: 294 _err:
@@ -293,30 +296,98 @@ static int __init snd_sgalaxy_probe(int dev)
293 return err; 296 return err;
294} 297}
295 298
299static int __devexit snd_sgalaxy_remove(struct platform_device *devptr)
300{
301 snd_card_free(platform_get_drvdata(devptr));
302 platform_set_drvdata(devptr, NULL);
303 return 0;
304}
305
306#ifdef CONFIG_PM
307static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state)
308{
309 struct snd_card *card = platform_get_drvdata(pdev);
310 struct snd_ad1848 *chip = card->private_data;
311
312 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
313 chip->suspend(chip);
314 return 0;
315}
316
317static int snd_sgalaxy_resume(struct platform_device *pdev)
318{
319 struct snd_card *card = platform_get_drvdata(pdev);
320 struct snd_ad1848 *chip = card->private_data;
321
322 chip->resume(chip);
323 snd_ad1848_out(chip, SGALAXY_AUXC_LEFT, chip->image[SGALAXY_AUXC_LEFT]);
324 snd_ad1848_out(chip, SGALAXY_AUXC_RIGHT, chip->image[SGALAXY_AUXC_RIGHT]);
325
326 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
327 return 0;
328}
329#endif
330
331#define SND_SGALAXY_DRIVER "snd_sgalaxy"
332
333static struct platform_driver snd_sgalaxy_driver = {
334 .probe = snd_sgalaxy_probe,
335 .remove = __devexit_p(snd_sgalaxy_remove),
336#ifdef CONFIG_PM
337 .suspend = snd_sgalaxy_suspend,
338 .resume = snd_sgalaxy_resume,
339#endif
340 .driver = {
341 .name = SND_SGALAXY_DRIVER
342 },
343};
344
345static void __init_or_module snd_sgalaxy_unregister_all(void)
346{
347 int i;
348
349 for (i = 0; i < ARRAY_SIZE(devices); ++i)
350 platform_device_unregister(devices[i]);
351 platform_driver_unregister(&snd_sgalaxy_driver);
352}
353
296static int __init alsa_card_sgalaxy_init(void) 354static int __init alsa_card_sgalaxy_init(void)
297{ 355{
298 int dev, cards; 356 int i, cards, err;
357
358 err = platform_driver_register(&snd_sgalaxy_driver);
359 if (err < 0)
360 return err;
299 361
300 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { 362 cards = 0;
301 if (snd_sgalaxy_probe(dev) >= 0) 363 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
302 cards++; 364 struct platform_device *device;
365 device = platform_device_register_simple(SND_SGALAXY_DRIVER,
366 i, NULL, 0);
367 if (IS_ERR(device)) {
368 err = PTR_ERR(device);
369 goto errout;
370 }
371 devices[i] = device;
372 cards++;
303 } 373 }
304 if (!cards) { 374 if (!cards) {
305#ifdef MODULE 375#ifdef MODULE
306 snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); 376 snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
307#endif 377#endif
308 return -ENODEV; 378 err = -ENODEV;
379 goto errout;
309 } 380 }
310
311 return 0; 381 return 0;
382
383 errout:
384 snd_sgalaxy_unregister_all();
385 return err;
312} 386}
313 387
314static void __exit alsa_card_sgalaxy_exit(void) 388static void __exit alsa_card_sgalaxy_exit(void)
315{ 389{
316 int idx; 390 snd_sgalaxy_unregister_all();
317
318 for (idx = 0; idx < SNDRV_CARDS; idx++)
319 snd_card_free(snd_sgalaxy_cards[idx]);
320} 391}
321 392
322module_init(alsa_card_sgalaxy_init) 393module_init(alsa_card_sgalaxy_init)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 11588067fa4f..5fb981c0a281 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -23,6 +23,8 @@
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h>
27#include <linux/platform_device.h>
26#include <linux/delay.h> 28#include <linux/delay.h>
27#include <linux/pnp.h> 29#include <linux/pnp.h>
28#include <linux/spinlock.h> 30#include <linux/spinlock.h>
@@ -65,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
65 67
66module_param_array(dma, int, NULL, 0444); 68module_param_array(dma, int, NULL, 0444);
67MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); 69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
70
71static struct platform_device *platform_devices[SNDRV_CARDS];
72static int pnp_registered;
68 73
69#ifdef CONFIG_PNP 74#ifdef CONFIG_PNP
70static struct pnp_card_device_id sscape_pnpids[] = { 75static struct pnp_card_device_id sscape_pnpids[] = {
@@ -75,8 +80,6 @@ static struct pnp_card_device_id sscape_pnpids[] = {
75MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); 80MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
76#endif 81#endif
77 82
78static snd_card_t *sscape_card[SNDRV_CARDS];
79
80 83
81#define MPU401_IO(i) ((i) + 0) 84#define MPU401_IO(i) ((i) + 0)
82#define MIDI_DATA_IO(i) ((i) + 0) 85#define MIDI_DATA_IO(i) ((i) + 0)
@@ -127,9 +130,9 @@ struct soundscape {
127 int codec_type; 130 int codec_type;
128 int ic_type; 131 int ic_type;
129 struct resource *io_res; 132 struct resource *io_res;
130 cs4231_t *chip; 133 struct snd_cs4231 *chip;
131 mpu401_t *mpu; 134 struct snd_mpu401 *mpu;
132 snd_hwdep_t *hw; 135 struct snd_hwdep *hw;
133 136
134 /* 137 /*
135 * The MIDI device won't work until we've loaded 138 * The MIDI device won't work until we've loaded
@@ -144,17 +147,17 @@ struct soundscape {
144#define INVALID_IRQ ((unsigned)-1) 147#define INVALID_IRQ ((unsigned)-1)
145 148
146 149
147static inline struct soundscape *get_card_soundscape(snd_card_t * c) 150static inline struct soundscape *get_card_soundscape(struct snd_card *c)
148{ 151{
149 return (struct soundscape *) (c->private_data); 152 return (struct soundscape *) (c->private_data);
150} 153}
151 154
152static inline struct soundscape *get_mpu401_soundscape(mpu401_t * mpu) 155static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu)
153{ 156{
154 return (struct soundscape *) (mpu->private_data); 157 return (struct soundscape *) (mpu->private_data);
155} 158}
156 159
157static inline struct soundscape *get_hwdep_soundscape(snd_hwdep_t * hw) 160static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw)
158{ 161{
159 return (struct soundscape *) (hw->private_data); 162 return (struct soundscape *) (hw->private_data);
160} 163}
@@ -308,7 +311,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
308 * 311 *
309 * NOTE: This check is based upon observation, not documentation. 312 * NOTE: This check is based upon observation, not documentation.
310 */ 313 */
311static inline int verify_mpu401(const mpu401_t * mpu) 314static inline int verify_mpu401(const struct snd_mpu401 * mpu)
312{ 315{
313 return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80); 316 return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80);
314} 317}
@@ -316,7 +319,7 @@ static inline int verify_mpu401(const mpu401_t * mpu)
316/* 319/*
317 * This is apparently the standard way to initailise an MPU-401 320 * This is apparently the standard way to initailise an MPU-401
318 */ 321 */
319static inline void initialise_mpu401(const mpu401_t * mpu) 322static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
320{ 323{
321 outb(0, MIDI_DATA_IO(mpu->port)); 324 outb(0, MIDI_DATA_IO(mpu->port));
322} 325}
@@ -335,7 +338,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base)
335/* 338/*
336 * Do the necessary ALSA-level cleanup to deallocate our driver ... 339 * Do the necessary ALSA-level cleanup to deallocate our driver ...
337 */ 340 */
338static void soundscape_free(snd_card_t * c) 341static void soundscape_free(struct snd_card *c)
339{ 342{
340 register struct soundscape *sscape = get_card_soundscape(c); 343 register struct soundscape *sscape = get_card_soundscape(c);
341 release_and_free_resource(sscape->io_res); 344 release_and_free_resource(sscape->io_res);
@@ -613,7 +616,7 @@ static int sscape_upload_microcode(struct soundscape *sscape,
613 * simultaneously, and that we can't open it at all if 616 * simultaneously, and that we can't open it at all if
614 * someone is using the MIDI device. 617 * someone is using the MIDI device.
615 */ 618 */
616static int sscape_hw_open(snd_hwdep_t * hw, struct file *file) 619static int sscape_hw_open(struct snd_hwdep * hw, struct file *file)
617{ 620{
618 register struct soundscape *sscape = get_hwdep_soundscape(hw); 621 register struct soundscape *sscape = get_hwdep_soundscape(hw);
619 unsigned long flags; 622 unsigned long flags;
@@ -632,7 +635,7 @@ static int sscape_hw_open(snd_hwdep_t * hw, struct file *file)
632 return err; 635 return err;
633} 636}
634 637
635static int sscape_hw_release(snd_hwdep_t * hw, struct file *file) 638static int sscape_hw_release(struct snd_hwdep * hw, struct file *file)
636{ 639{
637 register struct soundscape *sscape = get_hwdep_soundscape(hw); 640 register struct soundscape *sscape = get_hwdep_soundscape(hw);
638 unsigned long flags; 641 unsigned long flags;
@@ -643,7 +646,7 @@ static int sscape_hw_release(snd_hwdep_t * hw, struct file *file)
643 return 0; 646 return 0;
644} 647}
645 648
646static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, 649static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file,
647 unsigned int cmd, unsigned long arg) 650 unsigned int cmd, unsigned long arg)
648{ 651{
649 struct soundscape *sscape = get_hwdep_soundscape(hw); 652 struct soundscape *sscape = get_hwdep_soundscape(hw);
@@ -692,8 +695,8 @@ static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file,
692/* 695/*
693 * Mixer control for the SoundScape's MIDI device. 696 * Mixer control for the SoundScape's MIDI device.
694 */ 697 */
695static int sscape_midi_info(snd_kcontrol_t * ctl, 698static int sscape_midi_info(struct snd_kcontrol *ctl,
696 snd_ctl_elem_info_t * uinfo) 699 struct snd_ctl_elem_info *uinfo)
697{ 700{
698 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 701 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
699 uinfo->count = 1; 702 uinfo->count = 1;
@@ -702,11 +705,11 @@ static int sscape_midi_info(snd_kcontrol_t * ctl,
702 return 0; 705 return 0;
703} 706}
704 707
705static int sscape_midi_get(snd_kcontrol_t * kctl, 708static int sscape_midi_get(struct snd_kcontrol *kctl,
706 snd_ctl_elem_value_t * uctl) 709 struct snd_ctl_elem_value *uctl)
707{ 710{
708 cs4231_t *chip = snd_kcontrol_chip(kctl); 711 struct snd_cs4231 *chip = snd_kcontrol_chip(kctl);
709 snd_card_t *card = chip->card; 712 struct snd_card *card = chip->card;
710 register struct soundscape *s = get_card_soundscape(card); 713 register struct soundscape *s = get_card_soundscape(card);
711 unsigned long flags; 714 unsigned long flags;
712 715
@@ -722,11 +725,11 @@ static int sscape_midi_get(snd_kcontrol_t * kctl,
722 return 0; 725 return 0;
723} 726}
724 727
725static int sscape_midi_put(snd_kcontrol_t * kctl, 728static int sscape_midi_put(struct snd_kcontrol *kctl,
726 snd_ctl_elem_value_t * uctl) 729 struct snd_ctl_elem_value *uctl)
727{ 730{
728 cs4231_t *chip = snd_kcontrol_chip(kctl); 731 struct snd_cs4231 *chip = snd_kcontrol_chip(kctl);
729 snd_card_t *card = chip->card; 732 struct snd_card *card = chip->card;
730 register struct soundscape *s = get_card_soundscape(card); 733 register struct soundscape *s = get_card_soundscape(card);
731 unsigned long flags; 734 unsigned long flags;
732 int change; 735 int change;
@@ -763,7 +766,7 @@ static int sscape_midi_put(snd_kcontrol_t * kctl,
763 return change; 766 return change;
764} 767}
765 768
766static snd_kcontrol_new_t midi_mixer_ctl = { 769static struct snd_kcontrol_new midi_mixer_ctl = {
767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
768 .name = "MIDI", 771 .name = "MIDI",
769 .info = sscape_midi_info, 772 .info = sscape_midi_info,
@@ -849,7 +852,7 @@ static int __devinit detect_sscape(struct soundscape *s)
849 * to crash the machine. Also check that someone isn't using the hardware 852 * to crash the machine. Also check that someone isn't using the hardware
850 * IOCTL device. 853 * IOCTL device.
851 */ 854 */
852static int mpu401_open(mpu401_t * mpu) 855static int mpu401_open(struct snd_mpu401 * mpu)
853{ 856{
854 int err; 857 int err;
855 858
@@ -875,7 +878,7 @@ static int mpu401_open(mpu401_t * mpu)
875 return err; 878 return err;
876} 879}
877 880
878static void mpu401_close(mpu401_t * mpu) 881static void mpu401_close(struct snd_mpu401 * mpu)
879{ 882{
880 register struct soundscape *sscape = get_mpu401_soundscape(mpu); 883 register struct soundscape *sscape = get_mpu401_soundscape(mpu);
881 unsigned long flags; 884 unsigned long flags;
@@ -888,10 +891,10 @@ static void mpu401_close(mpu401_t * mpu)
888/* 891/*
889 * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. 892 * Initialse an MPU-401 subdevice for MIDI support on the SoundScape.
890 */ 893 */
891static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long port, int irq) 894static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq)
892{ 895{
893 struct soundscape *sscape = get_card_soundscape(card); 896 struct soundscape *sscape = get_card_soundscape(card);
894 snd_rawmidi_t *rawmidi; 897 struct snd_rawmidi *rawmidi;
895 int err; 898 int err;
896 899
897#define MPU401_SHARE_HARDWARE 1 900#define MPU401_SHARE_HARDWARE 1
@@ -900,7 +903,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long
900 port, MPU401_SHARE_HARDWARE, 903 port, MPU401_SHARE_HARDWARE,
901 irq, SA_INTERRUPT, 904 irq, SA_INTERRUPT,
902 &rawmidi)) == 0) { 905 &rawmidi)) == 0) {
903 mpu401_t *mpu = (mpu401_t *) rawmidi->private_data; 906 struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data;
904 mpu->open_input = mpu401_open; 907 mpu->open_input = mpu401_open;
905 mpu->open_output = mpu401_open; 908 mpu->open_output = mpu401_open;
906 mpu->close_input = mpu401_close; 909 mpu->close_input = mpu401_close;
@@ -919,7 +922,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long
919 * Override for the CS4231 playback format function. 922 * Override for the CS4231 playback format function.
920 * The AD1845 has much simpler format and rate selection. 923 * The AD1845 has much simpler format and rate selection.
921 */ 924 */
922static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) 925static void ad1845_playback_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format)
923{ 926{
924 unsigned long flags; 927 unsigned long flags;
925 unsigned rate = params_rate(params); 928 unsigned rate = params_rate(params);
@@ -955,7 +958,7 @@ static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params
955 * Override for the CS4231 capture format function. 958 * Override for the CS4231 capture format function.
956 * The AD1845 has much simpler format and rate selection. 959 * The AD1845 has much simpler format and rate selection.
957 */ 960 */
958static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) 961static void ad1845_capture_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format)
959{ 962{
960 unsigned long flags; 963 unsigned long flags;
961 unsigned rate = params_rate(params); 964 unsigned rate = params_rate(params);
@@ -993,10 +996,10 @@ static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params,
993 * try to support at least some of the extra bits by overriding 996 * try to support at least some of the extra bits by overriding
994 * some of the CS4231 callback. 997 * some of the CS4231 callback.
995 */ 998 */
996static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, int dma1) 999static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq, int dma1)
997{ 1000{
998 register struct soundscape *sscape = get_card_soundscape(card); 1001 register struct soundscape *sscape = get_card_soundscape(card);
999 cs4231_t *chip; 1002 struct snd_cs4231 *chip;
1000 int err; 1003 int err;
1001 1004
1002#define CS4231_SHARE_HARDWARE (CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2) 1005#define CS4231_SHARE_HARDWARE (CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2)
@@ -1009,7 +1012,7 @@ static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, in
1009 CS4231_HW_DETECT, 1012 CS4231_HW_DETECT,
1010 CS4231_HWSHARE_DMA1, &chip)) == 0) { 1013 CS4231_HWSHARE_DMA1, &chip)) == 0) {
1011 unsigned long flags; 1014 unsigned long flags;
1012 snd_pcm_t *pcm; 1015 struct snd_pcm *pcm;
1013 1016
1014#define AD1845_FREQ_SEL_ENABLE 0x08 1017#define AD1845_FREQ_SEL_ENABLE 0x08
1015 1018
@@ -1080,48 +1083,18 @@ static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, in
1080} 1083}
1081 1084
1082 1085
1083struct params
1084{
1085 int index;
1086 const char *id;
1087 unsigned port;
1088 int irq;
1089 int mpu_irq;
1090 int dma1;
1091};
1092
1093
1094static inline struct params*
1095init_params(struct params *params,
1096 int index,
1097 const char *id,
1098 unsigned port,
1099 int irq,
1100 int mpu_irq,
1101 int dma1)
1102{
1103 params->index = index;
1104 params->id = id;
1105 params->port = port;
1106 params->irq = irq;
1107 params->mpu_irq = mpu_irq;
1108 params->dma1 = (dma1 & 0x03);
1109
1110 return params;
1111}
1112
1113
1114/* 1086/*
1115 * Create an ALSA soundcard entry for the SoundScape, using 1087 * Create an ALSA soundcard entry for the SoundScape, using
1116 * the given list of port, IRQ and DMA resources. 1088 * the given list of port, IRQ and DMA resources.
1117 */ 1089 */
1118static int __devinit create_sscape(const struct params *params, snd_card_t **rcardp) 1090static int __devinit create_sscape(int dev, struct snd_card **rcardp)
1119{ 1091{
1120 snd_card_t *card; 1092 struct snd_card *card;
1121 register struct soundscape *sscape; 1093 register struct soundscape *sscape;
1122 register unsigned dma_cfg; 1094 register unsigned dma_cfg;
1123 unsigned irq_cfg; 1095 unsigned irq_cfg;
1124 unsigned mpu_irq_cfg; 1096 unsigned mpu_irq_cfg;
1097 unsigned xport;
1125 struct resource *io_res; 1098 struct resource *io_res;
1126 unsigned long flags; 1099 unsigned long flags;
1127 int err; 1100 int err;
@@ -1129,32 +1102,33 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1129 /* 1102 /*
1130 * Check that the user didn't pass us garbage data ... 1103 * Check that the user didn't pass us garbage data ...
1131 */ 1104 */
1132 irq_cfg = get_irq_config(params->irq); 1105 irq_cfg = get_irq_config(irq[dev]);
1133 if (irq_cfg == INVALID_IRQ) { 1106 if (irq_cfg == INVALID_IRQ) {
1134 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->irq); 1107 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
1135 return -ENXIO; 1108 return -ENXIO;
1136 } 1109 }
1137 1110
1138 mpu_irq_cfg = get_irq_config(params->mpu_irq); 1111 mpu_irq_cfg = get_irq_config(mpu_irq[dev]);
1139 if (mpu_irq_cfg == INVALID_IRQ) { 1112 if (mpu_irq_cfg == INVALID_IRQ) {
1140 printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->mpu_irq); 1113 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1141 return -ENXIO; 1114 return -ENXIO;
1142 } 1115 }
1116 xport = port[dev];
1143 1117
1144 /* 1118 /*
1145 * Grab IO ports that we will need to probe so that we 1119 * Grab IO ports that we will need to probe so that we
1146 * can detect and control this hardware ... 1120 * can detect and control this hardware ...
1147 */ 1121 */
1148 if ((io_res = request_region(params->port, 8, "SoundScape")) == NULL) { 1122 if ((io_res = request_region(xport, 8, "SoundScape")) == NULL) {
1149 snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", params->port); 1123 snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport);
1150 return -EBUSY; 1124 return -EBUSY;
1151 } 1125 }
1152 1126
1153 /* 1127 /*
1154 * Grab both DMA channels (OK, only one for now) ... 1128 * Grab both DMA channels (OK, only one for now) ...
1155 */ 1129 */
1156 if ((err = request_dma(params->dma1, "SoundScape")) < 0) { 1130 if ((err = request_dma(dma[dev], "SoundScape")) < 0) {
1157 snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", params->dma1); 1131 snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]);
1158 goto _release_region; 1132 goto _release_region;
1159 } 1133 }
1160 1134
@@ -1162,7 +1136,8 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1162 * Create a new ALSA sound card entry, in anticipation 1136 * Create a new ALSA sound card entry, in anticipation
1163 * of detecting our hardware ... 1137 * of detecting our hardware ...
1164 */ 1138 */
1165 if ((card = snd_card_new(params->index, params->id, THIS_MODULE, sizeof(struct soundscape))) == NULL) { 1139 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
1140 sizeof(struct soundscape))) == NULL) {
1166 err = -ENOMEM; 1141 err = -ENOMEM;
1167 goto _release_dma; 1142 goto _release_dma;
1168 } 1143 }
@@ -1171,7 +1146,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1171 spin_lock_init(&sscape->lock); 1146 spin_lock_init(&sscape->lock);
1172 spin_lock_init(&sscape->fwlock); 1147 spin_lock_init(&sscape->fwlock);
1173 sscape->io_res = io_res; 1148 sscape->io_res = io_res;
1174 sscape->io_base = params->port; 1149 sscape->io_base = xport;
1175 1150
1176 if (!detect_sscape(sscape)) { 1151 if (!detect_sscape(sscape)) {
1177 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); 1152 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base);
@@ -1180,7 +1155,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1180 } 1155 }
1181 1156
1182 printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", 1157 printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n",
1183 sscape->io_base, params->irq, params->dma1); 1158 sscape->io_base, irq[dev], dma[dev]);
1184 1159
1185 /* 1160 /*
1186 * Now create the hardware-specific device so that we can 1161 * Now create the hardware-specific device so that we can
@@ -1223,7 +1198,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1223 sscape_write_unsafe(sscape->io_base, 1198 sscape_write_unsafe(sscape->io_base,
1224 GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); 1199 GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg);
1225 sscape_write_unsafe(sscape->io_base, 1200 sscape_write_unsafe(sscape->io_base,
1226 GA_CDCFG_REG, 0x09 | DMA_8BIT | (params->dma1 << 4) | (irq_cfg << 1)); 1201 GA_CDCFG_REG, 0x09 | DMA_8BIT | (dma[dev] << 4) | (irq_cfg << 1));
1227 1202
1228 spin_unlock_irqrestore(&sscape->lock, flags); 1203 spin_unlock_irqrestore(&sscape->lock, flags);
1229 1204
@@ -1231,15 +1206,15 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1231 * We have now enabled the codec chip, and so we should 1206 * We have now enabled the codec chip, and so we should
1232 * detect the AD1845 device ... 1207 * detect the AD1845 device ...
1233 */ 1208 */
1234 if ((err = create_ad1845(card, CODEC_IO(params->port), params->irq, params->dma1)) < 0) { 1209 if ((err = create_ad1845(card, CODEC_IO(xport), irq[dev], dma[dev])) < 0) {
1235 printk(KERN_ERR "sscape: No AD1845 device at 0x%x, IRQ %d\n", 1210 printk(KERN_ERR "sscape: No AD1845 device at 0x%x, IRQ %d\n",
1236 CODEC_IO(params->port), params->irq); 1211 CODEC_IO(xport), irq[dev]);
1237 goto _release_card; 1212 goto _release_card;
1238 } 1213 }
1239#define MIDI_DEVNUM 0 1214#define MIDI_DEVNUM 0
1240 if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(params->port), params->mpu_irq)) < 0) { 1215 if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(xport), mpu_irq[dev])) < 0) {
1241 printk(KERN_ERR "sscape: Failed to create MPU-401 device at 0x%x\n", 1216 printk(KERN_ERR "sscape: Failed to create MPU-401 device at 0x%x\n",
1242 MPU401_IO(params->port)); 1217 MPU401_IO(xport));
1243 goto _release_card; 1218 goto _release_card;
1244 } 1219 }
1245 1220
@@ -1271,7 +1246,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1271 snd_card_free(card); 1246 snd_card_free(card);
1272 1247
1273 _release_dma: 1248 _release_dma:
1274 free_dma(params->dma1); 1249 free_dma(dma[dev]);
1275 1250
1276 _release_region: 1251 _release_region:
1277 release_and_free_resource(io_res); 1252 release_and_free_resource(io_res);
@@ -1280,44 +1255,66 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca
1280} 1255}
1281 1256
1282 1257
1283static int sscape_cards __devinitdata; 1258static int __init snd_sscape_probe(struct platform_device *pdev)
1284static struct params sscape_params[SNDRV_CARDS] __devinitdata; 1259{
1260 int dev = pdev->id;
1261 struct snd_card *card;
1262 int ret;
1263
1264 dma[dev] &= 0x03;
1265 ret = create_sscape(dev, &card);
1266 if (ret < 0)
1267 return ret;
1268 snd_card_set_dev(card, &pdev->dev);
1269 if ((ret = snd_card_register(card)) < 0) {
1270 printk(KERN_ERR "sscape: Failed to register sound card\n");
1271 return ret;
1272 }
1273 platform_set_drvdata(pdev, card);
1274 return 0;
1275}
1276
1277static int __devexit snd_sscape_remove(struct platform_device *devptr)
1278{
1279 snd_card_free(platform_get_drvdata(devptr));
1280 platform_set_drvdata(devptr, NULL);
1281 return 0;
1282}
1283
1284#define SSCAPE_DRIVER "snd_sscape"
1285
1286static struct platform_driver snd_sscape_driver = {
1287 .probe = snd_sscape_probe,
1288 .remove = __devexit_p(snd_sscape_remove),
1289 /* FIXME: suspend/resume */
1290 .driver = {
1291 .name = SSCAPE_DRIVER
1292 },
1293};
1285 1294
1286#ifdef CONFIG_PNP 1295#ifdef CONFIG_PNP
1287static inline int __devinit get_next_autoindex(int i) 1296static inline int __devinit get_next_autoindex(int i)
1288{ 1297{
1289 while ((i < SNDRV_CARDS) && (port[i] != SNDRV_AUTO_PORT)) { 1298 while (i < SNDRV_CARDS && port[i] != SNDRV_AUTO_PORT)
1290 ++i; 1299 ++i;
1291 } /* while */
1292
1293 return i; 1300 return i;
1294} 1301}
1295 1302
1296 1303
1297static inline int __devinit is_port_known(unsigned io, struct params *params, int cards)
1298{
1299 while (--cards >= 0) {
1300 if (params[cards].port == io)
1301 return 1;
1302 } /* while */
1303
1304 return 0;
1305}
1306
1307static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, 1304static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1308 const struct pnp_card_device_id *pid) 1305 const struct pnp_card_device_id *pid)
1309{ 1306{
1310 struct pnp_dev *dev;
1311 static int idx = 0; 1307 static int idx = 0;
1308 struct pnp_dev *dev;
1309 struct snd_card *card;
1312 int ret; 1310 int ret;
1313 1311
1314 /* 1312 /*
1315 * Allow this function to fail *quietly* if all the ISA PnP 1313 * Allow this function to fail *quietly* if all the ISA PnP
1316 * devices were configured using module parameters instead. 1314 * devices were configured using module parameters instead.
1317 */ 1315 */
1318 if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) { 1316 if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS)
1319 return -ENOSPC; 1317 return -ENOSPC;
1320 }
1321 1318
1322 /* 1319 /*
1323 * We have found a candidate ISA PnP card. Now we 1320 * We have found a candidate ISA PnP card. Now we
@@ -1339,66 +1336,45 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1339 /* 1336 /*
1340 * Check that we still have room for another sound card ... 1337 * Check that we still have room for another sound card ...
1341 */ 1338 */
1342 if (sscape_cards >= SNDRV_CARDS) {
1343 printk(KERN_ERR "sscape: No room for another ALSA device\n");
1344 return -ENOSPC;
1345 }
1346
1347 ret = -ENODEV;
1348
1349 dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); 1339 dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL);
1350 if (dev) { 1340 if (! dev)
1351 struct params *this; 1341 return -ENODEV;
1352 if (!pnp_is_active(dev)) {
1353 if (pnp_activate_dev(dev) < 0) {
1354 printk(KERN_INFO "sscape: device is inactive\n");
1355 return -EBUSY;
1356 }
1357 }
1358 /*
1359 * Read the correct parameters off the ISA PnP bus ...
1360 */
1361 this = init_params(&sscape_params[sscape_cards],
1362 index[idx],
1363 id[idx],
1364 pnp_port_start(dev, 0),
1365 pnp_irq(dev, 0),
1366 pnp_irq(dev, 1),
1367 pnp_dma(dev, 0));
1368 1342
1369 /* 1343 if (!pnp_is_active(dev)) {
1370 * Do we know about this sound card already? 1344 if (pnp_activate_dev(dev) < 0) {
1371 */ 1345 printk(KERN_INFO "sscape: device is inactive\n");
1372 if ( !is_port_known(this->port, sscape_params, sscape_cards) ) { 1346 return -EBUSY;
1373 snd_card_t *card;
1374
1375 ret = create_sscape(this, &card);
1376 if (ret < 0)
1377 return ret;
1378 snd_card_set_dev(card, &pcard->card->dev);
1379
1380 if ((ret = snd_card_register(card)) < 0) {
1381 printk(KERN_ERR "sscape: Failed to register sound card\n");
1382 snd_card_free(card);
1383 return ret;
1384 }
1385
1386 pnp_set_card_drvdata(pcard, card);
1387 ++sscape_cards;
1388 ++idx;
1389 } 1347 }
1390 } 1348 }
1391 1349
1350 /*
1351 * Read the correct parameters off the ISA PnP bus ...
1352 */
1353 port[idx] = pnp_port_start(dev, 0);
1354 irq[idx] = pnp_irq(dev, 0);
1355 mpu_irq[idx] = pnp_irq(dev, 1);
1356 dma[idx] = pnp_dma(dev, 0) & 0x03;
1357
1358 ret = create_sscape(idx, &card);
1359 if (ret < 0)
1360 return ret;
1361 snd_card_set_dev(card, &pcard->card->dev);
1362 if ((ret = snd_card_register(card)) < 0) {
1363 printk(KERN_ERR "sscape: Failed to register sound card\n");
1364 snd_card_free(card);
1365 return ret;
1366 }
1367
1368 pnp_set_card_drvdata(pcard, card);
1369 ++idx;
1370
1392 return ret; 1371 return ret;
1393} 1372}
1394 1373
1395static void __devexit sscape_pnp_remove(struct pnp_card_link * pcard) 1374static void __devexit sscape_pnp_remove(struct pnp_card_link * pcard)
1396{ 1375{
1397 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 1376 snd_card_free(pnp_get_card_drvdata(pcard));
1398
1399 pnp_set_card_drvdata(pcard, NULL); 1377 pnp_set_card_drvdata(pcard, NULL);
1400 snd_card_disconnect(card);
1401 snd_card_free_in_thread(card);
1402} 1378}
1403 1379
1404static struct pnp_card_driver sscape_pnpc_driver = { 1380static struct pnp_card_driver sscape_pnpc_driver = {
@@ -1411,11 +1387,25 @@ static struct pnp_card_driver sscape_pnpc_driver = {
1411 1387
1412#endif /* CONFIG_PNP */ 1388#endif /* CONFIG_PNP */
1413 1389
1414static int __init sscape_manual_probe(struct params *params) 1390static void __init_or_module sscape_unregister_all(void)
1415{ 1391{
1416 int ret; 1392 int i;
1417 unsigned i; 1393
1418 snd_card_t *card; 1394 if (pnp_registered)
1395 pnp_unregister_card_driver(&sscape_pnpc_driver);
1396 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
1397 platform_device_unregister(platform_devices[i]);
1398 platform_driver_unregister(&snd_sscape_driver);
1399}
1400
1401static int __init sscape_manual_probe(void)
1402{
1403 struct platform_device *device;
1404 int i, ret;
1405
1406 ret = platform_driver_register(&snd_sscape_driver);
1407 if (ret < 0)
1408 return ret;
1419 1409
1420 for (i = 0; i < SNDRV_CARDS; ++i) { 1410 for (i = 0; i < SNDRV_CARDS; ++i) {
1421 /* 1411 /*
@@ -1430,52 +1420,36 @@ static int __init sscape_manual_probe(struct params *params)
1430 /* 1420 /*
1431 * Make sure we were given ALL of the other parameters. 1421 * Make sure we were given ALL of the other parameters.
1432 */ 1422 */
1433 if ( (irq[i] == SNDRV_AUTO_IRQ) || 1423 if (irq[i] == SNDRV_AUTO_IRQ ||
1434 (mpu_irq[i] == SNDRV_AUTO_IRQ) || 1424 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1435 (dma[i] == SNDRV_AUTO_DMA) ) { 1425 dma[i] == SNDRV_AUTO_DMA) {
1436 printk(KERN_INFO 1426 printk(KERN_INFO
1437 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); 1427 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
1438 return -ENXIO; 1428 ret = -ENXIO;
1429 goto errout;
1439 } 1430 }
1440 1431
1441 /* 1432 /*
1442 * This cards looks OK ... 1433 * This cards looks OK ...
1443 */ 1434 */
1444 init_params(params, index[i], id[i], port[i], irq[i], mpu_irq[i], dma[i]); 1435 device = platform_device_register_simple(SSCAPE_DRIVER,
1445 1436 i, NULL, 0);
1446 ret = create_sscape(params, &card); 1437 if (IS_ERR(device)) {
1447 if (ret < 0) 1438 ret = PTR_ERR(device);
1448 return ret; 1439 goto errout;
1449
1450 if ((ret = snd_card_set_generic_dev(card)) < 0) {
1451 snd_card_free(card);
1452 return ret;
1453 }
1454 if ((ret = snd_card_register(card)) < 0) {
1455 printk(KERN_ERR "sscape: Failed to register sound card\n");
1456 snd_card_free(card);
1457 return ret;
1458 } 1440 }
1459 1441 platform_devices[i] = device;
1460 sscape_card[sscape_cards] = card; 1442 }
1461 params++;
1462 sscape_cards++;
1463 } /* for */
1464
1465 return 0; 1443 return 0;
1466}
1467 1444
1445 errout:
1446 sscape_unregister_all();
1447 return ret;
1448}
1468 1449
1469static void sscape_exit(void) 1450static void sscape_exit(void)
1470{ 1451{
1471 unsigned i; 1452 sscape_unregister_all();
1472
1473#ifdef CONFIG_PNP
1474 pnp_unregister_card_driver(&sscape_pnpc_driver);
1475#endif
1476 for (i = 0; i < ARRAY_SIZE(sscape_card); ++i) {
1477 snd_card_free(sscape_card[i]);
1478 } /* for */
1479} 1453}
1480 1454
1481 1455
@@ -1489,24 +1463,11 @@ static int __init sscape_init(void)
1489 * of allocating cards, because the operator is 1463 * of allocating cards, because the operator is
1490 * S-P-E-L-L-I-N-G it out for us... 1464 * S-P-E-L-L-I-N-G it out for us...
1491 */ 1465 */
1492 ret = sscape_manual_probe(sscape_params); 1466 ret = sscape_manual_probe();
1493 if (ret < 0) { 1467 if (ret < 0)
1494 int i;
1495 for (i = 0; i < sscape_cards; ++i)
1496 snd_card_free(sscape_card[i]);
1497 return ret; 1468 return ret;
1498 } 1469 if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0)
1499 1470 pnp_registered = 1;
1500#ifdef CONFIG_PNP
1501 if (sscape_cards < SNDRV_CARDS) {
1502 ret = pnp_register_card_driver(&sscape_pnpc_driver);
1503 if (ret < 0) {
1504 sscape_exit();
1505 return ret;
1506 }
1507 }
1508#endif
1509
1510 return 0; 1471 return 0;
1511} 1472}
1512 1473
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 1818f1013c3f..a6dcb2f970ca 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -23,6 +23,8 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/err.h>
27#include <linux/platform_device.h>
26#include <linux/pnp.h> 28#include <linux/pnp.h>
27#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
28#include <sound/core.h> 30#include <sound/core.h>
@@ -81,7 +83,9 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
81module_param_array(use_cs4232_midi, bool, NULL, 0444); 83module_param_array(use_cs4232_midi, bool, NULL, 0444);
82MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
83 85
84static snd_card_t *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 86static struct platform_device *platform_devices[SNDRV_CARDS];
87static int pnp_registered;
88
85 89
86#ifdef CONFIG_PNP 90#ifdef CONFIG_PNP
87 91
@@ -240,7 +244,7 @@ snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *c
240 cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); 244 cs4232_mpu_irq[dev] = pnp_irq(pdev, 0);
241 } 245 }
242 246
243 snd_printk ("CS4232 MPU: port=0x%lx, irq=%i\n", 247 snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n",
244 cs4232_mpu_port[dev], 248 cs4232_mpu_port[dev],
245 cs4232_mpu_irq[dev]); 249 cs4232_mpu_irq[dev]);
246 } 250 }
@@ -279,12 +283,12 @@ static irqreturn_t snd_wavefront_ics2115_interrupt(int irq,
279 return IRQ_HANDLED; 283 return IRQ_HANDLED;
280} 284}
281 285
282static snd_hwdep_t * __devinit 286static struct snd_hwdep * __devinit
283snd_wavefront_new_synth (snd_card_t *card, 287snd_wavefront_new_synth (struct snd_card *card,
284 int hw_dev, 288 int hw_dev,
285 snd_wavefront_card_t *acard) 289 snd_wavefront_card_t *acard)
286{ 290{
287 snd_hwdep_t *wavefront_synth; 291 struct snd_hwdep *wavefront_synth;
288 292
289 if (snd_wavefront_detect (acard) < 0) { 293 if (snd_wavefront_detect (acard) < 0) {
290 return NULL; 294 return NULL;
@@ -305,17 +309,17 @@ snd_wavefront_new_synth (snd_card_t *card,
305 return wavefront_synth; 309 return wavefront_synth;
306} 310}
307 311
308static snd_hwdep_t * __devinit 312static struct snd_hwdep * __devinit
309snd_wavefront_new_fx (snd_card_t *card, 313snd_wavefront_new_fx (struct snd_card *card,
310 int hw_dev, 314 int hw_dev,
311 snd_wavefront_card_t *acard, 315 snd_wavefront_card_t *acard,
312 unsigned long port) 316 unsigned long port)
313 317
314{ 318{
315 snd_hwdep_t *fx_processor; 319 struct snd_hwdep *fx_processor;
316 320
317 if (snd_wavefront_fx_start (&acard->wavefront)) { 321 if (snd_wavefront_fx_start (&acard->wavefront)) {
318 snd_printk ("cannot initialize YSS225 FX processor"); 322 snd_printk (KERN_ERR "cannot initialize YSS225 FX processor");
319 return NULL; 323 return NULL;
320 } 324 }
321 325
@@ -332,22 +336,22 @@ snd_wavefront_new_fx (snd_card_t *card,
332static snd_wavefront_mpu_id internal_id = internal_mpu; 336static snd_wavefront_mpu_id internal_id = internal_mpu;
333static snd_wavefront_mpu_id external_id = external_mpu; 337static snd_wavefront_mpu_id external_id = external_mpu;
334 338
335static snd_rawmidi_t * __devinit 339static struct snd_rawmidi *__devinit
336snd_wavefront_new_midi (snd_card_t *card, 340snd_wavefront_new_midi (struct snd_card *card,
337 int midi_dev, 341 int midi_dev,
338 snd_wavefront_card_t *acard, 342 snd_wavefront_card_t *acard,
339 unsigned long port, 343 unsigned long port,
340 snd_wavefront_mpu_id mpu) 344 snd_wavefront_mpu_id mpu)
341 345
342{ 346{
343 snd_rawmidi_t *rmidi; 347 struct snd_rawmidi *rmidi;
344 static int first = 1; 348 static int first = 1;
345 349
346 if (first) { 350 if (first) {
347 first = 0; 351 first = 0;
348 acard->wavefront.midi.base = port; 352 acard->wavefront.midi.base = port;
349 if (snd_wavefront_midi_start (acard)) { 353 if (snd_wavefront_midi_start (acard)) {
350 snd_printk ("cannot initialize MIDI interface\n"); 354 snd_printk (KERN_ERR "cannot initialize MIDI interface\n");
351 return NULL; 355 return NULL;
352 } 356 }
353 } 357 }
@@ -374,7 +378,7 @@ snd_wavefront_new_midi (snd_card_t *card,
374} 378}
375 379
376static void 380static void
377snd_wavefront_free(snd_card_t *card) 381snd_wavefront_free(struct snd_card *card)
378{ 382{
379 snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data; 383 snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
380 384
@@ -385,42 +389,17 @@ snd_wavefront_free(snd_card_t *card)
385 } 389 }
386} 390}
387 391
388static int __devinit 392static struct snd_card *snd_wavefront_card_new(int dev)
389snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
390 const struct pnp_card_device_id *pid)
391{ 393{
392 snd_card_t *card; 394 struct snd_card *card;
393 snd_wavefront_card_t *acard; 395 snd_wavefront_card_t *acard;
394 cs4231_t *chip;
395 snd_hwdep_t *wavefront_synth;
396 snd_rawmidi_t *ics2115_internal_rmidi = NULL;
397 snd_rawmidi_t *ics2115_external_rmidi = NULL;
398 snd_hwdep_t *fx_processor;
399 int hw_dev = 0, midi_dev = 0, err;
400 396
401#ifdef CONFIG_PNP 397 card = snd_card_new (index[dev], id[dev], THIS_MODULE,
402 if (!isapnp[dev]) {
403#endif
404 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
405 snd_printk("specify CS4232 port\n");
406 return -EINVAL;
407 }
408 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
409 snd_printk("specify ICS2115 port\n");
410 return -ENODEV;
411 }
412#ifdef CONFIG_PNP
413 }
414#endif
415 card = snd_card_new (index[dev],
416 id[dev],
417 THIS_MODULE,
418 sizeof(snd_wavefront_card_t)); 398 sizeof(snd_wavefront_card_t));
399 if (card == NULL)
400 return NULL;
419 401
420 if (card == NULL) { 402 acard = card->private_data;
421 return -ENOMEM;
422 }
423 acard = (snd_wavefront_card_t *)card->private_data;
424 acard->wavefront.irq = -1; 403 acard->wavefront.irq = -1;
425 spin_lock_init(&acard->wavefront.irq_lock); 404 spin_lock_init(&acard->wavefront.irq_lock);
426 init_waitqueue_head(&acard->wavefront.interrupt_sleeper); 405 init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
@@ -428,18 +407,19 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
428 spin_lock_init(&acard->wavefront.midi.virtual); 407 spin_lock_init(&acard->wavefront.midi.virtual);
429 card->private_free = snd_wavefront_free; 408 card->private_free = snd_wavefront_free;
430 409
431#ifdef CONFIG_PNP 410 return card;
432 if (isapnp[dev]) { 411}
433 if (snd_wavefront_pnp (dev, acard, pcard, pid) < 0) { 412
434 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 413static int __devinit
435 snd_printk ("isapnp detection failed\n"); 414snd_wavefront_probe (struct snd_card *card, int dev)
436 snd_card_free (card); 415{
437 return -ENODEV; 416 snd_wavefront_card_t *acard = card->private_data;
438 } 417 struct snd_cs4231 *chip;
439 } 418 struct snd_hwdep *wavefront_synth;
440 snd_card_set_dev(card, &pcard->card->dev); 419 struct snd_rawmidi *ics2115_internal_rmidi = NULL;
441 } 420 struct snd_rawmidi *ics2115_external_rmidi = NULL;
442#endif /* CONFIG_PNP */ 421 struct snd_hwdep *fx_processor;
422 int hw_dev = 0, midi_dev = 0, err;
443 423
444 /* --------- PCM --------------- */ 424 /* --------- PCM --------------- */
445 425
@@ -450,52 +430,46 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
450 dma1[dev], 430 dma1[dev],
451 dma2[dev], 431 dma2[dev],
452 CS4231_HW_DETECT, 0, &chip)) < 0) { 432 CS4231_HW_DETECT, 0, &chip)) < 0) {
453 snd_card_free(card); 433 snd_printk (KERN_ERR "can't allocate CS4231 device\n");
454 snd_printk ("can't allocate CS4231 device\n");
455 return err; 434 return err;
456 } 435 }
457 436
458 if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) { 437 if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0)
459 snd_card_free(card);
460 return err; 438 return err;
461 } 439
462 if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) { 440 if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0)
463 snd_card_free(card);
464 return err; 441 return err;
465 }
466 442
467 /* ---------- OPL3 synth --------- */ 443 /* ---------- OPL3 synth --------- */
468 444
469 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 445 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
470 opl3_t *opl3; 446 struct snd_opl3 *opl3;
471 447
472 if ((err = snd_opl3_create(card, 448 if ((err = snd_opl3_create(card,
473 fm_port[dev], 449 fm_port[dev],
474 fm_port[dev] + 2, 450 fm_port[dev] + 2,
475 OPL3_HW_OPL3_CS, 451 OPL3_HW_OPL3_CS,
476 0, &opl3)) < 0) { 452 0, &opl3)) < 0) {
477 snd_printk ("can't allocate or detect OPL3 synth\n"); 453 snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n");
478 snd_card_free(card);
479 return err; 454 return err;
480 } 455 }
481 456
482 if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) { 457 if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0)
483 snd_card_free(card);
484 return err; 458 return err;
485 }
486 hw_dev++; 459 hw_dev++;
487 } 460 }
488 461
489 /* ------- ICS2115 Wavetable synth ------- */ 462 /* ------- ICS2115 Wavetable synth ------- */
490 463
491 if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, "ICS2115")) == NULL) { 464 if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16,
492 snd_printk("unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", ics2115_port[dev], ics2115_port[dev] + 16 - 1); 465 "ICS2115")) == NULL) {
493 snd_card_free(card); 466 snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
467 ics2115_port[dev], ics2115_port[dev] + 16 - 1);
494 return -EBUSY; 468 return -EBUSY;
495 } 469 }
496 if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, SA_INTERRUPT, "ICS2115", (void *)acard)) { 470 if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt,
497 snd_printk("unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); 471 SA_INTERRUPT, "ICS2115", acard)) {
498 snd_card_free(card); 472 snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
499 return -EBUSY; 473 return -EBUSY;
500 } 474 }
501 475
@@ -503,8 +477,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
503 acard->wavefront.base = ics2115_port[dev]; 477 acard->wavefront.base = ics2115_port[dev];
504 478
505 if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) { 479 if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) {
506 snd_printk ("can't create WaveFront synth device\n"); 480 snd_printk (KERN_ERR "can't create WaveFront synth device\n");
507 snd_card_free(card);
508 return -ENOMEM; 481 return -ENOMEM;
509 } 482 }
510 483
@@ -515,8 +488,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
515 /* --------- Mixer ------------ */ 488 /* --------- Mixer ------------ */
516 489
517 if ((err = snd_cs4231_mixer(chip)) < 0) { 490 if ((err = snd_cs4231_mixer(chip)) < 0) {
518 snd_printk ("can't allocate mixer device\n"); 491 snd_printk (KERN_ERR "can't allocate mixer device\n");
519 snd_card_free(card);
520 return err; 492 return err;
521 } 493 }
522 494
@@ -528,8 +500,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
528 cs4232_mpu_irq[dev], 500 cs4232_mpu_irq[dev],
529 SA_INTERRUPT, 501 SA_INTERRUPT,
530 NULL)) < 0) { 502 NULL)) < 0) {
531 snd_printk ("can't allocate CS4232 MPU-401 device\n"); 503 snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n");
532 snd_card_free(card);
533 return err; 504 return err;
534 } 505 }
535 midi_dev++; 506 midi_dev++;
@@ -545,8 +516,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
545 ics2115_port[dev], 516 ics2115_port[dev],
546 internal_mpu); 517 internal_mpu);
547 if (ics2115_internal_rmidi == NULL) { 518 if (ics2115_internal_rmidi == NULL) {
548 snd_printk ("can't setup ICS2115 internal MIDI device\n"); 519 snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n");
549 snd_card_free(card);
550 return -ENOMEM; 520 return -ENOMEM;
551 } 521 }
552 midi_dev++; 522 midi_dev++;
@@ -562,8 +532,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
562 ics2115_port[dev], 532 ics2115_port[dev],
563 external_mpu); 533 external_mpu);
564 if (ics2115_external_rmidi == NULL) { 534 if (ics2115_external_rmidi == NULL) {
565 snd_printk ("can't setup ICS2115 external MIDI device\n"); 535 snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n");
566 snd_card_free(card);
567 return -ENOMEM; 536 return -ENOMEM;
568 } 537 }
569 midi_dev++; 538 midi_dev++;
@@ -577,8 +546,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
577 acard, 546 acard,
578 ics2115_port[dev]); 547 ics2115_port[dev]);
579 if (fx_processor == NULL) { 548 if (fx_processor == NULL) {
580 snd_printk ("can't setup FX device\n"); 549 snd_printk (KERN_ERR "can't setup FX device\n");
581 snd_card_free(card);
582 return -ENOMEM; 550 return -ENOMEM;
583 } 551 }
584 552
@@ -619,49 +587,97 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard,
619 ics2115_port[dev], 587 ics2115_port[dev],
620 ics2115_irq[dev]); 588 ics2115_irq[dev]);
621 589
622 if ((err = snd_card_set_generic_dev(card)) < 0) { 590 return snd_card_register(card);
623 snd_card_free(card); 591}
624 return err; 592
593static int __init snd_wavefront_nonpnp_probe(struct platform_device *pdev)
594{
595 int dev = pdev->id;
596 struct snd_card *card;
597 int err;
598
599 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
600 snd_printk("specify CS4232 port\n");
601 return -EINVAL;
602 }
603 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
604 snd_printk("specify ICS2115 port\n");
605 return -ENODEV;
625 } 606 }
626 607
627 if ((err = snd_card_register(card)) < 0) { 608 card = snd_wavefront_card_new(dev);
609 if (! card)
610 return -ENOMEM;
611 snd_card_set_dev(card, &pdev->dev);
612 if ((err = snd_wavefront_probe(card, dev)) < 0) {
628 snd_card_free(card); 613 snd_card_free(card);
629 return err; 614 return err;
630 } 615 }
631 if (pcard) 616
632 pnp_set_card_drvdata(pcard, card); 617 platform_set_drvdata(pdev, card);
633 else
634 snd_wavefront_legacy[dev] = card;
635 return 0; 618 return 0;
636} 619}
620
621static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr)
622{
623 snd_card_free(platform_get_drvdata(devptr));
624 platform_set_drvdata(devptr, NULL);
625 return 0;
626}
627
628#define WAVEFRONT_DRIVER "snd_wavefront"
629
630static struct platform_driver snd_wavefront_driver = {
631 .probe = snd_wavefront_nonpnp_probe,
632 .remove = __devexit_p(snd_wavefront_nonpnp_remove),
633 /* FIXME: suspend, resume */
634 .driver = {
635 .name = WAVEFRONT_DRIVER
636 },
637};
638
637 639
638#ifdef CONFIG_PNP 640#ifdef CONFIG_PNP
639 641
640static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, 642static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
641 const struct pnp_card_device_id *id) 643 const struct pnp_card_device_id *pid)
642{ 644{
643 static int dev; 645 static int dev;
644 int res; 646 struct snd_card *card;
645 647 int res;
646 for ( ; dev < SNDRV_CARDS; dev++) { 648
647 if (!enable[dev] || !isapnp[dev]) 649 for ( ; dev < SNDRV_CARDS; dev++) {
648 continue; 650 if (enable[dev] && isapnp[dev])
649 res = snd_wavefront_probe(dev, card, id); 651 break;
650 if (res < 0) 652 }
651 return res; 653 if (dev >= SNDRV_CARDS)
652 dev++; 654 return -ENODEV;
653 return 0; 655
654 } 656 card = snd_wavefront_card_new(dev);
655 657 if (! card)
656 return -ENODEV; 658 return -ENOMEM;
659
660 if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
661 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
662 snd_printk (KERN_ERR "isapnp detection failed\n");
663 snd_card_free (card);
664 return -ENODEV;
665 }
666 }
667 snd_card_set_dev(card, &pcard->card->dev);
668
669 if ((res = snd_wavefront_probe(card, dev)) < 0)
670 return res;
671
672 pnp_set_card_drvdata(pcard, card);
673 dev++;
674 return 0;
657} 675}
658 676
659static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) 677static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard)
660{ 678{
661 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 679 snd_card_free(pnp_get_card_drvdata(pcard));
662 680 pnp_set_card_drvdata(pcard, NULL);
663 snd_card_disconnect(card);
664 snd_card_free_in_thread(card);
665} 681}
666 682
667static struct pnp_card_driver wavefront_pnpc_driver = { 683static struct pnp_card_driver wavefront_pnpc_driver = {
@@ -670,48 +686,68 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
670 .id_table = snd_wavefront_pnpids, 686 .id_table = snd_wavefront_pnpids,
671 .probe = snd_wavefront_pnp_detect, 687 .probe = snd_wavefront_pnp_detect,
672 .remove = __devexit_p(snd_wavefront_pnp_remove), 688 .remove = __devexit_p(snd_wavefront_pnp_remove),
689 /* FIXME: suspend,resume */
673}; 690};
674 691
675#endif /* CONFIG_PNP */ 692#endif /* CONFIG_PNP */
676 693
694static void __init_or_module snd_wavefront_unregister_all(void)
695{
696 int i;
697
698 if (pnp_registered)
699 pnp_unregister_card_driver(&wavefront_pnpc_driver);
700 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
701 platform_device_unregister(platform_devices[i]);
702 platform_driver_unregister(&snd_wavefront_driver);
703}
704
677static int __init alsa_card_wavefront_init(void) 705static int __init alsa_card_wavefront_init(void)
678{ 706{
679 int cards = 0; 707 int i, err, cards = 0;
680 int dev; 708
681 for (dev = 0; dev < SNDRV_CARDS; dev++) { 709 if ((err = platform_driver_register(&snd_wavefront_driver)) < 0)
682 if (!enable[dev]) 710 return err;
683 continue; 711
712 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
713 struct platform_device *device;
684#ifdef CONFIG_PNP 714#ifdef CONFIG_PNP
685 if (isapnp[dev]) 715 if (isapnp[i])
686 continue; 716 continue;
687#endif 717#endif
688 if (snd_wavefront_probe(dev, NULL, NULL) >= 0) 718 device = platform_device_register_simple(WAVEFRONT_DRIVER,
689 cards++; 719 i, NULL, 0);
720 if (IS_ERR(device)) {
721 err = PTR_ERR(device);
722 goto errout;
723 }
724 platform_devices[i] = device;
725 cards++;
690 } 726 }
691#ifdef CONFIG_PNP 727
692 cards += pnp_register_card_driver(&wavefront_pnpc_driver); 728 i = pnp_register_card_driver(&wavefront_pnpc_driver);
693#endif 729 if (i >= 0) {
730 pnp_registered = 1;
731 cards += i;
732 }
733
694 if (!cards) { 734 if (!cards) {
695#ifdef CONFIG_PNP
696 pnp_unregister_card_driver(&wavefront_pnpc_driver);
697#endif
698#ifdef MODULE 735#ifdef MODULE
699 printk (KERN_ERR "No WaveFront cards found or devices busy\n"); 736 printk (KERN_ERR "No WaveFront cards found or devices busy\n");
700#endif 737#endif
701 return -ENODEV; 738 err = -ENODEV;
739 goto errout;
702 } 740 }
703 return 0; 741 return 0;
742
743 errout:
744 snd_wavefront_unregister_all();
745 return err;
704} 746}
705 747
706static void __exit alsa_card_wavefront_exit(void) 748static void __exit alsa_card_wavefront_exit(void)
707{ 749{
708 int idx; 750 snd_wavefront_unregister_all();
709
710#ifdef CONFIG_PNP
711 pnp_unregister_card_driver(&wavefront_pnpc_driver);
712#endif
713 for (idx = 0; idx < SNDRV_CARDS; idx++)
714 snd_card_free(snd_wavefront_legacy[idx]);
715} 751}
716 752
717module_init(alsa_card_wavefront_init) 753module_init(alsa_card_wavefront_init)
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index 32379688eed4..180661c5ffdc 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -460,7 +460,7 @@ snd_wavefront_fx_detect (snd_wavefront_t *dev)
460} 460}
461 461
462int 462int
463snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) 463snd_wavefront_fx_open (struct snd_hwdep *hw, struct file *file)
464 464
465{ 465{
466 if (!try_module_get(hw->card->module)) 466 if (!try_module_get(hw->card->module))
@@ -470,7 +470,7 @@ snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file)
470} 470}
471 471
472int 472int
473snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) 473snd_wavefront_fx_release (struct snd_hwdep *hw, struct file *file)
474 474
475{ 475{
476 module_put(hw->card->module); 476 module_put(hw->card->module);
@@ -478,11 +478,11 @@ snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file)
478} 478}
479 479
480int 480int
481snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file, 481snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
482 unsigned int cmd, unsigned long arg) 482 unsigned int cmd, unsigned long arg)
483 483
484{ 484{
485 snd_card_t *card; 485 struct snd_card *card;
486 snd_wavefront_card_t *acard; 486 snd_wavefront_card_t *acard;
487 snd_wavefront_t *dev; 487 snd_wavefront_t *dev;
488 wavefront_fx_info r; 488 wavefront_fx_info r;
diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c
index 6f51d64fb565..15888ba2169b 100644
--- a/sound/isa/wavefront/wavefront_midi.c
+++ b/sound/isa/wavefront/wavefront_midi.c
@@ -91,10 +91,10 @@ write_data (snd_wavefront_midi_t *midi, unsigned char byte)
91} 91}
92 92
93static snd_wavefront_midi_t * 93static snd_wavefront_midi_t *
94get_wavefront_midi (snd_rawmidi_substream_t *substream) 94get_wavefront_midi (struct snd_rawmidi_substream *substream)
95 95
96{ 96{
97 snd_card_t *card; 97 struct snd_card *card;
98 snd_wavefront_card_t *acard; 98 snd_wavefront_card_t *acard;
99 99
100 if (substream == NULL || substream->rmidi == NULL) 100 if (substream == NULL || substream->rmidi == NULL)
@@ -230,7 +230,7 @@ static void snd_wavefront_midi_output_write(snd_wavefront_card_t *card)
230 } 230 }
231} 231}
232 232
233static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream) 233static int snd_wavefront_midi_input_open(struct snd_rawmidi_substream *substream)
234{ 234{
235 unsigned long flags; 235 unsigned long flags;
236 snd_wavefront_midi_t *midi; 236 snd_wavefront_midi_t *midi;
@@ -252,7 +252,7 @@ static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream)
252 return 0; 252 return 0;
253} 253}
254 254
255static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream) 255static int snd_wavefront_midi_output_open(struct snd_rawmidi_substream *substream)
256{ 256{
257 unsigned long flags; 257 unsigned long flags;
258 snd_wavefront_midi_t *midi; 258 snd_wavefront_midi_t *midi;
@@ -274,7 +274,7 @@ static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream)
274 return 0; 274 return 0;
275} 275}
276 276
277static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream) 277static int snd_wavefront_midi_input_close(struct snd_rawmidi_substream *substream)
278{ 278{
279 unsigned long flags; 279 unsigned long flags;
280 snd_wavefront_midi_t *midi; 280 snd_wavefront_midi_t *midi;
@@ -295,7 +295,7 @@ static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream)
295 return 0; 295 return 0;
296} 296}
297 297
298static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream) 298static int snd_wavefront_midi_output_close(struct snd_rawmidi_substream *substream)
299{ 299{
300 unsigned long flags; 300 unsigned long flags;
301 snd_wavefront_midi_t *midi; 301 snd_wavefront_midi_t *midi;
@@ -315,7 +315,7 @@ static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream)
315 return 0; 315 return 0;
316} 316}
317 317
318static void snd_wavefront_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) 318static void snd_wavefront_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
319{ 319{
320 unsigned long flags; 320 unsigned long flags;
321 snd_wavefront_midi_t *midi; 321 snd_wavefront_midi_t *midi;
@@ -355,7 +355,7 @@ static void snd_wavefront_midi_output_timer(unsigned long data)
355 snd_wavefront_midi_output_write(card); 355 snd_wavefront_midi_output_write(card);
356} 356}
357 357
358static void snd_wavefront_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) 358static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
359{ 359{
360 unsigned long flags; 360 unsigned long flags;
361 snd_wavefront_midi_t *midi; 361 snd_wavefront_midi_t *midi;
@@ -401,7 +401,7 @@ snd_wavefront_midi_interrupt (snd_wavefront_card_t *card)
401{ 401{
402 unsigned long flags; 402 unsigned long flags;
403 snd_wavefront_midi_t *midi; 403 snd_wavefront_midi_t *midi;
404 static snd_rawmidi_substream_t *substream = NULL; 404 static struct snd_rawmidi_substream *substream = NULL;
405 static int mpu = external_mpu; 405 static int mpu = external_mpu;
406 int max = 128; 406 int max = 128;
407 unsigned char byte; 407 unsigned char byte;
@@ -554,14 +554,14 @@ snd_wavefront_midi_start (snd_wavefront_card_t *card)
554 return 0; 554 return 0;
555} 555}
556 556
557snd_rawmidi_ops_t snd_wavefront_midi_output = 557struct snd_rawmidi_ops snd_wavefront_midi_output =
558{ 558{
559 .open = snd_wavefront_midi_output_open, 559 .open = snd_wavefront_midi_output_open,
560 .close = snd_wavefront_midi_output_close, 560 .close = snd_wavefront_midi_output_close,
561 .trigger = snd_wavefront_midi_output_trigger, 561 .trigger = snd_wavefront_midi_output_trigger,
562}; 562};
563 563
564snd_rawmidi_ops_t snd_wavefront_midi_input = 564struct snd_rawmidi_ops snd_wavefront_midi_input =
565{ 565{
566 .open = snd_wavefront_midi_input_open, 566 .open = snd_wavefront_midi_input_open,
567 .close = snd_wavefront_midi_input_close, 567 .close = snd_wavefront_midi_input_close,
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index abd79b781412..ed81eec6e732 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -115,18 +115,11 @@ MODULE_PARM_DESC(osrun_time, "how many seconds to wait for the ICS2115 OS");
115 115
116#ifdef WF_DEBUG 116#ifdef WF_DEBUG
117 117
118#if defined(NEW_MACRO_VARARGS) || __GNUC__ >= 3
119#define DPRINT(cond, ...) \ 118#define DPRINT(cond, ...) \
120 if ((dev->debug & (cond)) == (cond)) { \ 119 if ((dev->debug & (cond)) == (cond)) { \
121 snd_printk (__VA_ARGS__); \ 120 snd_printk (__VA_ARGS__); \
122 } 121 }
123#else 122#else
124#define DPRINT(cond, args...) \
125 if ((dev->debug & (cond)) == (cond)) { \
126 snd_printk (args); \
127 }
128#endif
129#else
130#define DPRINT(cond, args...) 123#define DPRINT(cond, args...)
131#endif /* WF_DEBUG */ 124#endif /* WF_DEBUG */
132 125
@@ -144,13 +137,13 @@ MODULE_PARM_DESC(osrun_time, "how many seconds to wait for the ICS2115 OS");
144static int wavefront_delete_sample (snd_wavefront_t *, int sampnum); 137static int wavefront_delete_sample (snd_wavefront_t *, int sampnum);
145static int wavefront_find_free_sample (snd_wavefront_t *); 138static int wavefront_find_free_sample (snd_wavefront_t *);
146 139
147typedef struct { 140struct wavefront_command {
148 int cmd; 141 int cmd;
149 char *action; 142 char *action;
150 unsigned int read_cnt; 143 unsigned int read_cnt;
151 unsigned int write_cnt; 144 unsigned int write_cnt;
152 int need_ack; 145 int need_ack;
153} wavefront_command; 146};
154 147
155static struct { 148static struct {
156 int errno; 149 int errno;
@@ -170,7 +163,7 @@ static struct {
170 163
171#define NEEDS_ACK 1 164#define NEEDS_ACK 1
172 165
173static wavefront_command wavefront_commands[] = { 166static struct wavefront_command wavefront_commands[] = {
174 { WFC_SET_SYNTHVOL, "set synthesizer volume", 0, 1, NEEDS_ACK }, 167 { WFC_SET_SYNTHVOL, "set synthesizer volume", 0, 1, NEEDS_ACK },
175 { WFC_GET_SYNTHVOL, "get synthesizer volume", 1, 0, 0}, 168 { WFC_GET_SYNTHVOL, "get synthesizer volume", 1, 0, 0},
176 { WFC_SET_NVOICES, "set number of voices", 0, 1, NEEDS_ACK }, 169 { WFC_SET_NVOICES, "set number of voices", 0, 1, NEEDS_ACK },
@@ -249,7 +242,7 @@ wavefront_errorstr (int errnum)
249 return "Unknown WaveFront error"; 242 return "Unknown WaveFront error";
250} 243}
251 244
252static wavefront_command * 245static struct wavefront_command *
253wavefront_get_command (int cmd) 246wavefront_get_command (int cmd)
254 247
255{ 248{
@@ -261,7 +254,7 @@ wavefront_get_command (int cmd)
261 } 254 }
262 } 255 }
263 256
264 return (wavefront_command *) 0; 257 return NULL;
265} 258}
266 259
267static inline int 260static inline int
@@ -345,9 +338,9 @@ snd_wavefront_cmd (snd_wavefront_t *dev,
345 int ack; 338 int ack;
346 unsigned int i; 339 unsigned int i;
347 int c; 340 int c;
348 wavefront_command *wfcmd; 341 struct wavefront_command *wfcmd;
349 342
350 if ((wfcmd = wavefront_get_command (cmd)) == (wavefront_command *) 0) { 343 if ((wfcmd = wavefront_get_command (cmd)) == NULL) {
351 snd_printk ("command 0x%x not supported.\n", 344 snd_printk ("command 0x%x not supported.\n",
352 cmd); 345 cmd);
353 return 1; 346 return 1;
@@ -1625,7 +1618,7 @@ wavefront_synth_control (snd_wavefront_card_t *acard,
1625} 1618}
1626 1619
1627int 1620int
1628snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) 1621snd_wavefront_synth_open (struct snd_hwdep *hw, struct file *file)
1629 1622
1630{ 1623{
1631 if (!try_module_get(hw->card->module)) 1624 if (!try_module_get(hw->card->module))
@@ -1635,7 +1628,7 @@ snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file)
1635} 1628}
1636 1629
1637int 1630int
1638snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) 1631snd_wavefront_synth_release (struct snd_hwdep *hw, struct file *file)
1639 1632
1640{ 1633{
1641 module_put(hw->card->module); 1634 module_put(hw->card->module);
@@ -1643,18 +1636,18 @@ snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file)
1643} 1636}
1644 1637
1645int 1638int
1646snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file, 1639snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file,
1647 unsigned int cmd, unsigned long arg) 1640 unsigned int cmd, unsigned long arg)
1648 1641
1649{ 1642{
1650 snd_card_t *card; 1643 struct snd_card *card;
1651 snd_wavefront_t *dev; 1644 snd_wavefront_t *dev;
1652 snd_wavefront_card_t *acard; 1645 snd_wavefront_card_t *acard;
1653 wavefront_control *wc; 1646 wavefront_control *wc;
1654 void __user *argp = (void __user *)arg; 1647 void __user *argp = (void __user *)arg;
1655 int err; 1648 int err;
1656 1649
1657 card = (snd_card_t *) hw->card; 1650 card = (struct snd_card *) hw->card;
1658 1651
1659 snd_assert(card != NULL, return -ENODEV); 1652 snd_assert(card != NULL, return -ENODEV);
1660 1653