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)) return 1;
  77         supported_drivers[i].enabled=0; /* Mark as not detected */
  78         return 0;
  79     }
  80 
  81   return FALSE;
  82 }
  83 
  84 int
  85 sndtable_init_card (int unit, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  88 
  89   if (!unit)
  90     {
  91       if (sndtable_init (0) != 0)
  92         panic ("snd: Invalid memory allocation\n");
  93       return TRUE;
  94     }
  95 
  96   for (i = 0; i < (n - 1); i++)
  97     if (supported_drivers[i].card_type == unit)
  98       {
  99         supported_drivers[i].config.io_base = hw_config->io_base;
 100         supported_drivers[i].config.irq = hw_config->irq;
 101         supported_drivers[i].config.dma = hw_config->dma;
 102 
 103         if (supported_drivers[i].attach (0, hw_config) != 0)
 104           panic ("snd#: Invalid memory allocation\n");
 105         return TRUE;
 106       }
 107 
 108   return FALSE;
 109 }
 110 
 111 int
 112 sndtable_get_cardcount (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114   return num_dspdevs + num_mixers + num_synths + num_midis;
 115 }
 116 
 117 #ifdef linux
 118 void sound_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 119 {
 120   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
 121 
 122 /*
 123  * First disable all drivers
 124  */
 125 
 126         for (i=0;i<n;i++)
 127                 supported_drivers[i].enabled = 0;
 128 
 129         if (ints[0] == 0 || ints[1] == 0) return;
 130 /*
 131  * Then enable them one by time
 132  */
 133 
 134         for (i=1;i<=ints[0];i++)
 135         {
 136                 int card_type, ioaddr, irq, dma, ptr, j;
 137                 unsigned int val;
 138 
 139                 val = (unsigned int)ints[i];
 140 
 141                 card_type = (val & 0x0ff00000) >> 20;
 142 
 143                 if (card_type > 127)
 144                 {
 145                         /* Add any future extensions here*/
 146                         return;
 147                 }
 148 
 149                 ioaddr    = (val & 0x000fff00) >> 8;
 150                 irq       = (val & 0x000000f0) >> 4;
 151                 dma       = (val & 0x0000000f);
 152 
 153                 ptr = -1;
 154                 for (j=0;j<n && ptr == -1;j++)
 155                 if (supported_drivers[j].card_type == card_type)
 156                         ptr = j;
 157 
 158                 if (ptr == -1)
 159                    printk("Sound: Invalid setup parameter 0x%08x\n", val);
 160                 else
 161                 {
 162                         supported_drivers[ptr].enabled = 1;
 163                         supported_drivers[ptr].config.io_base = ioaddr;
 164                         supported_drivers[ptr].config.irq = irq;
 165                         supported_drivers[ptr].config.dma = dma;
 166                 }
 167         }
 168 }
 169 #else
 170 void sound_chconf(int card_type, int ioaddr, int irq, int dma)
     /* [previous][next][first][last][top][bottom][index][help] */
 171 {
 172   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
 173 
 174                 int ptr, j;
 175 
 176                 ptr = -1;
 177                 for (j=0;j<n && ptr == -1;j++)
 178                 if (supported_drivers[j].card_type == card_type)
 179                         ptr = j;
 180 
 181                 if (ptr != -1)
 182                 {
 183                         supported_drivers[ptr].enabled = 1;
 184                         if (ioaddr) supported_drivers[ptr].config.io_base = ioaddr;
 185                         if (irq) supported_drivers[ptr].config.irq = irq;
 186                         if (dma) supported_drivers[ptr].config.dma = dma;
 187                 }
 188 }
 189 #endif
 190 
 191 struct address_info *sound_getconf(int card_type)
     /* [previous][next][first][last][top][bottom][index][help] */
 192 {
 193         int j, ptr;
 194         int n = sizeof (supported_drivers) / sizeof (struct card_info);
 195 
 196         ptr = -1;
 197         for (j=0;j<n && ptr == -1;j++)
 198         if (supported_drivers[j].card_type == card_type)
 199                 ptr = j;
 200 
 201         if (ptr == -1) return (struct address_info *)NULL;
 202 
 203         return &supported_drivers[ptr].config;
 204 }
 205 #endif

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