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