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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/init.h> |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 25 | #include <linux/err.h> |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 26 | #include <linux/isa.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/delay.h> |
| 28 | #include <linux/time.h> |
| 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/moduleparam.h> |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 31 | #include <asm/dma.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <sound/core.h> |
| 33 | #include <sound/sb.h> |
Krzysztof Helt | 760fc6b8 | 2008-07-31 21:10:47 +0200 | [diff] [blame] | 34 | #include <sound/wss.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <sound/control.h> |
| 36 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
| 37 | #define SNDRV_LEGACY_FIND_FREE_DMA |
| 38 | #include <sound/initval.h> |
| 39 | |
| 40 | MODULE_AUTHOR("Christopher Butler <chrisb@sandy.force9.co.uk>"); |
| 41 | MODULE_DESCRIPTION("Aztech Sound Galaxy"); |
| 42 | MODULE_LICENSE("GPL"); |
| 43 | MODULE_SUPPORTED_DEVICE("{{Aztech Systems,Sound Galaxy}}"); |
| 44 | |
| 45 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 46 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 47 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
| 48 | static long sbport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240 */ |
| 49 | static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x530,0xe80,0xf40,0x604 */ |
| 50 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 7,9,10,11 */ |
| 51 | static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */ |
| 52 | |
| 53 | module_param_array(index, int, NULL, 0444); |
| 54 | MODULE_PARM_DESC(index, "Index value for Sound Galaxy soundcard."); |
| 55 | module_param_array(id, charp, NULL, 0444); |
| 56 | MODULE_PARM_DESC(id, "ID string for Sound Galaxy soundcard."); |
| 57 | module_param_array(sbport, long, NULL, 0444); |
| 58 | MODULE_PARM_DESC(sbport, "Port # for Sound Galaxy SB driver."); |
| 59 | module_param_array(wssport, long, NULL, 0444); |
| 60 | MODULE_PARM_DESC(wssport, "Port # for Sound Galaxy WSS driver."); |
| 61 | module_param_array(irq, int, NULL, 0444); |
| 62 | MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); |
| 63 | module_param_array(dma1, int, NULL, 0444); |
| 64 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); |
| 65 | |
| 66 | #define SGALAXY_AUXC_LEFT 18 |
| 67 | #define SGALAXY_AUXC_RIGHT 19 |
| 68 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 69 | #define PFX "sgalaxy: " |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | /* |
| 72 | |
| 73 | */ |
| 74 | |
| 75 | #define AD1848P1( port, x ) ( port + c_d_c_AD1848##x ) |
| 76 | |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 77 | /* 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] | 78 | /* short time we actually need it.. */ |
| 79 | |
| 80 | static int snd_sgalaxy_sbdsp_reset(unsigned long port) |
| 81 | { |
| 82 | int i; |
| 83 | |
| 84 | outb(1, SBP1(port, RESET)); |
| 85 | udelay(10); |
| 86 | outb(0, SBP1(port, RESET)); |
| 87 | udelay(30); |
| 88 | for (i = 0; i < 1000 && !(inb(SBP1(port, DATA_AVAIL)) & 0x80); i++); |
| 89 | if (inb(SBP1(port, READ)) != 0xaa) { |
| 90 | snd_printd("sb_reset: failed at 0x%lx!!!\n", port); |
| 91 | return -ENODEV; |
| 92 | } |
| 93 | return 0; |
| 94 | } |
| 95 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 96 | static int __devinit snd_sgalaxy_sbdsp_command(unsigned long port, |
| 97 | unsigned char val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
| 99 | int i; |
| 100 | |
| 101 | for (i = 10000; i; i--) |
| 102 | if ((inb(SBP1(port, STATUS)) & 0x80) == 0) { |
| 103 | outb(val, SBP1(port, COMMAND)); |
| 104 | return 1; |
| 105 | } |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 110 | static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
| 112 | return IRQ_NONE; |
| 113 | } |
| 114 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 115 | static int __devinit snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | { |
| 117 | static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, |
| 118 | 0x10, 0x18, 0x20, -1, -1, -1, -1}; |
| 119 | static int dma_bits[] = {1, 2, 0, 3}; |
| 120 | int tmp, tmp1; |
| 121 | |
| 122 | if ((tmp = inb(port + 3)) == 0xff) |
| 123 | { |
| 124 | snd_printdd("I/O address dead (0x%lx)\n", port); |
| 125 | return 0; |
| 126 | } |
| 127 | #if 0 |
| 128 | snd_printdd("WSS signature = 0x%x\n", tmp); |
| 129 | #endif |
| 130 | |
| 131 | if ((tmp & 0x3f) != 0x04 && |
| 132 | (tmp & 0x3f) != 0x0f && |
| 133 | (tmp & 0x3f) != 0x00) { |
| 134 | snd_printdd("No WSS signature detected on port 0x%lx\n", |
| 135 | port + 3); |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | #if 0 |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 140 | snd_printdd(PFX "setting up IRQ/DMA for WSS\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | #endif |
| 142 | |
| 143 | /* initialize IRQ for WSS codec */ |
| 144 | tmp = interrupt_bits[irq % 16]; |
| 145 | if (tmp < 0) |
| 146 | return -EINVAL; |
| 147 | |
Thomas Gleixner | 65ca68b | 2006-07-01 19:29:46 -0700 | [diff] [blame] | 148 | if (request_irq(irq, snd_sgalaxy_dummy_interrupt, IRQF_DISABLED, "sgalaxy", NULL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | snd_printk(KERN_ERR "sgalaxy: can't grab irq %d\n", irq); |
| 150 | return -EIO; |
| 151 | } |
| 152 | |
| 153 | outb(tmp | 0x40, port); |
| 154 | tmp1 = dma_bits[dma % 4]; |
| 155 | outb(tmp | tmp1, port); |
| 156 | |
| 157 | free_irq(irq, NULL); |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 162 | static int __devinit snd_sgalaxy_detect(int dev, int irq, int dma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | { |
| 164 | #if 0 |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 165 | snd_printdd(PFX "switching to WSS mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #endif |
| 167 | |
| 168 | /* switch to WSS mode */ |
| 169 | snd_sgalaxy_sbdsp_reset(sbport[dev]); |
| 170 | |
| 171 | snd_sgalaxy_sbdsp_command(sbport[dev], 9); |
| 172 | snd_sgalaxy_sbdsp_command(sbport[dev], 0); |
| 173 | |
| 174 | udelay(400); |
| 175 | return snd_sgalaxy_setup_wss(wssport[dev], irq, dma); |
| 176 | } |
| 177 | |
Krzysztof Helt | 0c5e3e9 | 2008-07-31 21:06:46 +0200 | [diff] [blame] | 178 | static struct snd_kcontrol_new snd_sgalaxy_controls[] = { |
| 179 | WSS_DOUBLE("Aux Playback Switch", 0, |
| 180 | SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7, 7, 1, 1), |
| 181 | WSS_DOUBLE("Aux Playback Volume", 0, |
| 182 | SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
Krzysztof Helt | 241b3ee | 2008-07-31 21:04:37 +0200 | [diff] [blame] | 185 | static int __devinit snd_sgalaxy_mixer(struct snd_wss *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++) { |
Krzysztof Helt | 0c5e3e9 | 2008-07-31 21:06:46 +0200 | [diff] [blame] | 215 | err = snd_ctl_add(card, |
| 216 | snd_ctl_new1(&snd_sgalaxy_controls[idx], chip)); |
| 217 | if (err < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | return err; |
| 219 | } |
| 220 | return 0; |
| 221 | } |
| 222 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 223 | static int __devinit snd_sgalaxy_match(struct device *devptr, unsigned int dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 225 | if (!enable[dev]) |
| 226 | return 0; |
| 227 | if (sbport[dev] == SNDRV_AUTO_PORT) { |
| 228 | snd_printk(KERN_ERR PFX "specify SB port\n"); |
| 229 | return 0; |
| 230 | } |
| 231 | if (wssport[dev] == SNDRV_AUTO_PORT) { |
| 232 | snd_printk(KERN_ERR PFX "specify WSS port\n"); |
| 233 | return 0; |
| 234 | } |
| 235 | return 1; |
| 236 | } |
| 237 | |
| 238 | static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) |
| 239 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | static int possible_irqs[] = {7, 9, 10, 11, -1}; |
| 241 | static int possible_dmas[] = {1, 3, 0, -1}; |
| 242 | int err, xirq, xdma1; |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 243 | struct snd_card *card; |
Krzysztof Helt | 241b3ee | 2008-07-31 21:04:37 +0200 | [diff] [blame] | 244 | struct snd_wss *chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
Takashi Iwai | c95eadd | 2008-12-28 16:43:35 +0100 | [diff] [blame] | 246 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); |
| 247 | if (err < 0) |
| 248 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
| 250 | xirq = irq[dev]; |
| 251 | if (xirq == SNDRV_AUTO_IRQ) { |
| 252 | if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 253 | snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); |
| 254 | err = -EBUSY; |
| 255 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | xdma1 = dma1[dev]; |
| 259 | if (xdma1 == SNDRV_AUTO_DMA) { |
| 260 | if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 261 | snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); |
| 262 | err = -EBUSY; |
| 263 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 267 | if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) |
| 268 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
Krzysztof Helt | 760fc6b8 | 2008-07-31 21:10:47 +0200 | [diff] [blame] | 270 | err = snd_wss_create(card, wssport[dev] + 4, -1, |
| 271 | xirq, xdma1, -1, |
| 272 | WSS_HW_DETECT, 0, &chip); |
| 273 | if (err < 0) |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 274 | goto _err; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 275 | card->private_data = chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Krzysztof Helt | ead893c | 2008-07-31 21:09:32 +0200 | [diff] [blame] | 277 | err = snd_wss_pcm(chip, 0, NULL); |
| 278 | if (err < 0) { |
| 279 | snd_printdd(PFX "error creating new WSS PCM device\n"); |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 280 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
Krzysztof Helt | 5664daa | 2008-07-31 21:08:32 +0200 | [diff] [blame] | 282 | err = snd_wss_mixer(chip); |
| 283 | if (err < 0) { |
| 284 | snd_printdd(PFX "error creating new WSS mixer\n"); |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 285 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 287 | if ((err = snd_sgalaxy_mixer(chip)) < 0) { |
| 288 | snd_printdd(PFX "the mixer rewrite failed\n"); |
| 289 | goto _err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | strcpy(card->driver, "Sound Galaxy"); |
| 293 | strcpy(card->shortname, "Sound Galaxy"); |
| 294 | sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", |
| 295 | wssport[dev], xirq, xdma1); |
| 296 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 297 | snd_card_set_dev(card, devptr); |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 298 | |
| 299 | if ((err = snd_card_register(card)) < 0) |
| 300 | goto _err; |
| 301 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 302 | dev_set_drvdata(devptr, card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | return 0; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 304 | |
| 305 | _err: |
| 306 | snd_card_free(card); |
| 307 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 310 | static int __devexit snd_sgalaxy_remove(struct device *devptr, unsigned int dev) |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 311 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 312 | snd_card_free(dev_get_drvdata(devptr)); |
| 313 | dev_set_drvdata(devptr, NULL); |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | #ifdef CONFIG_PM |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 318 | static int snd_sgalaxy_suspend(struct device *pdev, unsigned int n, |
| 319 | pm_message_t state) |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 320 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 321 | struct snd_card *card = dev_get_drvdata(pdev); |
Krzysztof Helt | 241b3ee | 2008-07-31 21:04:37 +0200 | [diff] [blame] | 322 | struct snd_wss *chip = card->private_data; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 323 | |
| 324 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
| 325 | chip->suspend(chip); |
| 326 | return 0; |
| 327 | } |
| 328 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 329 | static int snd_sgalaxy_resume(struct device *pdev, unsigned int n) |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 330 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 331 | struct snd_card *card = dev_get_drvdata(pdev); |
Krzysztof Helt | 241b3ee | 2008-07-31 21:04:37 +0200 | [diff] [blame] | 332 | struct snd_wss *chip = card->private_data; |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 333 | |
| 334 | chip->resume(chip); |
Krzysztof Helt | 760fc6b8 | 2008-07-31 21:10:47 +0200 | [diff] [blame] | 335 | snd_wss_out(chip, SGALAXY_AUXC_LEFT, chip->image[SGALAXY_AUXC_LEFT]); |
| 336 | snd_wss_out(chip, SGALAXY_AUXC_RIGHT, chip->image[SGALAXY_AUXC_RIGHT]); |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 337 | |
| 338 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 339 | return 0; |
| 340 | } |
| 341 | #endif |
| 342 | |
Rene Herman | 83c51c0 | 2007-03-20 11:33:46 +0100 | [diff] [blame] | 343 | #define DEV_NAME "sgalaxy" |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 344 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 345 | static struct isa_driver snd_sgalaxy_driver = { |
| 346 | .match = snd_sgalaxy_match, |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 347 | .probe = snd_sgalaxy_probe, |
| 348 | .remove = __devexit_p(snd_sgalaxy_remove), |
| 349 | #ifdef CONFIG_PM |
| 350 | .suspend = snd_sgalaxy_suspend, |
| 351 | .resume = snd_sgalaxy_resume, |
| 352 | #endif |
| 353 | .driver = { |
Rene Herman | 83c51c0 | 2007-03-20 11:33:46 +0100 | [diff] [blame] | 354 | .name = DEV_NAME |
Takashi Iwai | feb158e6a | 2005-11-17 17:12:43 +0100 | [diff] [blame] | 355 | }, |
| 356 | }; |
| 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | static int __init alsa_card_sgalaxy_init(void) |
| 359 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 360 | return isa_register_driver(&snd_sgalaxy_driver, SNDRV_CARDS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static void __exit alsa_card_sgalaxy_exit(void) |
| 364 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 365 | isa_unregister_driver(&snd_sgalaxy_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | module_init(alsa_card_sgalaxy_init) |
| 369 | module_exit(alsa_card_sgalaxy_exit) |