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