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  * 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 irq, struct pt_regs *dummy);
  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 sound_os_info  *gus_osp;
  44 
  45 long
  46 attach_gus_card (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48   int             io_addr;
  49 
  50   gus_osp = hw_config->osp;
  51   snd_set_irq_handler (hw_config->irq, gusintr, "Gravis Ultrasound", hw_config->osp);
  52 
  53   if (gus_wave_detect (hw_config->io_base))     /*
  54                                                  * Try first the default
  55                                                  */
  56     {
  57       mem_start = gus_wave_init (mem_start, hw_config);
  58 
  59       request_region (hw_config->io_base, 16, "GUS");
  60       request_region (hw_config->io_base + 0x100, 12, "GUS");   /* 0x10c-> is MAX */
  61 
  62       if (sound_alloc_dma (hw_config->dma, "GUS"))
  63         printk ("gus_card.c: Can't allocate DMA channel\n");
  64       if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
  65         if (sound_alloc_dma (hw_config->dma2, "GUS(2)"))
  66           printk ("gus_card.c: Can't allocate DMA channel2\n");
  67 #ifndef EXCLUDE_MIDI
  68       mem_start = gus_midi_init (mem_start);
  69 #endif
  70       return mem_start;
  71     }
  72 
  73 #ifndef EXCLUDE_GUS_IODETECT
  74 
  75   /*
  76    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
  77    */
  78 
  79   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
  80     if (io_addr != hw_config->io_base)  /*
  81                                          * Already tested
  82                                          */
  83       if (gus_wave_detect (io_addr))
  84         {
  85           hw_config->io_base = io_addr;
  86 
  87           printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
  88           mem_start = gus_wave_init (mem_start, hw_config);
  89           request_region (io_addr, 16, "GUS");
  90           request_region (io_addr + 0x100, 12, "GUS");  /* 0x10c-> is MAX */
  91           if (sound_alloc_dma (hw_config->dma, "GUS"))
  92             printk ("gus_card.c: Can't allocate DMA channel\n");
  93           if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
  94             if (sound_alloc_dma (hw_config->dma2, "GUS"))
  95               printk ("gus_card.c: Can't allocate DMA channel2\n");
  96 #ifndef EXCLUDE_MIDI
  97           mem_start = gus_midi_init (mem_start);
  98 #endif
  99           return mem_start;
 100         }
 101 
 102 #endif
 103 
 104   return mem_start;             /*
 105                                  * Not detected
 106                                  */
 107 }
 108 
 109 int
 110 probe_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 111 {
 112   int             io_addr;
 113 
 114   gus_osp = hw_config->osp;
 115 
 116   if (!check_region (hw_config->io_base, 16))
 117     if (!check_region (hw_config->io_base + 0x100, 16))
 118       if (gus_wave_detect (hw_config->io_base))
 119         return 1;
 120 
 121 #ifndef EXCLUDE_GUS_IODETECT
 122 
 123   /*
 124    * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
 125    */
 126 
 127   for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
 128     if (io_addr != hw_config->io_base)  /*
 129                                          * Already tested
 130                                          */
 131       if (!check_region (io_addr, 16))
 132         if (!check_region (io_addr + 0x100, 16))
 133           if (gus_wave_detect (io_addr))
 134             {
 135               hw_config->io_base = io_addr;
 136               return 1;
 137             }
 138 
 139 #endif
 140 
 141   return 0;
 142 }
 143 
 144 void
 145 unload_gus (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 146 {
 147   gus_wave_unload ();
 148 
 149   release_region (hw_config->io_base, 16);
 150   release_region (hw_config->io_base + 0x100, 12);      /* 0x10c-> is MAX */
 151   snd_release_irq (hw_config->irq);
 152 
 153   sound_free_dma (hw_config->dma);
 154 
 155   if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
 156     sound_free_dma (hw_config->dma2);
 157 }
 158 
 159 void
 160 gusintr (int irq, struct pt_regs *dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 161 {
 162   unsigned char   src;
 163   extern int      gus_timer_enabled;
 164 
 165   sti ();
 166 
 167 #ifndef EXCLUDE_GUSMAX
 168   if (have_gus_max)
 169     ad1848_interrupt (irq, NULL);
 170 #endif
 171 
 172   while (1)
 173     {
 174       if (!(src = inb (u_IrqStatus)))
 175         return;
 176 
 177       if (src & DMA_TC_IRQ)
 178         {
 179           guswave_dma_irq ();
 180         }
 181 
 182       if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
 183         {
 184 #ifndef EXCLUDE_MIDI
 185           gus_midi_interrupt (0);
 186 #endif
 187         }
 188 
 189       if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
 190         {
 191 #ifndef EXCLUDE_SEQUENCER
 192           if (gus_timer_enabled)
 193             sound_timer_interrupt ();
 194           gus_write8 (0x45, 0); /* Ack IRQ */
 195           gus_timer_command (4, 0x80);  /* Reset IRQ flags */
 196 
 197 #else
 198           gus_write8 (0x45, 0); /* Stop timers */
 199 #endif
 200         }
 201 
 202       if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 203         {
 204           gus_voice_irq ();
 205         }
 206     }
 207 }
 208 
 209 #endif
 210 
 211 /*
 212  * Some extra code for the 16 bit sampling option
 213  */
 214 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS16)
 215 
 216 int
 217 probe_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 218 {
 219   return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
 220 }
 221 
 222 long
 223 attach_gus_db16 (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 224 {
 225   gus_pcm_volume = 100;
 226   gus_wave_volume = 90;
 227 
 228   ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
 229                hw_config->irq,
 230                hw_config->dma,
 231                hw_config->dma, 0,
 232                hw_config->osp);
 233   return mem_start;
 234 }
 235 
 236 void
 237 unload_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 238 {
 239 
 240   ad1848_unload (hw_config->io_base,
 241                  hw_config->irq,
 242                  hw_config->dma,
 243                  hw_config->dma, 0);
 244 }
 245 #endif

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