Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | card-opti92x-ad1848.c - driver for OPTi 82c92x based soundcards. |
| 3 | Copyright (C) 1998-2000 by Massimo Piccioni <dafastidio@libero.it> |
| 4 | |
| 5 | Part of this code was developed at the Italian Ministry of Air Defence, |
| 6 | Sixth Division (oh, che pace ...), Rome. |
| 7 | |
| 8 | Thanks to Maria Grazia Pollarini, Salvatore Vassallo. |
| 9 | |
| 10 | This program is free software; you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation; either version 2 of the License, or |
| 13 | (at your option) any later version. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program; if not, write to the Free Software |
| 22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 27 | #include <linux/err.h> |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 28 | #include <linux/isa.h> |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 29 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/slab.h> |
| 31 | #include <linux/pnp.h> |
| 32 | #include <linux/moduleparam.h> |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 33 | #include <asm/io.h> |
| 34 | #include <asm/dma.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <sound/core.h> |
Krzysztof Helt | 61ef19d | 2008-07-31 21:02:42 +0200 | [diff] [blame] | 36 | #include <sound/wss.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <sound/mpu401.h> |
| 38 | #include <sound/opl3.h> |
| 39 | #ifndef OPTi93X |
| 40 | #include <sound/opl4.h> |
| 41 | #endif |
| 42 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
| 43 | #define SNDRV_LEGACY_FIND_FREE_DMA |
| 44 | #include <sound/initval.h> |
| 45 | |
| 46 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); |
| 47 | MODULE_LICENSE("GPL"); |
| 48 | #ifdef OPTi93X |
| 49 | MODULE_DESCRIPTION("OPTi93X"); |
| 50 | MODULE_SUPPORTED_DEVICE("{{OPTi,82C931/3}}"); |
| 51 | #else /* OPTi93X */ |
| 52 | #ifdef CS4231 |
| 53 | MODULE_DESCRIPTION("OPTi92X - CS4231"); |
| 54 | MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (CS4231)}," |
| 55 | "{OPTi,82C925 (CS4231)}}"); |
| 56 | #else /* CS4231 */ |
| 57 | MODULE_DESCRIPTION("OPTi92X - AD1848"); |
| 58 | MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)}," |
| 59 | "{OPTi,82C925 (AD1848)}," |
| 60 | "{OAK,Mozart}}"); |
| 61 | #endif /* CS4231 */ |
| 62 | #endif /* OPTi93X */ |
| 63 | |
| 64 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ |
| 65 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ |
| 66 | //static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ |
Rene Herman | 51f6baa | 2008-07-18 11:15:12 +0200 | [diff] [blame] | 67 | #ifdef CONFIG_PNP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | static int isapnp = 1; /* Enable ISA PnP detection */ |
Rene Herman | 51f6baa | 2008-07-18 11:15:12 +0200 | [diff] [blame] | 69 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | static long port = SNDRV_DEFAULT_PORT1; /* 0x530,0xe80,0xf40,0x604 */ |
| 71 | static long mpu_port = SNDRV_DEFAULT_PORT1; /* 0x300,0x310,0x320,0x330 */ |
| 72 | static long fm_port = SNDRV_DEFAULT_PORT1; /* 0x388 */ |
| 73 | static int irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10,11 */ |
| 74 | static int mpu_irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10 */ |
| 75 | static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ |
| 76 | #if defined(CS4231) || defined(OPTi93X) |
| 77 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ |
| 78 | #endif /* CS4231 || OPTi93X */ |
| 79 | |
| 80 | module_param(index, int, 0444); |
| 81 | MODULE_PARM_DESC(index, "Index value for opti9xx based soundcard."); |
| 82 | module_param(id, charp, 0444); |
| 83 | MODULE_PARM_DESC(id, "ID string for opti9xx based soundcard."); |
| 84 | //module_param(enable, bool, 0444); |
| 85 | //MODULE_PARM_DESC(enable, "Enable opti9xx soundcard."); |
Rene Herman | 51f6baa | 2008-07-18 11:15:12 +0200 | [diff] [blame] | 86 | #ifdef CONFIG_PNP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | module_param(isapnp, bool, 0444); |
| 88 | MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); |
Rene Herman | 51f6baa | 2008-07-18 11:15:12 +0200 | [diff] [blame] | 89 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | module_param(port, long, 0444); |
| 91 | MODULE_PARM_DESC(port, "WSS port # for opti9xx driver."); |
| 92 | module_param(mpu_port, long, 0444); |
| 93 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for opti9xx driver."); |
| 94 | module_param(fm_port, long, 0444); |
| 95 | MODULE_PARM_DESC(fm_port, "FM port # for opti9xx driver."); |
| 96 | module_param(irq, int, 0444); |
| 97 | MODULE_PARM_DESC(irq, "WSS irq # for opti9xx driver."); |
| 98 | module_param(mpu_irq, int, 0444); |
| 99 | MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for opti9xx driver."); |
| 100 | module_param(dma1, int, 0444); |
| 101 | MODULE_PARM_DESC(dma1, "1st dma # for opti9xx driver."); |
| 102 | #if defined(CS4231) || defined(OPTi93X) |
| 103 | module_param(dma2, int, 0444); |
| 104 | MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver."); |
| 105 | #endif /* CS4231 || OPTi93X */ |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | #define OPTi9XX_HW_82C928 1 |
| 108 | #define OPTi9XX_HW_82C929 2 |
| 109 | #define OPTi9XX_HW_82C924 3 |
| 110 | #define OPTi9XX_HW_82C925 4 |
| 111 | #define OPTi9XX_HW_82C930 5 |
| 112 | #define OPTi9XX_HW_82C931 6 |
| 113 | #define OPTi9XX_HW_82C933 7 |
| 114 | #define OPTi9XX_HW_LAST OPTi9XX_HW_82C933 |
| 115 | |
| 116 | #define OPTi9XX_MC_REG(n) n |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | #ifdef OPTi93X |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #define OPTi93X_STATUS 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | #define OPTi93X_PORT(chip, r) ((chip)->port + OPTi93X_##r) |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #define OPTi93X_IRQ_PLAYBACK 0x04 |
| 124 | #define OPTi93X_IRQ_CAPTURE 0x08 |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | #endif /* OPTi93X */ |
| 127 | |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 128 | struct snd_opti9xx { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | unsigned short hardware; |
| 130 | unsigned char password; |
| 131 | char name[7]; |
| 132 | |
| 133 | unsigned long mc_base; |
| 134 | struct resource *res_mc_base; |
| 135 | unsigned long mc_base_size; |
| 136 | #ifdef OPTi93X |
| 137 | unsigned long mc_indir_index; |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 138 | struct snd_wss *codec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | #endif /* OPTi93X */ |
| 140 | unsigned long pwd_reg; |
| 141 | |
| 142 | spinlock_t lock; |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | #ifdef CONFIG_PNP |
| 147 | struct pnp_dev *dev; |
| 148 | struct pnp_dev *devmpu; |
| 149 | #endif /* CONFIG_PNP */ |
| 150 | }; |
| 151 | |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 152 | static int snd_opti9xx_pnp_is_probed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | #ifdef CONFIG_PNP |
| 155 | |
| 156 | static struct pnp_card_device_id snd_opti9xx_pnpids[] = { |
| 157 | #ifndef OPTi93X |
| 158 | /* OPTi 82C924 */ |
| 159 | { .id = "OPT0924", .devs = { { "OPT0000" }, { "OPT0002" } }, .driver_data = 0x0924 }, |
| 160 | /* OPTi 82C925 */ |
| 161 | { .id = "OPT0925", .devs = { { "OPT9250" }, { "OPT0002" } }, .driver_data = 0x0925 }, |
| 162 | #else |
| 163 | /* OPTi 82C931/3 */ |
| 164 | { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, .driver_data = 0x0931 }, |
| 165 | #endif /* OPTi93X */ |
| 166 | { .id = "" } |
| 167 | }; |
| 168 | |
| 169 | MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); |
| 170 | |
| 171 | #endif /* CONFIG_PNP */ |
| 172 | |
| 173 | #ifdef OPTi93X |
Rene Herman | 83c51c0 | 2007-03-20 11:33:46 +0100 | [diff] [blame] | 174 | #define DEV_NAME "opti93x" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | #else |
Rene Herman | 83c51c0 | 2007-03-20 11:33:46 +0100 | [diff] [blame] | 176 | #define DEV_NAME "opti92x" |
| 177 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | static char * snd_opti9xx_names[] = { |
| 180 | "unkown", |
| 181 | "82C928", "82C929", |
| 182 | "82C924", "82C925", |
| 183 | "82C930", "82C931", "82C933" |
| 184 | }; |
| 185 | |
| 186 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 187 | static long __devinit snd_legacy_find_free_ioport(long *port_table, long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
| 189 | while (*port_table != -1) { |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 190 | if (request_region(*port_table, size, "ALSA test")) { |
| 191 | release_region(*port_table, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | return *port_table; |
| 193 | } |
| 194 | port_table++; |
| 195 | } |
| 196 | return -1; |
| 197 | } |
| 198 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 199 | static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, |
| 200 | unsigned short hardware) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | { |
| 202 | static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; |
| 203 | |
| 204 | chip->hardware = hardware; |
| 205 | strcpy(chip->name, snd_opti9xx_names[hardware]); |
| 206 | |
| 207 | chip->mc_base_size = opti9xx_mc_size[hardware]; |
| 208 | |
| 209 | spin_lock_init(&chip->lock); |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | chip->irq = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
| 213 | switch (hardware) { |
| 214 | #ifndef OPTi93X |
| 215 | case OPTi9XX_HW_82C928: |
| 216 | case OPTi9XX_HW_82C929: |
| 217 | chip->mc_base = 0xf8c; |
| 218 | chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; |
| 219 | chip->pwd_reg = 3; |
| 220 | break; |
| 221 | |
| 222 | case OPTi9XX_HW_82C924: |
| 223 | case OPTi9XX_HW_82C925: |
| 224 | chip->mc_base = 0xf8c; |
| 225 | chip->password = 0xe5; |
| 226 | chip->pwd_reg = 3; |
| 227 | break; |
| 228 | #else /* OPTi93X */ |
| 229 | |
| 230 | case OPTi9XX_HW_82C930: |
| 231 | case OPTi9XX_HW_82C931: |
| 232 | case OPTi9XX_HW_82C933: |
| 233 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; |
| 234 | chip->mc_indir_index = 0xe0e; |
| 235 | chip->password = 0xe4; |
| 236 | chip->pwd_reg = 0; |
| 237 | break; |
| 238 | #endif /* OPTi93X */ |
| 239 | |
| 240 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 241 | snd_printk(KERN_ERR "chip %d not supported\n", hardware); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | return -ENODEV; |
| 243 | } |
| 244 | return 0; |
| 245 | } |
| 246 | |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 247 | static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | unsigned char reg) |
| 249 | { |
| 250 | unsigned long flags; |
| 251 | unsigned char retval = 0xff; |
| 252 | |
| 253 | spin_lock_irqsave(&chip->lock, flags); |
| 254 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 255 | |
| 256 | switch (chip->hardware) { |
| 257 | #ifndef OPTi93X |
| 258 | case OPTi9XX_HW_82C924: |
| 259 | case OPTi9XX_HW_82C925: |
| 260 | if (reg > 7) { |
| 261 | outb(reg, chip->mc_base + 8); |
| 262 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 263 | retval = inb(chip->mc_base + 9); |
| 264 | break; |
| 265 | } |
| 266 | |
| 267 | case OPTi9XX_HW_82C928: |
| 268 | case OPTi9XX_HW_82C929: |
| 269 | retval = inb(chip->mc_base + reg); |
| 270 | break; |
| 271 | #else /* OPTi93X */ |
| 272 | |
| 273 | case OPTi9XX_HW_82C930: |
| 274 | case OPTi9XX_HW_82C931: |
| 275 | case OPTi9XX_HW_82C933: |
| 276 | outb(reg, chip->mc_indir_index); |
| 277 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 278 | retval = inb(chip->mc_indir_index + 1); |
| 279 | break; |
| 280 | #endif /* OPTi93X */ |
| 281 | |
| 282 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 283 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | spin_unlock_irqrestore(&chip->lock, flags); |
| 287 | return retval; |
| 288 | } |
| 289 | |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 290 | static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | unsigned char value) |
| 292 | { |
| 293 | unsigned long flags; |
| 294 | |
| 295 | spin_lock_irqsave(&chip->lock, flags); |
| 296 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 297 | |
| 298 | switch (chip->hardware) { |
| 299 | #ifndef OPTi93X |
| 300 | case OPTi9XX_HW_82C924: |
| 301 | case OPTi9XX_HW_82C925: |
| 302 | if (reg > 7) { |
| 303 | outb(reg, chip->mc_base + 8); |
| 304 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 305 | outb(value, chip->mc_base + 9); |
| 306 | break; |
| 307 | } |
| 308 | |
| 309 | case OPTi9XX_HW_82C928: |
| 310 | case OPTi9XX_HW_82C929: |
| 311 | outb(value, chip->mc_base + reg); |
| 312 | break; |
| 313 | #else /* OPTi93X */ |
| 314 | |
| 315 | case OPTi9XX_HW_82C930: |
| 316 | case OPTi9XX_HW_82C931: |
| 317 | case OPTi9XX_HW_82C933: |
| 318 | outb(reg, chip->mc_indir_index); |
| 319 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 320 | outb(value, chip->mc_indir_index + 1); |
| 321 | break; |
| 322 | #endif /* OPTi93X */ |
| 323 | |
| 324 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 325 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | spin_unlock_irqrestore(&chip->lock, flags); |
| 329 | } |
| 330 | |
| 331 | |
| 332 | #define snd_opti9xx_write_mask(chip, reg, value, mask) \ |
| 333 | snd_opti9xx_write(chip, reg, \ |
| 334 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) |
| 335 | |
| 336 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 337 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, |
| 338 | long wss_base, |
| 339 | int irq, int dma1, int dma2, |
| 340 | long mpu_port, int mpu_irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
| 342 | unsigned char wss_base_bits; |
| 343 | unsigned char irq_bits; |
| 344 | unsigned char dma_bits; |
| 345 | unsigned char mpu_port_bits = 0; |
| 346 | unsigned char mpu_irq_bits; |
| 347 | |
| 348 | switch (chip->hardware) { |
| 349 | #ifndef OPTi93X |
| 350 | case OPTi9XX_HW_82C924: |
| 351 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); |
| 352 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); |
| 353 | |
| 354 | case OPTi9XX_HW_82C925: |
| 355 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); |
| 356 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); |
| 357 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); |
| 358 | #ifdef CS4231 |
| 359 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); |
| 360 | #else |
| 361 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); |
| 362 | #endif /* CS4231 */ |
| 363 | break; |
| 364 | |
| 365 | case OPTi9XX_HW_82C928: |
| 366 | case OPTi9XX_HW_82C929: |
| 367 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); |
| 368 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); |
| 369 | /* |
| 370 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xa2, 0xae); |
| 371 | */ |
| 372 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c); |
| 373 | #ifdef CS4231 |
| 374 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); |
| 375 | #else |
| 376 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); |
| 377 | #endif /* CS4231 */ |
| 378 | break; |
| 379 | |
| 380 | #else /* OPTi93X */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | case OPTi9XX_HW_82C931: |
| 382 | case OPTi9XX_HW_82C933: |
Krzysztof Helt | 3ae5f36 | 2008-06-08 07:57:53 +0200 | [diff] [blame] | 383 | /* |
Krzysztof Helt | f81b953 | 2007-10-16 14:54:37 +0200 | [diff] [blame] | 384 | * The BTC 1817DW has QS1000 wavetable which is connected |
| 385 | * to the serial digital input of the OPTI931. |
| 386 | */ |
| 387 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(21), 0x82, 0xff); |
| 388 | /* |
| 389 | * This bit sets OPTI931 to automaticaly select FM |
| 390 | * or digital input signal. |
| 391 | */ |
| 392 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(26), 0x01, 0x01); |
Krzysztof Helt | 3ae5f36 | 2008-06-08 07:57:53 +0200 | [diff] [blame] | 393 | case OPTi9XX_HW_82C930: /* FALL THROUGH */ |
| 394 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03); |
| 395 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff); |
| 396 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x10 | |
| 397 | (chip->hardware == OPTi9XX_HW_82C930 ? 0x00 : 0x04), |
| 398 | 0x34); |
| 399 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x20, 0xbf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | break; |
| 401 | #endif /* OPTi93X */ |
| 402 | |
| 403 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 404 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | return -EINVAL; |
| 406 | } |
| 407 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 408 | switch (wss_base) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | case 0x530: |
| 410 | wss_base_bits = 0x00; |
| 411 | break; |
| 412 | case 0x604: |
| 413 | wss_base_bits = 0x03; |
| 414 | break; |
| 415 | case 0xe80: |
| 416 | wss_base_bits = 0x01; |
| 417 | break; |
| 418 | case 0xf40: |
| 419 | wss_base_bits = 0x02; |
| 420 | break; |
| 421 | default: |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 422 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", wss_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | goto __skip_base; |
| 424 | } |
| 425 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); |
| 426 | |
| 427 | __skip_base: |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 428 | switch (irq) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | //#ifdef OPTi93X |
| 430 | case 5: |
| 431 | irq_bits = 0x05; |
| 432 | break; |
| 433 | //#endif /* OPTi93X */ |
| 434 | case 7: |
| 435 | irq_bits = 0x01; |
| 436 | break; |
| 437 | case 9: |
| 438 | irq_bits = 0x02; |
| 439 | break; |
| 440 | case 10: |
| 441 | irq_bits = 0x03; |
| 442 | break; |
| 443 | case 11: |
| 444 | irq_bits = 0x04; |
| 445 | break; |
| 446 | default: |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 447 | snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | goto __skip_resources; |
| 449 | } |
| 450 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 451 | switch (dma1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | case 0: |
| 453 | dma_bits = 0x01; |
| 454 | break; |
| 455 | case 1: |
| 456 | dma_bits = 0x02; |
| 457 | break; |
| 458 | case 3: |
| 459 | dma_bits = 0x03; |
| 460 | break; |
| 461 | default: |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 462 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | goto __skip_resources; |
| 464 | } |
| 465 | |
| 466 | #if defined(CS4231) || defined(OPTi93X) |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 467 | if (dma1 == dma2) { |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 468 | snd_printk(KERN_ERR "don't want to share dmas\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | return -EBUSY; |
| 470 | } |
| 471 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 472 | switch (dma2) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | case 0: |
| 474 | case 1: |
| 475 | break; |
| 476 | default: |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 477 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | goto __skip_resources; |
| 479 | } |
| 480 | dma_bits |= 0x04; |
| 481 | #endif /* CS4231 || OPTi93X */ |
| 482 | |
| 483 | #ifndef OPTi93X |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 484 | outb(irq_bits << 3 | dma_bits, wss_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | #else /* OPTi93X */ |
| 486 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); |
| 487 | #endif /* OPTi93X */ |
| 488 | |
| 489 | __skip_resources: |
| 490 | if (chip->hardware > OPTi9XX_HW_82C928) { |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 491 | switch (mpu_port) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | case 0: |
| 493 | case -1: |
| 494 | break; |
| 495 | case 0x300: |
| 496 | mpu_port_bits = 0x03; |
| 497 | break; |
| 498 | case 0x310: |
| 499 | mpu_port_bits = 0x02; |
| 500 | break; |
| 501 | case 0x320: |
| 502 | mpu_port_bits = 0x01; |
| 503 | break; |
| 504 | case 0x330: |
| 505 | mpu_port_bits = 0x00; |
| 506 | break; |
| 507 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 508 | snd_printk(KERN_WARNING |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 509 | "MPU-401 port 0x%lx not valid\n", mpu_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | goto __skip_mpu; |
| 511 | } |
| 512 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 513 | switch (mpu_irq) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | case 5: |
| 515 | mpu_irq_bits = 0x02; |
| 516 | break; |
| 517 | case 7: |
| 518 | mpu_irq_bits = 0x03; |
| 519 | break; |
| 520 | case 9: |
| 521 | mpu_irq_bits = 0x00; |
| 522 | break; |
| 523 | case 10: |
| 524 | mpu_irq_bits = 0x01; |
| 525 | break; |
| 526 | default: |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 527 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 528 | mpu_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | goto __skip_mpu; |
| 530 | } |
| 531 | |
| 532 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 533 | (mpu_port <= 0) ? 0x00 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, |
| 535 | 0xf8); |
| 536 | } |
| 537 | __skip_mpu: |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | #ifdef OPTi93X |
| 543 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 544 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | { |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 546 | struct snd_wss *codec = dev_id; |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 547 | struct snd_opti9xx *chip = codec->card->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | unsigned char status; |
| 549 | |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 550 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) |
| 552 | snd_pcm_period_elapsed(codec->playback_substream); |
| 553 | if ((status & OPTi93X_IRQ_CAPTURE) && codec->capture_substream) { |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 554 | snd_wss_overrange(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | snd_pcm_period_elapsed(codec->capture_substream); |
| 556 | } |
| 557 | outb(0x00, OPTi93X_PORT(codec, STATUS)); |
| 558 | return IRQ_HANDLED; |
| 559 | } |
| 560 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | #endif /* OPTi93X */ |
| 562 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 563 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, |
| 564 | struct snd_opti9xx *chip) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | { |
| 566 | int i, err; |
| 567 | |
| 568 | #ifndef OPTi93X |
| 569 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { |
| 570 | unsigned char value; |
| 571 | |
| 572 | if ((err = snd_opti9xx_init(chip, i)) < 0) |
| 573 | return err; |
| 574 | |
| 575 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) |
| 576 | continue; |
| 577 | |
| 578 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); |
| 579 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) |
| 580 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) |
| 581 | return 1; |
| 582 | |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 583 | release_and_free_resource(chip->res_mc_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | chip->res_mc_base = NULL; |
| 585 | |
| 586 | } |
| 587 | #else /* OPTi93X */ |
| 588 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { |
| 589 | unsigned long flags; |
| 590 | unsigned char value; |
| 591 | |
| 592 | if ((err = snd_opti9xx_init(chip, i)) < 0) |
| 593 | return err; |
| 594 | |
| 595 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) |
| 596 | continue; |
| 597 | |
| 598 | spin_lock_irqsave(&chip->lock, flags); |
| 599 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
| 600 | outb(((chip->mc_indir_index & (1 << 8)) >> 4) | |
| 601 | ((chip->mc_indir_index & 0xf0) >> 4), chip->mc_base); |
| 602 | spin_unlock_irqrestore(&chip->lock, flags); |
| 603 | |
| 604 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)); |
| 605 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value); |
| 606 | if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) |
| 607 | return 1; |
| 608 | |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 609 | release_and_free_resource(chip->res_mc_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | chip->res_mc_base = NULL; |
| 611 | } |
| 612 | #endif /* OPTi93X */ |
| 613 | |
| 614 | return -ENODEV; |
| 615 | } |
| 616 | |
| 617 | #ifdef CONFIG_PNP |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 618 | static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, |
| 619 | struct pnp_card_link *card, |
| 620 | const struct pnp_card_device_id *pid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | { |
| 622 | struct pnp_dev *pdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | int err; |
| 624 | |
| 625 | chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); |
Rene Herman | 109c53f84 | 2007-11-30 17:59:25 +0100 | [diff] [blame] | 626 | if (chip->dev == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | return -EBUSY; |
Rene Herman | 109c53f84 | 2007-11-30 17:59:25 +0100 | [diff] [blame] | 628 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | chip->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); |
| 630 | |
| 631 | pdev = chip->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | err = pnp_activate_dev(pdev); |
| 634 | if (err < 0) { |
| 635 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | return err; |
| 637 | } |
| 638 | |
| 639 | #ifdef OPTi93X |
| 640 | port = pnp_port_start(pdev, 0) - 4; |
Takashi Iwai | 1ea7341 | 2007-09-17 16:44:06 +0200 | [diff] [blame] | 641 | fm_port = pnp_port_start(pdev, 1) + 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | #else |
| 643 | if (pid->driver_data != 0x0924) |
| 644 | port = pnp_port_start(pdev, 1); |
Takashi Iwai | 1ea7341 | 2007-09-17 16:44:06 +0200 | [diff] [blame] | 645 | fm_port = pnp_port_start(pdev, 2) + 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | #endif /* OPTi93X */ |
| 647 | irq = pnp_irq(pdev, 0); |
| 648 | dma1 = pnp_dma(pdev, 0); |
| 649 | #if defined(CS4231) || defined(OPTi93X) |
| 650 | dma2 = pnp_dma(pdev, 1); |
| 651 | #endif /* CS4231 || OPTi93X */ |
| 652 | |
| 653 | pdev = chip->devmpu; |
| 654 | if (pdev && mpu_port > 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | err = pnp_activate_dev(pdev); |
| 656 | if (err < 0) { |
| 657 | snd_printk(KERN_ERR "AUDIO pnp configure failure\n"); |
| 658 | mpu_port = -1; |
| 659 | chip->devmpu = NULL; |
| 660 | } else { |
| 661 | mpu_port = pnp_port_start(pdev, 0); |
| 662 | mpu_irq = pnp_irq(pdev, 0); |
| 663 | } |
| 664 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | return pid->driver_data; |
| 666 | } |
| 667 | #endif /* CONFIG_PNP */ |
| 668 | |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 669 | static void snd_card_opti9xx_free(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | { |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 671 | struct snd_opti9xx *chip = card->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 673 | if (chip) { |
| 674 | #ifdef OPTi93X |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 675 | struct snd_wss *codec = chip->codec; |
Takashi Iwai | 82af6bc | 2008-07-17 23:37:20 +0200 | [diff] [blame] | 676 | if (codec && codec->irq > 0) { |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 677 | disable_irq(codec->irq); |
| 678 | free_irq(codec->irq, codec); |
| 679 | } |
| 680 | #endif |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 681 | release_and_free_resource(chip->res_mc_base); |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 682 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 685 | static int __devinit snd_opti9xx_probe(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | { |
| 687 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | int error; |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 689 | int xdma2; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 690 | struct snd_opti9xx *chip = card->private_data; |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 691 | struct snd_wss *codec; |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 692 | #ifdef CS4231 |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 693 | struct snd_timer *timer; |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 694 | #endif |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 695 | struct snd_pcm *pcm; |
| 696 | struct snd_rawmidi *rmidi; |
| 697 | struct snd_hwdep *synth; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | |
| 699 | if (! chip->res_mc_base && |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 700 | (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, |
| 701 | "OPTi9xx MC")) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | #if defined(CS4231) || defined(OPTi93X) |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 705 | xdma2 = dma2; |
Rene Herman | a0d9274 | 2008-08-04 05:26:26 +0200 | [diff] [blame] | 706 | #else |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 707 | xdma2 = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | #endif |
| 709 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 710 | if (port == SNDRV_AUTO_PORT) { |
| 711 | port = snd_legacy_find_free_ioport(possible_ports, 4); |
| 712 | if (port < 0) { |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 713 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | return -EBUSY; |
| 715 | } |
| 716 | } |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 717 | error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2, |
| 718 | mpu_port, mpu_irq); |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 719 | if (error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 722 | error = snd_wss_create(card, port + 4, -1, irq, dma1, xdma2, |
Rene Herman | a0d9274 | 2008-08-04 05:26:26 +0200 | [diff] [blame] | 723 | #ifdef OPTi93X |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 724 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, |
Rene Herman | a0d9274 | 2008-08-04 05:26:26 +0200 | [diff] [blame] | 725 | #else |
| 726 | WSS_HW_DETECT, 0, |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 727 | #endif |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 728 | &codec); |
| 729 | if (error < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | return error; |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 731 | #ifdef OPTi93X |
| 732 | chip->codec = codec; |
| 733 | #endif |
Krzysztof Helt | ead893c | 2008-07-31 21:09:32 +0200 | [diff] [blame] | 734 | error = snd_wss_pcm(codec, 0, &pcm); |
Krzysztof Helt | 5664daa | 2008-07-31 21:08:32 +0200 | [diff] [blame] | 735 | if (error < 0) |
| 736 | return error; |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 737 | error = snd_wss_mixer(codec); |
| 738 | if (error < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | return error; |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 740 | #ifdef CS4231 |
Krzysztof Helt | 7779f75 | 2008-07-31 21:03:41 +0200 | [diff] [blame] | 741 | error = snd_wss_timer(codec, 0, &timer); |
| 742 | if (error < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | return error; |
Krzysztof Helt | 5664daa | 2008-07-31 21:08:32 +0200 | [diff] [blame] | 744 | #endif |
| 745 | #ifdef OPTi93X |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 746 | error = request_irq(irq, snd_opti93x_interrupt, |
Krzysztof Helt | 9f240a5 | 2008-06-11 12:26:32 +0200 | [diff] [blame] | 747 | IRQF_DISABLED, DEV_NAME" - WSS", codec); |
| 748 | if (error < 0) { |
| 749 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); |
| 750 | return error; |
| 751 | } |
| 752 | #endif |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 753 | chip->irq = irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | strcpy(card->driver, chip->name); |
| 755 | sprintf(card->shortname, "OPTi %s", card->driver); |
| 756 | #if defined(CS4231) || defined(OPTi93X) |
| 757 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 758 | card->shortname, pcm->name, port + 4, irq, dma1, xdma2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | #else |
| 760 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 761 | card->shortname, pcm->name, port + 4, irq, dma1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | #endif /* CS4231 || OPTi93X */ |
| 763 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 764 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | rmidi = NULL; |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 766 | else { |
| 767 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
| 768 | mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi); |
| 769 | if (error) |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 770 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 771 | mpu_port); |
| 772 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 774 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 775 | struct snd_opl3 *opl3 = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | #ifndef OPTi93X |
| 777 | if (chip->hardware == OPTi9XX_HW_82C928 || |
| 778 | chip->hardware == OPTi9XX_HW_82C929 || |
| 779 | chip->hardware == OPTi9XX_HW_82C924) { |
Takashi Iwai | 346c7a6 | 2005-11-17 14:37:56 +0100 | [diff] [blame] | 780 | struct snd_opl4 *opl4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | /* assume we have an OPL4 */ |
| 782 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
| 783 | 0x20, 0x20); |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 784 | if (snd_opl4_create(card, fm_port, fm_port - 8, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | 2, &opl3, &opl4) < 0) { |
| 786 | /* no luck, use OPL3 instead */ |
| 787 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
| 788 | 0x00, 0x20); |
| 789 | } |
| 790 | } |
| 791 | #endif /* !OPTi93X */ |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 792 | if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | OPL3_HW_AUTO, 0, &opl3) < 0) { |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 794 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", |
Krzysztof Helt | d8ea239 | 2009-12-02 23:27:12 +0100 | [diff] [blame^] | 795 | fm_port, fm_port + 4 - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | } |
| 797 | if (opl3) { |
Krzysztof Helt | aa9c293 | 2009-01-21 15:08:03 +0100 | [diff] [blame] | 798 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); |
| 799 | if (error < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 804 | return snd_card_register(card); |
| 805 | } |
| 806 | |
Takashi Iwai | 3e7fb9f | 2008-12-28 16:47:30 +0100 | [diff] [blame] | 807 | static int snd_opti9xx_card_new(struct snd_card **cardp) |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 808 | { |
| 809 | struct snd_card *card; |
Takashi Iwai | b1a0aac | 2009-01-14 09:34:06 +0100 | [diff] [blame] | 810 | int err; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 811 | |
Takashi Iwai | c95eadd | 2008-12-28 16:43:35 +0100 | [diff] [blame] | 812 | err = snd_card_create(index, id, THIS_MODULE, |
| 813 | sizeof(struct snd_opti9xx), &card); |
| 814 | if (err < 0) |
Takashi Iwai | 3e7fb9f | 2008-12-28 16:47:30 +0100 | [diff] [blame] | 815 | return err; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 816 | card->private_free = snd_card_opti9xx_free; |
Takashi Iwai | 3e7fb9f | 2008-12-28 16:47:30 +0100 | [diff] [blame] | 817 | *cardp = card; |
| 818 | return 0; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 819 | } |
| 820 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 821 | static int __devinit snd_opti9xx_isa_match(struct device *devptr, |
| 822 | unsigned int dev) |
| 823 | { |
Takashi Iwai | 101f6f4 | 2007-06-20 12:03:09 +0200 | [diff] [blame] | 824 | #ifdef CONFIG_PNP |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 825 | if (snd_opti9xx_pnp_is_probed) |
| 826 | return 0; |
| 827 | if (isapnp) |
| 828 | return 0; |
Takashi Iwai | 101f6f4 | 2007-06-20 12:03:09 +0200 | [diff] [blame] | 829 | #endif |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 830 | return 1; |
| 831 | } |
| 832 | |
| 833 | static int __devinit snd_opti9xx_isa_probe(struct device *devptr, |
| 834 | unsigned int dev) |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 835 | { |
| 836 | struct snd_card *card; |
| 837 | int error; |
| 838 | static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; |
| 839 | #ifdef OPTi93X |
| 840 | static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; |
| 841 | #else |
| 842 | static int possible_irqs[] = {9, 10, 11, 7, -1}; |
| 843 | #endif /* OPTi93X */ |
| 844 | static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; |
| 845 | static int possible_dma1s[] = {3, 1, 0, -1}; |
| 846 | #if defined(CS4231) || defined(OPTi93X) |
| 847 | static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; |
| 848 | #endif /* CS4231 || OPTi93X */ |
| 849 | |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 850 | if (mpu_port == SNDRV_AUTO_PORT) { |
| 851 | if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { |
| 852 | snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); |
| 853 | return -EBUSY; |
| 854 | } |
| 855 | } |
| 856 | if (irq == SNDRV_AUTO_IRQ) { |
| 857 | if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { |
| 858 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); |
| 859 | return -EBUSY; |
| 860 | } |
| 861 | } |
| 862 | if (mpu_irq == SNDRV_AUTO_IRQ) { |
| 863 | if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { |
| 864 | snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); |
| 865 | return -EBUSY; |
| 866 | } |
| 867 | } |
| 868 | if (dma1 == SNDRV_AUTO_DMA) { |
| 869 | if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { |
| 870 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); |
| 871 | return -EBUSY; |
| 872 | } |
| 873 | } |
| 874 | #if defined(CS4231) || defined(OPTi93X) |
| 875 | if (dma2 == SNDRV_AUTO_DMA) { |
| 876 | if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) { |
Takashi Iwai | 4c9f1d3 | 2009-02-05 15:47:51 +0100 | [diff] [blame] | 877 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 878 | return -EBUSY; |
| 879 | } |
| 880 | } |
| 881 | #endif |
| 882 | |
Takashi Iwai | 3e7fb9f | 2008-12-28 16:47:30 +0100 | [diff] [blame] | 883 | error = snd_opti9xx_card_new(&card); |
| 884 | if (error < 0) |
| 885 | return error; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 886 | |
| 887 | if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | snd_card_free(card); |
| 889 | return error; |
| 890 | } |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 891 | snd_card_set_dev(card, devptr); |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 892 | if ((error = snd_opti9xx_probe(card)) < 0) { |
| 893 | snd_card_free(card); |
| 894 | return error; |
| 895 | } |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 896 | dev_set_drvdata(devptr, card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | return 0; |
| 898 | } |
| 899 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 900 | static int __devexit snd_opti9xx_isa_remove(struct device *devptr, |
| 901 | unsigned int dev) |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 902 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 903 | snd_card_free(dev_get_drvdata(devptr)); |
| 904 | dev_set_drvdata(devptr, NULL); |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 905 | return 0; |
| 906 | } |
| 907 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 908 | static struct isa_driver snd_opti9xx_driver = { |
| 909 | .match = snd_opti9xx_isa_match, |
| 910 | .probe = snd_opti9xx_isa_probe, |
| 911 | .remove = __devexit_p(snd_opti9xx_isa_remove), |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 912 | /* FIXME: suspend/resume */ |
| 913 | .driver = { |
Rene Herman | 83c51c0 | 2007-03-20 11:33:46 +0100 | [diff] [blame] | 914 | .name = DEV_NAME |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 915 | }, |
| 916 | }; |
| 917 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | #ifdef CONFIG_PNP |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 919 | static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, |
| 920 | const struct pnp_card_device_id *pid) |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 921 | { |
| 922 | struct snd_card *card; |
| 923 | int error, hw; |
| 924 | struct snd_opti9xx *chip; |
| 925 | |
| 926 | if (snd_opti9xx_pnp_is_probed) |
| 927 | return -EBUSY; |
| 928 | if (! isapnp) |
| 929 | return -ENODEV; |
Takashi Iwai | 3e7fb9f | 2008-12-28 16:47:30 +0100 | [diff] [blame] | 930 | error = snd_opti9xx_card_new(&card); |
| 931 | if (error < 0) |
| 932 | return error; |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 933 | chip = card->private_data; |
| 934 | |
| 935 | hw = snd_card_opti9xx_pnp(chip, pcard, pid); |
| 936 | switch (hw) { |
| 937 | case 0x0924: |
| 938 | hw = OPTi9XX_HW_82C924; |
| 939 | break; |
| 940 | case 0x0925: |
| 941 | hw = OPTi9XX_HW_82C925; |
| 942 | break; |
| 943 | case 0x0931: |
| 944 | hw = OPTi9XX_HW_82C931; |
| 945 | break; |
| 946 | default: |
| 947 | snd_card_free(card); |
| 948 | return -ENODEV; |
| 949 | } |
| 950 | |
| 951 | if ((error = snd_opti9xx_init(chip, hw))) { |
| 952 | snd_card_free(card); |
| 953 | return error; |
| 954 | } |
| 955 | if (hw <= OPTi9XX_HW_82C930) |
| 956 | chip->mc_base -= 0x80; |
| 957 | snd_card_set_dev(card, &pcard->card->dev); |
| 958 | if ((error = snd_opti9xx_probe(card)) < 0) { |
| 959 | snd_card_free(card); |
| 960 | return error; |
| 961 | } |
| 962 | pnp_set_card_drvdata(pcard, card); |
| 963 | snd_opti9xx_pnp_is_probed = 1; |
| 964 | return 0; |
| 965 | } |
| 966 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) |
| 968 | { |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 969 | snd_card_free(pnp_get_card_drvdata(pcard)); |
| 970 | pnp_set_card_drvdata(pcard, NULL); |
| 971 | snd_opti9xx_pnp_is_probed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | static struct pnp_card_driver opti9xx_pnpc_driver = { |
| 975 | .flags = PNP_DRIVER_RES_DISABLE, |
| 976 | .name = "opti9xx", |
| 977 | .id_table = snd_opti9xx_pnpids, |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 978 | .probe = snd_opti9xx_pnp_probe, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | .remove = __devexit_p(snd_opti9xx_pnp_remove), |
| 980 | }; |
| 981 | #endif |
| 982 | |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 983 | #ifdef OPTi93X |
| 984 | #define CHIP_NAME "82C93x" |
| 985 | #else |
| 986 | #define CHIP_NAME "82C92x" |
| 987 | #endif |
| 988 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | static int __init alsa_card_opti9xx_init(void) |
| 990 | { |
Takashi Iwai | 0bbbc4c | 2006-02-27 17:23:46 +0100 | [diff] [blame] | 991 | #ifdef CONFIG_PNP |
Takashi Iwai | 99a0b76 | 2005-11-17 17:13:59 +0100 | [diff] [blame] | 992 | pnp_register_card_driver(&opti9xx_pnpc_driver); |
| 993 | if (snd_opti9xx_pnp_is_probed) |
| 994 | return 0; |
Takashi Iwai | 101f6f4 | 2007-06-20 12:03:09 +0200 | [diff] [blame] | 995 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); |
Takashi Iwai | 0bbbc4c | 2006-02-27 17:23:46 +0100 | [diff] [blame] | 996 | #endif |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 997 | return isa_register_driver(&snd_opti9xx_driver, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | static void __exit alsa_card_opti9xx_exit(void) |
| 1001 | { |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 1002 | if (!snd_opti9xx_pnp_is_probed) { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame] | 1003 | isa_unregister_driver(&snd_opti9xx_driver); |
| 1004 | return; |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 1005 | } |
Takashi Iwai | 0bbbc4c | 2006-02-27 17:23:46 +0100 | [diff] [blame] | 1006 | #ifdef CONFIG_PNP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); |
Takashi Iwai | 0bbbc4c | 2006-02-27 17:23:46 +0100 | [diff] [blame] | 1008 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | module_init(alsa_card_opti9xx_init) |
| 1012 | module_exit(alsa_card_opti9xx_exit) |