root/drivers/sound/gus_card.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. attach_gus_card
  2. probe_gus
  3. gusintr
  4. probe_gus_db16
  5. attach_gus_db16

   1 /*
   2  * sound/gus_card.c
   3  *
   4  * Detection routine for the Gravis Ultrasound.
   5  *
   6  * Copyright by Hannu Savolainen 1993
   7  *
   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.
  15  *
  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
  26  * SUCH DAMAGE.
  27  *
  28  */
  29 
  30 #include "sound_config.h"
  31 
  32 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS)
  33 
  34 #include "gus_hw.h"
  35 
  36 void            gusintr (int);
  37 
  38 int             gus_base, gus_irq, gus_dma;
  39 extern int      gus_wave_volume;
  40 extern int      gus_pcm_volume;
  41 extern int      have_gus_max;
  42 
  43 long
  44 attach_gus_card (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46   int             io_addr;
  47 
  48   snd_set_irq_handler (hw_config->irq, gusintr);
  49 
  50   if (gus_wave_detect (hw_config->io_base))     /*
  51                                                  * Try first the default
  52                                                  */
  53     {
  54       mem_start = gus_wave_init (mem_start, hw_config->irq, hw_config->dma);
  55 #ifndef EXCLUDE_MIDI
  56       mem_start = gus_midi_init (mem_start);
  57 #endif
  58 #ifndef EXCLUDE_SEQUENCER
  59       sound_timer_init (hw_config->io_base + 8);
  60 #endif
  61       return mem_start;
  62     }
  63 
  64 #ifndef EXCLUDE_GUS_IODETECT
  65 
  66   /*
  67    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
  68    */
  69 
  70   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
  71     if (io_addr != hw_config->io_base)  /*
  72                                          * Already tested
  73                                          */
  74       if (gus_wave_detect (io_addr))
  75         {
  76           printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
  77           mem_start = gus_wave_init (mem_start, hw_config->irq, hw_config->dma);
  78 #ifndef EXCLUDE_MIDI
  79           mem_start = gus_midi_init (mem_start);
  80 #endif
  81 #ifndef EXCLUDE_SEQUENCER
  82           sound_timer_init (io_addr + 8);
  83 #endif
  84           return mem_start;
  85         }
  86 
  87 #endif
  88 
  89   return mem_start;             /*
  90                                  * Not detected
  91                                  */
  92 }
  93 
  94 int
  95 probe_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  96 {
  97   int             io_addr;
  98 
  99   if (gus_wave_detect (hw_config->io_base))
 100     return 1;
 101 
 102 #ifndef EXCLUDE_GUS_IODETECT
 103 
 104   /*
 105    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
 106    */
 107 
 108   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
 109     if (io_addr != hw_config->io_base)  /*
 110                                          * Already tested
 111                                          */
 112       if (gus_wave_detect (io_addr))
 113         return 1;
 114 
 115 #endif
 116 
 117   return 0;
 118 }
 119 
 120 void
 121 gusintr (int irq)
     /* [previous][next][first][last][top][bottom][index][help] */
 122 {
 123   unsigned char   src;
 124 
 125 #ifdef linux
 126   sti ();
 127 #endif
 128 
 129 #ifndef EXCLUDE_GUSMAX
 130   if (have_gus_max)
 131     ad1848_interrupt (irq);
 132 #endif
 133 
 134   while (1)
 135     {
 136       if (!(src = INB (u_IrqStatus)))
 137         return;
 138 
 139       if (src & DMA_TC_IRQ)
 140         {
 141           guswave_dma_irq ();
 142         }
 143 
 144       if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
 145         {
 146 #ifndef EXCLUDE_MIDI
 147           gus_midi_interrupt (0);
 148 #endif
 149         }
 150 
 151       if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
 152         {
 153 #ifndef EXCLUDE_SEQUENCER
 154           sound_timer_interrupt ();
 155 #else
 156           gus_write8 (0x45, 0); /* Stop timers */
 157 #endif
 158         }
 159 
 160       if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 161         {
 162           gus_voice_irq ();
 163         }
 164     }
 165 }
 166 
 167 #endif
 168 
 169 /*
 170  * Some extra code for the 16 bit sampling option
 171  */
 172 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS16)
 173 
 174 int
 175 probe_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 176 {
 177   return ad1848_detect (hw_config->io_base);
 178 }
 179 
 180 long
 181 attach_gus_db16 (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 182 {
 183   gus_pcm_volume = 100;
 184   gus_wave_volume = 90;
 185 
 186   ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
 187                hw_config->irq,
 188                hw_config->dma,
 189                hw_config->dma);
 190   return mem_start;
 191 }
 192 
 193 #endif

/* [previous][next][first][last][top][bottom][index][help] */