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