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

   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 
  40 long
  41 attach_gus_card (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43   int             io_addr;
  44 
  45   snd_set_irq_handler (hw_config->irq, gusintr);
  46 
  47   if (gus_wave_detect (hw_config->io_base))     /* Try first the default */
  48     {
  49       mem_start = gus_wave_init (mem_start, hw_config->irq, hw_config->dma);
  50 #ifndef EXCLUDE_MIDI
  51       mem_start = gus_midi_init (mem_start);
  52 #endif
  53       return mem_start;
  54     }
  55 
  56 #ifndef EXCLUDE_GUS_IODETECT
  57 
  58   /*
  59    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
  60    */
  61 
  62   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
  63     if (io_addr != hw_config->io_base)  /* Already tested */
  64       if (gus_wave_detect (io_addr))
  65         {
  66           printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
  67           mem_start = gus_wave_init (mem_start, hw_config->irq, hw_config->dma);
  68 #ifndef EXCLUDE_MIDI
  69           mem_start = gus_midi_init (mem_start);
  70 #endif
  71           return mem_start;
  72         }
  73 
  74 #endif
  75 
  76   return mem_start;             /* Not detected */
  77 }
  78 
  79 int
  80 probe_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82   int             io_addr;
  83 
  84   if (gus_wave_detect (hw_config->io_base))
  85     return 1;
  86 
  87 #ifndef EXCLUDE_GUS_IODETECT
  88 
  89   /*
  90    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
  91    */
  92 
  93   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
  94     if (io_addr != hw_config->io_base)  /* Already tested */
  95       if (gus_wave_detect (io_addr))
  96         return 1;
  97 
  98 #endif
  99 
 100   return 0;
 101 }
 102 
 103 void
 104 gusintr (int unit)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106   unsigned char   src;
 107 
 108 #ifdef linux
 109   sti();
 110 #endif
 111 
 112   while (1)
 113     {
 114       if (!(src = INB (u_IrqStatus)))
 115         return;
 116 
 117       if (src & DMA_TC_IRQ)
 118         {
 119           guswave_dma_irq ();
 120         }
 121 
 122       if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
 123         {
 124 #ifndef EXCLUDE_MIDI
 125           gus_midi_interrupt (0);
 126 #endif
 127         }
 128 
 129       if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
 130         {
 131           printk ("T");
 132           gus_write8 (0x45, 0); /* Timer control */
 133         }
 134 
 135       if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 136         {
 137           gus_voice_irq ();
 138         }
 139     }
 140 }
 141 
 142 #endif

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