0001
0002
0003
0004
0005
0006
0007 #include <linux/init.h>
0008 #include <linux/err.h>
0009 #include <linux/isa.h>
0010 #include <linux/pnp.h>
0011 #include <linux/module.h>
0012 #include <sound/core.h>
0013 #include <sound/wss.h>
0014 #include <sound/mpu401.h>
0015 #include <sound/opl3.h>
0016 #include <sound/initval.h>
0017
0018 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
0019 MODULE_LICENSE("GPL");
0020 MODULE_DESCRIPTION("Cirrus Logic CS4232-9");
0021 MODULE_ALIAS("snd_cs4232");
0022
0023 #define IDENT "CS4232+"
0024 #define DEV_NAME "cs4232+"
0025
0026 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
0027 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
0028 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
0029 #ifdef CONFIG_PNP
0030 static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
0031 #endif
0032 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
0033 static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
0034 static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
0035 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
0036 static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
0037 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
0038 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
0039 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
0040 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
0041
0042 module_param_array(index, int, NULL, 0444);
0043 MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
0044 module_param_array(id, charp, NULL, 0444);
0045 MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
0046 module_param_array(enable, bool, NULL, 0444);
0047 MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
0048 #ifdef CONFIG_PNP
0049 module_param_array(isapnp, bool, NULL, 0444);
0050 MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
0051 #endif
0052 module_param_hw_array(port, long, ioport, NULL, 0444);
0053 MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
0054 module_param_hw_array(cport, long, ioport, NULL, 0444);
0055 MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
0056 module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
0057 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
0058 module_param_hw_array(fm_port, long, ioport, NULL, 0444);
0059 MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
0060 module_param_hw_array(sb_port, long, ioport, NULL, 0444);
0061 MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional).");
0062 module_param_hw_array(irq, int, irq, NULL, 0444);
0063 MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
0064 module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
0065 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
0066 module_param_hw_array(dma1, int, dma, NULL, 0444);
0067 MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
0068 module_param_hw_array(dma2, int, dma, NULL, 0444);
0069 MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
0070
0071 #ifdef CONFIG_PNP
0072 static int isa_registered;
0073 static int pnpc_registered;
0074 static int pnp_registered;
0075 #endif
0076
0077 struct snd_card_cs4236 {
0078 struct snd_wss *chip;
0079 #ifdef CONFIG_PNP
0080 struct pnp_dev *wss;
0081 struct pnp_dev *ctrl;
0082 struct pnp_dev *mpu;
0083 #endif
0084 };
0085
0086 #ifdef CONFIG_PNP
0087
0088
0089
0090
0091 static const struct pnp_device_id snd_cs423x_pnpbiosids[] = {
0092 { .id = "CSC0100" },
0093 { .id = "CSC0000" },
0094
0095
0096 { .id = "GIM0100" },
0097 { .id = "" }
0098 };
0099 MODULE_DEVICE_TABLE(pnp, snd_cs423x_pnpbiosids);
0100
0101 #define CS423X_ISAPNP_DRIVER "cs4232_isapnp"
0102 static const struct pnp_card_device_id snd_cs423x_pnpids[] = {
0103
0104 { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
0105
0106 { .id = "CSC1a32", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0107
0108 { .id = "CSC4232", .devs = { { "CSC0000" }, { "CSC0002" }, { "CSC0003" } } },
0109
0110 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0111
0112 { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSCb006" } } },
0113
0114 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
0115
0116 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0117
0118 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } },
0119
0120 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0121
0122 { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
0123
0124 { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" } } },
0125
0126 { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0127
0128 { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } },
0129
0130 { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0131
0132 { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0133
0134 { .id = "CSC1425", .devs = { { "CSC0100" }, { "CSC0110" } } },
0135
0136 { .id = "CSC1335", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0137
0138 { .id = "CSC1525", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
0139
0140 { .id = "CSC1e37", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0141
0142 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0143
0144 { .id = "CSC4237", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0145
0146 { .id = "CSC4336", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0147
0148 { .id = "CSC4536", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0149
0150 { .id = "CSC4625", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
0151
0152 { .id = "CSC4637", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0153
0154 { .id = "CSC4837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0155
0156 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0157
0158 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" } } },
0159
0160 { .id = "CSC6836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0161
0162 { .id = "CSC7537", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0163
0164 { .id = "CSC8025", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } },
0165
0166 { .id = "CSC8037", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0167
0168 { .id = "CSCc835", .devs = { { "CSC0000" }, { "CSC0010" } } },
0169
0170 { .id = "CSC9836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0171
0172 { .id = "CSC9837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0173
0174 { .id = "CSCa736", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0175
0176 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" }, { "CSCa803" } } },
0177
0178 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" } } },
0179
0180 { .id = "CSCd925", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0181
0182 { .id = "CSCd937", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0183
0184 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" } } },
0185
0186 { .id = "CSC4825", .devs = { { "CSC0100" }, { "CSC0110" } } },
0187
0188 { .id = "CSCe835", .devs = { { "CSC0000" }, { "CSC0010" } } },
0189
0190 { .id = "CSCe836", .devs = { { "CSC0000" }, { "CSC0010" } } },
0191
0192 { .id = "CSCe936", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0193
0194 { .id = "CSCf235", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0195
0196 { .id = "CSCf238", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
0197
0198 { .id = "" }
0199 };
0200
0201 MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids);
0202
0203
0204 static int snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev)
0205 {
0206 if (pnp_activate_dev(pdev) < 0) {
0207 printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n");
0208 return -EBUSY;
0209 }
0210 port[dev] = pnp_port_start(pdev, 0);
0211 if (fm_port[dev] > 0)
0212 fm_port[dev] = pnp_port_start(pdev, 1);
0213 sb_port[dev] = pnp_port_start(pdev, 2);
0214 irq[dev] = pnp_irq(pdev, 0);
0215 dma1[dev] = pnp_dma(pdev, 0);
0216 dma2[dev] = pnp_dma(pdev, 1) == 4 ? -1 : (int)pnp_dma(pdev, 1);
0217 snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n",
0218 port[dev], fm_port[dev], sb_port[dev]);
0219 snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n",
0220 irq[dev], dma1[dev], dma2[dev]);
0221 return 0;
0222 }
0223
0224
0225 static int snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev)
0226 {
0227 if (pnp_activate_dev(pdev) < 0) {
0228 printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n");
0229 return -EBUSY;
0230 }
0231 cport[dev] = pnp_port_start(pdev, 0);
0232 snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]);
0233 return 0;
0234 }
0235
0236
0237 static int snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
0238 {
0239 if (pnp_activate_dev(pdev) < 0) {
0240 printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n");
0241 mpu_port[dev] = SNDRV_AUTO_PORT;
0242 mpu_irq[dev] = SNDRV_AUTO_IRQ;
0243 } else {
0244 mpu_port[dev] = pnp_port_start(pdev, 0);
0245 if (mpu_irq[dev] >= 0 &&
0246 pnp_irq_valid(pdev, 0) &&
0247 pnp_irq(pdev, 0) != (resource_size_t)-1) {
0248 mpu_irq[dev] = pnp_irq(pdev, 0);
0249 } else {
0250 mpu_irq[dev] = -1;
0251 }
0252 }
0253 snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]);
0254 return 0;
0255 }
0256
0257 static int snd_card_cs423x_pnp(int dev, struct snd_card_cs4236 *acard,
0258 struct pnp_dev *pdev,
0259 struct pnp_dev *cdev)
0260 {
0261 acard->wss = pdev;
0262 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
0263 return -EBUSY;
0264 if (cdev)
0265 cport[dev] = pnp_port_start(cdev, 0);
0266 else
0267 cport[dev] = -1;
0268 return 0;
0269 }
0270
0271 static int snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard,
0272 struct pnp_card_link *card,
0273 const struct pnp_card_device_id *id)
0274 {
0275 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
0276 if (acard->wss == NULL)
0277 return -EBUSY;
0278 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL);
0279 if (acard->ctrl == NULL)
0280 return -EBUSY;
0281 if (id->devs[2].id[0]) {
0282 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
0283 if (acard->mpu == NULL)
0284 return -EBUSY;
0285 }
0286
0287
0288 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
0289 return -EBUSY;
0290
0291
0292 if (acard->ctrl && cport[dev] > 0) {
0293 if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl) < 0)
0294 return -EBUSY;
0295 }
0296
0297 if (acard->mpu && mpu_port[dev] > 0) {
0298 if (snd_cs423x_pnp_init_mpu(dev, acard->mpu) < 0)
0299 return -EBUSY;
0300 }
0301 return 0;
0302 }
0303 #endif
0304
0305 #ifdef CONFIG_PNP
0306 #define is_isapnp_selected(dev) isapnp[dev]
0307 #else
0308 #define is_isapnp_selected(dev) 0
0309 #endif
0310
0311 static int snd_cs423x_card_new(struct device *pdev, int dev,
0312 struct snd_card **cardp)
0313 {
0314 struct snd_card *card;
0315 int err;
0316
0317 err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
0318 sizeof(struct snd_card_cs4236), &card);
0319 if (err < 0)
0320 return err;
0321 *cardp = card;
0322 return 0;
0323 }
0324
0325 static int snd_cs423x_probe(struct snd_card *card, int dev)
0326 {
0327 struct snd_card_cs4236 *acard;
0328 struct snd_wss *chip;
0329 struct snd_opl3 *opl3;
0330 int err;
0331
0332 acard = card->private_data;
0333 if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) {
0334 if (!devm_request_region(card->dev, sb_port[dev], 16,
0335 IDENT " SB")) {
0336 printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);
0337 return -EBUSY;
0338 }
0339 }
0340
0341 err = snd_cs4236_create(card, port[dev], cport[dev],
0342 irq[dev],
0343 dma1[dev], dma2[dev],
0344 WSS_HW_DETECT3, 0, &chip);
0345 if (err < 0)
0346 return err;
0347
0348 acard->chip = chip;
0349 if (chip->hardware & WSS_HW_CS4236B_MASK) {
0350
0351 err = snd_cs4236_pcm(chip, 0);
0352 if (err < 0)
0353 return err;
0354
0355 err = snd_cs4236_mixer(chip);
0356 if (err < 0)
0357 return err;
0358 } else {
0359 err = snd_wss_pcm(chip, 0);
0360 if (err < 0)
0361 return err;
0362
0363 err = snd_wss_mixer(chip);
0364 if (err < 0)
0365 return err;
0366 }
0367 strscpy(card->driver, chip->pcm->name, sizeof(card->driver));
0368 strscpy(card->shortname, chip->pcm->name, sizeof(card->shortname));
0369 if (dma2[dev] < 0)
0370 snprintf(card->longname, sizeof(card->longname),
0371 "%s at 0x%lx, irq %i, dma %i",
0372 chip->pcm->name, chip->port, irq[dev], dma1[dev]);
0373 else
0374 snprintf(card->longname, sizeof(card->longname),
0375 "%s at 0x%lx, irq %i, dma %i&%d",
0376 chip->pcm->name, chip->port, irq[dev], dma1[dev],
0377 dma2[dev]);
0378
0379 err = snd_wss_timer(chip, 0);
0380 if (err < 0)
0381 return err;
0382
0383 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
0384 if (snd_opl3_create(card,
0385 fm_port[dev], fm_port[dev] + 2,
0386 OPL3_HW_OPL3_CS, 0, &opl3) < 0) {
0387 printk(KERN_WARNING IDENT ": OPL3 not detected\n");
0388 } else {
0389 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
0390 if (err < 0)
0391 return err;
0392 }
0393 }
0394
0395 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
0396 if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
0397 mpu_irq[dev] = -1;
0398 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
0399 mpu_port[dev], 0,
0400 mpu_irq[dev], NULL) < 0)
0401 printk(KERN_WARNING IDENT ": MPU401 not detected\n");
0402 }
0403
0404 return snd_card_register(card);
0405 }
0406
0407 static int snd_cs423x_isa_match(struct device *pdev,
0408 unsigned int dev)
0409 {
0410 if (!enable[dev] || is_isapnp_selected(dev))
0411 return 0;
0412
0413 if (port[dev] == SNDRV_AUTO_PORT) {
0414 dev_err(pdev, "please specify port\n");
0415 return 0;
0416 }
0417 if (cport[dev] == SNDRV_AUTO_PORT) {
0418 dev_err(pdev, "please specify cport\n");
0419 return 0;
0420 }
0421 if (irq[dev] == SNDRV_AUTO_IRQ) {
0422 dev_err(pdev, "please specify irq\n");
0423 return 0;
0424 }
0425 if (dma1[dev] == SNDRV_AUTO_DMA) {
0426 dev_err(pdev, "please specify dma1\n");
0427 return 0;
0428 }
0429 return 1;
0430 }
0431
0432 static int snd_cs423x_isa_probe(struct device *pdev,
0433 unsigned int dev)
0434 {
0435 struct snd_card *card;
0436 int err;
0437
0438 err = snd_cs423x_card_new(pdev, dev, &card);
0439 if (err < 0)
0440 return err;
0441 err = snd_cs423x_probe(card, dev);
0442 if (err < 0)
0443 return err;
0444 dev_set_drvdata(pdev, card);
0445 return 0;
0446 }
0447
0448 #ifdef CONFIG_PM
0449 static int snd_cs423x_suspend(struct snd_card *card)
0450 {
0451 struct snd_card_cs4236 *acard = card->private_data;
0452 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
0453 acard->chip->suspend(acard->chip);
0454 return 0;
0455 }
0456
0457 static int snd_cs423x_resume(struct snd_card *card)
0458 {
0459 struct snd_card_cs4236 *acard = card->private_data;
0460 acard->chip->resume(acard->chip);
0461 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
0462 return 0;
0463 }
0464
0465 static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
0466 pm_message_t state)
0467 {
0468 return snd_cs423x_suspend(dev_get_drvdata(dev));
0469 }
0470
0471 static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
0472 {
0473 return snd_cs423x_resume(dev_get_drvdata(dev));
0474 }
0475 #endif
0476
0477 static struct isa_driver cs423x_isa_driver = {
0478 .match = snd_cs423x_isa_match,
0479 .probe = snd_cs423x_isa_probe,
0480 #ifdef CONFIG_PM
0481 .suspend = snd_cs423x_isa_suspend,
0482 .resume = snd_cs423x_isa_resume,
0483 #endif
0484 .driver = {
0485 .name = DEV_NAME
0486 },
0487 };
0488
0489
0490 #ifdef CONFIG_PNP
0491 static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
0492 const struct pnp_device_id *id)
0493 {
0494 static int dev;
0495 int err;
0496 struct snd_card *card;
0497 struct pnp_dev *cdev, *iter;
0498 char cid[PNP_ID_LEN];
0499
0500 if (pnp_device_is_isapnp(pdev))
0501 return -ENOENT;
0502 for (; dev < SNDRV_CARDS; dev++) {
0503 if (enable[dev] && isapnp[dev])
0504 break;
0505 }
0506 if (dev >= SNDRV_CARDS)
0507 return -ENODEV;
0508
0509
0510 strcpy(cid, pdev->id[0].id);
0511 cid[5] = '1';
0512 cdev = NULL;
0513 list_for_each_entry(iter, &(pdev->protocol->devices), protocol_list) {
0514 if (!strcmp(iter->id[0].id, cid)) {
0515 cdev = iter;
0516 break;
0517 }
0518 }
0519 err = snd_cs423x_card_new(&pdev->dev, dev, &card);
0520 if (err < 0)
0521 return err;
0522 err = snd_card_cs423x_pnp(dev, card->private_data, pdev, cdev);
0523 if (err < 0) {
0524 printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n");
0525 return err;
0526 }
0527 err = snd_cs423x_probe(card, dev);
0528 if (err < 0)
0529 return err;
0530 pnp_set_drvdata(pdev, card);
0531 dev++;
0532 return 0;
0533 }
0534
0535 #ifdef CONFIG_PM
0536 static int snd_cs423x_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
0537 {
0538 return snd_cs423x_suspend(pnp_get_drvdata(pdev));
0539 }
0540
0541 static int snd_cs423x_pnp_resume(struct pnp_dev *pdev)
0542 {
0543 return snd_cs423x_resume(pnp_get_drvdata(pdev));
0544 }
0545 #endif
0546
0547 static struct pnp_driver cs423x_pnp_driver = {
0548 .name = "cs423x-pnpbios",
0549 .id_table = snd_cs423x_pnpbiosids,
0550 .probe = snd_cs423x_pnpbios_detect,
0551 #ifdef CONFIG_PM
0552 .suspend = snd_cs423x_pnp_suspend,
0553 .resume = snd_cs423x_pnp_resume,
0554 #endif
0555 };
0556
0557 static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
0558 const struct pnp_card_device_id *pid)
0559 {
0560 static int dev;
0561 struct snd_card *card;
0562 int res;
0563
0564 for ( ; dev < SNDRV_CARDS; dev++) {
0565 if (enable[dev] && isapnp[dev])
0566 break;
0567 }
0568 if (dev >= SNDRV_CARDS)
0569 return -ENODEV;
0570
0571 res = snd_cs423x_card_new(&pcard->card->dev, dev, &card);
0572 if (res < 0)
0573 return res;
0574 res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid);
0575 if (res < 0) {
0576 printk(KERN_ERR "isapnp detection failed and probing for " IDENT
0577 " is not supported\n");
0578 return res;
0579 }
0580 res = snd_cs423x_probe(card, dev);
0581 if (res < 0)
0582 return res;
0583 pnp_set_card_drvdata(pcard, card);
0584 dev++;
0585 return 0;
0586 }
0587
0588 #ifdef CONFIG_PM
0589 static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state)
0590 {
0591 return snd_cs423x_suspend(pnp_get_card_drvdata(pcard));
0592 }
0593
0594 static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard)
0595 {
0596 return snd_cs423x_resume(pnp_get_card_drvdata(pcard));
0597 }
0598 #endif
0599
0600 static struct pnp_card_driver cs423x_pnpc_driver = {
0601 .flags = PNP_DRIVER_RES_DISABLE,
0602 .name = CS423X_ISAPNP_DRIVER,
0603 .id_table = snd_cs423x_pnpids,
0604 .probe = snd_cs423x_pnpc_detect,
0605 #ifdef CONFIG_PM
0606 .suspend = snd_cs423x_pnpc_suspend,
0607 .resume = snd_cs423x_pnpc_resume,
0608 #endif
0609 };
0610 #endif
0611
0612 static int __init alsa_card_cs423x_init(void)
0613 {
0614 int err;
0615
0616 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
0617 #ifdef CONFIG_PNP
0618 if (!err)
0619 isa_registered = 1;
0620 err = pnp_register_driver(&cs423x_pnp_driver);
0621 if (!err)
0622 pnp_registered = 1;
0623 err = pnp_register_card_driver(&cs423x_pnpc_driver);
0624 if (!err)
0625 pnpc_registered = 1;
0626 if (pnp_registered)
0627 err = 0;
0628 if (isa_registered)
0629 err = 0;
0630 #endif
0631 return err;
0632 }
0633
0634 static void __exit alsa_card_cs423x_exit(void)
0635 {
0636 #ifdef CONFIG_PNP
0637 if (pnpc_registered)
0638 pnp_unregister_card_driver(&cs423x_pnpc_driver);
0639 if (pnp_registered)
0640 pnp_unregister_driver(&cs423x_pnp_driver);
0641 if (isa_registered)
0642 #endif
0643 isa_unregister_driver(&cs423x_isa_driver);
0644 }
0645
0646 module_init(alsa_card_cs423x_init)
0647 module_exit(alsa_card_cs423x_exit)