root/drivers/sound/dev_table.c

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

DEFINITIONS

This source file includes following definitions.
  1. sndtable_init
  2. sndtable_probe
  3. sndtable_init_card
  4. sndtable_get_cardcount
  5. sound_setup
  6. sound_chconf
  7. sound_getconf

   1 /*
   2  * sound/dev_table.c
   3  *
   4  * Device call tables.
   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 #define _DEV_TABLE_C_
  31 #include "sound_config.h"
  32 
  33 #ifdef CONFIGURE_SOUNDCARD
  34 
  35 long
  36 sndtable_init (long mem_start)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  39 
  40   for (i = 0; i < (n - 1); i++)
  41     if (supported_drivers[i].enabled)
  42       if (supported_drivers[i].probe (&supported_drivers[i].config))
  43         {
  44 #ifndef SHORT_BANNERS
  45           printk ("snd%d",
  46                   supported_drivers[i].card_type);
  47 #endif
  48 
  49           mem_start = supported_drivers[i].attach (mem_start, &supported_drivers[i].config);
  50 #ifndef SHORT_BANNERS
  51           printk (" at 0x%x irq %d drq %d\n",
  52                   supported_drivers[i].config.io_base,
  53                   supported_drivers[i].config.irq,
  54                   supported_drivers[i].config.dma);
  55 #endif
  56         }
  57       else
  58         supported_drivers[i].enabled = 0;       /* Mark as not detected */
  59   return mem_start;
  60 }
  61 
  62 int
  63 sndtable_probe (int unit, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  64 {
  65   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  66 
  67   if (!unit)
  68     return TRUE;
  69 
  70   for (i = 0; i < (n - 1); i++)
  71     if (supported_drivers[i].card_type == unit)
  72       {
  73         supported_drivers[i].config.io_base = hw_config->io_base;
  74         supported_drivers[i].config.irq = hw_config->irq;
  75         supported_drivers[i].config.dma = hw_config->dma;
  76         if (supported_drivers[i].probe (hw_config))
  77           return 1;
  78         supported_drivers[i].enabled = 0;       /* Mark as not detected */
  79         return 0;
  80       }
  81 
  82   return FALSE;
  83 }
  84 
  85 int
  86 sndtable_init_card (int unit, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  87 {
  88   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  89 
  90   if (!unit)
  91     {
  92       if (sndtable_init (0) != 0)
  93         panic ("snd: Invalid memory allocation\n");
  94       return TRUE;
  95     }
  96 
  97   for (i = 0; i < (n - 1); i++)
  98     if (supported_drivers[i].card_type == unit)
  99       {
 100         supported_drivers[i].config.io_base = hw_config->io_base;
 101         supported_drivers[i].config.irq = hw_config->irq;
 102         supported_drivers[i].config.dma = hw_config->dma;
 103 
 104         if (supported_drivers[i].attach (0, hw_config) != 0)
 105           panic ("snd#: Invalid memory allocation\n");
 106         return TRUE;
 107       }
 108 
 109   return FALSE;
 110 }
 111 
 112 int
 113 sndtable_get_cardcount (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115   return num_dspdevs + num_mixers + num_synths + num_midis;
 116 }
 117 
 118 #ifdef linux
 119 void
 120 sound_setup (char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 121 {
 122   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
 123 
 124   /*
 125  * First disable all drivers
 126  */
 127 
 128   for (i = 0; i < n; i++)
 129     supported_drivers[i].enabled = 0;
 130 
 131   if (ints[0] == 0 || ints[1] == 0)
 132     return;
 133   /*
 134  * Then enable them one by time
 135  */
 136 
 137   for (i = 1; i <= ints[0]; i++)
 138     {
 139       int             card_type, ioaddr, irq, dma, ptr, j;
 140       unsigned int    val;
 141 
 142       val = (unsigned int) ints[i];
 143 
 144       card_type = (val & 0x0ff00000) >> 20;
 145 
 146       if (card_type > 127)
 147         {
 148           /* Add any future extensions here */
 149           return;
 150         }
 151 
 152       ioaddr = (val & 0x000fff00) >> 8;
 153       irq = (val & 0x000000f0) >> 4;
 154       dma = (val & 0x0000000f);
 155 
 156       ptr = -1;
 157       for (j = 0; j < n && ptr == -1; j++)
 158         if (supported_drivers[j].card_type == card_type)
 159           ptr = j;
 160 
 161       if (ptr == -1)
 162         printk ("Sound: Invalid setup parameter 0x%08x\n", val);
 163       else
 164         {
 165           supported_drivers[ptr].enabled = 1;
 166           supported_drivers[ptr].config.io_base = ioaddr;
 167           supported_drivers[ptr].config.irq = irq;
 168           supported_drivers[ptr].config.dma = dma;
 169         }
 170     }
 171 }
 172 
 173 #else
 174 void
 175 sound_chconf (int card_type, int ioaddr, int irq, int dma)
     /* [previous][next][first][last][top][bottom][index][help] */
 176 {
 177   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
 178 
 179   int             ptr, j;
 180 
 181   ptr = -1;
 182   for (j = 0; j < n && ptr == -1; j++)
 183     if (supported_drivers[j].card_type == card_type)
 184       ptr = j;
 185 
 186   if (ptr != -1)
 187     {
 188       supported_drivers[ptr].enabled = 1;
 189       if (ioaddr)
 190         supported_drivers[ptr].config.io_base = ioaddr;
 191       if (irq)
 192         supported_drivers[ptr].config.irq = irq;
 193       if (dma)
 194         supported_drivers[ptr].config.dma = dma;
 195     }
 196 }
 197 
 198 #endif
 199 
 200 struct address_info *
 201 sound_getconf (int card_type)
     /* [previous][next][first][last][top][bottom][index][help] */
 202 {
 203   int             j, ptr;
 204   int             n = sizeof (supported_drivers) / sizeof (struct card_info);
 205 
 206   ptr = -1;
 207   for (j = 0; j < n && ptr == -1; j++)
 208     if (supported_drivers[j].card_type == card_type)
 209       ptr = j;
 210 
 211   if (ptr == -1)
 212     return (struct address_info *) NULL;
 213 
 214   return &supported_drivers[ptr].config;
 215 }
 216 
 217 #endif

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