Lines Matching refs:gus
12 extern int snd_gf1_synth_init(struct snd_gus_card * gus);
13 extern void snd_gf1_synth_done(struct snd_gus_card * gus);
19 static void snd_gf1_default_interrupt_handler_midi_out(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_midi_out() argument
21 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20); in snd_gf1_default_interrupt_handler_midi_out()
24 static void snd_gf1_default_interrupt_handler_midi_in(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_midi_in() argument
26 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80); in snd_gf1_default_interrupt_handler_midi_in()
29 static void snd_gf1_default_interrupt_handler_timer1(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_timer1() argument
31 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4); in snd_gf1_default_interrupt_handler_timer1()
34 static void snd_gf1_default_interrupt_handler_timer2(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_timer2() argument
36 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8); in snd_gf1_default_interrupt_handler_timer2()
39 static void snd_gf1_default_interrupt_handler_wave_and_volume(struct snd_gus_card * gus, struct snd… in snd_gf1_default_interrupt_handler_wave_and_volume() argument
41 snd_gf1_i_ctrl_stop(gus, 0x00); in snd_gf1_default_interrupt_handler_wave_and_volume()
42 snd_gf1_i_ctrl_stop(gus, 0x0d); in snd_gf1_default_interrupt_handler_wave_and_volume()
45 static void snd_gf1_default_interrupt_handler_dma_write(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_dma_write() argument
47 snd_gf1_i_write8(gus, 0x41, 0x00); in snd_gf1_default_interrupt_handler_dma_write()
50 static void snd_gf1_default_interrupt_handler_dma_read(struct snd_gus_card * gus) in snd_gf1_default_interrupt_handler_dma_read() argument
52 snd_gf1_i_write8(gus, 0x49, 0x00); in snd_gf1_default_interrupt_handler_dma_read()
55 void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what) in snd_gf1_set_default_handlers() argument
58 gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out; in snd_gf1_set_default_handlers()
60 gus->gf1.interrupt_handler_midi_in = snd_gf1_default_interrupt_handler_midi_in; in snd_gf1_set_default_handlers()
62 gus->gf1.interrupt_handler_timer1 = snd_gf1_default_interrupt_handler_timer1; in snd_gf1_set_default_handlers()
64 gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2; in snd_gf1_set_default_handlers()
68 voice = &gus->gf1.voices[what & 0xffff]; in snd_gf1_set_default_handlers()
75 gus->gf1.interrupt_handler_dma_write = snd_gf1_default_interrupt_handler_dma_write; in snd_gf1_set_default_handlers()
77 gus->gf1.interrupt_handler_dma_read = snd_gf1_default_interrupt_handler_dma_read; in snd_gf1_set_default_handlers()
84 static void snd_gf1_clear_regs(struct snd_gus_card * gus) in snd_gf1_clear_regs() argument
88 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_clear_regs()
89 inb(GUSP(gus, IRQSTAT)); in snd_gf1_clear_regs()
90 snd_gf1_write8(gus, 0x41, 0); /* DRAM DMA Control Register */ in snd_gf1_clear_regs()
91 snd_gf1_write8(gus, 0x45, 0); /* Timer Control */ in snd_gf1_clear_regs()
92 snd_gf1_write8(gus, 0x49, 0); /* Sampling Control Register */ in snd_gf1_clear_regs()
93 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_clear_regs()
96 static void snd_gf1_look_regs(struct snd_gus_card * gus) in snd_gf1_look_regs() argument
100 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_look_regs()
101 snd_gf1_look8(gus, 0x41); /* DRAM DMA Control Register */ in snd_gf1_look_regs()
102 snd_gf1_look8(gus, 0x49); /* Sampling Control Register */ in snd_gf1_look_regs()
103 inb(GUSP(gus, IRQSTAT)); in snd_gf1_look_regs()
104 snd_gf1_read8(gus, 0x0f); /* IRQ Source Register */ in snd_gf1_look_regs()
105 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_look_regs()
112 void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice) in snd_gf1_smart_stop_voice() argument
116 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_smart_stop_voice()
117 snd_gf1_select_voice(gus, voice); in snd_gf1_smart_stop_voice()
119 …printk(KERN_DEBUG " -%i- smart stop voice - volume = 0x%x\n", voice, snd_gf1_i_read16(gus, SNDRV_G… in snd_gf1_smart_stop_voice()
121 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL); in snd_gf1_smart_stop_voice()
122 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); in snd_gf1_smart_stop_voice()
123 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_smart_stop_voice()
126 void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice) in snd_gf1_stop_voice() argument
130 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_stop_voice()
131 snd_gf1_select_voice(gus, voice); in snd_gf1_stop_voice()
133 …printk(KERN_DEBUG " -%i- stop voice - volume = 0x%x\n", voice, snd_gf1_i_read16(gus, SNDRV_GF1_VW_… in snd_gf1_stop_voice()
135 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL); in snd_gf1_stop_voice()
136 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); in snd_gf1_stop_voice()
137 if (gus->gf1.enh_mode) in snd_gf1_stop_voice()
138 snd_gf1_write8(gus, SNDRV_GF1_VB_ACCUMULATOR, 0); in snd_gf1_stop_voice()
139 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_stop_voice()
141 snd_gf1_lfo_shutdown(gus, voice, ULTRA_LFO_VIBRATO); in snd_gf1_stop_voice()
142 snd_gf1_lfo_shutdown(gus, voice, ULTRA_LFO_TREMOLO); in snd_gf1_stop_voice()
146 static void snd_gf1_clear_voices(struct snd_gus_card * gus, unsigned short v_min, in snd_gf1_clear_voices() argument
153 daddr = gus->gf1.default_voice_address << 4; in snd_gf1_clear_voices()
156 if (gus->gf1.syn_voices) in snd_gf1_clear_voices()
157 gus->gf1.syn_voices[i].flags = ~VFLG_DYNAMIC; in snd_gf1_clear_voices()
159 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_clear_voices()
160 snd_gf1_select_voice(gus, i); in snd_gf1_clear_voices()
161 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL); /* Voice Control Register = voice stop */ in snd_gf1_clear_voices()
162 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); /* Volume Ramp Control Register = ramp off */ in snd_gf1_clear_voices()
163 if (gus->gf1.enh_mode) in snd_gf1_clear_voices()
164 snd_gf1_write8(gus, SNDRV_GF1_VB_MODE, gus->gf1.memory ? 0x02 : 0x82); /* Deactivate voice */ in snd_gf1_clear_voices()
165 w_16 = snd_gf1_read8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL) & 0x04; in snd_gf1_clear_voices()
166 snd_gf1_write16(gus, SNDRV_GF1_VW_FREQUENCY, 0x400); in snd_gf1_clear_voices()
167 snd_gf1_write_addr(gus, SNDRV_GF1_VA_START, daddr, w_16); in snd_gf1_clear_voices()
168 snd_gf1_write_addr(gus, SNDRV_GF1_VA_END, daddr, w_16); in snd_gf1_clear_voices()
169 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, 0); in snd_gf1_clear_voices()
170 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, 0); in snd_gf1_clear_voices()
171 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_RATE, 0); in snd_gf1_clear_voices()
172 snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, 0); in snd_gf1_clear_voices()
173 snd_gf1_write_addr(gus, SNDRV_GF1_VA_CURRENT, daddr, w_16); in snd_gf1_clear_voices()
174 snd_gf1_write8(gus, SNDRV_GF1_VB_PAN, 7); in snd_gf1_clear_voices()
175 if (gus->gf1.enh_mode) { in snd_gf1_clear_voices()
176 snd_gf1_write8(gus, SNDRV_GF1_VB_ACCUMULATOR, 0); in snd_gf1_clear_voices()
177 snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME, 0); in snd_gf1_clear_voices()
178 snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME_FINAL, 0); in snd_gf1_clear_voices()
180 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_clear_voices()
182 snd_gf1_lfo_shutdown(gus, i, ULTRA_LFO_VIBRATO); in snd_gf1_clear_voices()
183 snd_gf1_lfo_shutdown(gus, i, ULTRA_LFO_TREMOLO); in snd_gf1_clear_voices()
188 void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max) in snd_gf1_stop_voices() argument
196 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_stop_voices()
197 snd_gf1_select_voice(gus, i); in snd_gf1_stop_voices()
198 ramp_end = snd_gf1_read16(gus, 9) >> 8; in snd_gf1_stop_voices()
201 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_RATE, 20); /* ramp rate */ in snd_gf1_stop_voices()
202 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, SNDRV_GF1_MIN_OFFSET); /* ramp start */ in snd_gf1_stop_voices()
203 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, ramp_end); /* ramp end */ in snd_gf1_stop_voices()
204 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, 0x40); /* ramp down */ in snd_gf1_stop_voices()
205 if (gus->gf1.enh_mode) { in snd_gf1_stop_voices()
206 snd_gf1_delay(gus); in snd_gf1_stop_voices()
207 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, 0x40); in snd_gf1_stop_voices()
210 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_stop_voices()
214 snd_gf1_clear_voices(gus, v_min, v_max); in snd_gf1_stop_voices()
217 static void snd_gf1_alloc_voice_use(struct snd_gus_card * gus, in snd_gf1_alloc_voice_use() argument
224 gus->gf1.pcm_alloc_voices++; in snd_gf1_alloc_voice_use()
240 struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port) in snd_gf1_alloc_voice() argument
246 spin_lock_irqsave(&gus->voice_alloc, flags); in snd_gf1_alloc_voice()
248 if (gus->gf1.pcm_alloc_voices >= gus->gf1.pcm_channels) { in snd_gf1_alloc_voice()
249 spin_unlock_irqrestore(&gus->voice_alloc, flags); in snd_gf1_alloc_voice()
254 pvoice = &gus->gf1.voices[idx]; in snd_gf1_alloc_voice()
256 snd_gf1_alloc_voice_use(gus, pvoice, type, client, port); in snd_gf1_alloc_voice()
257 spin_unlock_irqrestore(&gus->voice_alloc, flags); in snd_gf1_alloc_voice()
262 pvoice = &gus->gf1.voices[idx]; in snd_gf1_alloc_voice()
264 snd_gf1_clear_voices(gus, pvoice->number, pvoice->number); in snd_gf1_alloc_voice()
265 snd_gf1_alloc_voice_use(gus, pvoice, type, client, port); in snd_gf1_alloc_voice()
266 spin_unlock_irqrestore(&gus->voice_alloc, flags); in snd_gf1_alloc_voice()
270 spin_unlock_irqrestore(&gus->voice_alloc, flags); in snd_gf1_alloc_voice()
274 void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice) in snd_gf1_free_voice() argument
281 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_VOICE | voice->number); in snd_gf1_free_voice()
282 snd_gf1_clear_voices(gus, voice->number, voice->number); in snd_gf1_free_voice()
283 spin_lock_irqsave(&gus->voice_alloc, flags); in snd_gf1_free_voice()
288 gus->gf1.pcm_alloc_voices--; in snd_gf1_free_voice()
291 spin_unlock_irqrestore(&gus->voice_alloc, flags); in snd_gf1_free_voice()
300 int snd_gf1_start(struct snd_gus_card * gus) in snd_gf1_start() argument
305 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ in snd_gf1_start()
307 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* disable IRQ & DAC */ in snd_gf1_start()
309 snd_gf1_i_write8(gus, SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL, gus->joystick_dac); in snd_gf1_start()
311 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_ALL); in snd_gf1_start()
313 gus->gf1.voices[i].number = i; in snd_gf1_start()
314 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_VOICE | i); in snd_gf1_start()
317 snd_gf1_uart_cmd(gus, 0x03); /* huh.. this cleanup took me some time... */ in snd_gf1_start()
319 if (gus->gf1.enh_mode) { /* enhanced mode !!!! */ in snd_gf1_start()
320 …snd_gf1_i_write8(gus, SNDRV_GF1_GB_GLOBAL_MODE, snd_gf1_i_look8(gus, SNDRV_GF1_GB_GLOBAL_MODE) | 0… in snd_gf1_start()
321 snd_gf1_i_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01); in snd_gf1_start()
323 snd_gf1_clear_regs(gus); in snd_gf1_start()
324 snd_gf1_select_active_voices(gus); in snd_gf1_start()
325 snd_gf1_delay(gus); in snd_gf1_start()
326 gus->gf1.default_voice_address = gus->gf1.memory > 0 ? 0 : 512 - 8; in snd_gf1_start()
328 if (gus->gf1.enh_mode && gus->gf1.memory) { in snd_gf1_start()
329 gus->gf1.hw_lfo = 1; in snd_gf1_start()
330 gus->gf1.default_voice_address += 1024; in snd_gf1_start()
332 gus->gf1.sw_lfo = 1; in snd_gf1_start()
335 snd_gf1_lfo_init(gus); in snd_gf1_start()
337 if (gus->gf1.memory > 0) in snd_gf1_start()
339 snd_gf1_poke(gus, gus->gf1.default_voice_address + i, 0); in snd_gf1_start()
340 snd_gf1_clear_regs(gus); in snd_gf1_start()
341 snd_gf1_clear_voices(gus, 0, 31); in snd_gf1_start()
342 snd_gf1_look_regs(gus); in snd_gf1_start()
344 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 7); /* Reset Register = IRQ enable, DAC enable */ in snd_gf1_start()
346 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 7); /* Reset Register = IRQ enable, DAC enable */ in snd_gf1_start()
347 if (gus->gf1.enh_mode) { /* enhanced mode !!!! */ in snd_gf1_start()
348 …snd_gf1_i_write8(gus, SNDRV_GF1_GB_GLOBAL_MODE, snd_gf1_i_look8(gus, SNDRV_GF1_GB_GLOBAL_MODE) | 0… in snd_gf1_start()
349 snd_gf1_i_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01); in snd_gf1_start()
351 while ((snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ) & 0xc0) != 0xc0); in snd_gf1_start()
353 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gf1_start()
354 outb(gus->gf1.active_voice = 0, GUSP(gus, GF1PAGE)); in snd_gf1_start()
355 outb(gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gf1_start()
356 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gf1_start()
358 snd_gf1_timers_init(gus); in snd_gf1_start()
359 snd_gf1_look_regs(gus); in snd_gf1_start()
360 snd_gf1_mem_init(gus); in snd_gf1_start()
361 snd_gf1_mem_proc_init(gus); in snd_gf1_start()
363 snd_gus_irq_profile_init(gus); in snd_gf1_start()
367 if (gus->pnp_flag) { in snd_gf1_start()
368 if (gus->chip.playback_fifo_size > 0) in snd_gf1_start()
369 …snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR, gus->chip.playback_fifo_block->ptr >> 8… in snd_gf1_start()
370 if (gus->chip.record_fifo_size > 0) in snd_gf1_start()
371 snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR, gus->chip.record_fifo_block->ptr >> 8); in snd_gf1_start()
372 snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_SIZE, gus->chip.interwave_fifo_reg); in snd_gf1_start()
383 int snd_gf1_stop(struct snd_gus_card * gus) in snd_gf1_stop() argument
385 snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */ in snd_gf1_stop()
386 snd_gf1_stop_voices(gus, 0, 31); /* stop all voices */ in snd_gf1_stop()
387 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* disable IRQ & DAC */ in snd_gf1_stop()
388 snd_gf1_timers_done(gus); in snd_gf1_stop()
389 snd_gf1_mem_done(gus); in snd_gf1_stop()
391 snd_gf1_lfo_done(gus); in snd_gf1_stop()