23 #include <linux/time.h>
36 static void snd_gf1_default_interrupt_handler_midi_out(
struct snd_gus_card * gus)
38 snd_gf1_uart_cmd(gus, gus->
gf1.uart_cmd &= ~0x20);
41 static void snd_gf1_default_interrupt_handler_midi_in(
struct snd_gus_card * gus)
43 snd_gf1_uart_cmd(gus, gus->
gf1.uart_cmd &= ~0x80);
46 static void snd_gf1_default_interrupt_handler_timer1(
struct snd_gus_card * gus)
51 static void snd_gf1_default_interrupt_handler_timer2(
struct snd_gus_card * gus)
62 static void snd_gf1_default_interrupt_handler_dma_write(
struct snd_gus_card * gus)
67 static void snd_gf1_default_interrupt_handler_dma_read(
struct snd_gus_card * gus)
75 gus->
gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out;
77 gus->
gf1.interrupt_handler_midi_in = snd_gf1_default_interrupt_handler_midi_in;
79 gus->
gf1.interrupt_handler_timer1 = snd_gf1_default_interrupt_handler_timer1;
81 gus->
gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2;
85 voice = &gus->
gf1.voices[what & 0xffff];
87 voice->
handler_volume = snd_gf1_default_interrupt_handler_wave_and_volume;
92 gus->
gf1.interrupt_handler_dma_write = snd_gf1_default_interrupt_handler_dma_write;
94 gus->
gf1.interrupt_handler_dma_read = snd_gf1_default_interrupt_handler_dma_read;
101 static void snd_gf1_clear_regs(
struct snd_gus_card * gus)
110 spin_unlock_irqrestore(&gus->
reg_lock, flags);
113 static void snd_gf1_look_regs(
struct snd_gus_card * gus)
121 snd_gf1_read8(gus, 0x0f);
122 spin_unlock_irqrestore(&gus->
reg_lock, flags);
134 snd_gf1_select_voice(gus, voice);
140 spin_unlock_irqrestore(&gus->
reg_lock, flags);
148 snd_gf1_select_voice(gus, voice);
154 if (gus->
gf1.enh_mode)
156 spin_unlock_irqrestore(&gus->
reg_lock, flags);
163 static void snd_gf1_clear_voices(
struct snd_gus_card * gus,
unsigned short v_min,
164 unsigned short v_max)
168 unsigned short i, w_16;
170 daddr = gus->
gf1.default_voice_address << 4;
171 for (i = v_min; i <= v_max; i++) {
173 if (gus->
gf1.syn_voices)
174 gus->
gf1.syn_voices[
i].flags = ~VFLG_DYNAMIC;
177 snd_gf1_select_voice(gus, i);
180 if (gus->
gf1.enh_mode)
192 if (gus->
gf1.enh_mode) {
197 spin_unlock_irqrestore(&gus->
reg_lock, flags);
209 unsigned short ramp_end;
212 for (i = v_min, ramp_ok = 0; i <= v_max; i++) {
214 snd_gf1_select_voice(gus, i);
215 ramp_end = snd_gf1_read16(gus, 9) >> 8;
222 if (gus->
gf1.enh_mode) {
227 spin_unlock_irqrestore(&gus->
reg_lock, flags);
231 snd_gf1_clear_voices(gus, v_min, v_max);
234 static void snd_gf1_alloc_voice_use(
struct snd_gus_card * gus,
241 gus->
gf1.pcm_alloc_voices++;
265 if (gus->
gf1.pcm_alloc_voices >= gus->
gf1.pcm_channels) {
270 for (idx = 0; idx < 32; idx++) {
271 pvoice = &gus->
gf1.voices[
idx];
273 snd_gf1_alloc_voice_use(gus, pvoice, type, client, port);
278 for (idx = 0; idx < 32; idx++) {
279 pvoice = &gus->
gf1.voices[
idx];
281 snd_gf1_clear_voices(gus, pvoice->
number, pvoice->
number);
282 snd_gf1_alloc_voice_use(gus, pvoice, type, client, port);
297 if (voice ==
NULL || !voice->
use)
300 snd_gf1_clear_voices(gus, voice->
number, voice->
number);
307 gus->
gf1.pcm_alloc_voices--;
308 voice->
use = voice->
pcm = 0;
331 for (i = 0; i < 32; i++) {
332 gus->
gf1.voices[
i].number =
i;
336 snd_gf1_uart_cmd(gus, 0x03);
338 if (gus->
gf1.enh_mode) {
342 snd_gf1_clear_regs(gus);
345 gus->
gf1.default_voice_address = gus->
gf1.memory > 0 ? 0 : 512 - 8;
347 if (gus->
gf1.enh_mode && gus->
gf1.memory) {
349 gus->
gf1.default_voice_address += 1024;
356 if (gus->
gf1.memory > 0)
357 for (i = 0; i < 4; i++)
359 snd_gf1_clear_regs(gus);
360 snd_gf1_clear_voices(gus, 0, 31);
361 snd_gf1_look_regs(gus);
366 if (gus->
gf1.enh_mode) {
373 outb(gus->
gf1.active_voice = 0,
GUSP(gus, GF1PAGE));
375 spin_unlock_irqrestore(&gus->
reg_lock, flags);
378 snd_gf1_look_regs(gus);
381 #ifdef CONFIG_SND_DEBUG
382 snd_gus_irq_profile_init(gus);
387 if (gus->chip.playback_fifo_size > 0)
389 if (gus->chip.record_fifo_size > 0)