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_getconf

   1 /*
   2  * linux/kernel/chr_drv/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%3x 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   return mem_start;
  58 }
  59 
  60 int
  61 sndtable_probe (int unit, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  62 {
  63   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  64 
  65   if (!unit)
  66     return TRUE;
  67 
  68   for (i = 0; i < (n - 1); i++)
  69     if (supported_drivers[i].card_type == unit)
  70       return supported_drivers[i].probe (hw_config);
  71 
  72   return FALSE;
  73 }
  74 
  75 int
  76 sndtable_init_card (int unit, struct address_info *hw_config)
     /* [previous][next][first][last][top][bottom][index][help] */
  77 {
  78   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
  79 
  80   if (!unit)
  81     {
  82       if (sndtable_init (0) != 0)
  83         panic ("snd: Invalid memory allocation\n");
  84       return TRUE;
  85     }
  86 
  87   for (i = 0; i < (n - 1); i++)
  88     if (supported_drivers[i].card_type == unit)
  89       {
  90         if (supported_drivers[i].attach (0, hw_config) != 0)
  91           panic ("snd#: Invalid memory allocation\n");
  92         return TRUE;
  93       }
  94 
  95   return FALSE;
  96 }
  97 
  98 int
  99 sndtable_get_cardcount (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 100 {
 101   return num_dspdevs + num_mixers + num_synths + num_midis;
 102 }
 103 
 104 void sound_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106   int             i, n = sizeof (supported_drivers) / sizeof (struct card_info);
 107 
 108         printk("sound_setup(%d) called\n", ints[0]);
 109 
 110 /*
 111  * First disable all drivers
 112  */
 113 
 114         for (i=0;i<n;i++)
 115                 supported_drivers[i].enabled = 0;
 116 
 117         if (ints[0] == 0 || ints[1] == 0) return;
 118 /*
 119  * Then enable them one by time
 120  */
 121 
 122         for (i=1;i<=ints[0];i++)
 123         {
 124                 int card_type, ioaddr, irq, dma, ptr, j;
 125                 unsigned int val;
 126 
 127                 val = (unsigned int)ints[i];
 128 
 129                 card_type = (val & 0x0ff00000) >> 20;
 130 
 131                 if (card_type > 127)
 132                 {
 133                         /* Add any future extensions here*/
 134                         return;
 135                 }
 136 
 137                 ioaddr    = (val & 0x000fff00) >> 8;
 138                 irq       = (val & 0x000000f0) >> 4;
 139                 dma       = (val & 0x0000000f);
 140 
 141                 ptr = -1;
 142                 for (j=0;j<n && ptr == -1;j++)
 143                 if (supported_drivers[j].card_type == card_type)
 144                         ptr = j;
 145 
 146                 if (ptr == -1)
 147                    printk("Sound: Invalid setup parameter 0x%08x\n", val);
 148                 else
 149                 {
 150                         supported_drivers[ptr].enabled = 1;
 151                         supported_drivers[ptr].config.io_base = ioaddr;
 152                         supported_drivers[ptr].config.irq = irq;
 153                         supported_drivers[ptr].config.dma = dma;
 154                 }
 155         }
 156 }
 157 
 158 struct address_info *sound_getconf(int card_type)
     /* [previous][next][first][last][top][bottom][index][help] */
 159 {
 160         int j, ptr;
 161         int n = sizeof (supported_drivers) / sizeof (struct card_info);
 162 
 163         ptr = -1;
 164         for (j=0;j<n && ptr == -1;j++)
 165         if (supported_drivers[j].card_type == card_type)
 166                 ptr = j;
 167 
 168         if (ptr == -1) return (struct address_info *)NULL;
 169 
 170         return &supported_drivers[ptr].config;
 171 }
 172 #endif

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