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   DDB (printk ("unload_gus(%x)\n", hw_config->io_base));
 148 
 149   gus_wave_unload ();
 150 
 151   release_region (hw_config->io_base, 16);
 152   release_region (hw_config->io_base + 0x100, 12);      /* 0x10c-> is MAX */
 153   snd_release_irq (hw_config->irq);
 154 
 155   sound_free_dma (hw_config->dma);
 156 
 157   if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
 158     sound_free_dma (hw_config->dma2);
 159 }
 160 
 161 void
 162 gusintr (int irq, struct pt_regs *dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 163 {
 164   unsigned char   src;
 165   extern int      gus_timer_enabled;
 166 
 167   sti ();
 168 
 169 #ifndef EXCLUDE_GUSMAX
 170   if (have_gus_max)
 171     ad1848_interrupt (irq, NULL);
 172 #endif
 173 
 174   while (1)
 175     {
 176       if (!(src = inb (u_IrqStatus)))
 177         return;
 178 
 179       if (src & DMA_TC_IRQ)
 180         {
 181           guswave_dma_irq ();
 182         }
 183 
 184       if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
 185         {
 186 #ifndef EXCLUDE_MIDI
 187           gus_midi_interrupt (0);
 188 #endif
 189         }
 190 
 191       if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
 192         {
 193 #ifndef EXCLUDE_SEQUENCER
 194           if (gus_timer_enabled)
 195             sound_timer_interrupt ();
 196           gus_write8 (0x45, 0); /* Ack IRQ */
 197           gus_timer_command (4, 0x80);  /* Reset IRQ flags */
 198 
 199 #else
 200           gus_write8 (0x45, 0); /* Stop timers */
 201 #endif
 202         }
 203 
 204       if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
 205         {
 206           gus_voice_irq ();
 207         }
 208     }
 209 }
 210 
 211 #endif
 212 
 213 /*
 214  * Some extra code for the 16 bit sampling option
 215  */
 216 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS16)
 217 
 218 int
 219 probe_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 220 {
 221   return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
 222 }
 223 
 224 long
 225 attach_gus_db16 (long mem_start, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 226 {
 227   gus_pcm_volume = 100;
 228   gus_wave_volume = 90;
 229 
 230   ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
 231                hw_config->irq,
 232                hw_config->dma,
 233                hw_config->dma, 0,
 234                hw_config->osp);
 235   return mem_start;
 236 }
 237 
 238 void
 239 unload_gus_db16 (struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
 240 {
 241 
 242   ad1848_unload (hw_config->io_base,
 243                  hw_config->irq,
 244                  hw_config->dma,
 245                  hw_config->dma, 0);
 246 }
 247 #endif

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