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