diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-12-01 09:58:10 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-01 09:58:10 -0500 |
commit | 75639e7ee1401b3876c7a00ffe96ea8027668690 (patch) | |
tree | 3d6813cd3fe0d974e0a40237d003a22c5f7438dd /sound/isa/sscape.c | |
parent | 7584af10cf46e0f4aa1696f1be79fa0f19a945ba (diff) | |
parent | ad1cd745060ae2f24026b3b3d09da3426df6ab36 (diff) |
Merge branch 'topic/beep-rename' into topic/core-change
Diffstat (limited to 'sound/isa/sscape.c')
-rw-r--r-- | sound/isa/sscape.c | 727 |
1 files changed, 319 insertions, 408 deletions
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 66187122377c..e2d5d2d3ed96 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Low-level ALSA driver for the ENSONIQ SoundScape PnP | 2 | * Low-level ALSA driver for the ENSONIQ SoundScape |
3 | * Copyright (c) by Chris Rankin | 3 | * Copyright (c) by Chris Rankin |
4 | * | 4 | * |
5 | * This driver was written in part using information obtained from | 5 | * This driver was written in part using information obtained from |
@@ -25,31 +25,36 @@ | |||
25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/isa.h> | 26 | #include <linux/isa.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/firmware.h> | ||
28 | #include <linux/pnp.h> | 29 | #include <linux/pnp.h> |
29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
30 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
31 | #include <asm/dma.h> | 32 | #include <asm/dma.h> |
32 | #include <sound/core.h> | 33 | #include <sound/core.h> |
33 | #include <sound/hwdep.h> | ||
34 | #include <sound/wss.h> | 34 | #include <sound/wss.h> |
35 | #include <sound/mpu401.h> | 35 | #include <sound/mpu401.h> |
36 | #include <sound/initval.h> | 36 | #include <sound/initval.h> |
37 | 37 | ||
38 | #include <sound/sscape_ioctl.h> | ||
39 | |||
40 | 38 | ||
41 | MODULE_AUTHOR("Chris Rankin"); | 39 | MODULE_AUTHOR("Chris Rankin"); |
42 | MODULE_DESCRIPTION("ENSONIQ SoundScape PnP driver"); | 40 | MODULE_DESCRIPTION("ENSONIQ SoundScape driver"); |
43 | MODULE_LICENSE("GPL"); | 41 | MODULE_LICENSE("GPL"); |
44 | 42 | MODULE_FIRMWARE("sndscape.co0"); | |
45 | static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX; | 43 | MODULE_FIRMWARE("sndscape.co1"); |
46 | static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR; | 44 | MODULE_FIRMWARE("sndscape.co2"); |
47 | static long port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 45 | MODULE_FIRMWARE("sndscape.co3"); |
48 | static long wss_port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 46 | MODULE_FIRMWARE("sndscape.co4"); |
49 | static int irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 47 | MODULE_FIRMWARE("scope.cod"); |
50 | static int mpu_irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 48 | |
51 | static int dma[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 49 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
52 | static int dma2[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 50 | static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
52 | static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
53 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
54 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
55 | static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
56 | static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
57 | static bool joystick[SNDRV_CARDS]; | ||
53 | 58 | ||
54 | module_param_array(index, int, NULL, 0444); | 59 | module_param_array(index, int, NULL, 0444); |
55 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); | 60 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); |
@@ -75,6 +80,9 @@ MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); | |||
75 | module_param_array(dma2, int, NULL, 0444); | 80 | module_param_array(dma2, int, NULL, 0444); |
76 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); | 81 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); |
77 | 82 | ||
83 | module_param_array(joystick, bool, NULL, 0444); | ||
84 | MODULE_PARM_DESC(joystick, "Enable gameport."); | ||
85 | |||
78 | #ifdef CONFIG_PNP | 86 | #ifdef CONFIG_PNP |
79 | static int isa_registered; | 87 | static int isa_registered; |
80 | static int pnp_registered; | 88 | static int pnp_registered; |
@@ -101,14 +109,14 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); | |||
101 | #define RX_READY 0x01 | 109 | #define RX_READY 0x01 |
102 | #define TX_READY 0x02 | 110 | #define TX_READY 0x02 |
103 | 111 | ||
104 | #define CMD_ACK 0x80 | 112 | #define CMD_ACK 0x80 |
105 | #define CMD_SET_MIDI_VOL 0x84 | 113 | #define CMD_SET_MIDI_VOL 0x84 |
106 | #define CMD_GET_MIDI_VOL 0x85 | 114 | #define CMD_GET_MIDI_VOL 0x85 |
107 | #define CMD_XXX_MIDI_VOL 0x86 | 115 | #define CMD_XXX_MIDI_VOL 0x86 |
108 | #define CMD_SET_EXTMIDI 0x8a | 116 | #define CMD_SET_EXTMIDI 0x8a |
109 | #define CMD_GET_EXTMIDI 0x8b | 117 | #define CMD_GET_EXTMIDI 0x8b |
110 | #define CMD_SET_MT32 0x8c | 118 | #define CMD_SET_MT32 0x8c |
111 | #define CMD_GET_MT32 0x8d | 119 | #define CMD_GET_MT32 0x8d |
112 | 120 | ||
113 | enum GA_REG { | 121 | enum GA_REG { |
114 | GA_INTSTAT_REG = 0, | 122 | GA_INTSTAT_REG = 0, |
@@ -127,7 +135,8 @@ enum GA_REG { | |||
127 | 135 | ||
128 | 136 | ||
129 | enum card_type { | 137 | enum card_type { |
130 | SSCAPE, | 138 | MEDIA_FX, /* Sequoia S-1000 */ |
139 | SSCAPE, /* Sequoia S-2000 */ | ||
131 | SSCAPE_PNP, | 140 | SSCAPE_PNP, |
132 | SSCAPE_VIVO, | 141 | SSCAPE_VIVO, |
133 | }; | 142 | }; |
@@ -140,16 +149,7 @@ struct soundscape { | |||
140 | struct resource *io_res; | 149 | struct resource *io_res; |
141 | struct resource *wss_res; | 150 | struct resource *wss_res; |
142 | struct snd_wss *chip; | 151 | struct snd_wss *chip; |
143 | struct snd_mpu401 *mpu; | ||
144 | struct snd_hwdep *hw; | ||
145 | 152 | ||
146 | /* | ||
147 | * The MIDI device won't work until we've loaded | ||
148 | * its firmware via a hardware-dependent device IOCTL | ||
149 | */ | ||
150 | spinlock_t fwlock; | ||
151 | int hw_in_use; | ||
152 | unsigned long midi_usage; | ||
153 | unsigned char midi_vol; | 153 | unsigned char midi_vol; |
154 | }; | 154 | }; |
155 | 155 | ||
@@ -161,28 +161,21 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c) | |||
161 | return (struct soundscape *) (c->private_data); | 161 | return (struct soundscape *) (c->private_data); |
162 | } | 162 | } |
163 | 163 | ||
164 | static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) | ||
165 | { | ||
166 | return (struct soundscape *) (mpu->private_data); | ||
167 | } | ||
168 | |||
169 | static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw) | ||
170 | { | ||
171 | return (struct soundscape *) (hw->private_data); | ||
172 | } | ||
173 | |||
174 | |||
175 | /* | 164 | /* |
176 | * Allocates some kernel memory that we can use for DMA. | 165 | * Allocates some kernel memory that we can use for DMA. |
177 | * I think this means that the memory has to map to | 166 | * I think this means that the memory has to map to |
178 | * contiguous pages of physical memory. | 167 | * contiguous pages of physical memory. |
179 | */ | 168 | */ |
180 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size) | 169 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, |
170 | unsigned long size) | ||
181 | { | 171 | { |
182 | if (buf) { | 172 | if (buf) { |
183 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), | 173 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, |
174 | snd_dma_isa_data(), | ||
184 | size, buf) < 0) { | 175 | size, buf) < 0) { |
185 | snd_printk(KERN_ERR "sscape: Failed to allocate %lu bytes for DMA\n", size); | 176 | snd_printk(KERN_ERR "sscape: Failed to allocate " |
177 | "%lu bytes for DMA\n", | ||
178 | size); | ||
186 | return NULL; | 179 | return NULL; |
187 | } | 180 | } |
188 | } | 181 | } |
@@ -199,13 +192,13 @@ static void free_dmabuf(struct snd_dma_buffer *buf) | |||
199 | snd_dma_free_pages(buf); | 192 | snd_dma_free_pages(buf); |
200 | } | 193 | } |
201 | 194 | ||
202 | |||
203 | /* | 195 | /* |
204 | * This function writes to the SoundScape's control registers, | 196 | * This function writes to the SoundScape's control registers, |
205 | * but doesn't do any locking. It's up to the caller to do that. | 197 | * but doesn't do any locking. It's up to the caller to do that. |
206 | * This is why this function is "unsafe" ... | 198 | * This is why this function is "unsafe" ... |
207 | */ | 199 | */ |
208 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val) | 200 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, |
201 | unsigned char val) | ||
209 | { | 202 | { |
210 | outb(reg, ODIE_ADDR_IO(io_base)); | 203 | outb(reg, ODIE_ADDR_IO(io_base)); |
211 | outb(val, ODIE_DATA_IO(io_base)); | 204 | outb(val, ODIE_DATA_IO(io_base)); |
@@ -215,7 +208,8 @@ static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsign | |||
215 | * Write to the SoundScape's control registers, and do the | 208 | * Write to the SoundScape's control registers, and do the |
216 | * necessary locking ... | 209 | * necessary locking ... |
217 | */ | 210 | */ |
218 | static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val) | 211 | static void sscape_write(struct soundscape *s, enum GA_REG reg, |
212 | unsigned char val) | ||
219 | { | 213 | { |
220 | unsigned long flags; | 214 | unsigned long flags; |
221 | 215 | ||
@@ -228,7 +222,8 @@ static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char va | |||
228 | * Read from the SoundScape's control registers, but leave any | 222 | * Read from the SoundScape's control registers, but leave any |
229 | * locking to the caller. This is why the function is "unsafe" ... | 223 | * locking to the caller. This is why the function is "unsafe" ... |
230 | */ | 224 | */ |
231 | static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg) | 225 | static inline unsigned char sscape_read_unsafe(unsigned io_base, |
226 | enum GA_REG reg) | ||
232 | { | 227 | { |
233 | outb(reg, ODIE_ADDR_IO(io_base)); | 228 | outb(reg, ODIE_ADDR_IO(io_base)); |
234 | return inb(ODIE_DATA_IO(io_base)); | 229 | return inb(ODIE_DATA_IO(io_base)); |
@@ -257,9 +252,8 @@ static inline void set_midi_mode_unsafe(unsigned io_base) | |||
257 | static inline int host_read_unsafe(unsigned io_base) | 252 | static inline int host_read_unsafe(unsigned io_base) |
258 | { | 253 | { |
259 | int data = -1; | 254 | int data = -1; |
260 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) { | 255 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) |
261 | data = inb(HOST_DATA_IO(io_base)); | 256 | data = inb(HOST_DATA_IO(io_base)); |
262 | } | ||
263 | 257 | ||
264 | return data; | 258 | return data; |
265 | } | 259 | } |
@@ -301,7 +295,7 @@ static inline int host_write_unsafe(unsigned io_base, unsigned char data) | |||
301 | * Also leaves all locking-issues to the caller ... | 295 | * Also leaves all locking-issues to the caller ... |
302 | */ | 296 | */ |
303 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | 297 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, |
304 | unsigned timeout) | 298 | unsigned timeout) |
305 | { | 299 | { |
306 | int err; | 300 | int err; |
307 | 301 | ||
@@ -320,7 +314,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | |||
320 | * | 314 | * |
321 | * NOTE: This check is based upon observation, not documentation. | 315 | * NOTE: This check is based upon observation, not documentation. |
322 | */ | 316 | */ |
323 | static inline int verify_mpu401(const struct snd_mpu401 * mpu) | 317 | static inline int verify_mpu401(const struct snd_mpu401 *mpu) |
324 | { | 318 | { |
325 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); | 319 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); |
326 | } | 320 | } |
@@ -328,7 +322,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu) | |||
328 | /* | 322 | /* |
329 | * This is apparently the standard way to initailise an MPU-401 | 323 | * This is apparently the standard way to initailise an MPU-401 |
330 | */ | 324 | */ |
331 | static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | 325 | static inline void initialise_mpu401(const struct snd_mpu401 *mpu) |
332 | { | 326 | { |
333 | outb(0, MPU401D(mpu)); | 327 | outb(0, MPU401D(mpu)); |
334 | } | 328 | } |
@@ -338,9 +332,10 @@ static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | |||
338 | * The AD1845 detection fails if we *don't* do this, so I | 332 | * The AD1845 detection fails if we *don't* do this, so I |
339 | * think that this is a good idea ... | 333 | * think that this is a good idea ... |
340 | */ | 334 | */ |
341 | static inline void activate_ad1845_unsafe(unsigned io_base) | 335 | static void activate_ad1845_unsafe(unsigned io_base) |
342 | { | 336 | { |
343 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (sscape_read_unsafe(io_base, GA_HMCTL_REG) & 0xcf) | 0x10); | 337 | unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG); |
338 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10); | ||
344 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); | 339 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); |
345 | } | 340 | } |
346 | 341 | ||
@@ -359,24 +354,27 @@ static void soundscape_free(struct snd_card *c) | |||
359 | * Tell the SoundScape to begin a DMA tranfer using the given channel. | 354 | * Tell the SoundScape to begin a DMA tranfer using the given channel. |
360 | * All locking issues are left to the caller. | 355 | * All locking issues are left to the caller. |
361 | */ | 356 | */ |
362 | static inline void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) | 357 | static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) |
363 | { | 358 | { |
364 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01); | 359 | sscape_write_unsafe(io_base, reg, |
365 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe); | 360 | sscape_read_unsafe(io_base, reg) | 0x01); |
361 | sscape_write_unsafe(io_base, reg, | ||
362 | sscape_read_unsafe(io_base, reg) & 0xfe); | ||
366 | } | 363 | } |
367 | 364 | ||
368 | /* | 365 | /* |
369 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", | 366 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", |
370 | * and all locking issues are left to the caller. | 367 | * and all locking issues are left to the caller. |
371 | */ | 368 | */ |
372 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout) | 369 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, |
370 | unsigned timeout) | ||
373 | { | 371 | { |
374 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { | 372 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { |
375 | udelay(100); | 373 | udelay(100); |
376 | --timeout; | 374 | --timeout; |
377 | } /* while */ | 375 | } /* while */ |
378 | 376 | ||
379 | return (sscape_read_unsafe(io_base, reg) & 0x01); | 377 | return sscape_read_unsafe(io_base, reg) & 0x01; |
380 | } | 378 | } |
381 | 379 | ||
382 | /* | 380 | /* |
@@ -392,12 +390,12 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout) | |||
392 | 390 | ||
393 | do { | 391 | do { |
394 | unsigned long flags; | 392 | unsigned long flags; |
395 | unsigned char x; | 393 | int x; |
396 | 394 | ||
397 | spin_lock_irqsave(&s->lock, flags); | 395 | spin_lock_irqsave(&s->lock, flags); |
398 | x = inb(HOST_DATA_IO(s->io_base)); | 396 | x = host_read_unsafe(s->io_base); |
399 | spin_unlock_irqrestore(&s->lock, flags); | 397 | spin_unlock_irqrestore(&s->lock, flags); |
400 | if ((x & 0xfe) == 0xfe) | 398 | if (x == 0xfe || x == 0xff) |
401 | return 1; | 399 | return 1; |
402 | 400 | ||
403 | msleep(10); | 401 | msleep(10); |
@@ -419,10 +417,10 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
419 | 417 | ||
420 | do { | 418 | do { |
421 | unsigned long flags; | 419 | unsigned long flags; |
422 | unsigned char x; | 420 | int x; |
423 | 421 | ||
424 | spin_lock_irqsave(&s->lock, flags); | 422 | spin_lock_irqsave(&s->lock, flags); |
425 | x = inb(HOST_DATA_IO(s->io_base)); | 423 | x = host_read_unsafe(s->io_base); |
426 | spin_unlock_irqrestore(&s->lock, flags); | 424 | spin_unlock_irqrestore(&s->lock, flags); |
427 | if (x == 0xfe) | 425 | if (x == 0xfe) |
428 | return 1; | 426 | return 1; |
@@ -436,15 +434,15 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
436 | /* | 434 | /* |
437 | * Upload a byte-stream into the SoundScape using DMA channel A. | 435 | * Upload a byte-stream into the SoundScape using DMA channel A. |
438 | */ | 436 | */ |
439 | static int upload_dma_data(struct soundscape *s, | 437 | static int upload_dma_data(struct soundscape *s, const unsigned char *data, |
440 | const unsigned char __user *data, | 438 | size_t size) |
441 | size_t size) | ||
442 | { | 439 | { |
443 | unsigned long flags; | 440 | unsigned long flags; |
444 | struct snd_dma_buffer dma; | 441 | struct snd_dma_buffer dma; |
445 | int ret; | 442 | int ret; |
443 | unsigned char val; | ||
446 | 444 | ||
447 | if (!get_dmabuf(&dma, PAGE_ALIGN(size))) | 445 | if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024))) |
448 | return -ENOMEM; | 446 | return -ENOMEM; |
449 | 447 | ||
450 | spin_lock_irqsave(&s->lock, flags); | 448 | spin_lock_irqsave(&s->lock, flags); |
@@ -452,70 +450,57 @@ static int upload_dma_data(struct soundscape *s, | |||
452 | /* | 450 | /* |
453 | * Reset the board ... | 451 | * Reset the board ... |
454 | */ | 452 | */ |
455 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f); | 453 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
454 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f); | ||
456 | 455 | ||
457 | /* | 456 | /* |
458 | * Enable the DMA channels and configure them ... | 457 | * Enable the DMA channels and configure them ... |
459 | */ | 458 | */ |
460 | sscape_write_unsafe(s->io_base, GA_DMACFG_REG, 0x50); | 459 | val = (s->chip->dma1 << 4) | DMA_8BIT; |
461 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT); | 460 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, val); |
462 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); | 461 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); |
463 | 462 | ||
464 | /* | 463 | /* |
465 | * Take the board out of reset ... | 464 | * Take the board out of reset ... |
466 | */ | 465 | */ |
467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80); | 466 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80); | ||
468 | 468 | ||
469 | /* | 469 | /* |
470 | * Upload the user's data (firmware?) to the SoundScape | 470 | * Upload the firmware to the SoundScape |
471 | * board through the DMA channel ... | 471 | * board through the DMA channel ... |
472 | */ | 472 | */ |
473 | while (size != 0) { | 473 | while (size != 0) { |
474 | unsigned long len; | 474 | unsigned long len; |
475 | 475 | ||
476 | /* | ||
477 | * Apparently, copying to/from userspace can sleep. | ||
478 | * We are therefore forbidden from holding any | ||
479 | * spinlocks while we copy ... | ||
480 | */ | ||
481 | spin_unlock_irqrestore(&s->lock, flags); | ||
482 | |||
483 | /* | ||
484 | * Remember that the data that we want to DMA | ||
485 | * comes from USERSPACE. We have already verified | ||
486 | * the userspace pointer ... | ||
487 | */ | ||
488 | len = min(size, dma.bytes); | 476 | len = min(size, dma.bytes); |
489 | len -= __copy_from_user(dma.area, data, len); | 477 | memcpy(dma.area, data, len); |
490 | data += len; | 478 | data += len; |
491 | size -= len; | 479 | size -= len; |
492 | 480 | ||
493 | /* | ||
494 | * Grab that spinlock again, now that we've | ||
495 | * finished copying! | ||
496 | */ | ||
497 | spin_lock_irqsave(&s->lock, flags); | ||
498 | |||
499 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); | 481 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); |
500 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); | 482 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); |
501 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { | 483 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { |
502 | /* | 484 | /* |
503 | * Don't forget to release this spinlock we're holding ... | 485 | * Don't forget to release this spinlock we're holding |
504 | */ | 486 | */ |
505 | spin_unlock_irqrestore(&s->lock, flags); | 487 | spin_unlock_irqrestore(&s->lock, flags); |
506 | 488 | ||
507 | snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); | 489 | snd_printk(KERN_ERR |
490 | "sscape: DMA upload has timed out\n"); | ||
508 | ret = -EAGAIN; | 491 | ret = -EAGAIN; |
509 | goto _release_dma; | 492 | goto _release_dma; |
510 | } | 493 | } |
511 | } /* while */ | 494 | } /* while */ |
512 | 495 | ||
513 | set_host_mode_unsafe(s->io_base); | 496 | set_host_mode_unsafe(s->io_base); |
497 | outb(0x0, s->io_base); | ||
514 | 498 | ||
515 | /* | 499 | /* |
516 | * Boot the board ... (I think) | 500 | * Boot the board ... (I think) |
517 | */ | 501 | */ |
518 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x40); | 502 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
503 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40); | ||
519 | spin_unlock_irqrestore(&s->lock, flags); | 504 | spin_unlock_irqrestore(&s->lock, flags); |
520 | 505 | ||
521 | /* | 506 | /* |
@@ -525,10 +510,12 @@ static int upload_dma_data(struct soundscape *s, | |||
525 | */ | 510 | */ |
526 | ret = 0; | 511 | ret = 0; |
527 | if (!obp_startup_ack(s, 5000)) { | 512 | if (!obp_startup_ack(s, 5000)) { |
528 | snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); | 513 | snd_printk(KERN_ERR "sscape: No response " |
514 | "from on-board processor after upload\n"); | ||
529 | ret = -EAGAIN; | 515 | ret = -EAGAIN; |
530 | } else if (!host_startup_ack(s, 5000)) { | 516 | } else if (!host_startup_ack(s, 5000)) { |
531 | snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); | 517 | snd_printk(KERN_ERR |
518 | "sscape: SoundScape failed to initialise\n"); | ||
532 | ret = -EAGAIN; | 519 | ret = -EAGAIN; |
533 | } | 520 | } |
534 | 521 | ||
@@ -536,7 +523,7 @@ _release_dma: | |||
536 | /* | 523 | /* |
537 | * NOTE!!! We are NOT holding any spinlocks at this point !!! | 524 | * NOTE!!! We are NOT holding any spinlocks at this point !!! |
538 | */ | 525 | */ |
539 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_ODIE ? 0x70 : 0x40)); | 526 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70)); |
540 | free_dmabuf(&dma); | 527 | free_dmabuf(&dma); |
541 | 528 | ||
542 | return ret; | 529 | return ret; |
@@ -546,167 +533,76 @@ _release_dma: | |||
546 | * Upload the bootblock(?) into the SoundScape. The only | 533 | * Upload the bootblock(?) into the SoundScape. The only |
547 | * purpose of this block of code seems to be to tell | 534 | * purpose of this block of code seems to be to tell |
548 | * us which version of the microcode we should be using. | 535 | * us which version of the microcode we should be using. |
549 | * | ||
550 | * NOTE: The boot-block data resides in USER-SPACE!!! | ||
551 | * However, we have already verified its memory | ||
552 | * addresses by the time we get here. | ||
553 | */ | 536 | */ |
554 | static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_bootblock __user *bb) | 537 | static int sscape_upload_bootblock(struct snd_card *card) |
555 | { | 538 | { |
539 | struct soundscape *sscape = get_card_soundscape(card); | ||
556 | unsigned long flags; | 540 | unsigned long flags; |
541 | const struct firmware *init_fw = NULL; | ||
557 | int data = 0; | 542 | int data = 0; |
558 | int ret; | 543 | int ret; |
559 | 544 | ||
560 | ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); | 545 | ret = request_firmware(&init_fw, "scope.cod", card->dev); |
561 | 546 | if (ret < 0) { | |
562 | spin_lock_irqsave(&sscape->lock, flags); | 547 | snd_printk(KERN_ERR "sscape: Error loading scope.cod"); |
563 | if (ret == 0) { | 548 | return ret; |
564 | data = host_read_ctrl_unsafe(sscape->io_base, 100); | ||
565 | } | ||
566 | set_midi_mode_unsafe(sscape->io_base); | ||
567 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
568 | |||
569 | if (ret == 0) { | ||
570 | if (data < 0) { | ||
571 | snd_printk(KERN_ERR "sscape: timeout reading firmware version\n"); | ||
572 | ret = -EAGAIN; | ||
573 | } | ||
574 | else if (__copy_to_user(&bb->version, &data, sizeof(bb->version))) { | ||
575 | ret = -EFAULT; | ||
576 | } | ||
577 | } | 549 | } |
550 | ret = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
578 | 551 | ||
579 | return ret; | 552 | release_firmware(init_fw); |
580 | } | ||
581 | |||
582 | /* | ||
583 | * Upload the microcode into the SoundScape. The | ||
584 | * microcode is 64K of data, and if we try to copy | ||
585 | * it into a local variable then we will SMASH THE | ||
586 | * KERNEL'S STACK! We therefore leave it in USER | ||
587 | * SPACE, and save ourselves from copying it at all. | ||
588 | */ | ||
589 | static int sscape_upload_microcode(struct soundscape *sscape, | ||
590 | const struct sscape_microcode __user *mc) | ||
591 | { | ||
592 | unsigned long flags; | ||
593 | char __user *code; | ||
594 | int err; | ||
595 | 553 | ||
596 | /* | 554 | spin_lock_irqsave(&sscape->lock, flags); |
597 | * We are going to have to copy this data into a special | 555 | if (ret == 0) |
598 | * DMA-able buffer before we can upload it. We shall therefore | 556 | data = host_read_ctrl_unsafe(sscape->io_base, 100); |
599 | * just check that the data pointer is valid for now. | ||
600 | * | ||
601 | * NOTE: This buffer is 64K long! That's WAY too big to | ||
602 | * copy into a stack-temporary anyway. | ||
603 | */ | ||
604 | if ( get_user(code, &mc->code) || | ||
605 | !access_ok(VERIFY_READ, code, SSCAPE_MICROCODE_SIZE) ) | ||
606 | return -EFAULT; | ||
607 | 557 | ||
608 | if ((err = upload_dma_data(sscape, code, SSCAPE_MICROCODE_SIZE)) == 0) { | 558 | if (data & 0x10) |
609 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); | 559 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f); |
610 | } | ||
611 | 560 | ||
612 | spin_lock_irqsave(&sscape->lock, flags); | ||
613 | set_midi_mode_unsafe(sscape->io_base); | ||
614 | spin_unlock_irqrestore(&sscape->lock, flags); | 561 | spin_unlock_irqrestore(&sscape->lock, flags); |
615 | 562 | ||
616 | initialise_mpu401(sscape->mpu); | 563 | data &= 0xf; |
564 | if (ret == 0 && data > 7) { | ||
565 | snd_printk(KERN_ERR | ||
566 | "sscape: timeout reading firmware version\n"); | ||
567 | ret = -EAGAIN; | ||
568 | } | ||
617 | 569 | ||
618 | return err; | 570 | return (ret == 0) ? data : ret; |
619 | } | 571 | } |
620 | 572 | ||
621 | /* | 573 | /* |
622 | * Hardware-specific device functions, to implement special | 574 | * Upload the microcode into the SoundScape. |
623 | * IOCTLs for the SoundScape card. This is how we upload | ||
624 | * the microcode into the card, for example, and so we | ||
625 | * must ensure that no two processes can open this device | ||
626 | * simultaneously, and that we can't open it at all if | ||
627 | * someone is using the MIDI device. | ||
628 | */ | 575 | */ |
629 | static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) | 576 | static int sscape_upload_microcode(struct snd_card *card, int version) |
630 | { | 577 | { |
631 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | 578 | struct soundscape *sscape = get_card_soundscape(card); |
632 | unsigned long flags; | 579 | const struct firmware *init_fw = NULL; |
580 | char name[14]; | ||
633 | int err; | 581 | int err; |
634 | 582 | ||
635 | spin_lock_irqsave(&sscape->fwlock, flags); | 583 | snprintf(name, sizeof(name), "sndscape.co%d", version); |
636 | 584 | ||
637 | if ((sscape->midi_usage != 0) || sscape->hw_in_use) { | 585 | err = request_firmware(&init_fw, name, card->dev); |
638 | err = -EBUSY; | 586 | if (err < 0) { |
639 | } else { | 587 | snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", |
640 | sscape->hw_in_use = 1; | 588 | version); |
641 | err = 0; | 589 | return err; |
642 | } | 590 | } |
591 | err = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
592 | if (err == 0) | ||
593 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n", | ||
594 | init_fw->size >> 10); | ||
643 | 595 | ||
644 | spin_unlock_irqrestore(&sscape->fwlock, flags); | 596 | release_firmware(init_fw); |
645 | return err; | ||
646 | } | ||
647 | |||
648 | static int sscape_hw_release(struct snd_hwdep * hw, struct file *file) | ||
649 | { | ||
650 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
651 | unsigned long flags; | ||
652 | |||
653 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
654 | sscape->hw_in_use = 0; | ||
655 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file, | ||
660 | unsigned int cmd, unsigned long arg) | ||
661 | { | ||
662 | struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
663 | int err = -EBUSY; | ||
664 | |||
665 | switch (cmd) { | ||
666 | case SND_SSCAPE_LOAD_BOOTB: | ||
667 | { | ||
668 | register struct sscape_bootblock __user *bb = (struct sscape_bootblock __user *) arg; | ||
669 | |||
670 | /* | ||
671 | * We are going to have to copy this data into a special | ||
672 | * DMA-able buffer before we can upload it. We shall therefore | ||
673 | * just check that the data pointer is valid for now ... | ||
674 | */ | ||
675 | if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) ) | ||
676 | return -EFAULT; | ||
677 | |||
678 | /* | ||
679 | * Now check that we can write the firmware version number too... | ||
680 | */ | ||
681 | if ( !access_ok(VERIFY_WRITE, &bb->version, sizeof(bb->version)) ) | ||
682 | return -EFAULT; | ||
683 | |||
684 | err = sscape_upload_bootblock(sscape, bb); | ||
685 | } | ||
686 | break; | ||
687 | |||
688 | case SND_SSCAPE_LOAD_MCODE: | ||
689 | { | ||
690 | register const struct sscape_microcode __user *mc = (const struct sscape_microcode __user *) arg; | ||
691 | |||
692 | err = sscape_upload_microcode(sscape, mc); | ||
693 | } | ||
694 | break; | ||
695 | |||
696 | default: | ||
697 | err = -EINVAL; | ||
698 | break; | ||
699 | } /* switch */ | ||
700 | 597 | ||
701 | return err; | 598 | return err; |
702 | } | 599 | } |
703 | 600 | ||
704 | |||
705 | /* | 601 | /* |
706 | * Mixer control for the SoundScape's MIDI device. | 602 | * Mixer control for the SoundScape's MIDI device. |
707 | */ | 603 | */ |
708 | static int sscape_midi_info(struct snd_kcontrol *ctl, | 604 | static int sscape_midi_info(struct snd_kcontrol *ctl, |
709 | struct snd_ctl_elem_info *uinfo) | 605 | struct snd_ctl_elem_info *uinfo) |
710 | { | 606 | { |
711 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 607 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
712 | uinfo->count = 1; | 608 | uinfo->count = 1; |
@@ -716,7 +612,7 @@ static int sscape_midi_info(struct snd_kcontrol *ctl, | |||
716 | } | 612 | } |
717 | 613 | ||
718 | static int sscape_midi_get(struct snd_kcontrol *kctl, | 614 | static int sscape_midi_get(struct snd_kcontrol *kctl, |
719 | struct snd_ctl_elem_value *uctl) | 615 | struct snd_ctl_elem_value *uctl) |
720 | { | 616 | { |
721 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 617 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
722 | struct snd_card *card = chip->card; | 618 | struct snd_card *card = chip->card; |
@@ -730,16 +626,18 @@ static int sscape_midi_get(struct snd_kcontrol *kctl, | |||
730 | } | 626 | } |
731 | 627 | ||
732 | static int sscape_midi_put(struct snd_kcontrol *kctl, | 628 | static int sscape_midi_put(struct snd_kcontrol *kctl, |
733 | struct snd_ctl_elem_value *uctl) | 629 | struct snd_ctl_elem_value *uctl) |
734 | { | 630 | { |
735 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 631 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
736 | struct snd_card *card = chip->card; | 632 | struct snd_card *card = chip->card; |
737 | register struct soundscape *s = get_card_soundscape(card); | 633 | struct soundscape *s = get_card_soundscape(card); |
738 | unsigned long flags; | 634 | unsigned long flags; |
739 | int change; | 635 | int change; |
636 | unsigned char new_val; | ||
740 | 637 | ||
741 | spin_lock_irqsave(&s->lock, flags); | 638 | spin_lock_irqsave(&s->lock, flags); |
742 | 639 | ||
640 | new_val = uctl->value.integer.value[0] & 127; | ||
743 | /* | 641 | /* |
744 | * We need to put the board into HOST mode before we | 642 | * We need to put the board into HOST mode before we |
745 | * can send any volume-changing HOST commands ... | 643 | * can send any volume-changing HOST commands ... |
@@ -752,15 +650,16 @@ static int sscape_midi_put(struct snd_kcontrol *kctl, | |||
752 | * and then perform another volume-related command. Perhaps the | 650 | * and then perform another volume-related command. Perhaps the |
753 | * first command is an "open" and the second command is a "close"? | 651 | * first command is an "open" and the second command is a "close"? |
754 | */ | 652 | */ |
755 | if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) { | 653 | if (s->midi_vol == new_val) { |
756 | change = 0; | 654 | change = 0; |
757 | goto __skip_change; | 655 | goto __skip_change; |
758 | } | 656 | } |
759 | change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) | 657 | change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) |
760 | && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) | 658 | && host_write_ctrl_unsafe(s->io_base, new_val, 100) |
761 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); | 659 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100) |
762 | s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127; | 660 | && host_write_ctrl_unsafe(s->io_base, new_val, 100); |
763 | __skip_change: | 661 | s->midi_vol = new_val; |
662 | __skip_change: | ||
764 | 663 | ||
765 | /* | 664 | /* |
766 | * Take the board out of HOST mode and back into MIDI mode ... | 665 | * Take the board out of HOST mode and back into MIDI mode ... |
@@ -784,20 +683,25 @@ static struct snd_kcontrol_new midi_mixer_ctl = { | |||
784 | * These IRQs are encoded as bit patterns so that they can be | 683 | * These IRQs are encoded as bit patterns so that they can be |
785 | * written to the control registers. | 684 | * written to the control registers. |
786 | */ | 685 | */ |
787 | static unsigned __devinit get_irq_config(int irq) | 686 | static unsigned __devinit get_irq_config(int sscape_type, int irq) |
788 | { | 687 | { |
789 | static const int valid_irq[] = { 9, 5, 7, 10 }; | 688 | static const int valid_irq[] = { 9, 5, 7, 10 }; |
689 | static const int old_irq[] = { 9, 7, 5, 15 }; | ||
790 | unsigned cfg; | 690 | unsigned cfg; |
791 | 691 | ||
792 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) { | 692 | if (sscape_type == MEDIA_FX) { |
793 | if (irq == valid_irq[cfg]) | 693 | for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg) |
794 | return cfg; | 694 | if (irq == old_irq[cfg]) |
795 | } /* for */ | 695 | return cfg; |
696 | } else { | ||
697 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) | ||
698 | if (irq == valid_irq[cfg]) | ||
699 | return cfg; | ||
700 | } | ||
796 | 701 | ||
797 | return INVALID_IRQ; | 702 | return INVALID_IRQ; |
798 | } | 703 | } |
799 | 704 | ||
800 | |||
801 | /* | 705 | /* |
802 | * Perform certain arcane port-checks to see whether there | 706 | * Perform certain arcane port-checks to see whether there |
803 | * is a SoundScape board lurking behind the given ports. | 707 | * is a SoundScape board lurking behind the given ports. |
@@ -842,11 +746,38 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
842 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) | 746 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) |
843 | goto _done; | 747 | goto _done; |
844 | 748 | ||
845 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | 749 | if (s->ic_type == IC_OPUS) |
846 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | 750 | activate_ad1845_unsafe(s->io_base); |
847 | 751 | ||
848 | if (s->type == SSCAPE_VIVO) | 752 | if (s->type == SSCAPE_VIVO) |
849 | wss_io += 4; | 753 | wss_io += 4; |
754 | |||
755 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
756 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
757 | |||
758 | /* wait for WSS codec */ | ||
759 | for (d = 0; d < 500; d++) { | ||
760 | if ((inb(wss_io) & 0x80) == 0) | ||
761 | break; | ||
762 | spin_unlock_irqrestore(&s->lock, flags); | ||
763 | msleep(1); | ||
764 | spin_lock_irqsave(&s->lock, flags); | ||
765 | } | ||
766 | |||
767 | if ((inb(wss_io) & 0x80) != 0) | ||
768 | goto _done; | ||
769 | |||
770 | if (inb(wss_io + 2) == 0xff) | ||
771 | goto _done; | ||
772 | |||
773 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | ||
774 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d); | ||
775 | |||
776 | if ((inb(wss_io) & 0x80) != 0) | ||
777 | s->type = MEDIA_FX; | ||
778 | |||
779 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
780 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
850 | /* wait for WSS codec */ | 781 | /* wait for WSS codec */ |
851 | for (d = 0; d < 500; d++) { | 782 | for (d = 0; d < 500; d++) { |
852 | if ((inb(wss_io) & 0x80) == 0) | 783 | if ((inb(wss_io) & 0x80) == 0) |
@@ -855,14 +786,13 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
855 | msleep(1); | 786 | msleep(1); |
856 | spin_lock_irqsave(&s->lock, flags); | 787 | spin_lock_irqsave(&s->lock, flags); |
857 | } | 788 | } |
858 | snd_printd(KERN_INFO "init delay = %d ms\n", d); | ||
859 | 789 | ||
860 | /* | 790 | /* |
861 | * SoundScape successfully detected! | 791 | * SoundScape successfully detected! |
862 | */ | 792 | */ |
863 | retval = 1; | 793 | retval = 1; |
864 | 794 | ||
865 | _done: | 795 | _done: |
866 | spin_unlock_irqrestore(&s->lock, flags); | 796 | spin_unlock_irqrestore(&s->lock, flags); |
867 | return retval; | 797 | return retval; |
868 | } | 798 | } |
@@ -873,63 +803,35 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
873 | * to crash the machine. Also check that someone isn't using the hardware | 803 | * to crash the machine. Also check that someone isn't using the hardware |
874 | * IOCTL device. | 804 | * IOCTL device. |
875 | */ | 805 | */ |
876 | static int mpu401_open(struct snd_mpu401 * mpu) | 806 | static int mpu401_open(struct snd_mpu401 *mpu) |
877 | { | 807 | { |
878 | int err; | ||
879 | |||
880 | if (!verify_mpu401(mpu)) { | 808 | if (!verify_mpu401(mpu)) { |
881 | snd_printk(KERN_ERR "sscape: MIDI disabled, please load firmware\n"); | 809 | snd_printk(KERN_ERR "sscape: MIDI disabled, " |
882 | err = -ENODEV; | 810 | "please load firmware\n"); |
883 | } else { | 811 | return -ENODEV; |
884 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
885 | unsigned long flags; | ||
886 | |||
887 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
888 | |||
889 | if (sscape->hw_in_use || (sscape->midi_usage == ULONG_MAX)) { | ||
890 | err = -EBUSY; | ||
891 | } else { | ||
892 | ++(sscape->midi_usage); | ||
893 | err = 0; | ||
894 | } | ||
895 | |||
896 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
897 | } | 812 | } |
898 | 813 | ||
899 | return err; | 814 | return 0; |
900 | } | ||
901 | |||
902 | static void mpu401_close(struct snd_mpu401 * mpu) | ||
903 | { | ||
904 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
905 | unsigned long flags; | ||
906 | |||
907 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
908 | --(sscape->midi_usage); | ||
909 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
910 | } | 815 | } |
911 | 816 | ||
912 | /* | 817 | /* |
913 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. | 818 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. |
914 | */ | 819 | */ |
915 | static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) | 820 | static int __devinit create_mpu401(struct snd_card *card, int devnum, |
821 | unsigned long port, int irq) | ||
916 | { | 822 | { |
917 | struct soundscape *sscape = get_card_soundscape(card); | 823 | struct soundscape *sscape = get_card_soundscape(card); |
918 | struct snd_rawmidi *rawmidi; | 824 | struct snd_rawmidi *rawmidi; |
919 | int err; | 825 | int err; |
920 | 826 | ||
921 | if ((err = snd_mpu401_uart_new(card, devnum, | 827 | err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port, |
922 | MPU401_HW_MPU401, | 828 | MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED, |
923 | port, MPU401_INFO_INTEGRATED, | 829 | &rawmidi); |
924 | irq, IRQF_DISABLED, | 830 | if (err == 0) { |
925 | &rawmidi)) == 0) { | 831 | struct snd_mpu401 *mpu = rawmidi->private_data; |
926 | struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; | ||
927 | mpu->open_input = mpu401_open; | 832 | mpu->open_input = mpu401_open; |
928 | mpu->open_output = mpu401_open; | 833 | mpu->open_output = mpu401_open; |
929 | mpu->close_input = mpu401_close; | ||
930 | mpu->close_output = mpu401_close; | ||
931 | mpu->private_data = sscape; | 834 | mpu->private_data = sscape; |
932 | sscape->mpu = mpu; | ||
933 | 835 | ||
934 | initialise_mpu401(mpu); | 836 | initialise_mpu401(mpu); |
935 | } | 837 | } |
@@ -950,32 +852,34 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
950 | register struct soundscape *sscape = get_card_soundscape(card); | 852 | register struct soundscape *sscape = get_card_soundscape(card); |
951 | struct snd_wss *chip; | 853 | struct snd_wss *chip; |
952 | int err; | 854 | int err; |
855 | int codec_type = WSS_HW_DETECT; | ||
953 | 856 | ||
954 | if (sscape->type == SSCAPE_VIVO) | 857 | switch (sscape->type) { |
955 | port += 4; | 858 | case MEDIA_FX: |
859 | case SSCAPE: | ||
860 | /* | ||
861 | * There are some freak examples of early Soundscape cards | ||
862 | * with CS4231 instead of AD1848/CS4248. Unfortunately, the | ||
863 | * CS4231 works only in CS4248 compatibility mode on | ||
864 | * these cards so force it. | ||
865 | */ | ||
866 | if (sscape->ic_type != IC_OPUS) | ||
867 | codec_type = WSS_HW_AD1848; | ||
868 | break; | ||
956 | 869 | ||
957 | if (dma1 == dma2) | 870 | case SSCAPE_VIVO: |
958 | dma2 = -1; | 871 | port += 4; |
872 | break; | ||
873 | default: | ||
874 | break; | ||
875 | } | ||
959 | 876 | ||
960 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, | 877 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, |
961 | WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); | 878 | codec_type, WSS_HWSHARE_DMA1, &chip); |
962 | if (!err) { | 879 | if (!err) { |
963 | unsigned long flags; | 880 | unsigned long flags; |
964 | struct snd_pcm *pcm; | 881 | struct snd_pcm *pcm; |
965 | 882 | ||
966 | /* | ||
967 | * It turns out that the PLAYBACK_ENABLE bit is set | ||
968 | * by the lowlevel driver ... | ||
969 | * | ||
970 | #define AD1845_IFACE_CONFIG \ | ||
971 | (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE) | ||
972 | snd_wss_mce_up(chip); | ||
973 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
974 | snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG); | ||
975 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
976 | snd_wss_mce_down(chip); | ||
977 | */ | ||
978 | |||
979 | if (sscape->type != SSCAPE_VIVO) { | 883 | if (sscape->type != SSCAPE_VIVO) { |
980 | /* | 884 | /* |
981 | * The input clock frequency on the SoundScape must | 885 | * The input clock frequency on the SoundScape must |
@@ -1022,17 +926,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
1022 | } | 926 | } |
1023 | } | 927 | } |
1024 | 928 | ||
1025 | strcpy(card->driver, "SoundScape"); | ||
1026 | strcpy(card->shortname, pcm->name); | ||
1027 | snprintf(card->longname, sizeof(card->longname), | ||
1028 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
1029 | pcm->name, chip->port, chip->irq, | ||
1030 | chip->dma1, chip->dma2); | ||
1031 | |||
1032 | sscape->chip = chip; | 929 | sscape->chip = chip; |
1033 | } | 930 | } |
1034 | 931 | ||
1035 | _error: | 932 | _error: |
1036 | return err; | 933 | return err; |
1037 | } | 934 | } |
1038 | 935 | ||
@@ -1051,21 +948,8 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1051 | struct resource *wss_res; | 948 | struct resource *wss_res; |
1052 | unsigned long flags; | 949 | unsigned long flags; |
1053 | int err; | 950 | int err; |
1054 | 951 | int val; | |
1055 | /* | 952 | const char *name; |
1056 | * Check that the user didn't pass us garbage data ... | ||
1057 | */ | ||
1058 | irq_cfg = get_irq_config(irq[dev]); | ||
1059 | if (irq_cfg == INVALID_IRQ) { | ||
1060 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); | ||
1061 | return -ENXIO; | ||
1062 | } | ||
1063 | |||
1064 | mpu_irq_cfg = get_irq_config(mpu_irq[dev]); | ||
1065 | if (mpu_irq_cfg == INVALID_IRQ) { | ||
1066 | printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); | ||
1067 | return -ENXIO; | ||
1068 | } | ||
1069 | 953 | ||
1070 | /* | 954 | /* |
1071 | * Grab IO ports that we will need to probe so that we | 955 | * Grab IO ports that we will need to probe so that we |
@@ -1098,41 +982,51 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1098 | } | 982 | } |
1099 | 983 | ||
1100 | spin_lock_init(&sscape->lock); | 984 | spin_lock_init(&sscape->lock); |
1101 | spin_lock_init(&sscape->fwlock); | ||
1102 | sscape->io_res = io_res; | 985 | sscape->io_res = io_res; |
1103 | sscape->wss_res = wss_res; | 986 | sscape->wss_res = wss_res; |
1104 | sscape->io_base = port[dev]; | 987 | sscape->io_base = port[dev]; |
1105 | 988 | ||
1106 | if (!detect_sscape(sscape, wss_port[dev])) { | 989 | if (!detect_sscape(sscape, wss_port[dev])) { |
1107 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); | 990 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", |
991 | sscape->io_base); | ||
1108 | err = -ENODEV; | 992 | err = -ENODEV; |
1109 | goto _release_dma; | 993 | goto _release_dma; |
1110 | } | 994 | } |
1111 | 995 | ||
1112 | printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", | 996 | switch (sscape->type) { |
1113 | sscape->io_base, irq[dev], dma[dev]); | 997 | case MEDIA_FX: |
998 | name = "MediaFX/SoundFX"; | ||
999 | break; | ||
1000 | case SSCAPE: | ||
1001 | name = "Soundscape"; | ||
1002 | break; | ||
1003 | case SSCAPE_PNP: | ||
1004 | name = "Soundscape PnP"; | ||
1005 | break; | ||
1006 | case SSCAPE_VIVO: | ||
1007 | name = "Soundscape VIVO"; | ||
1008 | break; | ||
1009 | default: | ||
1010 | name = "unknown Soundscape"; | ||
1011 | break; | ||
1012 | } | ||
1114 | 1013 | ||
1115 | if (sscape->type != SSCAPE_VIVO) { | 1014 | printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n", |
1116 | /* | 1015 | name, sscape->io_base, irq[dev], dma[dev]); |
1117 | * Now create the hardware-specific device so that we can | 1016 | |
1118 | * load the microcode into the on-board processor. | 1017 | /* |
1119 | * We cannot use the MPU-401 MIDI system until this firmware | 1018 | * Check that the user didn't pass us garbage data ... |
1120 | * has been loaded into the card. | 1019 | */ |
1121 | */ | 1020 | irq_cfg = get_irq_config(sscape->type, irq[dev]); |
1122 | err = snd_hwdep_new(card, "MC68EC000", 0, &(sscape->hw)); | 1021 | if (irq_cfg == INVALID_IRQ) { |
1123 | if (err < 0) { | 1022 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); |
1124 | printk(KERN_ERR "sscape: Failed to create " | 1023 | return -ENXIO; |
1125 | "firmware device\n"); | 1024 | } |
1126 | goto _release_dma; | 1025 | |
1127 | } | 1026 | mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); |
1128 | strlcpy(sscape->hw->name, "SoundScape M68K", | 1027 | if (mpu_irq_cfg == INVALID_IRQ) { |
1129 | sizeof(sscape->hw->name)); | 1028 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); |
1130 | sscape->hw->name[sizeof(sscape->hw->name) - 1] = '\0'; | 1029 | return -ENXIO; |
1131 | sscape->hw->iface = SNDRV_HWDEP_IFACE_SSCAPE; | ||
1132 | sscape->hw->ops.open = sscape_hw_open; | ||
1133 | sscape->hw->ops.release = sscape_hw_release; | ||
1134 | sscape->hw->ops.ioctl = sscape_hw_ioctl; | ||
1135 | sscape->hw->private_data = sscape; | ||
1136 | } | 1030 | } |
1137 | 1031 | ||
1138 | /* | 1032 | /* |
@@ -1141,9 +1035,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1141 | */ | 1035 | */ |
1142 | spin_lock_irqsave(&sscape->lock, flags); | 1036 | spin_lock_irqsave(&sscape->lock, flags); |
1143 | 1037 | ||
1144 | activate_ad1845_unsafe(sscape->io_base); | ||
1145 | |||
1146 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x00); /* disable */ | ||
1147 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); | 1038 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); |
1148 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); | 1039 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); |
1149 | 1040 | ||
@@ -1151,15 +1042,23 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1151 | * Enable and configure the DMA channels ... | 1042 | * Enable and configure the DMA channels ... |
1152 | */ | 1043 | */ |
1153 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); | 1044 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); |
1154 | dma_cfg = (sscape->ic_type == IC_ODIE ? 0x70 : 0x40); | 1045 | dma_cfg = (sscape->ic_type == IC_OPUS ? 0x40 : 0x70); |
1155 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); | 1046 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); |
1156 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); | 1047 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); |
1157 | 1048 | ||
1158 | sscape_write_unsafe(sscape->io_base, | 1049 | mpu_irq_cfg |= mpu_irq_cfg << 2; |
1159 | GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); | 1050 | val = sscape_read_unsafe(sscape->io_base, GA_HMCTL_REG) & 0xF7; |
1051 | if (joystick[dev]) | ||
1052 | val |= 8; | ||
1053 | sscape_write_unsafe(sscape->io_base, GA_HMCTL_REG, val | 0x10); | ||
1054 | sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | mpu_irq_cfg); | ||
1160 | sscape_write_unsafe(sscape->io_base, | 1055 | sscape_write_unsafe(sscape->io_base, |
1161 | GA_CDCFG_REG, 0x09 | DMA_8BIT | 1056 | GA_CDCFG_REG, 0x09 | DMA_8BIT |
1162 | | (dma[dev] << 4) | (irq_cfg << 1)); | 1057 | | (dma[dev] << 4) | (irq_cfg << 1)); |
1058 | /* | ||
1059 | * Enable the master IRQ ... | ||
1060 | */ | ||
1061 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80); | ||
1163 | 1062 | ||
1164 | spin_unlock_irqrestore(&sscape->lock, flags); | 1063 | spin_unlock_irqrestore(&sscape->lock, flags); |
1165 | 1064 | ||
@@ -1170,32 +1069,56 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1170 | err = create_ad1845(card, wss_port[dev], irq[dev], | 1069 | err = create_ad1845(card, wss_port[dev], irq[dev], |
1171 | dma[dev], dma2[dev]); | 1070 | dma[dev], dma2[dev]); |
1172 | if (err < 0) { | 1071 | if (err < 0) { |
1173 | printk(KERN_ERR "sscape: No AD1845 device at 0x%lx, IRQ %d\n", | 1072 | snd_printk(KERN_ERR |
1174 | wss_port[dev], irq[dev]); | 1073 | "sscape: No AD1845 device at 0x%lx, IRQ %d\n", |
1074 | wss_port[dev], irq[dev]); | ||
1175 | goto _release_dma; | 1075 | goto _release_dma; |
1176 | } | 1076 | } |
1077 | strcpy(card->driver, "SoundScape"); | ||
1078 | strcpy(card->shortname, name); | ||
1079 | snprintf(card->longname, sizeof(card->longname), | ||
1080 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
1081 | name, sscape->chip->port, sscape->chip->irq, | ||
1082 | sscape->chip->dma1, sscape->chip->dma2); | ||
1083 | |||
1177 | #define MIDI_DEVNUM 0 | 1084 | #define MIDI_DEVNUM 0 |
1178 | if (sscape->type != SSCAPE_VIVO) { | 1085 | if (sscape->type != SSCAPE_VIVO) { |
1179 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]); | 1086 | err = sscape_upload_bootblock(card); |
1180 | if (err < 0) { | 1087 | if (err >= 0) |
1181 | printk(KERN_ERR "sscape: Failed to create " | 1088 | err = sscape_upload_microcode(card, err); |
1182 | "MPU-401 device at 0x%lx\n", | ||
1183 | port[dev]); | ||
1184 | goto _release_dma; | ||
1185 | } | ||
1186 | 1089 | ||
1187 | /* | 1090 | if (err == 0) { |
1188 | * Enable the master IRQ ... | 1091 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], |
1189 | */ | 1092 | mpu_irq[dev]); |
1190 | sscape_write(sscape, GA_INTENA_REG, 0x80); | 1093 | if (err < 0) { |
1094 | snd_printk(KERN_ERR "sscape: Failed to create " | ||
1095 | "MPU-401 device at 0x%lx\n", | ||
1096 | port[dev]); | ||
1097 | goto _release_dma; | ||
1098 | } | ||
1191 | 1099 | ||
1192 | /* | 1100 | /* |
1193 | * Initialize mixer | 1101 | * Initialize mixer |
1194 | */ | 1102 | */ |
1195 | sscape->midi_vol = 0; | 1103 | spin_lock_irqsave(&sscape->lock, flags); |
1196 | host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100); | 1104 | sscape->midi_vol = 0; |
1197 | host_write_ctrl_unsafe(sscape->io_base, 0, 100); | 1105 | host_write_ctrl_unsafe(sscape->io_base, |
1198 | host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100); | 1106 | CMD_SET_MIDI_VOL, 100); |
1107 | host_write_ctrl_unsafe(sscape->io_base, | ||
1108 | sscape->midi_vol, 100); | ||
1109 | host_write_ctrl_unsafe(sscape->io_base, | ||
1110 | CMD_XXX_MIDI_VOL, 100); | ||
1111 | host_write_ctrl_unsafe(sscape->io_base, | ||
1112 | sscape->midi_vol, 100); | ||
1113 | host_write_ctrl_unsafe(sscape->io_base, | ||
1114 | CMD_SET_EXTMIDI, 100); | ||
1115 | host_write_ctrl_unsafe(sscape->io_base, | ||
1116 | 0, 100); | ||
1117 | host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100); | ||
1118 | |||
1119 | set_midi_mode_unsafe(sscape->io_base); | ||
1120 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
1121 | } | ||
1199 | } | 1122 | } |
1200 | 1123 | ||
1201 | /* | 1124 | /* |
@@ -1231,7 +1154,8 @@ static int __devinit snd_sscape_match(struct device *pdev, unsigned int i) | |||
1231 | mpu_irq[i] == SNDRV_AUTO_IRQ || | 1154 | mpu_irq[i] == SNDRV_AUTO_IRQ || |
1232 | dma[i] == SNDRV_AUTO_DMA) { | 1155 | dma[i] == SNDRV_AUTO_DMA) { |
1233 | printk(KERN_INFO | 1156 | printk(KERN_INFO |
1234 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | 1157 | "sscape: insufficient parameters, " |
1158 | "need IO, IRQ, MPU-IRQ and DMA\n"); | ||
1235 | return 0; | 1159 | return 0; |
1236 | } | 1160 | } |
1237 | 1161 | ||
@@ -1253,13 +1177,15 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) | |||
1253 | sscape->type = SSCAPE; | 1177 | sscape->type = SSCAPE; |
1254 | 1178 | ||
1255 | dma[dev] &= 0x03; | 1179 | dma[dev] &= 0x03; |
1180 | snd_card_set_dev(card, pdev); | ||
1181 | |||
1256 | ret = create_sscape(dev, card); | 1182 | ret = create_sscape(dev, card); |
1257 | if (ret < 0) | 1183 | if (ret < 0) |
1258 | goto _release_card; | 1184 | goto _release_card; |
1259 | 1185 | ||
1260 | snd_card_set_dev(card, pdev); | 1186 | ret = snd_card_register(card); |
1261 | if ((ret = snd_card_register(card)) < 0) { | 1187 | if (ret < 0) { |
1262 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1188 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1263 | goto _release_card; | 1189 | goto _release_card; |
1264 | } | 1190 | } |
1265 | dev_set_drvdata(pdev, card); | 1191 | dev_set_drvdata(pdev, card); |
@@ -1311,36 +1237,20 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1311 | * Allow this function to fail *quietly* if all the ISA PnP | 1237 | * Allow this function to fail *quietly* if all the ISA PnP |
1312 | * devices were configured using module parameters instead. | 1238 | * devices were configured using module parameters instead. |
1313 | */ | 1239 | */ |
1314 | if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) | 1240 | idx = get_next_autoindex(idx); |
1241 | if (idx >= SNDRV_CARDS) | ||
1315 | return -ENOSPC; | 1242 | return -ENOSPC; |
1316 | 1243 | ||
1317 | /* | 1244 | /* |
1318 | * We have found a candidate ISA PnP card. Now we | ||
1319 | * have to check that it has the devices that we | ||
1320 | * expect it to have. | ||
1321 | * | ||
1322 | * We will NOT try and autoconfigure all of the resources | ||
1323 | * needed and then activate the card as we are assuming that | ||
1324 | * has already been done at boot-time using /proc/isapnp. | ||
1325 | * We shall simply try to give each active card the resources | ||
1326 | * that it wants. This is a sensible strategy for a modular | ||
1327 | * system where unused modules are unloaded regularly. | ||
1328 | * | ||
1329 | * This strategy is utterly useless if we compile the driver | ||
1330 | * into the kernel, of course. | ||
1331 | */ | ||
1332 | // printk(KERN_INFO "sscape: %s\n", card->name); | ||
1333 | |||
1334 | /* | ||
1335 | * Check that we still have room for another sound card ... | 1245 | * Check that we still have room for another sound card ... |
1336 | */ | 1246 | */ |
1337 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); | 1247 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); |
1338 | if (! dev) | 1248 | if (!dev) |
1339 | return -ENODEV; | 1249 | return -ENODEV; |
1340 | 1250 | ||
1341 | if (!pnp_is_active(dev)) { | 1251 | if (!pnp_is_active(dev)) { |
1342 | if (pnp_activate_dev(dev) < 0) { | 1252 | if (pnp_activate_dev(dev) < 0) { |
1343 | printk(KERN_INFO "sscape: device is inactive\n"); | 1253 | snd_printk(KERN_INFO "sscape: device is inactive\n"); |
1344 | return -EBUSY; | 1254 | return -EBUSY; |
1345 | } | 1255 | } |
1346 | } | 1256 | } |
@@ -1378,14 +1288,15 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1378 | wss_port[idx] = pnp_port_start(dev, 1); | 1288 | wss_port[idx] = pnp_port_start(dev, 1); |
1379 | dma2[idx] = pnp_dma(dev, 1); | 1289 | dma2[idx] = pnp_dma(dev, 1); |
1380 | } | 1290 | } |
1291 | snd_card_set_dev(card, &pcard->card->dev); | ||
1381 | 1292 | ||
1382 | ret = create_sscape(idx, card); | 1293 | ret = create_sscape(idx, card); |
1383 | if (ret < 0) | 1294 | if (ret < 0) |
1384 | goto _release_card; | 1295 | goto _release_card; |
1385 | 1296 | ||
1386 | snd_card_set_dev(card, &pcard->card->dev); | 1297 | ret = snd_card_register(card); |
1387 | if ((ret = snd_card_register(card)) < 0) { | 1298 | if (ret < 0) { |
1388 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1299 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1389 | goto _release_card; | 1300 | goto _release_card; |
1390 | } | 1301 | } |
1391 | 1302 | ||