This source file includes following definitions.
- attach_gus_card
- probe_gus
- unload_gus
- gusintr
- probe_gus_db16
- attach_gus_db16
- unload_gus_db16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include <linux/config.h>
30
31
32 #include "sound_config.h"
33
34 #if defined(CONFIG_GUS)
35
36 #include "gus_hw.h"
37
38 void gusintr (int irq, void *dev_id, struct pt_regs *dummy);
39
40 int gus_base, gus_irq, gus_dma;
41 extern int gus_wave_volume;
42 extern int gus_pcm_volume;
43 extern int have_gus_max;
44
45 int *gus_osp;
46
47 long
48 attach_gus_card (long mem_start, struct address_info *hw_config)
49 {
50 int io_addr;
51
52 gus_osp = hw_config->osp;
53 snd_set_irq_handler (hw_config->irq, gusintr, "Gravis Ultrasound", hw_config->osp);
54
55 if (gus_wave_detect (hw_config->io_base))
56
57
58 {
59 mem_start = gus_wave_init (mem_start, hw_config);
60
61 request_region (hw_config->io_base, 16, "GUS");
62 request_region (hw_config->io_base + 0x100, 12, "GUS");
63
64 if (sound_alloc_dma (hw_config->dma, "GUS"))
65 printk ("gus_card.c: Can't allocate DMA channel\n");
66 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
67 if (sound_alloc_dma (hw_config->dma2, "GUS(2)"))
68 printk ("gus_card.c: Can't allocate DMA channel2\n");
69 #ifdef CONFIG_MIDI
70 mem_start = gus_midi_init (mem_start);
71 #endif
72 return mem_start;
73 }
74
75 #ifndef EXCLUDE_GUS_IODETECT
76
77
78
79
80
81 for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
82 if (io_addr != hw_config->io_base)
83
84
85 if (gus_wave_detect (io_addr))
86 {
87 hw_config->io_base = io_addr;
88
89 printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
90 mem_start = gus_wave_init (mem_start, hw_config);
91 request_region (io_addr, 16, "GUS");
92 request_region (io_addr + 0x100, 12, "GUS");
93 if (sound_alloc_dma (hw_config->dma, "GUS"))
94 printk ("gus_card.c: Can't allocate DMA channel\n");
95 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
96 if (sound_alloc_dma (hw_config->dma2, "GUS"))
97 printk ("gus_card.c: Can't allocate DMA channel2\n");
98 #ifdef CONFIG_MIDI
99 mem_start = gus_midi_init (mem_start);
100 #endif
101 return mem_start;
102 }
103
104 #endif
105
106 return mem_start;
107
108
109 }
110
111 int
112 probe_gus (struct address_info *hw_config)
113 {
114 int io_addr, irq;
115
116 gus_osp = hw_config->osp;
117
118 irq = hw_config->irq;
119
120 if (hw_config->card_subtype == 0)
121 if (irq != 3 && irq != 5 && irq != 7 && irq != 9 &&
122 irq != 11 && irq != 12 && irq != 15)
123 {
124 printk ("GUS: Unsupported IRQ %d\n", irq);
125 return 0;
126 }
127
128 if (!check_region (hw_config->io_base, 16))
129 if (!check_region (hw_config->io_base + 0x100, 16))
130 if (gus_wave_detect (hw_config->io_base))
131 return 1;
132
133 #ifndef EXCLUDE_GUS_IODETECT
134
135
136
137
138
139 for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
140 if (io_addr != hw_config->io_base)
141
142
143 if (!check_region (io_addr, 16))
144 if (!check_region (io_addr + 0x100, 16))
145 if (gus_wave_detect (io_addr))
146 {
147 hw_config->io_base = io_addr;
148 return 1;
149 }
150
151 #endif
152
153 return 0;
154 }
155
156 void
157 unload_gus (struct address_info *hw_config)
158 {
159 DDB (printk ("unload_gus(%x)\n", hw_config->io_base));
160
161 gus_wave_unload ();
162
163 release_region (hw_config->io_base, 16);
164 release_region (hw_config->io_base + 0x100, 12);
165 snd_release_irq (hw_config->irq);
166
167 sound_free_dma (hw_config->dma);
168
169 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
170 sound_free_dma (hw_config->dma2);
171 }
172
173 void
174 gusintr (int irq, void *dev_id, struct pt_regs *dummy)
175 {
176 unsigned char src;
177 extern int gus_timer_enabled;
178
179 sti ();
180
181 #ifdef CONFIG_GUSMAX
182 if (have_gus_max)
183 ad1848_interrupt (irq, NULL, NULL);
184 #endif
185
186 while (1)
187 {
188 if (!(src = inb (u_IrqStatus)))
189 return;
190
191 if (src & DMA_TC_IRQ)
192 {
193 guswave_dma_irq ();
194 }
195
196 if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
197 {
198 #ifdef CONFIG_MIDI
199 gus_midi_interrupt (0);
200 #endif
201 }
202
203 if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
204 {
205 #ifdef CONFIG_SEQUENCER
206 if (gus_timer_enabled)
207 {
208 sound_timer_interrupt ();
209 }
210
211 gus_write8 (0x45, 0);
212 gus_timer_command (4, 0x80);
213
214 #else
215 gus_write8 (0x45, 0);
216 #endif
217 }
218
219 if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
220 {
221 gus_voice_irq ();
222 }
223 }
224 }
225
226 #endif
227
228
229
230
231 #if defined(CONFIG_GUS16)
232
233 int
234 probe_gus_db16 (struct address_info *hw_config)
235 {
236 return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
237 }
238
239 long
240 attach_gus_db16 (long mem_start, struct address_info *hw_config)
241 {
242 #ifdef CONFIG_GUS
243 gus_pcm_volume = 100;
244 gus_wave_volume = 90;
245 #endif
246
247 ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
248 hw_config->irq,
249 hw_config->dma,
250 hw_config->dma, 0,
251 hw_config->osp);
252 return mem_start;
253 }
254
255 void
256 unload_gus_db16 (struct address_info *hw_config)
257 {
258
259 ad1848_unload (hw_config->io_base,
260 hw_config->irq,
261 hw_config->dma,
262 hw_config->dma, 0);
263 }
264 #endif