Changeset 246 for GPL/branches/alsa-resync1/alsa-kernel/isa/cmi8330.c
- Timestamp:
- Aug 22, 2007, 5:33:25 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/alsa-resync1/alsa-kernel/isa/cmi8330.c
r224 r246 47 47 #include <linux/init.h> 48 48 #include <linux/slab.h> 49 #ifndef LINUX_ISAPNP_H 50 #include <linux/isapnp.h> 51 #define isapnp_card pci_bus 52 #define isapnp_dev pci_dev 53 #endif 49 #include <linux/pnp.h> 54 50 #include <sound/core.h> 55 51 #include <sound/ad1848.h> … … 74 70 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 75 71 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; 76 #ifdef __ISAPNP__72 #ifdef CONFIG_PNP 77 73 #ifdef TARGET_OS2 78 74 static int isapnp[SNDRV_CARDS] = {REPEAT_SNDRV(1)}; … … 98 94 MODULE_PARM_DESC(enable, "Enable CMI8330 soundcard."); 99 95 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 100 #ifdef __ISAPNP__96 #ifdef CONFIG_PNP 101 97 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 102 MODULE_PARM_DESC(isapnp, " ISAPnP detection for specified soundcard.");98 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 103 99 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); 104 100 #endif … … 161 157 162 158 struct snd_cmi8330 { 163 #ifdef __ISAPNP__164 struct isapnp_dev *cap;165 struct isapnp_dev *play;159 #ifdef CONFIG_PNP 160 struct pnp_dev *cap; 161 struct pnp_dev *play; 166 162 #endif 167 163 snd_card_t *card; … … 177 173 }; 178 174 179 static snd_card_t *snd_cmi8330_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 180 181 #ifdef __ISAPNP__ 182 183 static struct isapnp_card *snd_cmi8330_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 184 static const struct isapnp_card_id *snd_cmi8330_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 185 186 #define ISAPNP_CMI8330(_va, _vb, _vc, _device, _audio1, _audio2) \ 187 { \ 188 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 189 .devs = { ISAPNP_DEVICE_ID('@', '@', '@', _audio1), \ 190 ISAPNP_DEVICE_ID('@', 'X', '@', _audio2), } \ 191 } 192 193 static struct isapnp_card_id snd_cmi8330_pnpids[] __devinitdata = 194 { 195 ISAPNP_CMI8330('C','M','I',0x0001,0x0001,0x0001), 196 { ISAPNP_CARD_END, } 175 static snd_card_t *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 176 177 #ifdef CONFIG_PNP 178 179 static struct pnp_card_device_id snd_cmi8330_pnpids[] __devinitdata = { 180 { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" } } }, 181 { .id = "" } 197 182 }; 198 183 199 ISAPNP_CARD_TABLE(snd_cmi8330_pnpids);184 MODULE_DEVICE_TABLE(pnp_card, snd_cmi8330_pnpids); 200 185 201 186 #endif … … 263 248 264 249 265 static int __ init cmi8330_add_sb_mixers(sb_t *chip)250 static int __devinit cmi8330_add_sb_mixers(sb_t *chip) 266 251 { 267 252 int idx, err; … … 288 273 #endif 289 274 290 static int __ init snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard)275 static int __devinit snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard) 291 276 { 292 277 unsigned int idx; … … 307 292 } 308 293 309 #ifdef __ISAPNP__ 310 static int __init snd_cmi8330_isapnp(int dev, struct snd_cmi8330 *acard) 311 { 312 const struct isapnp_card_id *id = snd_cmi8330_isapnp_id[dev]; 313 struct isapnp_card *card = snd_cmi8330_isapnp_cards[dev]; 314 struct isapnp_dev *pdev; 315 316 acard->cap = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 317 if (acard->cap->active) { 318 acard->cap = NULL; 294 #ifdef CONFIG_PNP 295 static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, 296 struct pnp_card_link *card, 297 const struct pnp_card_device_id *id) 298 { 299 struct pnp_dev *pdev; 300 struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table)); 301 int err; 302 303 acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL); 304 if (acard->cap == NULL) { 305 kfree(cfg); 319 306 return -EBUSY; 320 307 } 321 acard->play = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);322 if (acard->play ->active) {323 acard->cap = acard->play = NULL;308 acard->play = pnp_request_card_device(card, id->devs[1].id, NULL); 309 if (acard->play == NULL) { 310 kfree(cfg); 324 311 return -EBUSY; 325 312 } 326 313 327 314 pdev = acard->cap; 328 if (pdev->prepare(pdev)<0) 329 return -EAGAIN; 315 pnp_init_resource_table(cfg); 330 316 /* allocate AD1848 resources */ 331 317 if (wssport[dev] != SNDRV_AUTO_PORT) 332 isapnp_resource_change(&pdev->resource[0], wssport[dev], 8);318 pnp_resource_change(&cfg->port_resource[0], wssport[dev], 8); 333 319 if (wssdma[dev] != SNDRV_AUTO_DMA) 334 isapnp_resource_change(&pdev->dma_resource[0], wssdma[dev], 1);320 pnp_resource_change(&cfg->dma_resource[0], wssdma[dev], 1); 335 321 if (wssirq[dev] != SNDRV_AUTO_IRQ) 336 isapnp_resource_change(&pdev->irq_resource[0], wssirq[dev], 1); 337 338 if (pdev->activate(pdev)<0) { 339 snd_printk("(AD1848) PnP configure failure\n"); 322 pnp_resource_change(&cfg->irq_resource[0], wssirq[dev], 1); 323 324 err = pnp_manual_config_dev(pdev, cfg, 0); 325 if (err < 0) 326 snd_printk(KERN_ERR "CMI8330/C3D (AD1848) PnP manual resources are invalid, using auto config\n"); 327 err = pnp_activate_dev(pdev); 328 if (err < 0) { 329 snd_printk(KERN_ERR "CMI8330/C3D (AD1848) PnP configure failure\n"); 330 kfree(cfg); 340 331 return -EBUSY; 341 332 } 342 wssport[dev] = p dev->resource[0].start;343 wssdma[dev] = p dev->dma_resource[0].start;344 wssirq[dev] = p dev->irq_resource[0].start;333 wssport[dev] = pnp_port_start(pdev, 0); 334 wssdma[dev] = pnp_dma(pdev, 0); 335 wssirq[dev] = pnp_irq(pdev, 0); 345 336 346 337 /* allocate SB16 resources */ 347 338 pdev = acard->play; 348 if (pdev->prepare(pdev)<0) { 349 acard->cap->deactivate(acard->cap); 350 return -EAGAIN; 351 } 339 pnp_init_resource_table(cfg); 352 340 if (sbport[dev] != SNDRV_AUTO_PORT) 353 isapnp_resource_change(&pdev->resource[0], sbport[dev], 16);341 pnp_resource_change(&cfg->port_resource[0], sbport[dev], 16); 354 342 if (sbdma8[dev] != SNDRV_AUTO_DMA) 355 isapnp_resource_change(&pdev->dma_resource[0], sbdma8[dev], 1);343 pnp_resource_change(&cfg->dma_resource[0], sbdma8[dev], 1); 356 344 if (sbdma16[dev] != SNDRV_AUTO_DMA) 357 isapnp_resource_change(&pdev->dma_resource[1], sbdma16[dev], 1);345 pnp_resource_change(&cfg->dma_resource[1], sbdma16[dev], 1); 358 346 if (sbirq[dev] != SNDRV_AUTO_IRQ) 359 isapnp_resource_change(&pdev->irq_resource[0], sbirq[dev], 1); 360 361 if (pdev->activate(pdev)<0) { 362 snd_printk("CMI8330/C3D (SB16) PnP configure failure\n"); 363 acard->cap->deactivate(acard->cap); 347 pnp_resource_change(&cfg->irq_resource[0], sbirq[dev], 1); 348 349 err = pnp_manual_config_dev(pdev, cfg, 0); 350 if (err < 0) 351 snd_printk(KERN_ERR "CMI8330/C3D (SB16) PnP manual resources are invalid, using auto config\n"); 352 err = pnp_activate_dev(pdev); 353 if (err < 0) { 354 snd_printk(KERN_ERR "CMI8330/C3D (SB16) PnP configure failure\n"); 355 kfree(cfg); 364 356 return -EBUSY; 365 357 } 366 sbport[dev] = pdev->resource[0].start; 367 sbdma8[dev] = pdev->dma_resource[0].start; 368 sbdma16[dev] = pdev->dma_resource[1].start; 369 sbirq[dev] = pdev->irq_resource[0].start; 370 358 sbport[dev] = pnp_port_start(pdev, 0); 359 sbdma8[dev] = pnp_dma(pdev, 0); 360 sbdma16[dev] = pnp_dma(pdev, 1); 361 sbirq[dev] = pnp_irq(pdev, 0); 362 363 kfree(cfg); 371 364 return 0; 372 }373 374 static void snd_cmi8330_deactivate(struct snd_cmi8330 *acard)375 {376 if (acard->cap) {377 acard->cap->deactivate(acard->cap);378 acard->cap = NULL;379 }380 if (acard->play) {381 acard->play->deactivate(acard->play);382 acard->play = NULL;383 }384 365 } 385 366 #endif … … 429 410 } 430 411 431 static int __ init snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)412 static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) 432 413 { 433 414 snd_pcm_t *pcm; … … 472 453 */ 473 454 474 static void snd_cmi8330_free(snd_card_t *card) 475 { 476 struct snd_cmi8330 *acard = (struct snd_cmi8330 *)card->private_data; 477 478 if (acard) { 479 #ifdef __ISAPNP__ 480 snd_cmi8330_deactivate(acard); 481 #endif 482 } 483 } 484 485 static int __init snd_cmi8330_probe(int dev) 455 static int __devinit snd_cmi8330_probe(int dev, 456 struct pnp_card_link *pcard, 457 const struct pnp_card_device_id *pid) 486 458 { 487 459 snd_card_t *card; … … 490 462 int i, err; 491 463 492 #ifdef __ISAPNP__464 #ifdef CONFIG_PNP 493 465 if (!isapnp[dev]) { 494 466 #endif … … 501 473 return -EINVAL; 502 474 } 503 #ifdef __ISAPNP__475 #ifdef CONFIG_PNP 504 476 } 505 477 #endif … … 512 484 acard = (struct snd_cmi8330 *)card->private_data; 513 485 acard->card = card; 514 card->private_free = snd_cmi8330_free; 515 516 #ifdef __ISAPNP__ 517 if (isapnp[dev] && (err = snd_cmi8330_isapnp(dev, acard)) < 0) { 486 487 #ifdef CONFIG_PNP 488 if (isapnp[dev] && (err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { 518 489 snd_printk("PnP detection failed\n"); 519 490 snd_card_free(card); … … 585 556 } 586 557 587 snd_cmi8330_cards[dev] = card; 558 if (pcard) 559 pnp_set_card_drvdata(pcard, card); 560 else 561 snd_cmi8330_legacy[dev] = card; 588 562 return 0; 589 563 } 590 564 591 static void __exit alsa_card_cmi8330_exit(void) 592 { 593 int i; 594 595 for (i = 0; i < SNDRV_CARDS; i++) 596 snd_card_free(snd_cmi8330_cards[i]); 597 } 598 599 #ifdef __ISAPNP__ 600 static int __init snd_cmi8330_isapnp_detect(struct isapnp_card *card, 601 const struct isapnp_card_id *id) 565 #ifdef CONFIG_PNP 566 static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, 567 const struct pnp_card_device_id *id) 602 568 { 603 569 static int dev; … … 607 573 if (!enable[dev] || !isapnp[dev]) 608 574 continue; 609 snd_cmi8330_isapnp_cards[dev] = card; 610 snd_cmi8330_isapnp_id[dev] = id; 611 res = snd_cmi8330_probe(dev); 575 res = snd_cmi8330_probe(dev, card, id); 612 576 if (res < 0) 613 577 return res; … … 617 581 return -ENODEV; 618 582 } 619 #endif /* __ISAPNP__ */ 583 584 static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) 585 { 586 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 587 588 snd_card_disconnect(card); 589 snd_card_free_in_thread(card); 590 } 591 592 static struct pnp_card_driver cmi8330_pnpc_driver = { 593 .flags = PNP_DRIVER_RES_DISABLE, 594 .name = "cmi8330", 595 .id_table = snd_cmi8330_pnpids, 596 .probe = snd_cmi8330_pnp_detect, 597 .remove = __devexit_p(snd_cmi8330_pnp_remove), 598 }; 599 #endif /* CONFIG_PNP */ 620 600 621 601 static int __init alsa_card_cmi8330_init(void) … … 626 606 if (!enable[dev]) 627 607 continue; 628 #ifdef __ISAPNP__608 #ifdef CONFIG_PNP 629 609 if (isapnp[dev]) 630 610 continue; 631 611 #endif 632 if (snd_cmi8330_probe(dev ) >= 0)612 if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) 633 613 cards++; 634 614 } 635 #ifdef __ISAPNP__636 cards += isapnp_probe_cards(snd_cmi8330_pnpids, snd_cmi8330_isapnp_detect);615 #ifdef CONFIG_PNP 616 cards += pnp_register_card_driver(&cmi8330_pnpc_driver); 637 617 #endif 638 618 639 619 if (!cards) { 620 #ifdef CONFIG_PNP 621 pnp_unregister_card_driver(&cmi8330_pnpc_driver); 622 #endif 640 623 #ifdef MODULE 641 printk(KERN_ERR "CMI8330 not found or device busy\n");624 snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); 642 625 #endif 643 626 return -ENODEV; 644 627 } 645 628 return 0; 629 } 630 631 static void __exit alsa_card_cmi8330_exit(void) 632 { 633 int i; 634 635 #ifdef CONFIG_PNP 636 /* PnP cards first */ 637 pnp_unregister_card_driver(&cmi8330_pnpc_driver); 638 #endif 639 for (i = 0; i < SNDRV_CARDS; i++) 640 snd_card_free(snd_cmi8330_legacy[i]); 646 641 } 647 642 … … 675 670 get_option(&str,&wssirq[nr_dev]) == 2 && 676 671 get_option(&str,&wssdma[nr_dev]) == 2); 677 #ifdef __ISAPNP__672 #ifdef CONFIG_PNP 678 673 if (pnp != INT_MAX) 679 674 isapnp[nr_dev] = pnp;
Note:
See TracChangeset
for help on using the changeset viewer.
