blob: 750f51c904fcb446b0726109516f04c1bd348bac [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Driver for generic CS4232/CS4235/CS4236/CS4236B/CS4237B/CS4238B/CS4239 chips
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02003 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
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 Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/init.h>
Takashi Iwai6bba41a2005-11-17 17:00:53 +010023#include <linux/err.h>
Takashi Iwai5e24c1c2007-02-22 12:50:54 +010024#include <linux/isa.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/pnp.h>
Paul Gortmaker65a77212011-07-15 13:13:37 -040026#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <sound/core.h>
Krzysztof Helt61ef19d2008-07-31 21:02:42 +020028#include <sound/wss.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <sound/mpu401.h>
30#include <sound/opl3.h>
31#include <sound/initval.h>
32
Jaroslav Kyselac1017a42007-10-15 09:50:19 +020033MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
Linus Torvalds1da177e2005-04-16 15:20:36 -070034MODULE_LICENSE("GPL");
Krzysztof Heltc2b73d12009-02-16 21:38:37 +010035MODULE_DESCRIPTION("Cirrus Logic CS4232-9");
Linus Torvalds1da177e2005-04-16 15:20:36 -070036MODULE_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 Heltc2b73d12009-02-16 21:38:37 +010041 "{Philips,PCA70PS}},"
42 "{{Crystal Semiconductors,CS4235},"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 "{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 Torvalds1da177e2005-04-16 15:20:36 -070069
Krzysztof Heltc2b73d12009-02-16 21:38:37 +010070MODULE_ALIAS("snd_cs4232");
71
72#define IDENT "CS4232+"
73#define DEV_NAME "cs4232+"
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
Rusty Russella67ff6a2011-12-15 13:49:36 +103077static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#ifdef CONFIG_PNP
Rusty Russella67ff6a2011-12-15 13:49:36 +103079static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif
81static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
82static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
83static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */
84static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
85static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
86static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
87static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
88static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
89static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
90
91module_param_array(index, int, NULL, 0444);
92MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
93module_param_array(id, charp, NULL, 0444);
94MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
95module_param_array(enable, bool, NULL, 0444);
96MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
97#ifdef CONFIG_PNP
98module_param_array(isapnp, bool, NULL, 0444);
99MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
100#endif
101module_param_array(port, long, NULL, 0444);
102MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
103module_param_array(cport, long, NULL, 0444);
104MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
105module_param_array(mpu_port, long, NULL, 0444);
106MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
107module_param_array(fm_port, long, NULL, 0444);
108MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
109module_param_array(sb_port, long, NULL, 0444);
110MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional).");
111module_param_array(irq, int, NULL, 0444);
112MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
113module_param_array(mpu_irq, int, NULL, 0444);
114MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
115module_param_array(dma1, int, NULL, 0444);
116MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
117module_param_array(dma2, int, NULL, 0444);
118MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
119
Takashi Iwai59b1b342006-01-04 15:06:44 +0100120#ifdef CONFIG_PNP
Rene Herman609d7692007-05-15 11:42:56 +0200121static int isa_registered;
Clemens Ladischf7a92752005-12-07 09:13:42 +0100122static int pnpc_registered;
Clemens Ladischf7a92752005-12-07 09:13:42 +0100123static int pnp_registered;
Takashi Iwai59b1b342006-01-04 15:06:44 +0100124#endif /* CONFIG_PNP */
Clemens Ladischf7a92752005-12-07 09:13:42 +0100125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126struct snd_card_cs4236 {
Krzysztof Helt7779f752008-07-31 21:03:41 +0200127 struct snd_wss *chip;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 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 Torvalds1da177e2005-04-16 15:20:36 -0700136#ifdef CONFIG_PNP
137
Takashi Iwaia9824c82005-11-17 17:51:00 +0100138/*
139 * PNP BIOS
140 */
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100141static const struct pnp_device_id snd_cs423x_pnpbiosids[] = {
Takashi Iwaia9824c82005-11-17 17:51:00 +0100142 { .id = "CSC0100" },
143 { .id = "CSC0000" },
144 /* Guillemot Turtlebeach something appears to be cs4232 compatible
145 * (untested) */
146 { .id = "GIM0100" },
147 { .id = "" }
148};
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100149MODULE_DEVICE_TABLE(pnp, snd_cs423x_pnpbiosids);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100151#define CS423X_ISAPNP_DRIVER "cs4232_isapnp"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152static 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 Stemach50f794c2006-01-23 15:22:13 +0100167 /* Netfinity 3000 on-board soundcard */
168 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 /* 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 Rosaaf901ca2009-11-14 13:09:05 -0200179 /* some unknown CS4236B */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 { .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 Hermanebae2252008-08-04 01:23:43 +0200223 /* Techmakers MF-4236PW */
224 { .id = "CSCa736", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 /* 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 Torvalds1da177e2005-04-16 15:20:36 -0700250
251MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids);
252
Takashi Iwaia9824c82005-11-17 17:51:00 +0100253/* WSS initialization */
Bill Pemberton1bff2922012-12-06 12:35:21 -0500254static int snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
Rene Herman109c53f842007-11-30 17:59:25 +0100256 if (pnp_activate_dev(pdev) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 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 Iwaia9824c82005-11-17 17:51:00 +0100271 return 0;
272}
273
274/* CTRL initialization */
Bill Pemberton1bff2922012-12-06 12:35:21 -0500275static int snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100276{
Rene Herman109c53f842007-11-30 17:59:25 +0100277 if (pnp_activate_dev(pdev) < 0) {
Takashi Iwaia9824c82005-11-17 17:51:00 +0100278 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 Pemberton1bff2922012-12-06 12:35:21 -0500287static int snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100288{
Rene Herman109c53f842007-11-30 17:59:25 +0100289 if (pnp_activate_dev(pdev) < 0) {
Takashi Iwaia9824c82005-11-17 17:51:00 +0100290 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 Pemberton1bff2922012-12-06 12:35:21 -0500306static int snd_card_cs423x_pnp(int dev, struct snd_card_cs4236 *acard,
307 struct pnp_dev *pdev,
308 struct pnp_dev *cdev)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100309{
Krzysztof Heltb15ebe22008-07-23 07:48:49 +0200310 acard->wss = pdev;
Rene Herman109c53f842007-11-30 17:59:25 +0100311 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100312 return -EBUSY;
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100313 if (cdev)
314 cport[dev] = pnp_port_start(cdev, 0);
315 else
316 cport[dev] = -1;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100317 return 0;
318}
Takashi Iwaia9824c82005-11-17 17:51:00 +0100319
Bill Pemberton1bff2922012-12-06 12:35:21 -0500320static 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 Iwaia9824c82005-11-17 17:51:00 +0100323{
Takashi Iwaia9824c82005-11-17 17:51:00 +0100324 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
325 if (acard->wss == NULL)
Rene Herman109c53f842007-11-30 17:59:25 +0100326 return -EBUSY;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100327 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL);
328 if (acard->ctrl == NULL)
Rene Herman109c53f842007-11-30 17:59:25 +0100329 return -EBUSY;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100330 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 Herman109c53f842007-11-30 17:59:25 +0100333 return -EBUSY;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100334 }
335
336 /* WSS initialization */
Rene Herman109c53f842007-11-30 17:59:25 +0100337 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
338 return -EBUSY;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100339
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 /* CTRL initialization */
341 if (acard->ctrl && cport[dev] > 0) {
Rene Herman109c53f842007-11-30 17:59:25 +0100342 if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl) < 0)
343 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 }
345 /* MPU initialization */
346 if (acard->mpu && mpu_port[dev] > 0) {
Rene Herman109c53f842007-11-30 17:59:25 +0100347 if (snd_cs423x_pnp_init_mpu(dev, acard->mpu) < 0)
348 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 return 0;
351}
352#endif /* CONFIG_PNP */
353
Takashi Iwai43bcd972005-09-05 17:19:20 +0200354#ifdef CONFIG_PNP
355#define is_isapnp_selected(dev) isapnp[dev]
356#else
357#define is_isapnp_selected(dev) 0
358#endif
359
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100360static 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 Iwai4323cc42014-01-29 13:03:56 +0100367static int snd_cs423x_card_new(struct device *pdev, int dev,
368 struct snd_card **cardp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
Takashi Iwaiba2375a2005-11-17 14:30:42 +0100370 struct snd_card *card;
Takashi Iwaic95eadd2008-12-28 16:43:35 +0100371 int err;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100372
Takashi Iwai4323cc42014-01-29 13:03:56 +0100373 err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
374 sizeof(struct snd_card_cs4236), &card);
Takashi Iwaic95eadd2008-12-28 16:43:35 +0100375 if (err < 0)
Takashi Iwai3e7fb9f2008-12-28 16:47:30 +0100376 return err;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100377 card->private_free = snd_card_cs4236_free;
Takashi Iwai3e7fb9f2008-12-28 16:47:30 +0100378 *cardp = card;
379 return 0;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100380}
381
Bill Pemberton1bff2922012-12-06 12:35:21 -0500382static int snd_cs423x_probe(struct snd_card *card, int dev)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100383{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 struct snd_card_cs4236 *acard;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100385 struct snd_pcm *pcm;
Krzysztof Helt7779f752008-07-31 21:03:41 +0200386 struct snd_wss *chip;
Takashi Iwaiba2375a2005-11-17 14:30:42 +0100387 struct snd_opl3 *opl3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 int err;
389
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100390 acard = card->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 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 Iwai6bba41a2005-11-17 17:00:53 +0100394 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 }
396
Krzysztof Heltd114cd82009-11-05 18:32:41 +0100397 err = snd_cs4236_create(card, port[dev], cport[dev],
Krzysztof Helt7779f752008-07-31 21:03:41 +0200398 irq[dev],
399 dma1[dev], dma2[dev],
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100400 WSS_HW_DETECT3, 0, &chip);
Krzysztof Helt7779f752008-07-31 21:03:41 +0200401 if (err < 0)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100402 return err;
Krzysztof Heltd114cd82009-11-05 18:32:41 +0100403
404 acard->chip = chip;
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100405 if (chip->hardware & WSS_HW_CS4236B_MASK) {
Takashi Iwai43bcd972005-09-05 17:19:20 +0200406
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100407 err = snd_cs4236_pcm(chip, 0, &pcm);
408 if (err < 0)
409 return err;
Takashi Iwai43bcd972005-09-05 17:19:20 +0200410
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100411 err = snd_cs4236_mixer(chip);
412 if (err < 0)
413 return err;
414 } else {
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100415 err = snd_wss_pcm(chip, 0, &pcm);
416 if (err < 0)
417 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100419 err = snd_wss_mixer(chip);
420 if (err < 0)
421 return err;
422 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 strcpy(card->driver, pcm->name);
424 strcpy(card->shortname, pcm->name);
425 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
426 pcm->name,
427 chip->port,
428 irq[dev],
429 dma1[dev]);
430 if (dma2[dev] >= 0)
431 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
432
Krzysztof Helt7779f752008-07-31 21:03:41 +0200433 err = snd_wss_timer(chip, 0, NULL);
434 if (err < 0)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100435 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
437 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
438 if (snd_opl3_create(card,
439 fm_port[dev], fm_port[dev] + 2,
440 OPL3_HW_OPL3_CS, 0, &opl3) < 0) {
Takashi Iwai43bcd972005-09-05 17:19:20 +0200441 printk(KERN_WARNING IDENT ": OPL3 not detected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 } else {
Takashi Iwai43bcd972005-09-05 17:19:20 +0200443 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100444 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 }
446 }
447
448 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
449 if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
450 mpu_irq[dev] = -1;
451 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
452 mpu_port[dev], 0,
Clemens Ladischdba8b462011-09-13 11:24:41 +0200453 mpu_irq[dev], NULL) < 0)
Takashi Iwai43bcd972005-09-05 17:19:20 +0200454 printk(KERN_WARNING IDENT ": MPU401 not detected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 }
Takashi Iwai43bcd972005-09-05 17:19:20 +0200456
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100457 return snd_card_register(card);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458}
459
Bill Pemberton1bff2922012-12-06 12:35:21 -0500460static int snd_cs423x_isa_match(struct device *pdev,
461 unsigned int dev)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100462{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100463 if (!enable[dev] || is_isapnp_selected(dev))
464 return 0;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100465
466 if (port[dev] == SNDRV_AUTO_PORT) {
Takashi Iwai0418ff02008-11-03 08:51:33 +0100467 dev_err(pdev, "please specify port\n");
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100468 return 0;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100469 }
470 if (cport[dev] == SNDRV_AUTO_PORT) {
Takashi Iwai0418ff02008-11-03 08:51:33 +0100471 dev_err(pdev, "please specify cport\n");
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100472 return 0;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100473 }
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100474 if (irq[dev] == SNDRV_AUTO_IRQ) {
Takashi Iwai0418ff02008-11-03 08:51:33 +0100475 dev_err(pdev, "please specify irq\n");
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100476 return 0;
477 }
478 if (dma1[dev] == SNDRV_AUTO_DMA) {
Takashi Iwai0418ff02008-11-03 08:51:33 +0100479 dev_err(pdev, "please specify dma1\n");
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100480 return 0;
481 }
482 return 1;
483}
484
Bill Pemberton1bff2922012-12-06 12:35:21 -0500485static int snd_cs423x_isa_probe(struct device *pdev,
486 unsigned int dev)
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100487{
488 struct snd_card *card;
489 int err;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100490
Takashi Iwai4323cc42014-01-29 13:03:56 +0100491 err = snd_cs423x_card_new(pdev, dev, &card);
Takashi Iwai3e7fb9f2008-12-28 16:47:30 +0100492 if (err < 0)
493 return err;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100494 if ((err = snd_cs423x_probe(card, dev)) < 0) {
495 snd_card_free(card);
496 return err;
497 }
Bjorn Helgaased7cb192006-03-27 01:17:04 -0800498
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100499 dev_set_drvdata(pdev, card);
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100500 return 0;
501}
502
Bill Pemberton1bff2922012-12-06 12:35:21 -0500503static int snd_cs423x_isa_remove(struct device *pdev,
504 unsigned int dev)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100505{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100506 snd_card_free(dev_get_drvdata(pdev));
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100507 return 0;
508}
509
510#ifdef CONFIG_PM
511static int snd_cs423x_suspend(struct snd_card *card)
512{
513 struct snd_card_cs4236 *acard = card->private_data;
514 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
515 acard->chip->suspend(acard->chip);
516 return 0;
517}
518
519static int snd_cs423x_resume(struct snd_card *card)
520{
521 struct snd_card_cs4236 *acard = card->private_data;
522 acard->chip->resume(acard->chip);
523 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
524 return 0;
525}
526
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100527static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
528 pm_message_t state)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100529{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100530 return snd_cs423x_suspend(dev_get_drvdata(dev));
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100531}
532
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100533static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100534{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100535 return snd_cs423x_resume(dev_get_drvdata(dev));
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100536}
537#endif
538
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100539static struct isa_driver cs423x_isa_driver = {
540 .match = snd_cs423x_isa_match,
541 .probe = snd_cs423x_isa_probe,
Bill Pemberton1bff2922012-12-06 12:35:21 -0500542 .remove = snd_cs423x_isa_remove,
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100543#ifdef CONFIG_PM
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100544 .suspend = snd_cs423x_isa_suspend,
545 .resume = snd_cs423x_isa_resume,
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100546#endif
547 .driver = {
Rene Herman83c51c02007-03-20 11:33:46 +0100548 .name = DEV_NAME
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100549 },
550};
551
552
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553#ifdef CONFIG_PNP
Bill Pemberton1bff2922012-12-06 12:35:21 -0500554static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
555 const struct pnp_device_id *id)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100556{
557 static int dev;
558 int err;
559 struct snd_card *card;
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100560 struct pnp_dev *cdev;
561 char cid[PNP_ID_LEN];
Takashi Iwaia9824c82005-11-17 17:51:00 +0100562
563 if (pnp_device_is_isapnp(pdev))
564 return -ENOENT; /* we have another procedure - card */
565 for (; dev < SNDRV_CARDS; dev++) {
566 if (enable[dev] && isapnp[dev])
567 break;
568 }
569 if (dev >= SNDRV_CARDS)
570 return -ENODEV;
571
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100572 /* prepare second id */
573 strcpy(cid, pdev->id[0].id);
574 cid[5] = '1';
575 cdev = NULL;
576 list_for_each_entry(cdev, &(pdev->protocol->devices), protocol_list) {
577 if (!strcmp(cdev->id[0].id, cid))
578 break;
579 }
Takashi Iwai4323cc42014-01-29 13:03:56 +0100580 err = snd_cs423x_card_new(&pdev->dev, dev, &card);
Takashi Iwai3e7fb9f2008-12-28 16:47:30 +0100581 if (err < 0)
582 return err;
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100583 err = snd_card_cs423x_pnp(dev, card->private_data, pdev, cdev);
584 if (err < 0) {
Takashi Iwaia9824c82005-11-17 17:51:00 +0100585 printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n");
586 snd_card_free(card);
587 return err;
588 }
Takashi Iwaia9824c82005-11-17 17:51:00 +0100589 if ((err = snd_cs423x_probe(card, dev)) < 0) {
590 snd_card_free(card);
591 return err;
592 }
593 pnp_set_drvdata(pdev, card);
594 dev++;
595 return 0;
596}
597
Bill Pemberton1bff2922012-12-06 12:35:21 -0500598static void snd_cs423x_pnp_remove(struct pnp_dev *pdev)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100599{
600 snd_card_free(pnp_get_drvdata(pdev));
Takashi Iwaia9824c82005-11-17 17:51:00 +0100601}
602
603#ifdef CONFIG_PM
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100604static int snd_cs423x_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100605{
606 return snd_cs423x_suspend(pnp_get_drvdata(pdev));
607}
608
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100609static int snd_cs423x_pnp_resume(struct pnp_dev *pdev)
Takashi Iwaia9824c82005-11-17 17:51:00 +0100610{
611 return snd_cs423x_resume(pnp_get_drvdata(pdev));
612}
613#endif
614
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100615static struct pnp_driver cs423x_pnp_driver = {
616 .name = "cs423x-pnpbios",
617 .id_table = snd_cs423x_pnpbiosids,
618 .probe = snd_cs423x_pnpbios_detect,
Bill Pemberton1bff2922012-12-06 12:35:21 -0500619 .remove = snd_cs423x_pnp_remove,
Takashi Iwaia9824c82005-11-17 17:51:00 +0100620#ifdef CONFIG_PM
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100621 .suspend = snd_cs423x_pnp_suspend,
622 .resume = snd_cs423x_pnp_resume,
Takashi Iwaia9824c82005-11-17 17:51:00 +0100623#endif
624};
Takashi Iwaia9824c82005-11-17 17:51:00 +0100625
Bill Pemberton1bff2922012-12-06 12:35:21 -0500626static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
627 const struct pnp_card_device_id *pid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628{
629 static int dev;
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100630 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 int res;
632
633 for ( ; dev < SNDRV_CARDS; dev++) {
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100634 if (enable[dev] && isapnp[dev])
635 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 }
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100637 if (dev >= SNDRV_CARDS)
638 return -ENODEV;
639
Takashi Iwai4323cc42014-01-29 13:03:56 +0100640 res = snd_cs423x_card_new(&pcard->card->dev, dev, &card);
Takashi Iwai3e7fb9f2008-12-28 16:47:30 +0100641 if (res < 0)
642 return res;
Takashi Iwaia9824c82005-11-17 17:51:00 +0100643 if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) {
644 printk(KERN_ERR "isapnp detection failed and probing for " IDENT
645 " is not supported\n");
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100646 snd_card_free(card);
647 return res;
648 }
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100649 if ((res = snd_cs423x_probe(card, dev)) < 0) {
650 snd_card_free(card);
651 return res;
652 }
653 pnp_set_card_drvdata(pcard, card);
654 dev++;
655 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656}
657
Bill Pemberton1bff2922012-12-06 12:35:21 -0500658static void snd_cs423x_pnpc_remove(struct pnp_card_link *pcard)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659{
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100660 snd_card_free(pnp_get_card_drvdata(pcard));
661 pnp_set_card_drvdata(pcard, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662}
Bjorn Helgaased7cb192006-03-27 01:17:04 -0800663
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100664#ifdef CONFIG_PM
Takashi Iwaia9824c82005-11-17 17:51:00 +0100665static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100666{
667 return snd_cs423x_suspend(pnp_get_card_drvdata(pcard));
668}
669
Takashi Iwaia9824c82005-11-17 17:51:00 +0100670static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard)
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100671{
672 return snd_cs423x_resume(pnp_get_card_drvdata(pcard));
673}
674#endif
675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676static struct pnp_card_driver cs423x_pnpc_driver = {
677 .flags = PNP_DRIVER_RES_DISABLE,
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100678 .name = CS423X_ISAPNP_DRIVER,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .id_table = snd_cs423x_pnpids,
Takashi Iwaia9824c82005-11-17 17:51:00 +0100680 .probe = snd_cs423x_pnpc_detect,
Bill Pemberton1bff2922012-12-06 12:35:21 -0500681 .remove = snd_cs423x_pnpc_remove,
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100682#ifdef CONFIG_PM
Takashi Iwaia9824c82005-11-17 17:51:00 +0100683 .suspend = snd_cs423x_pnpc_suspend,
684 .resume = snd_cs423x_pnpc_resume,
Takashi Iwai6bba41a2005-11-17 17:00:53 +0100685#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686};
687#endif /* CONFIG_PNP */
688
689static int __init alsa_card_cs423x_init(void)
690{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100691 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100693 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
Takashi Iwai59b1b342006-01-04 15:06:44 +0100694#ifdef CONFIG_PNP
Rene Herman609d7692007-05-15 11:42:56 +0200695 if (!err)
696 isa_registered = 1;
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100697 err = pnp_register_driver(&cs423x_pnp_driver);
Bjorn Helgaased7cb192006-03-27 01:17:04 -0800698 if (!err)
Clemens Ladischf7a92752005-12-07 09:13:42 +0100699 pnp_registered = 1;
Bjorn Helgaased7cb192006-03-27 01:17:04 -0800700 err = pnp_register_card_driver(&cs423x_pnpc_driver);
701 if (!err)
Clemens Ladischf7a92752005-12-07 09:13:42 +0100702 pnpc_registered = 1;
Rene Herman609d7692007-05-15 11:42:56 +0200703 if (pnp_registered)
704 err = 0;
Rene Herman609d7692007-05-15 11:42:56 +0200705 if (isa_registered)
706 err = 0;
707#endif
708 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709}
710
711static void __exit alsa_card_cs423x_exit(void)
712{
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100713#ifdef CONFIG_PNP
714 if (pnpc_registered)
715 pnp_unregister_card_driver(&cs423x_pnpc_driver);
Takashi Iwai5e24c1c2007-02-22 12:50:54 +0100716 if (pnp_registered)
Krzysztof Heltc2b73d12009-02-16 21:38:37 +0100717 pnp_unregister_driver(&cs423x_pnp_driver);
Rene Herman609d7692007-05-15 11:42:56 +0200718 if (isa_registered)
719#endif
720 isa_unregister_driver(&cs423x_isa_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721}
722
723module_init(alsa_card_cs423x_init)
724module_exit(alsa_card_cs423x_exit)