Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Driver for Aztech Sound Galaxy cards |
| 3 | * Copyright (c) by Christopher Butler <chrisb@sandy.force9.co.uk. |
| 4 | * |
| 5 | * I don't have documentation for this card, I based this driver on the |
| 6 | * driver for OSS/Free included in the kernel source (drivers/sound/sgalaxy.c) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <sound/driver.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/init.h> |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 26 | #include <linux/err.h> |
| 27 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/delay.h> |
| 29 | #include <linux/time.h> |
| 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/moduleparam.h> |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 32 | #include <asm/dma.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <sound/core.h> |
| 34 | #include <sound/sb.h> |
| 35 | #include <sound/ad1848.h> |
| 36 | #include <sound/control.h> |
| 37 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
| 38 | #define SNDRV_LEGACY_FIND_FREE_DMA |
| 39 | #include <sound/initval.h> |
| 40 | |
| 41 | MODULE_AUTHOR("Christopher Butler <chrisb@sandy.force9.co.uk>"); |
| 42 | MODULE_DESCRIPTION("Aztech Sound Galaxy"); |
| 43 | MODULE_LICENSE("GPL"); |
| 44 | MODULE_SUPPORTED_DEVICE("{{Aztech Systems,Sound Galaxy}}"); |
| 45 | |
| 46 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 47 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 48 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
| 49 | static long sbport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240 */ |
| 50 | static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x530,0xe80,0xf40,0x604 */ |
| 51 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 7,9,10,11 */ |
| 52 | static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */ |
| 53 | |
| 54 | module_param_array(index, int, NULL, 0444); |
| 55 | MODULE_PARM_DESC(index, "Index value for Sound Galaxy soundcard."); |
| 56 | module_param_array(id, charp, NULL, 0444); |
| 57 | MODULE_PARM_DESC(id, "ID string for Sound Galaxy soundcard."); |
| 58 | module_param_array(sbport, long, NULL, 0444); |
| 59 | MODULE_PARM_DESC(sbport, "Port # for Sound Galaxy SB driver."); |
| 60 | module_param_array(wssport, long, NULL, 0444); |
| 61 | MODULE_PARM_DESC(wssport, "Port # for Sound Galaxy WSS driver."); |
| 62 | module_param_array(irq, int, NULL, 0444); |
| 63 | MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); |
| 64 | module_param_array(dma1, int, NULL, 0444); |
| 65 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); |
| 66 | |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 67 | static struct platform_device *devices[SNDRV_CARDS]; |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define SGALAXY_AUXC_LEFT 18 |
| 70 | #define SGALAXY_AUXC_RIGHT 19 |
| 71 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 72 | #define PFX "sgalaxy: " |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | /* |
| 75 | |
| 76 | */ |
| 77 | |
| 78 | #define AD1848P1( port, x ) ( port + c_d_c_AD1848##x ) |
| 79 | |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 80 | /* from lowlevel/sb/sb.c - to avoid having to allocate a struct snd_sb for the */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* short time we actually need it.. */ |
| 82 | |
| 83 | static int snd_sgalaxy_sbdsp_reset(unsigned long port) |
| 84 | { |
| 85 | int i; |
| 86 | |
| 87 | outb(1, SBP1(port, RESET)); |
| 88 | udelay(10); |
| 89 | outb(0, SBP1(port, RESET)); |
| 90 | udelay(30); |
| 91 | for (i = 0; i < 1000 && !(inb(SBP1(port, DATA_AVAIL)) & 0x80); i++); |
| 92 | if (inb(SBP1(port, READ)) != 0xaa) { |
| 93 | snd_printd("sb_reset: failed at 0x%lx!!!\n", port); |
| 94 | return -ENODEV; |
| 95 | } |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | static int __init snd_sgalaxy_sbdsp_command(unsigned long port, unsigned char val) |
| 100 | { |
| 101 | int i; |
| 102 | |
| 103 | for (i = 10000; i; i--) |
| 104 | if ((inb(SBP1(port, STATUS)) & 0x80) == 0) { |
| 105 | outb(val, SBP1(port, COMMAND)); |
| 106 | return 1; |
| 107 | } |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
| 113 | { |
| 114 | return IRQ_NONE; |
| 115 | } |
| 116 | |
| 117 | static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) |
| 118 | { |
| 119 | static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, |
| 120 | 0x10, 0x18, 0x20, -1, -1, -1, -1}; |
| 121 | static int dma_bits[] = {1, 2, 0, 3}; |
| 122 | int tmp, tmp1; |
| 123 | |
| 124 | if ((tmp = inb(port + 3)) == 0xff) |
| 125 | { |
| 126 | snd_printdd("I/O address dead (0x%lx)\n", port); |
| 127 | return 0; |
| 128 | } |
| 129 | #if 0 |
| 130 | snd_printdd("WSS signature = 0x%x\n", tmp); |
| 131 | #endif |
| 132 | |
| 133 | if ((tmp & 0x3f) != 0x04 && |
| 134 | (tmp & 0x3f) != 0x0f && |
| 135 | (tmp & 0x3f) != 0x00) { |
| 136 | snd_printdd("No WSS signature detected on port 0x%lx\n", |
| 137 | port + 3); |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | #if 0 |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 142 | snd_printdd(PFX "setting up IRQ/DMA for WSS\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #endif |
| 144 | |
| 145 | /* initialize IRQ for WSS codec */ |
| 146 | tmp = interrupt_bits[irq % 16]; |
| 147 | if (tmp < 0) |
| 148 | return -EINVAL; |
| 149 | |
| 150 | if (request_irq(irq, snd_sgalaxy_dummy_interrupt, SA_INTERRUPT, "sgalaxy", NULL)) { |
| 151 | snd_printk(KERN_ERR "sgalaxy: can't grab irq %d\n", irq); |
| 152 | return -EIO; |
| 153 | } |
| 154 | |
| 155 | outb(tmp | 0x40, port); |
| 156 | tmp1 = dma_bits[dma % 4]; |
| 157 | outb(tmp | tmp1, port); |
| 158 | |
| 159 | free_irq(irq, NULL); |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static int __init snd_sgalaxy_detect(int dev, int irq, int dma) |
| 165 | { |
| 166 | #if 0 |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 167 | snd_printdd(PFX "switching to WSS mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | #endif |
| 169 | |
| 170 | /* switch to WSS mode */ |
| 171 | snd_sgalaxy_sbdsp_reset(sbport[dev]); |
| 172 | |
| 173 | snd_sgalaxy_sbdsp_command(sbport[dev], 9); |
| 174 | snd_sgalaxy_sbdsp_command(sbport[dev], 0); |
| 175 | |
| 176 | udelay(400); |
| 177 | return snd_sgalaxy_setup_wss(wssport[dev], irq, dma); |
| 178 | } |
| 179 | |
| 180 | static struct ad1848_mix_elem snd_sgalaxy_controls[] = { |
| 181 | AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7, 7, 1, 1), |
| 182 | AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) |
| 183 | }; |
| 184 | |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 185 | static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | { |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 187 | struct snd_card *card = chip->card; |
| 188 | struct snd_ctl_elem_id id1, id2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | unsigned int idx; |
| 190 | int err; |
| 191 | |
| 192 | memset(&id1, 0, sizeof(id1)); |
| 193 | memset(&id2, 0, sizeof(id2)); |
| 194 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 195 | /* reassign AUX0 to LINE */ |
| 196 | strcpy(id1.name, "Aux Playback Switch"); |
| 197 | strcpy(id2.name, "Line Playback Switch"); |
| 198 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) |
| 199 | return err; |
| 200 | strcpy(id1.name, "Aux Playback Volume"); |
| 201 | strcpy(id2.name, "Line Playback Volume"); |
| 202 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) |
| 203 | return err; |
| 204 | /* reassign AUX1 to FM */ |
| 205 | strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; |
| 206 | strcpy(id2.name, "FM Playback Switch"); |
| 207 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) |
| 208 | return err; |
| 209 | strcpy(id1.name, "Aux Playback Volume"); |
| 210 | strcpy(id2.name, "FM Playback Volume"); |
| 211 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) |
| 212 | return err; |
| 213 | /* build AUX2 input */ |
| 214 | for (idx = 0; idx < ARRAY_SIZE(snd_sgalaxy_controls); idx++) { |
| 215 | if ((err = snd_ad1848_add_ctl_elem(chip, &snd_sgalaxy_controls[idx])) < 0) |
| 216 | return err; |
| 217 | } |
| 218 | return 0; |
| 219 | } |
| 220 | |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 221 | static int __init snd_sgalaxy_probe(struct platform_device *devptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 223 | int dev = devptr->id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | static int possible_irqs[] = {7, 9, 10, 11, -1}; |
| 225 | static int possible_dmas[] = {1, 3, 0, -1}; |
| 226 | int err, xirq, xdma1; |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 227 | struct snd_card *card; |
| 228 | struct snd_ad1848 *chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | |
| 230 | if (sbport[dev] == SNDRV_AUTO_PORT) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 231 | snd_printk(KERN_ERR PFX "specify SB port\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | return -EINVAL; |
| 233 | } |
| 234 | if (wssport[dev] == SNDRV_AUTO_PORT) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 235 | snd_printk(KERN_ERR PFX "specify WSS port\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | return -EINVAL; |
| 237 | } |
| 238 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); |
| 239 | if (card == NULL) |
| 240 | return -ENOMEM; |
| 241 | |
| 242 | xirq = irq[dev]; |
| 243 | if (xirq == SNDRV_AUTO_IRQ) { |
| 244 | if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 245 | snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); |
| 246 | err = -EBUSY; |
| 247 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | xdma1 = dma1[dev]; |
| 251 | if (xdma1 == SNDRV_AUTO_DMA) { |
| 252 | if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 253 | snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); |
| 254 | err = -EBUSY; |
| 255 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 259 | if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) |
| 260 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
| 262 | if ((err = snd_ad1848_create(card, wssport[dev] + 4, |
| 263 | xirq, xdma1, |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 264 | AD1848_HW_DETECT, &chip)) < 0) |
| 265 | goto _err; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 266 | card->private_data = chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
| 268 | if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 269 | snd_printdd(PFX "error creating new ad1848 PCM device\n"); |
| 270 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | } |
| 272 | if ((err = snd_ad1848_mixer(chip)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 273 | snd_printdd(PFX "error creating new ad1848 mixer\n"); |
| 274 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 276 | if ((err = snd_sgalaxy_mixer(chip)) < 0) { |
| 277 | snd_printdd(PFX "the mixer rewrite failed\n"); |
| 278 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | strcpy(card->driver, "Sound Galaxy"); |
| 282 | strcpy(card->shortname, "Sound Galaxy"); |
| 283 | sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", |
| 284 | wssport[dev], xirq, xdma1); |
| 285 | |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 286 | snd_card_set_dev(card, &devptr->dev); |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 287 | |
| 288 | if ((err = snd_card_register(card)) < 0) |
| 289 | goto _err; |
| 290 | |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 291 | platform_set_drvdata(devptr, card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return 0; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 293 | |
| 294 | _err: |
| 295 | snd_card_free(card); |
| 296 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 299 | static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) |
| 300 | { |
| 301 | snd_card_free(platform_get_drvdata(devptr)); |
| 302 | platform_set_drvdata(devptr, NULL); |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | #ifdef CONFIG_PM |
| 307 | static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) |
| 308 | { |
| 309 | struct snd_card *card = platform_get_drvdata(pdev); |
| 310 | struct snd_ad1848 *chip = card->private_data; |
| 311 | |
| 312 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
| 313 | chip->suspend(chip); |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | static int snd_sgalaxy_resume(struct platform_device *pdev) |
| 318 | { |
| 319 | struct snd_card *card = platform_get_drvdata(pdev); |
| 320 | struct snd_ad1848 *chip = card->private_data; |
| 321 | |
| 322 | chip->resume(chip); |
| 323 | snd_ad1848_out(chip, SGALAXY_AUXC_LEFT, chip->image[SGALAXY_AUXC_LEFT]); |
| 324 | snd_ad1848_out(chip, SGALAXY_AUXC_RIGHT, chip->image[SGALAXY_AUXC_RIGHT]); |
| 325 | |
| 326 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 327 | return 0; |
| 328 | } |
| 329 | #endif |
| 330 | |
| 331 | #define SND_SGALAXY_DRIVER "snd_sgalaxy" |
| 332 | |
| 333 | static struct platform_driver snd_sgalaxy_driver = { |
| 334 | .probe = snd_sgalaxy_probe, |
| 335 | .remove = __devexit_p(snd_sgalaxy_remove), |
| 336 | #ifdef CONFIG_PM |
| 337 | .suspend = snd_sgalaxy_suspend, |
| 338 | .resume = snd_sgalaxy_resume, |
| 339 | #endif |
| 340 | .driver = { |
| 341 | .name = SND_SGALAXY_DRIVER |
| 342 | }, |
| 343 | }; |
| 344 | |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 345 | static void __init_or_module snd_sgalaxy_unregister_all(void) |
| 346 | { |
| 347 | int i; |
| 348 | |
| 349 | for (i = 0; i < ARRAY_SIZE(devices); ++i) |
| 350 | platform_device_unregister(devices[i]); |
| 351 | platform_driver_unregister(&snd_sgalaxy_driver); |
| 352 | } |
| 353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | static int __init alsa_card_sgalaxy_init(void) |
| 355 | { |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 356 | int i, cards, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 358 | err = platform_driver_register(&snd_sgalaxy_driver); |
| 359 | if (err < 0) |
| 360 | return err; |
| 361 | |
| 362 | cards = 0; |
| 363 | for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { |
| 364 | struct platform_device *device; |
| 365 | device = platform_device_register_simple(SND_SGALAXY_DRIVER, |
| 366 | i, NULL, 0); |
| 367 | if (IS_ERR(device)) { |
| 368 | err = PTR_ERR(device); |
| 369 | goto errout; |
| 370 | } |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 371 | devices[i] = device; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 372 | cards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | } |
| 374 | if (!cards) { |
| 375 | #ifdef MODULE |
| 376 | snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); |
| 377 | #endif |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 378 | err = -ENODEV; |
| 379 | goto errout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | return 0; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 382 | |
| 383 | errout: |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 384 | snd_sgalaxy_unregister_all(); |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 385 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | static void __exit alsa_card_sgalaxy_exit(void) |
| 389 | { |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 390 | snd_sgalaxy_unregister_all(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | module_init(alsa_card_sgalaxy_init) |
| 394 | module_exit(alsa_card_sgalaxy_exit) |