Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Driver for generic CS4232/CS4235/CS4236/CS4236B/CS4237B/CS4238B/CS4239 chips |
| 3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> |
| 4 | * |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <sound/driver.h> |
| 23 | #include <linux/init.h> |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 24 | #include <linux/err.h> |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 25 | #include <linux/isa.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/slab.h> |
| 27 | #include <linux/pnp.h> |
| 28 | #include <linux/moduleparam.h> |
| 29 | #include <sound/core.h> |
| 30 | #include <sound/cs4231.h> |
| 31 | #include <sound/mpu401.h> |
| 32 | #include <sound/opl3.h> |
| 33 | #include <sound/initval.h> |
| 34 | |
| 35 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); |
| 36 | MODULE_LICENSE("GPL"); |
| 37 | #ifdef CS4232 |
| 38 | MODULE_DESCRIPTION("Cirrus Logic CS4232"); |
| 39 | MODULE_SUPPORTED_DEVICE("{{Turtle Beach,TBS-2000}," |
| 40 | "{Turtle Beach,Tropez Plus}," |
| 41 | "{SIC CrystalWave 32}," |
| 42 | "{Hewlett Packard,Omnibook 5500}," |
| 43 | "{TerraTec,Maestro 32/96}," |
| 44 | "{Philips,PCA70PS}}"); |
| 45 | #else |
| 46 | MODULE_DESCRIPTION("Cirrus Logic CS4235-9"); |
| 47 | MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235}," |
| 48 | "{Crystal Semiconductors,CS4236}," |
| 49 | "{Crystal Semiconductors,CS4237}," |
| 50 | "{Crystal Semiconductors,CS4238}," |
| 51 | "{Crystal Semiconductors,CS4239}," |
| 52 | "{Acer,AW37}," |
| 53 | "{Acer,AW35/Pro}," |
| 54 | "{Crystal,3D}," |
| 55 | "{Crystal Computer,TidalWave128}," |
| 56 | "{Dell,Optiplex GX1}," |
| 57 | "{Dell,Workstation 400 sound}," |
| 58 | "{EliteGroup,P5TX-LA sound}," |
| 59 | "{Gallant,SC-70P}," |
| 60 | "{Gateway,E1000 Onboard CS4236B}," |
| 61 | "{Genius,Sound Maker 3DJ}," |
| 62 | "{Hewlett Packard,HP6330 sound}," |
| 63 | "{IBM,PC 300PL sound}," |
| 64 | "{IBM,Aptiva 2137 E24}," |
| 65 | "{IBM,IntelliStation M Pro}," |
| 66 | "{Intel,Marlin Spike Mobo CS4235}," |
| 67 | "{Intel PR440FX Onboard}," |
| 68 | "{Guillemot,MaxiSound 16 PnP}," |
| 69 | "{NewClear,3D}," |
| 70 | "{TerraTec,AudioSystem EWS64L/XL}," |
| 71 | "{Typhoon Soundsystem,CS4236B}," |
| 72 | "{Turtle Beach,Malibu}," |
| 73 | "{Unknown,Digital PC 5000 Onboard}}"); |
| 74 | #endif |
| 75 | |
| 76 | #ifdef CS4232 |
| 77 | #define IDENT "CS4232" |
Jaroslav Kysela | ec80859 | 2006-01-22 09:28:15 +0100 | [diff] [blame] | 78 | #define CS423X_DRIVER "snd_cs4232" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #else |
| 80 | #define IDENT "CS4236+" |
Jaroslav Kysela | ec80859 | 2006-01-22 09:28:15 +0100 | [diff] [blame] | 81 | #define CS423X_DRIVER "snd_cs4236" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #endif |
| 83 | |
| 84 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 85 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 86 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ |
| 87 | #ifdef CONFIG_PNP |
| 88 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; |
| 89 | #endif |
| 90 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 91 | static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 92 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */ |
| 93 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 94 | static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 95 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ |
| 96 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */ |
| 97 | static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ |
| 98 | static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ |
| 99 | |
| 100 | module_param_array(index, int, NULL, 0444); |
| 101 | MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard."); |
| 102 | module_param_array(id, charp, NULL, 0444); |
| 103 | MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard."); |
| 104 | module_param_array(enable, bool, NULL, 0444); |
| 105 | MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard."); |
| 106 | #ifdef CONFIG_PNP |
| 107 | module_param_array(isapnp, bool, NULL, 0444); |
| 108 | MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard."); |
| 109 | #endif |
| 110 | module_param_array(port, long, NULL, 0444); |
| 111 | MODULE_PARM_DESC(port, "Port # for " IDENT " driver."); |
| 112 | module_param_array(cport, long, NULL, 0444); |
| 113 | MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver."); |
| 114 | module_param_array(mpu_port, long, NULL, 0444); |
| 115 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver."); |
| 116 | module_param_array(fm_port, long, NULL, 0444); |
| 117 | MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver."); |
| 118 | module_param_array(sb_port, long, NULL, 0444); |
| 119 | MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional)."); |
| 120 | module_param_array(irq, int, NULL, 0444); |
| 121 | MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver."); |
| 122 | module_param_array(mpu_irq, int, NULL, 0444); |
| 123 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver."); |
| 124 | module_param_array(dma1, int, NULL, 0444); |
| 125 | MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver."); |
| 126 | module_param_array(dma2, int, NULL, 0444); |
| 127 | MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); |
| 128 | |
Takashi Iwai | 59b1b34 | 2006-01-04 15:06:44 +0100 | [diff] [blame] | 129 | #ifdef CONFIG_PNP |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 130 | static int pnpc_registered; |
| 131 | #ifdef CS4232 |
| 132 | static int pnp_registered; |
| 133 | #endif |
Takashi Iwai | 59b1b34 | 2006-01-04 15:06:44 +0100 | [diff] [blame] | 134 | #endif /* CONFIG_PNP */ |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct snd_card_cs4236 { |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 137 | struct snd_cs4231 *chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | struct resource *res_sb_port; |
| 139 | #ifdef CONFIG_PNP |
| 140 | struct pnp_dev *wss; |
| 141 | struct pnp_dev *ctrl; |
| 142 | struct pnp_dev *mpu; |
| 143 | #endif |
| 144 | }; |
| 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | #ifdef CONFIG_PNP |
| 147 | |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 148 | #ifdef CS4232 |
| 149 | /* |
| 150 | * PNP BIOS |
| 151 | */ |
| 152 | static const struct pnp_device_id snd_cs4232_pnpbiosids[] = { |
| 153 | { .id = "CSC0100" }, |
| 154 | { .id = "CSC0000" }, |
| 155 | /* Guillemot Turtlebeach something appears to be cs4232 compatible |
| 156 | * (untested) */ |
| 157 | { .id = "GIM0100" }, |
| 158 | { .id = "" } |
| 159 | }; |
| 160 | MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids); |
| 161 | #endif /* CS4232 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | #ifdef CS4232 |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 164 | #define CS423X_ISAPNP_DRIVER "cs4232_isapnp" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | static struct pnp_card_device_id snd_cs423x_pnpids[] = { |
| 166 | /* Philips PCA70PS */ |
| 167 | { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, |
| 168 | /* TerraTec Maestro 32/96 (CS4232) */ |
| 169 | { .id = "CSC1a32", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 170 | /* HP Omnibook 5500 onboard */ |
| 171 | { .id = "CSC4232", .devs = { { "CSC0000" }, { "CSC0002" }, { "CSC0003" } } }, |
| 172 | /* Unnamed CS4236 card (Made in Taiwan) */ |
| 173 | { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 174 | /* Turtle Beach TBS-2000 (CS4232) */ |
| 175 | { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSCb006" } } }, |
| 176 | /* Turtle Beach Tropez Plus (CS4232) */ |
| 177 | { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, |
| 178 | /* SIC CrystalWave 32 (CS4232) */ |
| 179 | { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
Lukasz Stemach | 50f794c | 2006-01-23 15:22:13 +0100 | [diff] [blame] | 180 | /* Netfinity 3000 on-board soundcard */ |
| 181 | { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | /* --- */ |
| 183 | { .id = "" } /* end */ |
| 184 | }; |
| 185 | #else /* CS4236 */ |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 186 | #define CS423X_ISAPNP_DRIVER "cs4236_isapnp" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | static struct pnp_card_device_id snd_cs423x_pnpids[] = { |
| 188 | /* Intel Marlin Spike Motherboard - CS4235 */ |
| 189 | { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 190 | /* Intel Marlin Spike Motherboard (#2) - CS4235 */ |
| 191 | { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, |
| 192 | /* Unknown Intel mainboard - CS4235 */ |
| 193 | { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" } } }, |
| 194 | /* Genius Sound Maker 3DJ - CS4237B */ |
| 195 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 196 | /* Digital PC 5000 Onboard - CS4236B */ |
| 197 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 198 | /* some uknown CS4236B */ |
| 199 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 200 | /* Intel PR440FX Onboard sound */ |
| 201 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 202 | /* CS4235 on mainboard without MPU */ |
| 203 | { .id = "CSC1425", .devs = { { "CSC0100" }, { "CSC0110" } } }, |
| 204 | /* Gateway E1000 Onboard CS4236B */ |
| 205 | { .id = "CSC1335", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 206 | /* HP 6330 Onboard sound */ |
| 207 | { .id = "CSC1525", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, |
| 208 | /* Crystal Computer TidalWave128 */ |
| 209 | { .id = "CSC1e37", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 210 | /* ACER AW37 - CS4235 */ |
| 211 | { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 212 | /* build-in soundcard in EliteGroup P5TX-LA motherboard - CS4237B */ |
| 213 | { .id = "CSC4237", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 214 | /* Crystal 3D - CS4237B */ |
| 215 | { .id = "CSC4336", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 216 | /* Typhoon Soundsystem PnP - CS4236B */ |
| 217 | { .id = "CSC4536", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 218 | /* Crystal CX4235-XQ3 EP - CS4235 */ |
| 219 | { .id = "CSC4625", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, |
| 220 | /* Crystal Semiconductors CS4237B */ |
| 221 | { .id = "CSC4637", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 222 | /* NewClear 3D - CX4237B-XQ3 */ |
| 223 | { .id = "CSC4837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 224 | /* Dell Optiplex GX1 - CS4236B */ |
| 225 | { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 226 | /* Dell P410 motherboard - CS4236B */ |
| 227 | { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 228 | /* Dell Workstation 400 Onboard - CS4236B */ |
| 229 | { .id = "CSC6836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 230 | /* Turtle Beach Malibu - CS4237B */ |
| 231 | { .id = "CSC7537", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 232 | /* CS4235 - onboard */ |
| 233 | { .id = "CSC8025", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, |
| 234 | /* IBM Aptiva 2137 E24 Onboard - CS4237B */ |
| 235 | { .id = "CSC8037", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 236 | /* IBM IntelliStation M Pro motherboard */ |
| 237 | { .id = "CSCc835", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 238 | /* Guillemot MaxiSound 16 PnP - CS4236B */ |
| 239 | { .id = "CSC9836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 240 | /* Gallant SC-70P */ |
| 241 | { .id = "CSC9837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 242 | /* TerraTec AudioSystem EWS64XL - CS4236B */ |
| 243 | { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" }, { "CSCa803" } } }, |
| 244 | /* TerraTec AudioSystem EWS64XL - CS4236B */ |
| 245 | { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" } } }, |
| 246 | /* ACER AW37/Pro - CS4235 */ |
| 247 | { .id = "CSCd925", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 248 | /* ACER AW35/Pro - CS4237B */ |
| 249 | { .id = "CSCd937", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 250 | /* CS4235 without MPU401 */ |
| 251 | { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" } } }, |
| 252 | /* Unknown SiS530 - CS4235 */ |
| 253 | { .id = "CSC4825", .devs = { { "CSC0100" }, { "CSC0110" } } }, |
| 254 | /* IBM IntelliStation M Pro 6898 11U - CS4236B */ |
| 255 | { .id = "CSCe835", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 256 | /* IBM PC 300PL Onboard - CS4236B */ |
| 257 | { .id = "CSCe836", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 258 | /* Some noname CS4236 based card */ |
| 259 | { .id = "CSCe936", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 260 | /* CS4236B */ |
| 261 | { .id = "CSCf235", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 262 | /* CS4236B */ |
| 263 | { .id = "CSCf238", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 264 | /* --- */ |
| 265 | { .id = "" } /* end */ |
| 266 | }; |
| 267 | #endif |
| 268 | |
| 269 | MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); |
| 270 | |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 271 | /* WSS initialization */ |
| 272 | static int __devinit snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev, |
| 273 | struct pnp_resource_table *cfg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | int err; |
| 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | pnp_init_resource_table(cfg); |
| 278 | if (port[dev] != SNDRV_AUTO_PORT) |
| 279 | pnp_resource_change(&cfg->port_resource[0], port[dev], 4); |
| 280 | if (fm_port[dev] != SNDRV_AUTO_PORT && fm_port[dev] > 0) |
| 281 | pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); |
| 282 | if (sb_port[dev] != SNDRV_AUTO_PORT) |
| 283 | pnp_resource_change(&cfg->port_resource[2], sb_port[dev], 16); |
| 284 | if (irq[dev] != SNDRV_AUTO_IRQ) |
| 285 | pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); |
| 286 | if (dma1[dev] != SNDRV_AUTO_DMA) |
| 287 | pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); |
| 288 | if (dma2[dev] != SNDRV_AUTO_DMA) |
| 289 | pnp_resource_change(&cfg->dma_resource[1], dma2[dev] < 0 ? 4 : dma2[dev], 1); |
| 290 | err = pnp_manual_config_dev(pdev, cfg, 0); |
| 291 | if (err < 0) |
| 292 | snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n"); |
| 293 | err = pnp_activate_dev(pdev); |
| 294 | if (err < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n"); |
| 296 | return -EBUSY; |
| 297 | } |
| 298 | port[dev] = pnp_port_start(pdev, 0); |
| 299 | if (fm_port[dev] > 0) |
| 300 | fm_port[dev] = pnp_port_start(pdev, 1); |
| 301 | sb_port[dev] = pnp_port_start(pdev, 2); |
| 302 | irq[dev] = pnp_irq(pdev, 0); |
| 303 | dma1[dev] = pnp_dma(pdev, 0); |
| 304 | dma2[dev] = pnp_dma(pdev, 1) == 4 ? -1 : (int)pnp_dma(pdev, 1); |
| 305 | snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n", |
| 306 | port[dev], fm_port[dev], sb_port[dev]); |
| 307 | snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n", |
| 308 | irq[dev], dma1[dev], dma2[dev]); |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | /* CTRL initialization */ |
| 313 | static int __devinit snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev, |
| 314 | struct pnp_resource_table *cfg) |
| 315 | { |
| 316 | int err; |
| 317 | |
| 318 | pnp_init_resource_table(cfg); |
| 319 | if (cport[dev] != SNDRV_AUTO_PORT) |
| 320 | pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); |
| 321 | err = pnp_manual_config_dev(pdev, cfg, 0); |
| 322 | if (err < 0) |
| 323 | snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); |
| 324 | err = pnp_activate_dev(pdev); |
| 325 | if (err < 0) { |
| 326 | printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); |
| 327 | return -EBUSY; |
| 328 | } |
| 329 | cport[dev] = pnp_port_start(pdev, 0); |
| 330 | snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); |
| 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | /* MPU initialization */ |
| 335 | static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev, |
| 336 | struct pnp_resource_table *cfg) |
| 337 | { |
| 338 | int err; |
| 339 | |
| 340 | pnp_init_resource_table(cfg); |
| 341 | if (mpu_port[dev] != SNDRV_AUTO_PORT) |
| 342 | pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); |
| 343 | if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) |
| 344 | pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); |
| 345 | err = pnp_manual_config_dev(pdev, cfg, 0); |
| 346 | if (err < 0) |
| 347 | snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); |
| 348 | err = pnp_activate_dev(pdev); |
| 349 | if (err < 0) { |
| 350 | printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); |
| 351 | mpu_port[dev] = SNDRV_AUTO_PORT; |
| 352 | mpu_irq[dev] = SNDRV_AUTO_IRQ; |
| 353 | } else { |
| 354 | mpu_port[dev] = pnp_port_start(pdev, 0); |
| 355 | if (mpu_irq[dev] >= 0 && |
| 356 | pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { |
| 357 | mpu_irq[dev] = pnp_irq(pdev, 0); |
| 358 | } else { |
| 359 | mpu_irq[dev] = -1; /* disable interrupt */ |
| 360 | } |
| 361 | } |
| 362 | snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); |
| 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | #ifdef CS4232 |
| 367 | static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard, |
| 368 | struct pnp_dev *pdev) |
| 369 | { |
| 370 | struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); |
| 371 | |
| 372 | if (!cfg) |
| 373 | return -ENOMEM; |
| 374 | if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) { |
| 375 | kfree(cfg); |
| 376 | return -EBUSY; |
| 377 | } |
| 378 | kfree(cfg); |
| 379 | cport[dev] = -1; |
| 380 | return 0; |
| 381 | } |
| 382 | #endif |
| 383 | |
| 384 | static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard, |
| 385 | struct pnp_card_link *card, |
| 386 | const struct pnp_card_device_id *id) |
| 387 | { |
| 388 | struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); |
| 389 | |
| 390 | if (!cfg) |
| 391 | return -ENOMEM; |
| 392 | |
| 393 | acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); |
| 394 | if (acard->wss == NULL) |
| 395 | goto error; |
| 396 | acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); |
| 397 | if (acard->ctrl == NULL) |
| 398 | goto error; |
| 399 | if (id->devs[2].id[0]) { |
| 400 | acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); |
| 401 | if (acard->mpu == NULL) |
| 402 | goto error; |
| 403 | } |
| 404 | |
| 405 | /* WSS initialization */ |
| 406 | if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) |
| 407 | goto error; |
| 408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | /* CTRL initialization */ |
| 410 | if (acard->ctrl && cport[dev] > 0) { |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 411 | if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl, cfg) < 0) |
| 412 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
| 414 | /* MPU initialization */ |
| 415 | if (acard->mpu && mpu_port[dev] > 0) { |
Rene Herman | 6f595cf | 2006-02-24 13:03:51 -0800 | [diff] [blame] | 416 | if (snd_cs423x_pnp_init_mpu(dev, acard->mpu, cfg) < 0) |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 417 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | } |
| 419 | kfree(cfg); |
| 420 | return 0; |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 421 | |
| 422 | error: |
| 423 | kfree(cfg); |
| 424 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | } |
| 426 | #endif /* CONFIG_PNP */ |
| 427 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 428 | #ifdef CONFIG_PNP |
| 429 | #define is_isapnp_selected(dev) isapnp[dev] |
| 430 | #else |
| 431 | #define is_isapnp_selected(dev) 0 |
| 432 | #endif |
| 433 | |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 434 | static void snd_card_cs4236_free(struct snd_card *card) |
| 435 | { |
| 436 | struct snd_card_cs4236 *acard = card->private_data; |
| 437 | |
| 438 | release_and_free_resource(acard->res_sb_port); |
| 439 | } |
| 440 | |
| 441 | static struct snd_card *snd_cs423x_card_new(int dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | { |
Takashi Iwai | ba2375a | 2005-11-17 14:30:42 +0100 | [diff] [blame] | 443 | struct snd_card *card; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 444 | |
| 445 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, |
| 446 | sizeof(struct snd_card_cs4236)); |
| 447 | if (card == NULL) |
| 448 | return NULL; |
| 449 | card->private_free = snd_card_cs4236_free; |
| 450 | return card; |
| 451 | } |
| 452 | |
| 453 | static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) |
| 454 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | struct snd_card_cs4236 *acard; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 456 | struct snd_pcm *pcm; |
Takashi Iwai | ba2375a | 2005-11-17 14:30:42 +0100 | [diff] [blame] | 457 | struct snd_cs4231 *chip; |
| 458 | struct snd_opl3 *opl3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | int err; |
| 460 | |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 461 | acard = card->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) |
| 463 | if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { |
| 464 | printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 465 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | #ifdef CS4232 |
| 469 | if ((err = snd_cs4231_create(card, |
| 470 | port[dev], |
| 471 | cport[dev], |
| 472 | irq[dev], |
| 473 | dma1[dev], |
| 474 | dma2[dev], |
| 475 | CS4231_HW_DETECT, |
| 476 | 0, |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 477 | &chip)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 478 | return err; |
| 479 | acard->chip = chip; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 480 | |
| 481 | if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 482 | return err; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 483 | |
| 484 | if ((err = snd_cs4231_mixer(chip)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 485 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
| 487 | #else /* CS4236 */ |
| 488 | if ((err = snd_cs4236_create(card, |
| 489 | port[dev], |
| 490 | cport[dev], |
| 491 | irq[dev], |
| 492 | dma1[dev], |
| 493 | dma2[dev], |
| 494 | CS4231_HW_DETECT, |
| 495 | 0, |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 496 | &chip)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 497 | return err; |
| 498 | acard->chip = chip; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 499 | |
| 500 | if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 501 | return err; |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 502 | |
| 503 | if ((err = snd_cs4236_mixer(chip)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 504 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | #endif |
| 506 | strcpy(card->driver, pcm->name); |
| 507 | strcpy(card->shortname, pcm->name); |
| 508 | sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", |
| 509 | pcm->name, |
| 510 | chip->port, |
| 511 | irq[dev], |
| 512 | dma1[dev]); |
| 513 | if (dma2[dev] >= 0) |
| 514 | sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); |
| 515 | |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 516 | if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 517 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | |
| 519 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { |
| 520 | if (snd_opl3_create(card, |
| 521 | fm_port[dev], fm_port[dev] + 2, |
| 522 | OPL3_HW_OPL3_CS, 0, &opl3) < 0) { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 523 | printk(KERN_WARNING IDENT ": OPL3 not detected\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | } else { |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 525 | if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 526 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | |
| 530 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
| 531 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) |
| 532 | mpu_irq[dev] = -1; |
| 533 | if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, |
| 534 | mpu_port[dev], 0, |
| 535 | mpu_irq[dev], |
Thomas Gleixner | 65ca68b | 2006-07-01 19:29:46 -0700 | [diff] [blame] | 536 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL) < 0) |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 537 | printk(KERN_WARNING IDENT ": MPU401 not detected\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | } |
Takashi Iwai | 43bcd97 | 2005-09-05 17:19:20 +0200 | [diff] [blame] | 539 | |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 540 | return snd_card_register(card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 543 | static int __devinit snd_cs423x_isa_match(struct device *pdev, |
| 544 | unsigned int dev) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 545 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 546 | if (!enable[dev] || is_isapnp_selected(dev)) |
| 547 | return 0; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 548 | |
| 549 | if (port[dev] == SNDRV_AUTO_PORT) { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 550 | snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id); |
| 551 | return 0; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 552 | } |
| 553 | if (cport[dev] == SNDRV_AUTO_PORT) { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 554 | snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id); |
| 555 | return 0; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 556 | } |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 557 | if (irq[dev] == SNDRV_AUTO_IRQ) { |
| 558 | snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); |
| 559 | return 0; |
| 560 | } |
| 561 | if (dma1[dev] == SNDRV_AUTO_DMA) { |
| 562 | snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id); |
| 563 | return 0; |
| 564 | } |
| 565 | return 1; |
| 566 | } |
| 567 | |
| 568 | static int __devinit snd_cs423x_isa_probe(struct device *pdev, |
| 569 | unsigned int dev) |
| 570 | { |
| 571 | struct snd_card *card; |
| 572 | int err; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 573 | |
| 574 | card = snd_cs423x_card_new(dev); |
| 575 | if (! card) |
| 576 | return -ENOMEM; |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 577 | snd_card_set_dev(card, pdev); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 578 | if ((err = snd_cs423x_probe(card, dev)) < 0) { |
| 579 | snd_card_free(card); |
| 580 | return err; |
| 581 | } |
Bjorn Helgaas | ed7cb19 | 2006-03-27 01:17:04 -0800 | [diff] [blame] | 582 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 583 | dev_set_drvdata(pdev, card); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 584 | return 0; |
| 585 | } |
| 586 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 587 | static int __devexit snd_cs423x_isa_remove(struct device *pdev, |
| 588 | unsigned int dev) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 589 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 590 | snd_card_free(dev_get_drvdata(pdev)); |
| 591 | dev_set_drvdata(pdev, NULL); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | #ifdef CONFIG_PM |
| 596 | static int snd_cs423x_suspend(struct snd_card *card) |
| 597 | { |
| 598 | struct snd_card_cs4236 *acard = card->private_data; |
| 599 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
| 600 | acard->chip->suspend(acard->chip); |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | static int snd_cs423x_resume(struct snd_card *card) |
| 605 | { |
| 606 | struct snd_card_cs4236 *acard = card->private_data; |
| 607 | acard->chip->resume(acard->chip); |
| 608 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 609 | return 0; |
| 610 | } |
| 611 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 612 | static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n, |
| 613 | pm_message_t state) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 614 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 615 | return snd_cs423x_suspend(dev_get_drvdata(dev)); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 616 | } |
| 617 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 618 | static int snd_cs423x_isa_resume(struct device *dev, unsigned int n) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 619 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 620 | return snd_cs423x_resume(dev_get_drvdata(dev)); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 621 | } |
| 622 | #endif |
| 623 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 624 | static struct isa_driver cs423x_isa_driver = { |
| 625 | .match = snd_cs423x_isa_match, |
| 626 | .probe = snd_cs423x_isa_probe, |
| 627 | .remove = __devexit_p(snd_cs423x_isa_remove), |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 628 | #ifdef CONFIG_PM |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 629 | .suspend = snd_cs423x_isa_suspend, |
| 630 | .resume = snd_cs423x_isa_resume, |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 631 | #endif |
| 632 | .driver = { |
| 633 | .name = CS423X_DRIVER |
| 634 | }, |
| 635 | }; |
| 636 | |
| 637 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | #ifdef CONFIG_PNP |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 639 | #ifdef CS4232 |
| 640 | static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev, |
| 641 | const struct pnp_device_id *id) |
| 642 | { |
| 643 | static int dev; |
| 644 | int err; |
| 645 | struct snd_card *card; |
| 646 | |
| 647 | if (pnp_device_is_isapnp(pdev)) |
| 648 | return -ENOENT; /* we have another procedure - card */ |
| 649 | for (; dev < SNDRV_CARDS; dev++) { |
| 650 | if (enable[dev] && isapnp[dev]) |
| 651 | break; |
| 652 | } |
| 653 | if (dev >= SNDRV_CARDS) |
| 654 | return -ENODEV; |
| 655 | |
| 656 | card = snd_cs423x_card_new(dev); |
| 657 | if (! card) |
| 658 | return -ENOMEM; |
| 659 | if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) { |
| 660 | printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n"); |
| 661 | snd_card_free(card); |
| 662 | return err; |
| 663 | } |
| 664 | snd_card_set_dev(card, &pdev->dev); |
| 665 | if ((err = snd_cs423x_probe(card, dev)) < 0) { |
| 666 | snd_card_free(card); |
| 667 | return err; |
| 668 | } |
| 669 | pnp_set_drvdata(pdev, card); |
| 670 | dev++; |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | static void __devexit snd_cs4232_pnp_remove(struct pnp_dev * pdev) |
| 675 | { |
| 676 | snd_card_free(pnp_get_drvdata(pdev)); |
| 677 | pnp_set_drvdata(pdev, NULL); |
| 678 | } |
| 679 | |
| 680 | #ifdef CONFIG_PM |
| 681 | static int snd_cs4232_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) |
| 682 | { |
| 683 | return snd_cs423x_suspend(pnp_get_drvdata(pdev)); |
| 684 | } |
| 685 | |
| 686 | static int snd_cs4232_pnp_resume(struct pnp_dev *pdev) |
| 687 | { |
| 688 | return snd_cs423x_resume(pnp_get_drvdata(pdev)); |
| 689 | } |
| 690 | #endif |
| 691 | |
| 692 | static struct pnp_driver cs4232_pnp_driver = { |
| 693 | .name = "cs4232-pnpbios", |
| 694 | .id_table = snd_cs4232_pnpbiosids, |
| 695 | .probe = snd_cs4232_pnpbios_detect, |
| 696 | .remove = __devexit_p(snd_cs4232_pnp_remove), |
| 697 | #ifdef CONFIG_PM |
| 698 | .suspend = snd_cs4232_pnp_suspend, |
| 699 | .resume = snd_cs4232_pnp_resume, |
| 700 | #endif |
| 701 | }; |
| 702 | #endif /* CS4232 */ |
| 703 | |
| 704 | static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard, |
| 705 | const struct pnp_card_device_id *pid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | { |
| 707 | static int dev; |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 708 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | int res; |
| 710 | |
| 711 | for ( ; dev < SNDRV_CARDS; dev++) { |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 712 | if (enable[dev] && isapnp[dev]) |
| 713 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | } |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 715 | if (dev >= SNDRV_CARDS) |
| 716 | return -ENODEV; |
| 717 | |
| 718 | card = snd_cs423x_card_new(dev); |
| 719 | if (! card) |
| 720 | return -ENOMEM; |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 721 | if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) { |
| 722 | printk(KERN_ERR "isapnp detection failed and probing for " IDENT |
| 723 | " is not supported\n"); |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 724 | snd_card_free(card); |
| 725 | return res; |
| 726 | } |
| 727 | snd_card_set_dev(card, &pcard->card->dev); |
| 728 | if ((res = snd_cs423x_probe(card, dev)) < 0) { |
| 729 | snd_card_free(card); |
| 730 | return res; |
| 731 | } |
| 732 | pnp_set_card_drvdata(pcard, card); |
| 733 | dev++; |
| 734 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | } |
| 736 | |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 737 | static void __devexit snd_cs423x_pnpc_remove(struct pnp_card_link * pcard) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | { |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 739 | snd_card_free(pnp_get_card_drvdata(pcard)); |
| 740 | pnp_set_card_drvdata(pcard, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | } |
Bjorn Helgaas | ed7cb19 | 2006-03-27 01:17:04 -0800 | [diff] [blame] | 742 | |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 743 | #ifdef CONFIG_PM |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 744 | static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 745 | { |
| 746 | return snd_cs423x_suspend(pnp_get_card_drvdata(pcard)); |
| 747 | } |
| 748 | |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 749 | static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 750 | { |
| 751 | return snd_cs423x_resume(pnp_get_card_drvdata(pcard)); |
| 752 | } |
| 753 | #endif |
| 754 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | static struct pnp_card_driver cs423x_pnpc_driver = { |
| 756 | .flags = PNP_DRIVER_RES_DISABLE, |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 757 | .name = CS423X_ISAPNP_DRIVER, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | .id_table = snd_cs423x_pnpids, |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 759 | .probe = snd_cs423x_pnpc_detect, |
| 760 | .remove = __devexit_p(snd_cs423x_pnpc_remove), |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 761 | #ifdef CONFIG_PM |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 762 | .suspend = snd_cs423x_pnpc_suspend, |
| 763 | .resume = snd_cs423x_pnpc_resume, |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 764 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | }; |
| 766 | #endif /* CONFIG_PNP */ |
| 767 | |
| 768 | static int __init alsa_card_cs423x_init(void) |
| 769 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 770 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 772 | err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS); |
| 773 | if (err < 0) |
Takashi Iwai | 6bba41a | 2005-11-17 17:00:53 +0100 | [diff] [blame] | 774 | return err; |
Takashi Iwai | 59b1b34 | 2006-01-04 15:06:44 +0100 | [diff] [blame] | 775 | #ifdef CONFIG_PNP |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 776 | #ifdef CS4232 |
Bjorn Helgaas | ed7cb19 | 2006-03-27 01:17:04 -0800 | [diff] [blame] | 777 | err = pnp_register_driver(&cs4232_pnp_driver); |
| 778 | if (!err) |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 779 | pnp_registered = 1; |
Takashi Iwai | a9824c8 | 2005-11-17 17:51:00 +0100 | [diff] [blame] | 780 | #endif |
Bjorn Helgaas | ed7cb19 | 2006-03-27 01:17:04 -0800 | [diff] [blame] | 781 | err = pnp_register_card_driver(&cs423x_pnpc_driver); |
| 782 | if (!err) |
Clemens Ladisch | f7a9275 | 2005-12-07 09:13:42 +0100 | [diff] [blame] | 783 | pnpc_registered = 1; |
Takashi Iwai | 59b1b34 | 2006-01-04 15:06:44 +0100 | [diff] [blame] | 784 | #endif /* CONFIG_PNP */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | return 0; |
| 786 | } |
| 787 | |
| 788 | static void __exit alsa_card_cs423x_exit(void) |
| 789 | { |
Takashi Iwai | 5e24c1c | 2007-02-22 12:50:54 +0100 | [diff] [blame^] | 790 | #ifdef CONFIG_PNP |
| 791 | if (pnpc_registered) |
| 792 | pnp_unregister_card_driver(&cs423x_pnpc_driver); |
| 793 | #ifdef CS4232 |
| 794 | if (pnp_registered) |
| 795 | pnp_unregister_driver(&cs4232_pnp_driver); |
| 796 | #endif |
| 797 | #endif /* CONFIG_PNP */ |
| 798 | isa_unregister_driver(&cs423x_isa_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | module_init(alsa_card_cs423x_init) |
| 802 | module_exit(alsa_card_cs423x_exit) |