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