Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/sound/isa/gus/gusmax.c (Version 2.6.25.8) and /linux/sound/isa/gus/gusmax.c (Version 2.6.25)


  1 /*                                                  1 /*
  2  *  Driver for Gravis UltraSound MAX soundcard      2  *  Driver for Gravis UltraSound MAX soundcard
  3  *  Copyright (c) by Jaroslav Kysela <perex@pe      3  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4  *                                                  4  *
  5  *                                                  5  *
  6  *   This program is free software; you can re      6  *   This program is free software; you can redistribute it and/or modify
  7  *   it under the terms of the GNU General Pub      7  *   it under the terms of the GNU General Public License as published by
  8  *   the Free Software Foundation; either vers      8  *   the Free Software Foundation; either version 2 of the License, or
  9  *   (at your option) any later version.            9  *   (at your option) any later version.
 10  *                                                 10  *
 11  *   This program is distributed in the hope t     11  *   This program is distributed in the hope that it will be useful,
 12  *   but WITHOUT ANY WARRANTY; without even th     12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  *   MERCHANTABILITY or FITNESS FOR A PARTICUL     13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  *   GNU General Public License for more detai     14  *   GNU General Public License for more details.
 15  *                                                 15  *
 16  *   You should have received a copy of the GN     16  *   You should have received a copy of the GNU General Public License
 17  *   along with this program; if not, write to     17  *   along with this program; if not, write to the Free Software
 18  *   Foundation, Inc., 59 Temple Place, Suite      18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 19  *                                                 19  *
 20  */                                                20  */
 21                                                    21 
 22 #include <linux/init.h>                            22 #include <linux/init.h>
 23 #include <linux/err.h>                             23 #include <linux/err.h>
 24 #include <linux/isa.h>                             24 #include <linux/isa.h>
 25 #include <linux/delay.h>                           25 #include <linux/delay.h>
 26 #include <linux/time.h>                            26 #include <linux/time.h>
 27 #include <linux/moduleparam.h>                     27 #include <linux/moduleparam.h>
 28 #include <asm/dma.h>                               28 #include <asm/dma.h>
 29 #include <sound/core.h>                            29 #include <sound/core.h>
 30 #include <sound/gus.h>                             30 #include <sound/gus.h>
 31 #include <sound/cs4231.h>                          31 #include <sound/cs4231.h>
 32 #define SNDRV_LEGACY_FIND_FREE_IRQ                 32 #define SNDRV_LEGACY_FIND_FREE_IRQ
 33 #define SNDRV_LEGACY_FIND_FREE_DMA                 33 #define SNDRV_LEGACY_FIND_FREE_DMA
 34 #include <sound/initval.h>                         34 #include <sound/initval.h>
 35                                                    35 
 36 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz     36 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 37 MODULE_DESCRIPTION("Gravis UltraSound MAX");       37 MODULE_DESCRIPTION("Gravis UltraSound MAX");
 38 MODULE_LICENSE("GPL");                             38 MODULE_LICENSE("GPL");
 39 MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound M     39 MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound MAX}}");
 40                                                    40 
 41 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_     41 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
 42 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_S     42 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
 43 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT     43 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
 44 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_     44 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x230,0x240,0x250,0x260 */
 45 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IR     45 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 2,3,5,9,11,12,15 */
 46 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_D     46 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 1,3,5,6,7 */
 47 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_D     47 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 1,3,5,6,7 */
 48 static int joystick_dac[SNDRV_CARDS] = {[0 ...     48 static int joystick_dac[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 29};
 49                                 /* 0 to 31, (0     49                                 /* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
 50 static int channels[SNDRV_CARDS] = {[0 ... (SN     50 static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
 51 static int pcm_channels[SNDRV_CARDS] = {[0 ...     51 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
 52                                                    52 
 53 module_param_array(index, int, NULL, 0444);        53 module_param_array(index, int, NULL, 0444);
 54 MODULE_PARM_DESC(index, "Index value for GUS M     54 MODULE_PARM_DESC(index, "Index value for GUS MAX soundcard.");
 55 module_param_array(id, charp, NULL, 0444);         55 module_param_array(id, charp, NULL, 0444);
 56 MODULE_PARM_DESC(id, "ID string for GUS MAX so     56 MODULE_PARM_DESC(id, "ID string for GUS MAX soundcard.");
 57 module_param_array(enable, bool, NULL, 0444);      57 module_param_array(enable, bool, NULL, 0444);
 58 MODULE_PARM_DESC(enable, "Enable GUS MAX sound     58 MODULE_PARM_DESC(enable, "Enable GUS MAX soundcard.");
 59 module_param_array(port, long, NULL, 0444);        59 module_param_array(port, long, NULL, 0444);
 60 MODULE_PARM_DESC(port, "Port # for GUS MAX dri     60 MODULE_PARM_DESC(port, "Port # for GUS MAX driver.");
 61 module_param_array(irq, int, NULL, 0444);          61 module_param_array(irq, int, NULL, 0444);
 62 MODULE_PARM_DESC(irq, "IRQ # for GUS MAX drive     62 MODULE_PARM_DESC(irq, "IRQ # for GUS MAX driver.");
 63 module_param_array(dma1, int, NULL, 0444);         63 module_param_array(dma1, int, NULL, 0444);
 64 MODULE_PARM_DESC(dma1, "DMA1 # for GUS MAX dri     64 MODULE_PARM_DESC(dma1, "DMA1 # for GUS MAX driver.");
 65 module_param_array(dma2, int, NULL, 0444);         65 module_param_array(dma2, int, NULL, 0444);
 66 MODULE_PARM_DESC(dma2, "DMA2 # for GUS MAX dri     66 MODULE_PARM_DESC(dma2, "DMA2 # for GUS MAX driver.");
 67 module_param_array(joystick_dac, int, NULL, 04     67 module_param_array(joystick_dac, int, NULL, 0444);
 68 MODULE_PARM_DESC(joystick_dac, "Joystick DAC l     68 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS MAX driver.");
 69 module_param_array(channels, int, NULL, 0444);     69 module_param_array(channels, int, NULL, 0444);
 70 MODULE_PARM_DESC(channels, "Used GF1 channels      70 MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
 71 module_param_array(pcm_channels, int, NULL, 04     71 module_param_array(pcm_channels, int, NULL, 0444);
 72 MODULE_PARM_DESC(pcm_channels, "Reserved PCM c     72 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
 73                                                    73 
 74 struct snd_gusmax {                                74 struct snd_gusmax {
 75         int irq;                                   75         int irq;
 76         struct snd_card *card;                     76         struct snd_card *card;
 77         struct snd_gus_card *gus;                  77         struct snd_gus_card *gus;
 78         struct snd_cs4231 *cs4231;                 78         struct snd_cs4231 *cs4231;
 79         unsigned short gus_status_reg;             79         unsigned short gus_status_reg;
 80         unsigned short pcm_status_reg;             80         unsigned short pcm_status_reg;
 81 };                                                 81 };
 82                                                    82 
 83 #define PFX     "gusmax: "                         83 #define PFX     "gusmax: "
 84                                                    84 
 85 static int __devinit snd_gusmax_detect(struct      85 static int __devinit snd_gusmax_detect(struct snd_gus_card * gus)
 86 {                                                  86 {
 87         unsigned char d;                           87         unsigned char d;
 88                                                    88 
 89         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES     89         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0);   /* reset GF1 */
 90         if (((d = snd_gf1_i_look8(gus, SNDRV_G     90         if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
 91                 snd_printdd("[0x%lx] check 1 f     91                 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
 92                 return -ENODEV;                    92                 return -ENODEV;
 93         }                                          93         }
 94         udelay(160);                               94         udelay(160);
 95         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES     95         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1);   /* release reset */
 96         udelay(160);                               96         udelay(160);
 97         if (((d = snd_gf1_i_look8(gus, SNDRV_G     97         if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
 98                 snd_printdd("[0x%lx] check 2 f     98                 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
 99                 return -ENODEV;                    99                 return -ENODEV;
100         }                                         100         }
101                                                   101 
102         return 0;                                 102         return 0;
103 }                                                 103 }
104                                                   104 
105 static irqreturn_t snd_gusmax_interrupt(int ir    105 static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id)
106 {                                                 106 {
107         struct snd_gusmax *maxcard = dev_id;      107         struct snd_gusmax *maxcard = dev_id;
108         int loop, max = 5;                        108         int loop, max = 5;
109         int handled = 0;                          109         int handled = 0;
110                                                   110 
111         do {                                      111         do {
112                 loop = 0;                         112                 loop = 0;
113                 if (inb(maxcard->gus_status_re    113                 if (inb(maxcard->gus_status_reg)) {
114                         handled = 1;              114                         handled = 1;
115                         snd_gus_interrupt(irq,    115                         snd_gus_interrupt(irq, maxcard->gus);
116                         loop++;                   116                         loop++;
117                 }                                 117                 }
118                 if (inb(maxcard->pcm_status_re    118                 if (inb(maxcard->pcm_status_reg) & 0x01) { /* IRQ bit is set? */
119                         handled = 1;              119                         handled = 1;
120                         snd_cs4231_interrupt(i    120                         snd_cs4231_interrupt(irq, maxcard->cs4231);
121                         loop++;                   121                         loop++;
122                 }                                 122                 }
123         } while (loop && --max > 0);              123         } while (loop && --max > 0);
124         return IRQ_RETVAL(handled);               124         return IRQ_RETVAL(handled);
125 }                                                 125 }
126                                                   126 
127 static void __devinit snd_gusmax_init(int dev,    127 static void __devinit snd_gusmax_init(int dev, struct snd_card *card,
128                                       struct s    128                                       struct snd_gus_card * gus)
129 {                                                 129 {
130         gus->equal_irq = 1;                       130         gus->equal_irq = 1;
131         gus->codec_flag = 1;                      131         gus->codec_flag = 1;
132         gus->joystick_dac = joystick_dac[dev];    132         gus->joystick_dac = joystick_dac[dev];
133         /* init control register */               133         /* init control register */
134         gus->max_cntrl_val = (gus->gf1.port >>    134         gus->max_cntrl_val = (gus->gf1.port >> 4) & 0x0f;
135         if (gus->gf1.dma1 > 3)                    135         if (gus->gf1.dma1 > 3)
136                 gus->max_cntrl_val |= 0x10;       136                 gus->max_cntrl_val |= 0x10;
137         if (gus->gf1.dma2 > 3)                    137         if (gus->gf1.dma2 > 3)
138                 gus->max_cntrl_val |= 0x20;       138                 gus->max_cntrl_val |= 0x20;
139         gus->max_cntrl_val |= 0x40;               139         gus->max_cntrl_val |= 0x40;
140         outb(gus->max_cntrl_val, GUSP(gus, MAX    140         outb(gus->max_cntrl_val, GUSP(gus, MAXCNTRLPORT));
141 }                                                 141 }
142                                                   142 
143 #define CS4231_PRIVATE( left, right, shift, mu    143 #define CS4231_PRIVATE( left, right, shift, mute ) \
144                         ((left << 24)|(right <    144                         ((left << 24)|(right << 16)|(shift<<8)|mute)
145                                                   145 
146 static int __devinit snd_gusmax_mixer(struct s    146 static int __devinit snd_gusmax_mixer(struct snd_cs4231 *chip)
147 {                                                 147 {
148         struct snd_card *card = chip->card;       148         struct snd_card *card = chip->card;
149         struct snd_ctl_elem_id id1, id2;          149         struct snd_ctl_elem_id id1, id2;
150         int err;                                  150         int err;
151                                                   151         
152         memset(&id1, 0, sizeof(id1));             152         memset(&id1, 0, sizeof(id1));
153         memset(&id2, 0, sizeof(id2));             153         memset(&id2, 0, sizeof(id2));
154         id1.iface = id2.iface = SNDRV_CTL_ELEM    154         id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
155         /* reassign AUXA to SYNTHESIZER */        155         /* reassign AUXA to SYNTHESIZER */
156         strcpy(id1.name, "Aux Playback Switch"    156         strcpy(id1.name, "Aux Playback Switch");
157         strcpy(id2.name, "Synth Playback Switc    157         strcpy(id2.name, "Synth Playback Switch");
158         if ((err = snd_ctl_rename_id(card, &id    158         if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
159                 return err;                       159                 return err;
160         strcpy(id1.name, "Aux Playback Volume"    160         strcpy(id1.name, "Aux Playback Volume");
161         strcpy(id2.name, "Synth Playback Volum    161         strcpy(id2.name, "Synth Playback Volume");
162         if ((err = snd_ctl_rename_id(card, &id    162         if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
163                 return err;                       163                 return err;
164         /* reassign AUXB to CD */                 164         /* reassign AUXB to CD */
165         strcpy(id1.name, "Aux Playback Switch"    165         strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
166         strcpy(id2.name, "CD Playback Switch")    166         strcpy(id2.name, "CD Playback Switch");
167         if ((err = snd_ctl_rename_id(card, &id    167         if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
168                 return err;                       168                 return err;
169         strcpy(id1.name, "Aux Playback Volume"    169         strcpy(id1.name, "Aux Playback Volume");
170         strcpy(id2.name, "CD Playback Volume")    170         strcpy(id2.name, "CD Playback Volume");
171         if ((err = snd_ctl_rename_id(card, &id    171         if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
172                 return err;                       172                 return err;
173 #if 0                                             173 #if 0
174         /* reassign Mono Input to MIC */          174         /* reassign Mono Input to MIC */
175         if (snd_mixer_group_rename(mixer,         175         if (snd_mixer_group_rename(mixer,
176                                 SNDRV_MIXER_IN    176                                 SNDRV_MIXER_IN_MONO, 0,
177                                 SNDRV_MIXER_IN    177                                 SNDRV_MIXER_IN_MIC, 0) < 0)
178                 goto __error;                     178                 goto __error;
179         if (snd_mixer_elem_rename(mixer,          179         if (snd_mixer_elem_rename(mixer,
180                                 SNDRV_MIXER_IN    180                                 SNDRV_MIXER_IN_MONO, 0, SNDRV_MIXER_ETYPE_INPUT,
181                                 SNDRV_MIXER_IN    181                                 SNDRV_MIXER_IN_MIC, 0) < 0)
182                 goto __error;                     182                 goto __error;
183         if (snd_mixer_elem_rename(mixer,          183         if (snd_mixer_elem_rename(mixer,
184                                 "Mono Capture     184                                 "Mono Capture Volume", 0, SNDRV_MIXER_ETYPE_VOLUME1,
185                                 "Mic Capture V    185                                 "Mic Capture Volume", 0) < 0)
186                 goto __error;                     186                 goto __error;
187         if (snd_mixer_elem_rename(mixer,          187         if (snd_mixer_elem_rename(mixer,
188                                 "Mono Capture     188                                 "Mono Capture Switch", 0, SNDRV_MIXER_ETYPE_SWITCH1,
189                                 "Mic Capture S    189                                 "Mic Capture Switch", 0) < 0)
190                 goto __error;                     190                 goto __error;
191 #endif                                            191 #endif
192         return 0;                                 192         return 0;
193 }                                                 193 }
194                                                   194 
195 static void snd_gusmax_free(struct snd_card *c    195 static void snd_gusmax_free(struct snd_card *card)
196 {                                                 196 {
197         struct snd_gusmax *maxcard = (struct s    197         struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data;
198                                                   198         
199         if (maxcard == NULL)                      199         if (maxcard == NULL)
200                 return;                           200                 return;
201         if (maxcard->irq >= 0)                    201         if (maxcard->irq >= 0)
202                 free_irq(maxcard->irq, (void *    202                 free_irq(maxcard->irq, (void *)maxcard);
203 }                                                 203 }
204                                                   204 
205 static int __devinit snd_gusmax_match(struct d    205 static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev)
206 {                                                 206 {
207         return enable[dev];                       207         return enable[dev];
208 }                                                 208 }
209                                                   209 
210 static int __devinit snd_gusmax_probe(struct d    210 static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev)
211 {                                                 211 {
212         static int possible_irqs[] = {5, 11, 1    212         static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
213         static int possible_dmas[] = {5, 6, 7,    213         static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
214         int xirq, xdma1, xdma2, err;              214         int xirq, xdma1, xdma2, err;
215         struct snd_card *card;                    215         struct snd_card *card;
216         struct snd_gus_card *gus = NULL;          216         struct snd_gus_card *gus = NULL;
217         struct snd_cs4231 *cs4231;                217         struct snd_cs4231 *cs4231;
218         struct snd_gusmax *maxcard;               218         struct snd_gusmax *maxcard;
219                                                   219 
220         card = snd_card_new(index[dev], id[dev    220         card = snd_card_new(index[dev], id[dev], THIS_MODULE,
221                             sizeof(struct snd_    221                             sizeof(struct snd_gusmax));
222         if (card == NULL)                         222         if (card == NULL)
223                 return -ENOMEM;                   223                 return -ENOMEM;
224         card->private_free = snd_gusmax_free;     224         card->private_free = snd_gusmax_free;
225         maxcard = (struct snd_gusmax *)card->p    225         maxcard = (struct snd_gusmax *)card->private_data;
226         maxcard->card = card;                     226         maxcard->card = card;
227         maxcard->irq = -1;                        227         maxcard->irq = -1;
228                                                   228         
229         xirq = irq[dev];                          229         xirq = irq[dev];
230         if (xirq == SNDRV_AUTO_IRQ) {             230         if (xirq == SNDRV_AUTO_IRQ) {
231                 if ((xirq = snd_legacy_find_fr    231                 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
232                         snd_printk(KERN_ERR PF    232                         snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
233                         err = -EBUSY;             233                         err = -EBUSY;
234                         goto _err;                234                         goto _err;
235                 }                                 235                 }
236         }                                         236         }
237         xdma1 = dma1[dev];                        237         xdma1 = dma1[dev];
238         if (xdma1 == SNDRV_AUTO_DMA) {            238         if (xdma1 == SNDRV_AUTO_DMA) {
239                 if ((xdma1 = snd_legacy_find_f    239                 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
240                         snd_printk(KERN_ERR PF    240                         snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
241                         err = -EBUSY;             241                         err = -EBUSY;
242                         goto _err;                242                         goto _err;
243                 }                                 243                 }
244         }                                         244         }
245         xdma2 = dma2[dev];                        245         xdma2 = dma2[dev];
246         if (xdma2 == SNDRV_AUTO_DMA) {            246         if (xdma2 == SNDRV_AUTO_DMA) {
247                 if ((xdma2 = snd_legacy_find_f    247                 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
248                         snd_printk(KERN_ERR PF    248                         snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
249                         err = -EBUSY;             249                         err = -EBUSY;
250                         goto _err;                250                         goto _err;
251                 }                                 251                 }
252         }                                         252         }
253                                                   253 
254         if (port[dev] != SNDRV_AUTO_PORT) {       254         if (port[dev] != SNDRV_AUTO_PORT) {
255                 err = snd_gus_create(card,        255                 err = snd_gus_create(card,
256                                      port[dev]    256                                      port[dev],
257                                      -xirq, xd    257                                      -xirq, xdma1, xdma2,
258                                      0, channe    258                                      0, channels[dev],
259                                      pcm_chann    259                                      pcm_channels[dev],
260                                      0, &gus);    260                                      0, &gus);
261         } else {                                  261         } else {
262                 static unsigned long possible_    262                 static unsigned long possible_ports[] = {
263                         0x220, 0x230, 0x240, 0    263                         0x220, 0x230, 0x240, 0x250, 0x260
264                 };                                264                 };
265                 int i;                            265                 int i;
266                 for (i = 0; i < ARRAY_SIZE(pos    266                 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
267                         err = snd_gus_create(c    267                         err = snd_gus_create(card,
268                                              p    268                                              possible_ports[i],
269                                              -    269                                              -xirq, xdma1, xdma2,
270                                              0    270                                              0, channels[dev],
271                                              p    271                                              pcm_channels[dev],
272                                              0    272                                              0, &gus);
273                         if (err >= 0) {           273                         if (err >= 0) {
274                                 port[dev] = po    274                                 port[dev] = possible_ports[i];
275                                 break;            275                                 break;
276                         }                         276                         }
277                 }                                 277                 }
278         }                                         278         }
279         if (err < 0)                              279         if (err < 0)
280                 goto _err;                        280                 goto _err;
281                                                   281 
282         if ((err = snd_gusmax_detect(gus)) < 0    282         if ((err = snd_gusmax_detect(gus)) < 0)
283                 goto _err;                        283                 goto _err;
284                                                   284 
285         maxcard->gus_status_reg = gus->gf1.reg    285         maxcard->gus_status_reg = gus->gf1.reg_irqstat;
286         maxcard->pcm_status_reg = gus->gf1.por    286         maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
287         snd_gusmax_init(dev, card, gus);          287         snd_gusmax_init(dev, card, gus);
288         if ((err = snd_gus_initialize(gus)) <     288         if ((err = snd_gus_initialize(gus)) < 0)
289                 goto _err;                        289                 goto _err;
290                                                   290 
291         if (!gus->max_flag) {                     291         if (!gus->max_flag) {
292                 snd_printk(KERN_ERR PFX "GUS M    292                 snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
293                 err = -ENODEV;                    293                 err = -ENODEV;
294                 goto _err;                        294                 goto _err;
295         }                                         295         }
296                                                   296 
297         if (request_irq(xirq, snd_gusmax_inter    297         if (request_irq(xirq, snd_gusmax_interrupt, IRQF_DISABLED, "GUS MAX", (void *)maxcard)) {
298                 snd_printk(KERN_ERR PFX "unabl    298                 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
299                 err = -EBUSY;                     299                 err = -EBUSY;
300                 goto _err;                        300                 goto _err;
301         }                                         301         }
302         maxcard->irq = xirq;                      302         maxcard->irq = xirq;
303                                                   303         
304         if ((err = snd_cs4231_create(card,        304         if ((err = snd_cs4231_create(card,
305                                      gus->gf1.    305                                      gus->gf1.port + 0x10c, -1, xirq,
306                                      xdma2 < 0    306                                      xdma2 < 0 ? xdma1 : xdma2, xdma1,
307                                      CS4231_HW    307                                      CS4231_HW_DETECT,
308                                      CS4231_HW    308                                      CS4231_HWSHARE_IRQ |
309                                      CS4231_HW    309                                      CS4231_HWSHARE_DMA1 |
310                                      CS4231_HW    310                                      CS4231_HWSHARE_DMA2,
311                                      &cs4231))    311                                      &cs4231)) < 0)
312                 goto _err;                        312                 goto _err;
313                                                   313 
314         if ((err = snd_cs4231_pcm(cs4231, 0, N    314         if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
315                 goto _err;                        315                 goto _err;
316                                                   316 
317         if ((err = snd_cs4231_mixer(cs4231)) <    317         if ((err = snd_cs4231_mixer(cs4231)) < 0)
318                 goto _err;                        318                 goto _err;
319                                                   319 
320         if ((err = snd_cs4231_timer(cs4231, 2,    320         if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
321                 goto _err;                        321                 goto _err;
322                                                   322 
323         if (pcm_channels[dev] > 0) {              323         if (pcm_channels[dev] > 0) {
324                 if ((err = snd_gf1_pcm_new(gus    324                 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
325                         goto _err;                325                         goto _err;
326         }                                         326         }
327         if ((err = snd_gusmax_mixer(cs4231)) <    327         if ((err = snd_gusmax_mixer(cs4231)) < 0)
328                 goto _err;                        328                 goto _err;
329                                                   329 
330         if ((err = snd_gf1_rawmidi_new(gus, 0,    330         if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
331                 goto _err;                        331                 goto _err;
332                                                   332 
333         sprintf(card->longname + strlen(card->    333         sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1);
334         if (xdma2 >= 0)                           334         if (xdma2 >= 0)
335                 sprintf(card->longname + strle    335                 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
336                                                   336 
337         snd_card_set_dev(card, pdev);             337         snd_card_set_dev(card, pdev);
338                                                   338 
339         if ((err = snd_card_register(card)) <     339         if ((err = snd_card_register(card)) < 0)
340                 goto _err;                        340                 goto _err;
341                                                   341                 
342         maxcard->gus = gus;                       342         maxcard->gus = gus;
343         maxcard->cs4231 = cs4231;                 343         maxcard->cs4231 = cs4231;
344                                                   344 
345         dev_set_drvdata(pdev, card);              345         dev_set_drvdata(pdev, card);
346         return 0;                                 346         return 0;
347                                                   347 
348  _err:                                            348  _err:
349         snd_card_free(card);                      349         snd_card_free(card);
350         return err;                               350         return err;
351 }                                                 351 }
352                                                   352 
353 static int __devexit snd_gusmax_remove(struct     353 static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev)
354 {                                                 354 {
355         snd_card_free(dev_get_drvdata(devptr))    355         snd_card_free(dev_get_drvdata(devptr));
356         dev_set_drvdata(devptr, NULL);            356         dev_set_drvdata(devptr, NULL);
357         return 0;                                 357         return 0;
358 }                                                 358 }
359                                                   359 
360 #define DEV_NAME "gusmax"                         360 #define DEV_NAME "gusmax"
361                                                   361 
362 static struct isa_driver snd_gusmax_driver = {    362 static struct isa_driver snd_gusmax_driver = {
363         .match          = snd_gusmax_match,       363         .match          = snd_gusmax_match,
364         .probe          = snd_gusmax_probe,       364         .probe          = snd_gusmax_probe,
365         .remove         = __devexit_p(snd_gusm    365         .remove         = __devexit_p(snd_gusmax_remove),
366         /* FIXME: suspend/resume */               366         /* FIXME: suspend/resume */
367         .driver         = {                       367         .driver         = {
368                 .name   = DEV_NAME                368                 .name   = DEV_NAME
369         },                                        369         },
370 };                                                370 };
371                                                   371 
372 static int __init alsa_card_gusmax_init(void)     372 static int __init alsa_card_gusmax_init(void)
373 {                                                 373 {
374         return isa_register_driver(&snd_gusmax    374         return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
375 }                                                 375 }
376                                                   376 
377 static void __exit alsa_card_gusmax_exit(void)    377 static void __exit alsa_card_gusmax_exit(void)
378 {                                                 378 {
379         isa_unregister_driver(&snd_gusmax_driv    379         isa_unregister_driver(&snd_gusmax_driver);
380 }                                                 380 }
381                                                   381 
382 module_init(alsa_card_gusmax_init)                382 module_init(alsa_card_gusmax_init)
383 module_exit(alsa_card_gusmax_exit)                383 module_exit(alsa_card_gusmax_exit)
384                                                   384 
  This page was automatically generated by the LXR engine.