4 * Detection routine for the Gravis Ultrasound.
6 * Copyright by Hannu Savolainen 1993
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met: 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 2.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <i386/isa/sound/sound_config.h>
32 #if defined(CONFIG_GUS)
34 #include <i386/isa/sound/gus_hw.h>
35 #include <i386/isa/sound/iwdefs.h>
37 int gus_base, gus_irq, gus_dma;
38 extern int gus_wave_volume;
39 extern int gus_pcm_volume;
40 extern int have_gus_max;
41 extern int gus_timer_enabled;
43 static sound_os_info *gus_osp;
46 int IwaveOpen(char voices, char mode, struct address_info * hw);
50 attach_gus_card(struct address_info * hw_config)
54 gus_osp = hw_config->osp;
56 snd_set_irq_handler(hw_config->irq, gusintr, hw_config->osp);
58 if (gus_wave_detect(hw_config->io_base)) {
59 /* Try first the default */
60 gus_wave_init(hw_config);
64 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
66 printf("gus_card.c: Can't allocate DMA channel2\n");
72 #ifndef EXCLUDE_GUS_IODETECT
75 * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
78 for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
79 if ( (io_addr != hw_config->io_base) /* Already tested */
80 && (gus_wave_detect(io_addr)) ) {
81 hw_config->io_base = io_addr;
83 printf(" WARNING! GUS found at %x, config was %x ",
84 io_addr, hw_config->io_base);
85 gus_wave_init(hw_config);
87 if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
89 printf("gus_card.c: Can't allocate DMA channel2\n");
99 probe_gus(struct address_info * hw_config)
103 gus_osp = hw_config->osp;
105 IwaveOpen((char) 32, (char) GUS_MODE, hw_config);
107 if (gus_wave_detect(hw_config->io_base))
109 printf("oops I didnt find gus \n");
110 #undef EXCLUDE_GUS_IODETECT
111 #ifndef EXCLUDE_GUS_IODETECT
114 * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
116 for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
117 if ( (io_addr != hw_config->io_base) /* Already tested */
118 && (gus_wave_detect(io_addr)) ) {
119 hw_config->io_base = io_addr;
134 ad1848_interrupt(irq);
138 if (!(src = inb(u_IrqStatus)))
141 if (src & DMA_TC_IRQ)
144 if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
145 gus_midi_interrupt(0);
147 if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ)) {
148 #ifdef CONFIG_SEQUENCER
149 if (gus_timer_enabled)
150 sound_timer_interrupt();
151 gus_write8(0x45, 0); /* Ack IRQ */
152 gus_timer_command(4, 0x80); /* Reset IRQ flags */
154 gus_write8(0x45, 0); /* Stop timers */
157 if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
165 * Some extra code for the 16 bit sampling option
167 #if defined(CONFIG_GUS16)
170 probe_gus_db16(struct address_info * hw_config)
172 return ad1848_detect(hw_config->io_base, NULL, hw_config->osp);
176 attach_gus_db16(struct address_info * hw_config)
178 gus_pcm_volume = 100;
179 gus_wave_volume = 90;
181 ad1848_init("GUS 16 bit sampling", hw_config->io_base,