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. unload_gus
  4. gusintr
  5. probe_gus_db16
  6. attach_gus_db16
  7. unload_gus_db16

   1 /*
   2  * sound/gus_card.c
   3  *
   4  * Detection routine for the Gravis Ultrasound.
   5  */
   6 /*
   7  * Copyright by Hannu Savolainen 1993-1996
   8  *
   9  * Redistribution and use in source and binary forms, with or without
  10  * modification, are permitted provided that the following conditions are
  11  * met: 1. Redistributions of source code must retain the above copyright
  12  * notice, this list of conditions and the following disclaimer. 2.
  13  * Redistributions in binary form must reproduce the above copyright notice,
  14  * this list of conditions and the following disclaimer in the documentation
  15  * and/or other materials provided with the distribution.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
  18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 #include <linux/config.h>
  30 
  31 
  32 #include "sound_config.h"
  33 
  34 #if defined(CONFIG_GUS)
  35 
  36 #include "gus_hw.h"
  37 
  38 void            gusintr (int irq, struct pt_regs *dummy);
  39 
  40 int             gus_base, gus_irq, gus_dma;
  41 extern int      gus_wave_volume;
  42 extern int      gus_pcm_volume;
  43 extern int      have_gus_max;
  44 
  45 int            *gus_osp;
  46 
  47 long
  48 attach_gus_card (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50   int             io_addr;
  51 
  52   gus_osp = hw_config->osp;
  53   snd_set_irq_handler (hw_config->irq, gusintr, "Gravis Ultrasound", hw_config->osp);
  54 
  55   if (gus_wave_detect (hw_config->io_base))     /*
  56                                                  * Try first the default
  57                                                  */
  58     {
  59       mem_start = gus_wave_init (mem_start, hw_config);
  60 
  61       request_region (hw_config->io_base, 16, "GUS");
  62       request_region (hw_config->io_base + 0x100, 12, "GUS");   /* 0x10c-> is MAX */
  63 
  64       if (sound_alloc_dma (hw_config->dma, "GUS"))
  65         printk ("gus_card.c: Can't allocate DMA channel\n");
  66       if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
  67         if (sound_alloc_dma (hw_config->dma2, "GUS(2)"))
  68           printk ("gus_card.c: Can't allocate DMA channel2\n");
  69 #ifdef CONFIG_MIDI
  70       mem_start = gus_midi_init (mem_start);
  71 #endif
  72       return mem_start;
  73     }
  74 
  75 #ifndef EXCLUDE_GUS_IODETECT
  76 
  77   /*
  78    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
  79    */
  80 
  81   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
  82     if (io_addr != hw_config->io_base)  /*
  83                                          * Already tested
  84                                          */
  85       if (gus_wave_detect (io_addr))
  86         {
  87           hw_config->io_base = io_addr;
  88 
  89           printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
  90           mem_start = gus_wave_init (mem_start, hw_config);
  91           request_region (io_addr, 16, "GUS");
  92           request_region (io_addr + 0x100, 12, "GUS");  /* 0x10c-> is MAX */
  93           if (sound_alloc_dma (hw_config->dma, "GUS"))
  94             printk ("gus_card.c: Can't allocate DMA channel\n");
  95           if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
  96             if (sound_alloc_dma (hw_config->dma2, "GUS"))
  97               printk ("gus_card.c: Can't allocate DMA channel2\n");
  98 #ifdef CONFIG_MIDI
  99           mem_start = gus_midi_init (mem_start);
 100 #endif
 101           return mem_start;
 102         }
 103 
 104 #endif
 105 
 106   return mem_start;             /*
 107                                  * Not detected
 108                                  */
 109 }
 110 
 111 int
 112 probe_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114   int             io_addr;
 115 
 116   gus_osp = hw_config->osp;
 117 
 118   if (!check_region (hw_config->io_base, 16))
 119     if (!check_region (hw_config->io_base + 0x100, 16))
 120       if (gus_wave_detect (hw_config->io_base))
 121         return 1;
 122 
 123 #ifndef EXCLUDE_GUS_IODETECT
 124 
 125   /*
 126    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
 127    */
 128 
 129   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
 130     if (io_addr != hw_config->io_base)  /*
 131                                          * Already tested
 132                                          */
 133       if (!check_region (io_addr, 16))
 134         if (!check_region (io_addr + 0x100, 16))
 135           if (gus_wave_detect (io_addr))
 136             {
 137               hw_config->io_base = io_addr;
 138               return 1;
 139             }
 140 
 141 #endif
 142 
 143   return 0;
 144 }
 145 
 146 void
 147 unload_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149   DDB (printk ("unload_gus(%x)\n", hw_config->io_base));
 150 
 151   gus_wave_unload ();
 152 
 153   release_region (hw_config->io_base, 16);
 154   release_region (hw_config->io_base + 0x100, 12);      /* 0x10c-> is MAX */
 155   snd_release_irq (hw_config->irq);
 156 
 157   sound_free_dma (hw_config->dma);
 158 
 159   if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
 160     sound_free_dma (hw_config->dma2);
 161 }
 162 
 163 void
 164 gusintr (int irq, struct pt_regs *dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 165 {
 166   unsigned char   src;
 167   extern int      gus_timer_enabled;
 168 
 169   sti ();
 170 
 171 #ifdef CONFIG_GUSMAX
 172   if (have_gus_max)
 173     ad1848_interrupt (irq, NULL);
 174 #endif
 175 
 176   while (1)
 177     {
 178       if (!(src = inb (u_IrqStatus)))
 179         return;
 180 
 181       if (src & DMA_TC_IRQ)
 182         {
 183           guswave_dma_irq ();
 184         }
 185 
 186       if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
 187         {
 188 #ifdef CONFIG_MIDI
 189           gus_midi_interrupt (0);
 190 #endif
 191         }
 192 
 193       if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
 194         {
 195 #ifdef CONFIG_SEQUENCER
 196           if (gus_timer_enabled)
 197             {
 198               sound_timer_interrupt ();
 199             }
 200 
 201           gus_write8 (0x45, 0); /* Ack IRQ */
 202           gus_timer_command (4, 0x80);  /* Reset IRQ flags */
 203 
 204 #else
 205           gus_write8 (0x45, 0); /* Stop timers */
 206 #endif
 207         }
 208 
 209       if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 210         {
 211           gus_voice_irq ();
 212         }
 213     }
 214 }
 215 
 216 #endif
 217 
 218 /*
 219  * Some extra code for the 16 bit sampling option
 220  */
 221 #if defined(CONFIG_GUS16)
 222 
 223 int
 224 probe_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 225 {
 226   return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
 227 }
 228 
 229 long
 230 attach_gus_db16 (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 231 {
 232 #ifdef CONFIG_GUS
 233   gus_pcm_volume = 100;
 234   gus_wave_volume = 90;
 235 #endif
 236 
 237   ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
 238                hw_config->irq,
 239                hw_config->dma,
 240                hw_config->dma, 0,
 241                hw_config->osp);
 242   return mem_start;
 243 }
 244 
 245 void
 246 unload_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 247 {
 248 
 249   ad1848_unload (hw_config->io_base,
 250                  hw_config->irq,
 251                  hw_config->dma,
 252                  hw_config->dma, 0);
 253 }
 254 #endif

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