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

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