Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | card-als100.c - driver for Avance Logic ALS100 based soundcards. |
| 5 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 6 | Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | Thanks to Pierfrancesco 'qM2' Passerini. |
| 9 | |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 10 | Generalised for soundcards based on DT-0196 and ALS-007 chips |
Jonathan Woithe | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 11 | by Jonathan Woithe <jwoithe@just42.net>: June 2002. |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/wait.h> |
| 17 | #include <linux/time.h> |
| 18 | #include <linux/pnp.h> |
Paul Gortmaker | 65a7721 | 2011-07-15 13:13:37 -0400 | [diff] [blame] | 19 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <sound/core.h> |
| 21 | #include <sound/initval.h> |
| 22 | #include <sound/mpu401.h> |
| 23 | #include <sound/opl3.h> |
| 24 | #include <sound/sb.h> |
| 25 | |
| 26 | #define PFX "als100: " |
| 27 | |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 28 | MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0"); |
| 29 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," |
| 30 | "{Avance Logic ALS-007}}" |
| 31 | "{{Avance Logic,ALS100 - PRO16PNP}," |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | "{Avance Logic,ALS110}," |
| 33 | "{Avance Logic,ALS120}," |
| 34 | "{Avance Logic,ALS200}," |
| 35 | "{3D Melody,MF1000}," |
| 36 | "{Digimate,3D Sound}," |
| 37 | "{Avance Logic,ALS120}," |
| 38 | "{RTL,RTL3000}}"); |
| 39 | |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 40 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); |
| 41 | MODULE_LICENSE("GPL"); |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 44 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
Rusty Russell | a67ff6a | 2011-12-15 13:49:36 +1030 | [diff] [blame] | 45 | static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 47 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 48 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 49 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ |
| 50 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ |
| 51 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ |
| 52 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ |
| 53 | |
| 54 | module_param_array(index, int, NULL, 0444); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 55 | MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | module_param_array(id, charp, NULL, 0444); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 57 | MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | module_param_array(enable, bool, NULL, 0444); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 59 | MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard."); |
| 60 | |
| 61 | MODULE_ALIAS("snd-dt019x"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | struct snd_card_als100 { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | struct pnp_dev *dev; |
| 65 | struct pnp_dev *devmpu; |
| 66 | struct pnp_dev *devopl; |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 67 | struct snd_sb *chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Arvind Yadav | 815cfec | 2017-08-17 15:36:20 +0530 | [diff] [blame] | 70 | static const struct pnp_card_device_id snd_als100_pnpids[] = { |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 71 | /* DT197A30 */ |
| 72 | { .id = "RWB1688", |
| 73 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, |
| 74 | .driver_data = SB_HW_DT019X }, |
| 75 | /* DT0196 / ALS-007 */ |
| 76 | { .id = "ALS0007", |
| 77 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, |
| 78 | .driver_data = SB_HW_DT019X }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | /* ALS100 - PRO16PNP */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 80 | { .id = "ALS0001", |
| 81 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, |
| 82 | .driver_data = SB_HW_ALS100 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | /* ALS110 - MF1000 - Digimate 3D Sound */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 84 | { .id = "ALS0110", |
| 85 | .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } }, |
| 86 | .driver_data = SB_HW_ALS100 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | /* ALS120 */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 88 | { .id = "ALS0120", |
| 89 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, |
| 90 | .driver_data = SB_HW_ALS100 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | /* ALS200 */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 92 | { .id = "ALS0200", |
| 93 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } }, |
| 94 | .driver_data = SB_HW_ALS100 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | /* ALS200 OEM */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 96 | { .id = "ALS0200", |
| 97 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } }, |
| 98 | .driver_data = SB_HW_ALS100 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* RTL3000 */ |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 100 | { .id = "RTL3000", |
| 101 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, |
| 102 | .driver_data = SB_HW_ALS100 }, |
| 103 | { .id = "" } /* end */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); |
| 107 | |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 108 | static int snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, |
| 109 | struct pnp_card_link *card, |
| 110 | const struct pnp_card_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
| 112 | struct pnp_dev *pdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | int err; |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); |
Rene Herman | 109c53f84 | 2007-11-30 17:59:25 +0100 | [diff] [blame] | 116 | if (acard->dev == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | return -ENODEV; |
Rene Herman | 109c53f84 | 2007-11-30 17:59:25 +0100 | [diff] [blame] | 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | acard->devmpu = pnp_request_card_device(card, id->devs[1].id, acard->dev); |
| 120 | acard->devopl = pnp_request_card_device(card, id->devs[2].id, acard->dev); |
| 121 | |
| 122 | pdev = acard->dev; |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | err = pnp_activate_dev(pdev); |
| 125 | if (err < 0) { |
| 126 | snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | return err; |
| 128 | } |
| 129 | port[dev] = pnp_port_start(pdev, 0); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 130 | if (id->driver_data == SB_HW_DT019X) |
| 131 | dma8[dev] = pnp_dma(pdev, 0); |
| 132 | else { |
| 133 | dma8[dev] = pnp_dma(pdev, 1); |
| 134 | dma16[dev] = pnp_dma(pdev, 0); |
| 135 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | irq[dev] = pnp_irq(pdev, 0); |
| 137 | |
| 138 | pdev = acard->devmpu; |
| 139 | if (pdev != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | err = pnp_activate_dev(pdev); |
| 141 | if (err < 0) |
| 142 | goto __mpu_error; |
| 143 | mpu_port[dev] = pnp_port_start(pdev, 0); |
| 144 | mpu_irq[dev] = pnp_irq(pdev, 0); |
| 145 | } else { |
| 146 | __mpu_error: |
| 147 | if (pdev) { |
| 148 | pnp_release_card_device(pdev); |
| 149 | snd_printk(KERN_ERR PFX "MPU401 pnp configure failure, skipping\n"); |
| 150 | } |
| 151 | acard->devmpu = NULL; |
| 152 | mpu_port[dev] = -1; |
| 153 | } |
| 154 | |
| 155 | pdev = acard->devopl; |
| 156 | if (pdev != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | err = pnp_activate_dev(pdev); |
| 158 | if (err < 0) |
| 159 | goto __fm_error; |
| 160 | fm_port[dev] = pnp_port_start(pdev, 0); |
| 161 | } else { |
| 162 | __fm_error: |
| 163 | if (pdev) { |
| 164 | pnp_release_card_device(pdev); |
| 165 | snd_printk(KERN_ERR PFX "OPL3 pnp configure failure, skipping\n"); |
| 166 | } |
| 167 | acard->devopl = NULL; |
| 168 | fm_port[dev] = -1; |
| 169 | } |
| 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | return 0; |
| 172 | } |
| 173 | |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 174 | static int snd_card_als100_probe(int dev, |
| 175 | struct pnp_card_link *pcard, |
| 176 | const struct pnp_card_device_id *pid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | { |
| 178 | int error; |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 179 | struct snd_sb *chip; |
| 180 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | struct snd_card_als100 *acard; |
Takashi Iwai | 11ff5c6 | 2005-11-17 14:42:36 +0100 | [diff] [blame] | 182 | struct snd_opl3 *opl3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Takashi Iwai | 4323cc4 | 2014-01-29 13:03:56 +0100 | [diff] [blame] | 184 | error = snd_card_new(&pcard->card->dev, |
| 185 | index[dev], id[dev], THIS_MODULE, |
| 186 | sizeof(struct snd_card_als100), &card); |
Takashi Iwai | c95eadd | 2008-12-28 16:43:35 +0100 | [diff] [blame] | 187 | if (error < 0) |
| 188 | return error; |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 189 | acard = card->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
| 191 | if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { |
| 192 | snd_card_free(card); |
| 193 | return error; |
| 194 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 196 | if (pid->driver_data == SB_HW_DT019X) |
| 197 | dma16[dev] = -1; |
| 198 | |
| 199 | error = snd_sbdsp_create(card, port[dev], irq[dev], |
| 200 | snd_sb16dsp_interrupt, |
| 201 | dma8[dev], dma16[dev], |
| 202 | pid->driver_data, |
| 203 | &chip); |
| 204 | if (error < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | snd_card_free(card); |
| 206 | return error; |
| 207 | } |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 208 | acard->chip = chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 210 | if (pid->driver_data == SB_HW_DT019X) { |
| 211 | strcpy(card->driver, "DT-019X"); |
| 212 | strcpy(card->shortname, "Diamond Tech. DT-019X"); |
Arnd Bergmann | 8a46363 | 2017-07-18 13:48:04 +0200 | [diff] [blame] | 213 | snprintf(card->longname, sizeof(card->longname), |
| 214 | "Diamond Tech. DT-019X, %s at 0x%lx, irq %d, dma %d", |
| 215 | chip->name, chip->port, irq[dev], dma8[dev]); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 216 | } else { |
| 217 | strcpy(card->driver, "ALS100"); |
| 218 | strcpy(card->shortname, "Avance Logic ALS100"); |
Arnd Bergmann | 8a46363 | 2017-07-18 13:48:04 +0200 | [diff] [blame] | 219 | snprintf(card->longname, sizeof(card->longname), |
| 220 | "Avance Logic ALS100, %s at 0x%lx, irq %d, dma %d&%d", |
| 221 | chip->name, chip->port, irq[dev], dma8[dev], |
| 222 | dma16[dev]); |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Lars-Peter Clausen | 92533f1 | 2015-01-02 12:24:42 +0100 | [diff] [blame] | 225 | if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | snd_card_free(card); |
| 227 | return error; |
| 228 | } |
| 229 | |
| 230 | if ((error = snd_sbmixer_new(chip)) < 0) { |
| 231 | snd_card_free(card); |
| 232 | return error; |
| 233 | } |
| 234 | |
| 235 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 236 | int mpu_type = MPU401_HW_ALS100; |
| 237 | |
| 238 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) |
| 239 | mpu_irq[dev] = -1; |
| 240 | |
| 241 | if (pid->driver_data == SB_HW_DT019X) |
| 242 | mpu_type = MPU401_HW_MPU401; |
| 243 | |
| 244 | if (snd_mpu401_uart_new(card, 0, |
| 245 | mpu_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | mpu_port[dev], 0, |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 247 | mpu_irq[dev], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | NULL) < 0) |
| 249 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); |
| 250 | } |
| 251 | |
| 252 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { |
| 253 | if (snd_opl3_create(card, |
| 254 | fm_port[dev], fm_port[dev] + 2, |
| 255 | OPL3_HW_AUTO, 0, &opl3) < 0) { |
| 256 | snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", |
| 257 | fm_port[dev], fm_port[dev] + 2); |
| 258 | } else { |
| 259 | if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { |
| 260 | snd_card_free(card); |
| 261 | return error; |
| 262 | } |
| 263 | if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { |
| 264 | snd_card_free(card); |
| 265 | return error; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if ((error = snd_card_register(card)) < 0) { |
| 271 | snd_card_free(card); |
| 272 | return error; |
| 273 | } |
| 274 | pnp_set_card_drvdata(pcard, card); |
| 275 | return 0; |
| 276 | } |
| 277 | |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 278 | static unsigned int als100_devices; |
Bjorn Helgaas | 51427ec | 2006-03-27 01:17:09 -0800 | [diff] [blame] | 279 | |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 280 | static int snd_als100_pnp_detect(struct pnp_card_link *card, |
| 281 | const struct pnp_card_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
| 283 | static int dev; |
| 284 | int res; |
| 285 | |
| 286 | for ( ; dev < SNDRV_CARDS; dev++) { |
| 287 | if (!enable[dev]) |
| 288 | continue; |
| 289 | res = snd_card_als100_probe(dev, card, id); |
| 290 | if (res < 0) |
| 291 | return res; |
| 292 | dev++; |
Bjorn Helgaas | 51427ec | 2006-03-27 01:17:09 -0800 | [diff] [blame] | 293 | als100_devices++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | return -ENODEV; |
| 297 | } |
| 298 | |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 299 | static void snd_als100_pnp_remove(struct pnp_card_link *pcard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | { |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 301 | snd_card_free(pnp_get_card_drvdata(pcard)); |
| 302 | pnp_set_card_drvdata(pcard, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 305 | #ifdef CONFIG_PM |
| 306 | static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) |
| 307 | { |
| 308 | struct snd_card *card = pnp_get_card_drvdata(pcard); |
| 309 | struct snd_card_als100 *acard = card->private_data; |
| 310 | struct snd_sb *chip = acard->chip; |
| 311 | |
| 312 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 313 | snd_sbmixer_suspend(chip); |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | static int snd_als100_pnp_resume(struct pnp_card_link *pcard) |
| 318 | { |
| 319 | struct snd_card *card = pnp_get_card_drvdata(pcard); |
| 320 | struct snd_card_als100 *acard = card->private_data; |
| 321 | struct snd_sb *chip = acard->chip; |
| 322 | |
| 323 | snd_sbdsp_reset(chip); |
| 324 | snd_sbmixer_resume(chip); |
| 325 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 326 | return 0; |
| 327 | } |
| 328 | #endif |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | static struct pnp_card_driver als100_pnpc_driver = { |
| 331 | .flags = PNP_DRIVER_RES_DISABLE, |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 332 | .name = "als100", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | .id_table = snd_als100_pnpids, |
| 334 | .probe = snd_als100_pnp_detect, |
Bill Pemberton | 1bff292 | 2012-12-06 12:35:21 -0500 | [diff] [blame] | 335 | .remove = snd_als100_pnp_remove, |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 336 | #ifdef CONFIG_PM |
| 337 | .suspend = snd_als100_pnp_suspend, |
| 338 | .resume = snd_als100_pnp_resume, |
| 339 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | static int __init alsa_card_als100_init(void) |
| 343 | { |
Bjorn Helgaas | 51427ec | 2006-03-27 01:17:09 -0800 | [diff] [blame] | 344 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Bjorn Helgaas | 51427ec | 2006-03-27 01:17:09 -0800 | [diff] [blame] | 346 | err = pnp_register_card_driver(&als100_pnpc_driver); |
| 347 | if (err) |
| 348 | return err; |
| 349 | |
| 350 | if (!als100_devices) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | pnp_unregister_card_driver(&als100_pnpc_driver); |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 352 | #ifdef MODULE |
Krzysztof Helt | 14ff3e7 | 2009-12-10 20:39:28 +0100 | [diff] [blame] | 353 | snd_printk(KERN_ERR "no Avance Logic based soundcards found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | #endif |
Takashi Iwai | 480615f | 2005-11-17 17:03:53 +0100 | [diff] [blame] | 355 | return -ENODEV; |
| 356 | } |
| 357 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | static void __exit alsa_card_als100_exit(void) |
| 361 | { |
| 362 | pnp_unregister_card_driver(&als100_pnpc_driver); |
| 363 | } |
| 364 | |
| 365 | module_init(alsa_card_als100_init) |
| 366 | module_exit(alsa_card_als100_exit) |