4 * Detection routine for the Gravis Ultrasound.
7 * Copyright (C) by Hannu Savolainen 1993-1997
9 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
10 * Version 2 (June 1991). See the "COPYING" file distributed with this software
13 #include <linux/config.h>
14 #include <linux/module.h>
16 #include "sound_config.h"
17 #include "soundmodule.h"
19 #if defined(CONFIG_GUSHW) || defined(MODULE)
23 void gusintr(int irq
, void *dev_id
, struct pt_regs
*dummy
);
25 int gus_base
= 0, gus_irq
= 0, gus_dma
= 0;
26 extern int gus_wave_volume
;
27 extern int gus_pcm_volume
;
28 extern int have_gus_max
;
31 void attach_gus_card(struct address_info
*hw_config
)
33 snd_set_irq_handler(hw_config
->irq
, gusintr
, "Gravis Ultrasound", hw_config
->osp
);
35 gus_wave_init(hw_config
);
37 request_region(hw_config
->io_base
, 16, "GUS");
38 request_region(hw_config
->io_base
+ 0x100, 12, "GUS"); /* 0x10c-> is MAX */
40 if (sound_alloc_dma(hw_config
->dma
, "GUS"))
41 printk("gus_card.c: Can't allocate DMA channel\n");
42 if (hw_config
->dma2
!= -1 && hw_config
->dma2
!= hw_config
->dma
)
43 if (sound_alloc_dma(hw_config
->dma2
, "GUS(2)"))
44 printk("gus_card.c: Can't allocate DMA channel 2\n");
45 #if defined(CONFIG_MIDI)
46 gus_midi_init(hw_config
);
50 int probe_gus(struct address_info
*hw_config
)
55 if (hw_config
->card_subtype
== 1)
60 if (hw_config
->card_subtype
== 0) /* GUS/MAX/ACE */
61 if (irq
!= 3 && irq
!= 5 && irq
!= 7 && irq
!= 9 &&
62 irq
!= 11 && irq
!= 12 && irq
!= 15)
64 printk(KERN_ERR
"GUS: Unsupported IRQ %d\n", irq
);
67 if (check_region(hw_config
->io_base
, 16))
68 printk(KERN_ERR
"GUS: I/O range conflict (1)\n");
69 else if (check_region(hw_config
->io_base
+ 0x100, 16))
70 printk(KERN_ERR
"GUS: I/O range conflict (2)\n");
71 else if (gus_wave_detect(hw_config
->io_base
))
74 #ifndef EXCLUDE_GUS_IODETECT
77 * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
80 for (io_addr
= 0x210; io_addr
<= 0x260; io_addr
+= 0x10)
81 if (io_addr
!= hw_config
->io_base
) /*
84 if (!check_region(io_addr
, 16))
85 if (!check_region(io_addr
+ 0x100, 16))
86 if (gus_wave_detect(io_addr
))
88 hw_config
->io_base
= io_addr
;
96 void unload_gus(struct address_info
*hw_config
)
98 DDB(printk("unload_gus(%x)\n", hw_config
->io_base
));
100 gus_wave_unload(hw_config
);
102 release_region(hw_config
->io_base
, 16);
103 release_region(hw_config
->io_base
+ 0x100, 12); /* 0x10c-> is MAX */
104 snd_release_irq(hw_config
->irq
);
106 sound_free_dma(hw_config
->dma
);
108 if (hw_config
->dma2
!= -1 && hw_config
->dma2
!= hw_config
->dma
)
109 sound_free_dma(hw_config
->dma2
);
112 void gusintr(int irq
, void *dev_id
, struct pt_regs
*dummy
)
115 extern int gus_timer_enabled
;
121 adintr(irq
, NULL
, NULL
);
126 if (!(src
= inb(u_IrqStatus
)))
129 if (src
& DMA_TC_IRQ
)
133 if (src
& (MIDI_TX_IRQ
| MIDI_RX_IRQ
))
135 #if defined(CONFIG_MIDI)
136 gus_midi_interrupt(0);
139 if (src
& (GF1_TIMER1_IRQ
| GF1_TIMER2_IRQ
))
141 #if defined(CONFIG_SEQUENCER) || defined(CONFIG_SEQUENCER_MODULE)
142 if (gus_timer_enabled
)
143 sound_timer_interrupt();
144 gus_write8(0x45, 0); /* Ack IRQ */
145 gus_timer_command(4, 0x80); /* Reset IRQ flags */
147 gus_write8(0x45, 0); /* Stop timers */
150 if (src
& (WAVETABLE_IRQ
| ENVELOPE_IRQ
))
158 * Some extra code for the 16 bit sampling option
163 int probe_gus_db16(struct address_info
*hw_config
)
165 return ad1848_detect(hw_config
->io_base
, NULL
, hw_config
->osp
);
168 void attach_gus_db16(struct address_info
*hw_config
)
170 #if defined(CONFIG_GUSHW) || defined(MODULE)
171 gus_pcm_volume
= 100;
172 gus_wave_volume
= 90;
175 hw_config
->slots
[3] = ad1848_init("GUS 16 bit sampling", hw_config
->io_base
,
182 void unload_gus_db16(struct address_info
*hw_config
)
185 ad1848_unload(hw_config
->io_base
,
189 sound_unload_audiodev(hw_config
->slots
[3]);
195 static struct address_info config
;
198 * Note DMA2 of -1 has the right meaning in the GUS driver as well
205 int dma16
= -1; /* Set this for modules that need it */
206 int type
= 0; /* 1 for PnP */
208 static int db16
= 0; /* Has a Gus16 AD1848 on it */
210 MODULE_PARM(io
, "i");
211 MODULE_PARM(irq
, "i");
212 MODULE_PARM(dma
, "i");
213 MODULE_PARM(dma16
, "i");
214 MODULE_PARM(type
, "i");
215 MODULE_PARM(gus16
, "i");
216 MODULE_PARM(db16
, "i");
218 int init_module(void)
220 printk(KERN_INFO
"Gravis Ultrasound audio driver Copyright (C) by Hannu Savolainen 1993-1996\n");
222 if (io
== -1 || dma
== -1 || irq
== -1)
224 printk(KERN_ERR
"I/O, IRQ, and DMA are mandatory\n");
231 config
.card_subtype
= type
;
233 #if defined(CONFIG_GUS16)
234 if (probe_gus_db16(&config
) && gus16
)
236 attach_gus_db16(&config
);
240 if (probe_gus(&config
) == 0)
242 attach_gus_card(&config
);
247 void cleanup_module(void)
249 #if defined(CONFIG_GUS16)
251 unload_gus_db16(&config
);