4 * Detection routine for the Pro Audio Spectrum cards.
7 #include <linux/config.h>
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include "sound_config.h"
15 static unsigned char dma_bits
[] = {
16 4, 1, 2, 3, 0, 5, 6, 7
19 static unsigned char irq_bits
[] = {
20 0, 0, 1, 2, 3, 4, 5, 6, 0, 1, 7, 8, 9, 0, 10, 11
23 static unsigned char sb_irq_bits
[] = {
24 0x00, 0x00, 0x08, 0x10, 0x00, 0x18, 0x00, 0x20,
25 0x00, 0x08, 0x28, 0x30, 0x38, 0, 0
28 static unsigned char sb_dma_bits
[] = {
29 0x00, 0x40, 0x80, 0xC0, 0, 0, 0, 0
33 * The Address Translation code is used to convert I/O register addresses to
34 * be relative to the given base -register
37 int translate_code
= 0;
38 static int pas_intr_mask
= 0;
39 static int pas_irq
= 0;
40 static int pas_sb_base
= 0;
41 #ifndef CONFIG_PAS_JOYSTICK
42 static int joystick
= 0;
44 static int joystick
= 1;
47 static int symphony
= 1;
49 static int symphony
= 0;
51 #ifdef BROKEN_BUS_CLOCK
52 static int broken_bus_clock
= 1;
54 static int broken_bus_clock
= 0;
57 static struct address_info cfg
;
58 static struct address_info cfg2
;
61 static char *pas_model_names
[] = {
65 "Pro AudioSpectrum 16",
66 "Pro AudioSpectrum 16D"
70 * pas_read() and pas_write() are equivalents of inb and outb
71 * These routines perform the I/O address translation required
72 * to support other than the default base address
75 extern void mix_write(unsigned char data
, int ioaddr
);
77 unsigned char pas_read(int ioaddr
)
79 return inb(ioaddr
+ translate_code
);
82 void pas_write(unsigned char data
, int ioaddr
)
84 outb((data
), ioaddr
+ translate_code
);
87 /******************* Begin of the Interrupt Handler ********************/
89 void pasintr(int irq
, void *dev_id
, struct pt_regs
*dummy
)
93 status
= pas_read(0x0B89);
94 pas_write(status
, 0x0B89); /* Clear interrupt */
98 pas_pcm_interrupt(status
, 1);
103 pas_midi_interrupt();
108 int pas_set_intr(int mask
)
113 pas_intr_mask
|= mask
;
115 pas_write(pas_intr_mask
, 0x0B8B);
119 int pas_remove_intr(int mask
)
124 pas_intr_mask
&= ~mask
;
125 pas_write(pas_intr_mask
, 0x0B8B);
130 /******************* End of the Interrupt handler **********************/
132 /******************* Begin of the Initialization Code ******************/
134 static int __init
config_pas_hw(struct address_info
*hw_config
)
137 unsigned int_ptrs
; /* scsi/sound interrupt pointers */
139 pas_irq
= hw_config
->irq
;
141 pas_write(0x00, 0x0B8B);
142 pas_write(0x36, 0x138B);
143 pas_write(0x36, 0x1388);
144 pas_write(0, 0x1388);
145 pas_write(0x74, 0x138B);
146 pas_write(0x74, 0x1389);
147 pas_write(0, 0x1389);
149 pas_write(0x80 | 0x40 | 0x20 | 1, 0x0B8A);
150 pas_write(0x80 | 0x20 | 0x10 | 0x08 | 0x01, 0xF8A);
151 pas_write(0x01 | 0x02 | 0x04 | 0x10 /*
160 if (pas_irq
< 0 || pas_irq
> 15)
162 printk(KERN_ERR
"PAS16: Invalid IRQ %d", pas_irq
);
168 int_ptrs
= pas_read(0xF38A);
169 int_ptrs
= (int_ptrs
& 0xf0) | irq_bits
[pas_irq
];
170 pas_write(int_ptrs
, 0xF38A);
171 if (!irq_bits
[pas_irq
])
173 printk(KERN_ERR
"PAS16: Invalid IRQ %d", pas_irq
);
179 if (request_irq(pas_irq
, pasintr
, 0, "PAS16",hw_config
) < 0) {
180 printk(KERN_ERR
"PAS16: Cannot allocate IRQ %d\n",pas_irq
);
187 if (hw_config
->dma
< 0 || hw_config
->dma
> 7)
189 printk(KERN_ERR
"PAS16: Invalid DMA selection %d", hw_config
->dma
);
195 pas_write(dma_bits
[hw_config
->dma
], 0xF389);
196 if (!dma_bits
[hw_config
->dma
])
198 printk(KERN_ERR
"PAS16: Invalid DMA selection %d", hw_config
->dma
);
204 if (sound_alloc_dma(hw_config
->dma
, "PAS16"))
206 printk(KERN_ERR
"pas2_card.c: Can't allocate DMA channel\n");
214 * This fixes the timing problems of the PAS due to the Symphony chipset
215 * as per Media Vision. Only define this if your PAS doesn't work correctly.
225 pas_write(0x01 | 0x10 | 0x20 | 0x04, 0x8388);
228 * pas_write(0x01, 0x8388);
230 pas_write(0x01 | 0x10 | 0x20, 0x8388);
232 pas_write(0x18, 0x838A); /* ??? */
233 pas_write(0x20 | 0x01, 0x0B8A); /* Mute off, filter = 17.897 kHz */
234 pas_write(8, 0xBF8A);
236 mix_write(0x80 | 5, 0x078B);
237 mix_write(5, 0x078B);
239 #if !defined(DISABLE_SB_EMULATION)
242 struct address_info
*sb_config
;
245 if (sb_config
->io_base
)
247 unsigned char irq_dma
;
250 * Turn on Sound Blaster compatibility
251 * bit 1 = SB emulation
252 * bit 0 = MPU401 emulation (CDPC only :-( )
255 pas_write(0x02, 0xF788);
258 * "Emulation address"
261 pas_write((sb_config
->io_base
>> 4) & 0x0f, 0xF789);
262 pas_sb_base
= sb_config
->io_base
;
264 if (!sb_dma_bits
[sb_config
->dma
])
265 printk(KERN_ERR
"PAS16 Warning: Invalid SB DMA %d\n\n", sb_config
->dma
);
267 if (!sb_irq_bits
[sb_config
->irq
])
268 printk(KERN_ERR
"PAS16 Warning: Invalid SB IRQ %d\n\n", sb_config
->irq
);
270 irq_dma
= sb_dma_bits
[sb_config
->dma
] |
271 sb_irq_bits
[sb_config
->irq
];
273 pas_write(irq_dma
, 0xFB8A);
276 pas_write(0x00, 0xF788);
279 pas_write(0x00, 0xF788);
283 printk(KERN_WARNING
"PAS16: Driver not enabled\n");
288 static int __init
detect_pas_hw(struct address_info
*hw_config
)
290 unsigned char board_id
, foo
;
293 * WARNING: Setting an option like W:1 or so that disables warm boot reset
294 * of the card will screw up this detect code something fierce. Adding code
295 * to handle this means possibly interfering with other cards on the bus if
296 * you have something on base port 0x388. SO be forewarned.
299 outb((0xBC), 0x9A01); /* Activate first board */
300 outb((hw_config
->io_base
>> 2), 0x9A01); /* Set base address */
301 translate_code
= hw_config
->io_base
- 0x388;
302 pas_write(1, 0xBF88); /* Select one wait states */
304 board_id
= pas_read(0x0B8B);
306 if (board_id
== 0xff)
310 * We probably have a PAS-series board, now check for a PAS16-series board
311 * by trying to change the board revision bits. PAS16-series hardware won't
312 * let you do this - the bits are read-only.
315 foo
= board_id
^ 0xe0;
317 pas_write(foo
, 0x0B8B);
318 foo
= pas_read(0x0B8B);
319 pas_write(board_id
, 0x0B8B);
324 pas_model
= pas_read(0xFF88);
329 static void __init
attach_pas_card(struct address_info
*hw_config
)
331 pas_irq
= hw_config
->irq
;
333 if (detect_pas_hw(hw_config
))
336 if ((pas_model
= pas_read(0xFF88)))
341 "%s rev %d", pas_model_names
[(int) pas_model
],
343 conf_printf(temp
, hw_config
);
345 if (config_pas_hw(hw_config
))
347 pas_pcm_init(hw_config
);
349 #if !defined(MODULE) && !defined(DISABLE_SB_EMULATION)
350 sb_dsp_disable_midi(pas_sb_base
); /* No MIDI capability */
359 static inline int __init
probe_pas(struct address_info
*hw_config
)
361 return detect_pas_hw(hw_config
);
364 static void __exit
unload_pas(struct address_info
*hw_config
)
366 extern int pas_audiodev
;
367 extern int pas2_mididev
;
369 if (hw_config
->dma
>0)
370 sound_free_dma(hw_config
->dma
);
371 if (hw_config
->irq
>0)
372 free_irq(hw_config
->irq
, hw_config
);
375 sound_unload_mixerdev(audio_devs
[pas_audiodev
]->mixer_dev
);
377 sound_unload_mididev(pas2_mididev
);
379 sound_unload_audiodev(pas_audiodev
);
382 static int __initdata io
= -1;
383 static int __initdata irq
= -1;
384 static int __initdata dma
= -1;
385 static int __initdata dma16
= -1; /* Set this for modules that need it */
387 static int __initdata sb_io
= 0;
388 static int __initdata sb_irq
= -1;
389 static int __initdata sb_dma
= -1;
390 static int __initdata sb_dma16
= -1;
393 MODULE_PARM(irq
,"i");
394 MODULE_PARM(dma
,"i");
395 MODULE_PARM(dma16
,"i");
397 MODULE_PARM(sb_io
,"i");
398 MODULE_PARM(sb_irq
,"i");
399 MODULE_PARM(sb_dma
,"i");
400 MODULE_PARM(sb_dma16
,"i");
402 MODULE_PARM(joystick
,"i");
403 MODULE_PARM(symphony
,"i");
404 MODULE_PARM(broken_bus_clock
,"i");
406 static int __init
init_pas2(void)
408 printk(KERN_INFO
"Pro Audio Spectrum driver Copyright (C) by Hannu Savolainen 1993-1996\n");
415 cfg2
.io_base
= sb_io
;
418 cfg2
.dma2
= sb_dma16
;
420 if (cfg
.io_base
== -1 || cfg
.dma
== -1 || cfg
.irq
== -1) {
421 printk(KERN_INFO
"I/O, IRQ, DMA and type are mandatory\n");
425 if (!probe_pas(&cfg
))
427 attach_pas_card(&cfg
);
432 static void __exit
cleanup_pas2(void)
437 module_init(init_pas2
);
438 module_exit(cleanup_pas2
);
441 static int __init
setup_pas2(char *str
)
443 /* io, irq, dma, dma2, sb_io, sb_irq, sb_dma, sb_dma2 */
446 str
= get_options(str
, ARRAY_SIZE(ints
), ints
);
461 __setup("pas2=", setup_pas2
);