Changeset 305 for GPL/branches/uniaud-2.0/alsa-kernel/pci/atiixp.c
- Timestamp:
- Mar 24, 2008, 2:43:42 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud-2.0/alsa-kernel/pci/atiixp.c
r79 r305 20 20 */ 21 21 22 #include <sound/driver.h>23 22 #include <asm/io.h> 24 23 #include <linux/delay.h> … … 28 27 #include <linux/slab.h> 29 28 #include <linux/moduleparam.h> 29 #include <linux/mutex.h> 30 30 #include <sound/core.h> 31 31 #include <sound/pcm.h> … … 45 45 static char *ac97_quirk; 46 46 static int spdif_aclink = 1; 47 48 //module_param(index, int, 0444); 47 static int ac97_codec = -1; 48 49 module_param(index, int, 0444); 49 50 MODULE_PARM_DESC(index, "Index value for ATI IXP controller."); 50 //module_param(id, charp, 0444);51 module_param(id, charp, 0444); 51 52 MODULE_PARM_DESC(id, "ID string for ATI IXP controller."); 52 //module_param(ac97_clock, int, 0444);53 module_param(ac97_clock, int, 0444); 53 54 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 54 //module_param(ac97_quirk, charp, 0444);55 module_param(ac97_quirk, charp, 0444); 55 56 MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 56 //module_param(spdif_aclink, bool, 0444); 57 module_param(ac97_codec, int, 0444); 58 MODULE_PARM_DESC(ac97_codec, "Specify codec instead of probing."); 59 module_param(spdif_aclink, bool, 0444); 57 60 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); 58 61 59 62 /* just for backward compatibility */ 60 63 static int enable; 61 //module_param(enable, bool, 0444);64 module_param(enable, bool, 0444); 62 65 63 66 … … 278 281 279 282 int spdif_over_aclink; /* passed from the module option */ 280 struct semaphoreopen_mutex; /* playback open mutex */283 struct mutex open_mutex; /* playback open mutex */ 281 284 }; 282 285 … … 293 296 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); 294 297 298 static struct snd_pci_quirk atiixp_quirks[] __devinitdata = { 299 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0), 300 {0} /* terminator */ 301 }; 295 302 296 303 /* … … 305 312 unsigned int mask, unsigned int value) 306 313 { 307 void __iomem *addr = (char*)chip->remap_addr + reg;314 void __iomem *addr = chip->remap_addr + reg; 308 315 unsigned int data, old_data; 309 316 old_data = data = readl(addr); … … 320 327 */ 321 328 #define atiixp_write(chip,reg,value) \ 322 writel(value, (char*)chip->remap_addr + ATI_REG_##reg)329 writel(value, chip->remap_addr + ATI_REG_##reg) 323 330 #define atiixp_read(chip,reg) \ 324 readl( (char*)chip->remap_addr + ATI_REG_##reg)331 readl(chip->remap_addr + ATI_REG_##reg) 325 332 #define atiixp_update(chip,reg,mask,val) \ 326 333 snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val) … … 366 373 } 367 374 375 if (dma->periods == periods && dma->period_bytes == period_bytes) 376 return 0; 377 368 378 /* reset DMA before changing the descriptor table */ 369 379 spin_lock_irqsave(&chip->reg_lock, flags); 370 writel(0, (char*)chip->remap_addr + dma->ops->llp_offset);380 writel(0, chip->remap_addr + dma->ops->llp_offset); 371 381 dma->ops->enable_dma(chip, 0); 372 382 dma->ops->enable_dma(chip, 1); 373 383 spin_unlock_irqrestore(&chip->reg_lock, flags); 374 375 if (dma->periods == periods && dma->period_bytes == period_bytes)376 {377 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,378 (char*)chip->remap_addr + dma->ops->llp_offset);379 return 0;380 }381 384 382 385 /* fill the entries */ … … 398 401 399 402 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 400 (char*)chip->remap_addr + dma->ops->llp_offset);403 chip->remap_addr + dma->ops->llp_offset); 401 404 402 405 dma->period_bytes = period_bytes; … … 413 416 { 414 417 if (dma->desc_buf.area) { 415 writel(0, (char*)chip->remap_addr + dma->ops->llp_offset);418 writel(0, chip->remap_addr + dma->ops->llp_offset); 416 419 snd_dma_free_pages(&dma->desc_buf); 417 420 dma->desc_buf.area = NULL; … … 557 560 #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) 558 561 559 static int snd_atiixp_codec_detect(struct atiixp *chip) 562 static int __devinit ac97_probing_bugs(struct pci_dev *pci) 563 { 564 const struct snd_pci_quirk *q; 565 566 q = snd_pci_quirk_lookup(pci, atiixp_quirks); 567 if (q) { 568 #ifndef TARGET_OS2 569 snd_printdd(KERN_INFO "Atiixp quirk for %s. " 570 "Forcing codec %d\n", q->name, q->value); 571 #endif 572 return q->value; 573 } 574 /* this hardware doesn't need workarounds. Probe for codec */ 575 return -1; 576 } 577 578 static int __devinit snd_atiixp_codec_detect(struct atiixp *chip) 560 579 { 561 580 int timeout; 562 581 563 582 chip->codec_not_ready_bits = 0; 583 if (ac97_codec == -1) 584 ac97_codec = ac97_probing_bugs(chip->pci); 585 if (ac97_codec >= 0) { 586 chip->codec_not_ready_bits |= 587 CODEC_CHECK_BITS ^ (1 << (ac97_codec + 10)); 588 return 0; 589 } 590 564 591 atiixp_write(chip, IER, CODEC_CHECK_BITS); 565 592 /* wait for the interrupts */ … … 641 668 642 669 while (timeout--) { 643 curptr = readl( (char*)chip->remap_addr + dma->ops->dt_cur);670 curptr = readl(chip->remap_addr + dma->ops->dt_cur); 644 671 if (curptr < dma->buf_addr) 645 672 continue; … … 650 677 } 651 678 snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n", 652 readl( (char*)chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);679 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr); 653 680 return 0; 654 681 } … … 1056 1083 int err; 1057 1084 1058 down(&chip->open_mutex);1085 mutex_lock(&chip->open_mutex); 1059 1086 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0); 1060 up(&chip->open_mutex);1087 mutex_unlock(&chip->open_mutex); 1061 1088 if (err < 0) 1062 1089 return err; … … 1073 1100 struct atiixp *chip = snd_pcm_substream_chip(substream); 1074 1101 int err; 1075 down(&chip->open_mutex);1102 mutex_lock(&chip->open_mutex); 1076 1103 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); 1077 up(&chip->open_mutex);1104 mutex_unlock(&chip->open_mutex); 1078 1105 return err; 1079 1106 } … … 1095 1122 struct atiixp *chip = snd_pcm_substream_chip(substream); 1096 1123 int err; 1097 down(&chip->open_mutex);1124 mutex_lock(&chip->open_mutex); 1098 1125 if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */ 1099 1126 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2); 1100 1127 else 1101 1128 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1); 1102 up(&chip->open_mutex);1129 mutex_unlock(&chip->open_mutex); 1103 1130 return err; 1104 1131 } … … 1108 1135 struct atiixp *chip = snd_pcm_substream_chip(substream); 1109 1136 int err; 1110 down(&chip->open_mutex);1137 mutex_lock(&chip->open_mutex); 1111 1138 if (chip->spdif_over_aclink) 1112 1139 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); 1113 1140 else 1114 1141 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]); 1115 up(&chip->open_mutex);1142 mutex_unlock(&chip->open_mutex); 1116 1143 return err; 1117 1144 } … … 1304 1331 * interrupt handler 1305 1332 */ 1306 static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id , struct pt_regs *regs)1333 static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id) 1307 1334 { 1308 1335 struct atiixp *chip = dev_id; … … 1400 1427 ac97.pci = chip->pci; 1401 1428 ac97.num = i; 1402 ac97.scaps = AC97_SCAP_SKIP_MODEM ;1429 ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; 1403 1430 if (! chip->spdif_over_aclink) 1404 1431 ac97.scaps |= AC97_SCAP_NO_SPDIF; … … 1437 1464 struct atiixp_dma *dma = &chip->dmas[i]; 1438 1465 if (dma->substream && dma->running) 1439 dma->saved_curptr = readl( (char*)chip->remap_addr +1466 dma->saved_curptr = readl(chip->remap_addr + 1440 1467 dma->ops->dt_cur); 1441 1468 snd_pcm_suspend_all(chip->pcmdevs[i]); … … 1446 1473 snd_atiixp_chip_stop(chip); 1447 1474 1448 pci_set_power_state(pci, PCI_D3hot);1449 1475 pci_disable_device(pci); 1450 1476 pci_save_state(pci); 1477 pci_set_power_state(pci, pci_choose_state(pci, state)); 1451 1478 return 0; 1452 1479 } … … 1458 1485 int i; 1459 1486 1487 pci_set_power_state(pci, PCI_D0); 1460 1488 pci_restore_state(pci); 1461 pci_enable_device(pci); 1462 pci_set_power_state(pci, PCI_D0); 1489 if (pci_enable_device(pci) < 0) { 1490 printk(KERN_ERR "atiixp: pci_enable_device failed, " 1491 "disabling device\n"); 1492 snd_card_disconnect(card); 1493 return -EIO; 1494 } 1463 1495 pci_set_master(pci); 1464 1496 … … 1476 1508 dma->substream->ops->prepare(dma->substream); 1477 1509 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1478 (char*)chip->remap_addr + dma->ops->llp_offset);1479 writel(dma->saved_curptr, (char*)chip->remap_addr +1510 chip->remap_addr + dma->ops->llp_offset); 1511 writel(dma->saved_curptr, chip->remap_addr + 1480 1512 dma->ops->dt_cur); 1481 1513 } … … 1500 1532 1501 1533 for (i = 0; i < 256; i += 4) 1502 snd_iprintf(buffer, "%02x: %08x\n", i, readl( (char*)chip->remap_addr + i));1534 snd_iprintf(buffer, "%02x: %08x\n", i, readl(chip->remap_addr + i)); 1503 1535 } 1504 1536 … … 1508 1540 1509 1541 if (! snd_card_proc_new(chip->card, "atiixp", &entry)) 1510 snd_info_set_text_ops(entry, chip, 1024,snd_atiixp_proc_read);1542 snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read); 1511 1543 } 1512 1544 #else /* !CONFIG_PROC_FS */ … … 1565 1597 1566 1598 spin_lock_init(&chip->reg_lock); 1567 init_MUTEX(&chip->open_mutex);1599 mutex_init(&chip->open_mutex); 1568 1600 chip->card = card; 1569 1601 chip->pci = pci; … … 1582 1614 } 1583 1615 1584 if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ,1616 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED, 1585 1617 card->shortname, chip)) { 1586 1618 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); … … 1609 1641 struct snd_card *card; 1610 1642 struct atiixp *chip; 1611 unsigned char revision;1612 1643 int err; 1613 1644 … … 1615 1646 if (card == NULL) 1616 1647 return -ENOMEM; 1617 1618 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);1619 1648 1620 1649 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); … … 1639 1668 snd_atiixp_chip_start(chip); 1640 1669 1641 sprintf(card->longname, 1642 "%s rev %x with %s at %#lx, irq %i", card->shortname, revision, 1670 snprintf(card->longname, sizeof(card->longname), 1671 "%s rev %x with %s at %#lx, irq %i", card->shortname, 1672 #ifndef TARGET_OS2 1673 pci->revision, 1674 #else 1675 snd_pci_revision(pci), 1676 #endif 1643 1677 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?", 1644 1678 chip->addr, chip->irq);
Note:
See TracChangeset
for help on using the changeset viewer.