2 * Driver for generic CS4232/CS4235/CS4236/CS4236B/CS4237B/CS4238B/CS4239 chips
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
22 #include <sound/driver.h>
23 #include <linux/init.h>
24 #include <linux/slab.h>
25 #include <linux/pnp.h>
26 #include <sound/core.h>
27 #include <sound/cs4231.h>
28 #include <sound/mpu401.h>
29 #include <sound/opl3.h>
31 #include <sound/initval.h>
33 #define chip_t cs4231_t
35 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36 MODULE_LICENSE("GPL");
37 MODULE_CLASSES("{sound}");
39 MODULE_DESCRIPTION("Cirrus Logic CS4232");
40 MODULE_DEVICES("{{Turtle Beach,TBS-2000},"
41 "{Turtle Beach,Tropez Plus},"
42 "{SIC CrystalWave 32},"
43 "{Hewlett Packard,Omnibook 5500},"
44 "{TerraTec,Maestro 32/96},"
45 "{Philips,PCA70PS}}");
47 MODULE_DESCRIPTION("Cirrus Logic CS4235-9");
48 MODULE_DEVICES("{{Crystal Semiconductors,CS4235},"
49 "{Crystal Semiconductors,CS4236},"
50 "{Crystal Semiconductors,CS4237},"
51 "{Crystal Semiconductors,CS4238},"
52 "{Crystal Semiconductors,CS4239},"
56 "{Crystal Computer,TidalWave128},"
57 "{Dell,Optiplex GX1},"
58 "{Dell,Workstation 400 sound},"
59 "{EliteGroup,P5TX-LA sound},"
61 "{Gateway,E1000 Onboard CS4236B},"
62 "{Genius,Sound Maker 3DJ},"
63 "{Hewlett Packard,HP6330 sound},"
64 "{IBM,PC 300PL sound},"
65 "{IBM,Aptiva 2137 E24},"
66 "{IBM,IntelliStation M Pro},"
67 "{Intel,Marlin Spike Mobo CS4235},"
68 "{Intel PR440FX Onboard},"
69 "{Guillemot,MaxiSound 16 PnP},"
71 "{TerraTec,AudioSystem EWS64L/XL},"
72 "{Typhoon Soundsystem,CS4236B},"
73 "{Turtle Beach,Malibu},"
74 "{Unknown,Digital PC 5000 Onboard}}");
78 #define IDENT "CS4232"
80 #define IDENT "CS4236+"
83 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
84 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
85 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
87 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
89 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
90 static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
91 static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */
92 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
93 static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
94 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
95 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
96 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
97 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
99 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
100 MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
101 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
102 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
103 MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
104 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
105 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
106 MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
107 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
109 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
110 MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
111 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC);
113 MODULE_PARM(port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
114 MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
115 MODULE_PARM_SYNTAX(port, SNDRV_PORT12_DESC);
116 MODULE_PARM(cport, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
117 MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
118 MODULE_PARM_SYNTAX(cport, SNDRV_PORT12_DESC);
119 MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
120 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
121 MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT12_DESC);
122 MODULE_PARM(fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
123 MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
124 MODULE_PARM_SYNTAX(fm_port, SNDRV_PORT12_DESC);
125 MODULE_PARM(sb_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
126 MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional).");
127 MODULE_PARM_SYNTAX(sb_port, SNDRV_PORT12_DESC);
128 MODULE_PARM(irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
129 MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
130 MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC);
131 MODULE_PARM(mpu_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
132 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
133 MODULE_PARM_SYNTAX(mpu_irq, SNDRV_IRQ_DESC);
134 MODULE_PARM(dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
135 MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
136 MODULE_PARM_SYNTAX(dma1, SNDRV_DMA_DESC);
137 MODULE_PARM(dma2, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
138 MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
139 MODULE_PARM_SYNTAX(dma2, SNDRV_DMA_DESC);
141 struct snd_card_cs4236 {
142 struct resource *res_sb_port;
145 struct pnp_dev *ctrl;
150 static snd_card_t *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
154 #define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \
156 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
157 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \
158 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \
159 ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401) } \
161 #define ISAPNP_CS4232_1(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \
163 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
164 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \
165 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \
166 ISAPNP_DEVICE_ID('P', 'N', 'P', _mpu401) } \
168 #define ISAPNP_CS4232_WOMPU(_va, _vb, _vc, _device, _wss, _ctrl) \
170 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
171 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \
172 ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl) } \
177 static struct pnp_card_device_id snd_cs423x_pnpids[] __devinitdata = {
178 /* Philips PCA70PS */
179 { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
180 /* TerraTec Maestro 32/96 (CS4232) */
181 { .id = "CSC1a32", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
182 /* HP Omnibook 5500 onboard */
183 { .id = "CSC4232", .devs = { { "CSC0000" }, { "CSC0002" }, { "CSC0003" } } },
184 /* Unnamed CS4236 card (Made in Taiwan) */
185 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
186 /* Turtle Beach TBS-2000 (CS4232) */
187 { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSCb006" } } },
188 /* Turtle Beach Tropez Plus (CS4232) */
189 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
190 /* SIC CrystalWave 32 (CS4232) */
191 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
193 { .id = "" } /* end */
196 static struct pnp_card_device_id snd_cs423x_pnpids[] __devinitdata = {
197 /* Intel Marlin Spike Motherboard - CS4235 */
198 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
199 /* Intel Marlin Spike Motherboard (#2) - CS4235 */
200 { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
201 /* Genius Sound Maker 3DJ - CS4237B */
202 { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
203 /* Digital PC 5000 Onboard - CS4236B */
204 { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } },
205 /* some uknown CS4236B */
206 { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
207 /* Intel PR440FX Onboard sound */
208 { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
209 /* CS4235 on mainboard without MPU */
210 { .id = "CSC1425", .devs = { { "CSC0100" }, { "CSC0110" } } },
211 /* Gateway E1000 Onboard CS4236B */
212 { .id = "CSC1335", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
213 /* HP 6330 Onboard sound */
214 { .id = "CSC1525", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
215 /* Crystal Computer TidalWave128 */
216 { .id = "CSC1e37", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
217 /* ACER AW37 - CS4235 */
218 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
219 /* build-in soundcard in EliteGroup P5TX-LA motherboard - CS4237B */
220 { .id = "CSC4237", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
221 /* Crystal 3D - CS4237B */
222 { .id = "CSC4336", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
223 /* Typhoon Soundsystem PnP - CS4236B */
224 { .id = "CSC4536", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
225 /* Crystal CX4235-XQ3 EP - CS4235 */
226 { .id = "CSC4625", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
227 /* Crystal Semiconductors CS4237B */
228 { .id = "CSC4637", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
229 /* NewClear 3D - CX4237B-XQ3 */
230 { .id = "CSC4837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
231 /* Dell Optiplex GX1 - CS4236B */
232 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
233 /* Dell P410 motherboard - CS4236B */
234 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" } } },
235 /* Dell Workstation 400 Onboard - CS4236B */
236 { .id = "CSC6836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
237 /* Turtle Beach Malibu - CS4237B */
238 { .id = "CSC7537", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
239 /* CS4235 - onboard */
240 { .id = "CSC8025", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
241 /* IBM Aptiva 2137 E24 Onboard - CS4237B */
242 { .id = "CSC8037", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
243 /* IBM IntelliStation M Pro motherboard */
244 { .id = "CSCc835", .devs = { { "CSC0000" }, { "CSC0010" } } },
245 /* Guillemot MaxiSound 16 PnP - CS4236B */
246 { .id = "CSC9836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
248 { .id = "CSC9837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
249 /* TerraTec AudioSystem EWS64XL - CS4236B */
250 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" }, { "CSCa803" } } },
251 /* TerraTec AudioSystem EWS64XL - CS4236B */
252 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" } } },
253 /* ACER AW37/Pro - CS4235 */
254 { .id = "CSCd925", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
255 /* ACER AW35/Pro - CS4237B */
256 { .id = "CSCd937", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
257 /* CS4235 without MPU401 */
258 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" } } },
259 /* IBM IntelliStation M Pro 6898 11U - CS4236B */
260 { .id = "CSCe835", .devs = { { "CSC0000" }, { "CSC0010" } } },
261 /* IBM PC 300PL Onboard - CS4236B */
262 { .id = "CSCe836", .devs = { { "CSC0000" }, { "CSC0010" } } },
263 /* Some noname CS4236 based card */
264 { .id = "CSCe936", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
266 { .id = "CSCf235", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
268 { .id = "CSCf238", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
270 { .id = "" } /* end */
274 MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids);
276 static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard,
277 struct pnp_card_link *card,
278 const struct pnp_card_device_id *id)
280 struct pnp_dev *pdev;
281 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
287 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
288 if (acard->wss == NULL) {
292 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL);
293 if (acard->ctrl == NULL) {
297 if (id->devs[2].id[0]) {
298 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
299 if (acard->mpu == NULL) {
305 /* WSS initialization */
307 pnp_init_resource_table(cfg);
308 if (port[dev] != SNDRV_AUTO_PORT)
309 pnp_resource_change(&cfg->port_resource[0], port[dev], 4);
310 if (fm_port[dev] != SNDRV_AUTO_PORT && fm_port[dev] >= 0)
311 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4);
312 if (sb_port[dev] != SNDRV_AUTO_PORT)
313 pnp_resource_change(&cfg->port_resource[2], sb_port[dev], 16);
314 if (irq[dev] != SNDRV_AUTO_IRQ)
315 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
316 if (dma1[dev] != SNDRV_AUTO_DMA)
317 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1);
318 if (dma2[dev] != SNDRV_AUTO_DMA)
319 pnp_resource_change(&cfg->dma_resource[1], dma2[dev] < 0 ? 4 : dma2[dev], 1);
320 err = pnp_manual_config_dev(pdev, cfg, 0);
322 snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n");
323 err = pnp_activate_dev(pdev);
326 printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n");
329 port[dev] = pnp_port_start(pdev, 0);
330 if (fm_port[dev] >= 0)
331 fm_port[dev] = pnp_port_start(pdev, 1);
332 sb_port[dev] = pnp_port_start(pdev, 2);
333 irq[dev] = pnp_irq(pdev, 0);
334 dma1[dev] = pnp_dma(pdev, 0);
335 dma2[dev] = pnp_dma(pdev, 1) == 4 ? -1 : (int)pnp_dma(pdev, 1);
336 snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n",
337 port[dev], fm_port[dev], sb_port[dev]);
338 snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n",
339 irq[dev], dma1[dev], dma2[dev]);
340 /* CTRL initialization */
341 if (acard->ctrl && cport[dev] >= 0) {
343 pnp_init_resource_table(cfg);
344 if (cport[dev] != SNDRV_AUTO_PORT)
345 pnp_resource_change(&cfg->port_resource[0], cport[dev], 8);
346 err = pnp_manual_config_dev(pdev, cfg, 0);
348 snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n");
349 err = pnp_activate_dev(pdev);
352 printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n");
355 cport[dev] = pnp_port_start(pdev, 0);
356 snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]);
358 /* MPU initialization */
359 if (acard->mpu && mpu_port[dev] >= 0) {
361 pnp_init_resource_table(cfg);
362 if (mpu_port[dev] != SNDRV_AUTO_PORT)
363 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);
364 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0)
365 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);
366 err = pnp_manual_config_dev(pdev, cfg, 0);
368 snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n");
369 err = pnp_activate_dev(pdev);
371 printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n");
372 mpu_port[dev] = SNDRV_AUTO_PORT;
373 mpu_irq[dev] = SNDRV_AUTO_IRQ;
375 mpu_port[dev] = pnp_port_start(pdev, 0);
376 if (pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
377 mpu_irq[dev] = pnp_irq(pdev, 0);
379 mpu_irq[dev] = -1; /* disable interrupt */
382 snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]);
387 #endif /* CONFIG_PNP */
389 static void snd_card_cs4236_free(snd_card_t *card)
391 struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data;
394 if (acard->res_sb_port) {
395 release_resource(acard->res_sb_port);
396 kfree_nocheck(acard->res_sb_port);
401 static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard,
402 const struct pnp_card_device_id *pid)
405 struct snd_card_cs4236 *acard;
406 snd_pcm_t *pcm = NULL;
414 if (port[dev] == SNDRV_AUTO_PORT) {
415 snd_printk("specify port\n");
418 if (cport[dev] == SNDRV_AUTO_PORT) {
419 snd_printk("specify cport\n");
425 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
426 sizeof(struct snd_card_cs4236));
429 acard = (struct snd_card_cs4236 *)card->private_data;
430 card->private_free = snd_card_cs4236_free;
432 if (isapnp[dev] && (err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) {
433 printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n");
438 if (mpu_port[dev] < 0)
439 mpu_port[dev] = SNDRV_AUTO_PORT;
440 if (fm_port[dev] < 0)
441 fm_port[dev] = SNDRV_AUTO_PORT;
442 if (sb_port[dev] < 0)
443 sb_port[dev] = SNDRV_AUTO_PORT;
444 if (sb_port[dev] != SNDRV_AUTO_PORT)
445 if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) {
446 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);
452 if ((err = snd_cs4231_create(card,
464 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) {
468 if ((err = snd_cs4231_mixer(chip)) < 0) {
474 if ((err = snd_cs4236_create(card,
486 if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) {
490 if ((err = snd_cs4236_mixer(chip)) < 0) {
496 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) {
501 if (fm_port[dev] != SNDRV_AUTO_PORT) {
502 if (snd_opl3_create(card,
503 fm_port[dev], fm_port[dev] + 2,
504 OPL3_HW_OPL3_CS, 0, &opl3) < 0) {
505 printk(KERN_ERR IDENT ": OPL3 not detected\n");
507 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
514 if (mpu_port[dev] != SNDRV_AUTO_PORT) {
515 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
518 mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0)
519 printk(KERN_ERR IDENT ": MPU401 not detected\n");
521 strcpy(card->driver, pcm->name);
522 strcpy(card->shortname, pcm->name);
523 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
529 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
530 if ((err = snd_card_register(card)) < 0) {
535 pnp_set_card_drvdata(pcard, card);
537 snd_cs4236_legacy[dev] = card;
542 static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card,
543 const struct pnp_card_device_id *id)
548 for ( ; dev < SNDRV_CARDS; dev++) {
551 res = snd_card_cs423x_probe(dev, card, id);
560 static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard)
562 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
564 snd_card_disconnect(card);
565 snd_card_free_in_thread(card);
568 static struct pnp_card_driver cs423x_pnpc_driver = {
569 .flags = PNP_DRIVER_RES_DISABLE,
571 .id_table = snd_cs423x_pnpids,
572 .probe = snd_cs423x_pnp_detect,
573 .remove = __devexit_p(snd_cs423x_pnp_remove),
575 #endif /* CONFIG_PNP */
577 static int __init alsa_card_cs423x_init(void)
581 for (dev = 0; dev < SNDRV_CARDS; dev++) {
588 if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0)
592 cards += pnp_register_card_driver(&cs423x_pnpc_driver);
596 pnp_unregister_card_driver(&cs423x_pnpc_driver);
599 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
606 static void __exit alsa_card_cs423x_exit(void)
611 /* PnP cards first */
612 pnp_unregister_card_driver(&cs423x_pnpc_driver);
614 for (idx = 0; idx < SNDRV_CARDS; idx++)
615 snd_card_free(snd_cs4236_legacy[idx]);
618 module_init(alsa_card_cs423x_init)
619 module_exit(alsa_card_cs423x_exit)
623 /* format is: snd-cs4232=enable,index,id,isapnp,port,
624 cport,mpu_port,fm_port,sb_port,
625 irq,mpu_irq,dma1,dma2 */
626 /* format is: snd-cs4236=enable,index,id,isapnp,port,
627 cport,mpu_port,fm_port,sb_port,
628 irq,mpu_irq,dma1,dma2 */
630 static int __init alsa_card_cs423x_setup(char *str)
632 static unsigned __initdata nr_dev = 0;
633 int __attribute__ ((__unused__)) pnp = INT_MAX;
635 if (nr_dev >= SNDRV_CARDS)
637 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
638 get_option(&str,&index[nr_dev]) == 2 &&
639 get_id(&str,&id[nr_dev]) == 2 &&
640 get_option(&str,&pnp) == 2 &&
641 get_option(&str,(int *)&port[nr_dev]) == 2 &&
642 get_option(&str,(int *)&cport[nr_dev]) == 2 &&
643 get_option(&str,(int *)&mpu_port[nr_dev]) == 2 &&
644 get_option(&str,(int *)&fm_port[nr_dev]) == 2 &&
645 get_option(&str,(int *)&sb_port[nr_dev]) == 2 &&
646 get_option(&str,&irq[nr_dev]) == 2 &&
647 get_option(&str,&mpu_irq[nr_dev]) == 2 &&
648 get_option(&str,&dma1[nr_dev]) == 2 &&
649 get_option(&str,&dma2[nr_dev]) == 2);
652 isapnp[nr_dev] = pnp;
659 __setup("snd-cs4232=", alsa_card_cs423x_setup);
661 __setup("snd-cs4236=", alsa_card_cs423x_setup);
664 #endif /* ifndef MODULE */