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, 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;
115
116 gus_osp = hw_config->osp;
117
118 if (!check_region (hw_config->io_base, 16))
119 if (!check_region (hw_config->io_base + 0x100, 16))
120 if (gus_wave_detect (hw_config->io_base))
121 return 1;
122
123 #ifndef EXCLUDE_GUS_IODETECT
124
125
126
127
128
129 for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
130 if (io_addr != hw_config->io_base)
131
132
133 if (!check_region (io_addr, 16))
134 if (!check_region (io_addr + 0x100, 16))
135 if (gus_wave_detect (io_addr))
136 {
137 hw_config->io_base = io_addr;
138 return 1;
139 }
140
141 #endif
142
143 return 0;
144 }
145
146 void
147 unload_gus (struct address_info *hw_config)
148 {
149 DDB (printk ("unload_gus(%x)\n", hw_config->io_base));
150
151 gus_wave_unload ();
152
153 release_region (hw_config->io_base, 16);
154 release_region (hw_config->io_base + 0x100, 12);
155 snd_release_irq (hw_config->irq);
156
157 sound_free_dma (hw_config->dma);
158
159 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
160 sound_free_dma (hw_config->dma2);
161 }
162
163 void
164 gusintr (int irq, struct pt_regs *dummy)
165 {
166 unsigned char src;
167 extern int gus_timer_enabled;
168
169 sti ();
170
171 #ifdef CONFIG_GUSMAX
172 if (have_gus_max)
173 ad1848_interrupt (irq, NULL);
174 #endif
175
176 while (1)
177 {
178 if (!(src = inb (u_IrqStatus)))
179 return;
180
181 if (src & DMA_TC_IRQ)
182 {
183 guswave_dma_irq ();
184 }
185
186 if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
187 {
188 #ifdef CONFIG_MIDI
189 gus_midi_interrupt (0);
190 #endif
191 }
192
193 if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
194 {
195 #ifdef CONFIG_SEQUENCER
196 if (gus_timer_enabled)
197 {
198 sound_timer_interrupt ();
199 }
200
201 gus_write8 (0x45, 0);
202 gus_timer_command (4, 0x80);
203
204 #else
205 gus_write8 (0x45, 0);
206 #endif
207 }
208
209 if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
210 {
211 gus_voice_irq ();
212 }
213 }
214 }
215
216 #endif
217
218
219
220
221 #if defined(CONFIG_GUS16)
222
223 int
224 probe_gus_db16 (struct address_info *hw_config)
225 {
226 return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
227 }
228
229 long
230 attach_gus_db16 (long mem_start, struct address_info *hw_config)
231 {
232 #ifdef CONFIG_GUS
233 gus_pcm_volume = 100;
234 gus_wave_volume = 90;
235 #endif
236
237 ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
238 hw_config->irq,
239 hw_config->dma,
240 hw_config->dma, 0,
241 hw_config->osp);
242 return mem_start;
243 }
244
245 void
246 unload_gus_db16 (struct address_info *hw_config)
247 {
248
249 ad1848_unload (hw_config->io_base,
250 hw_config->irq,
251 hw_config->dma,
252 hw_config->dma, 0);
253 }
254 #endif