Changeset 615 for GPL/branches/uniaud32-next/alsa-kernel/pci/atiixp.c
- Timestamp:
- Jan 1, 2021, 5:31:48 AM (5 years ago)
- Location:
- GPL/branches/uniaud32-next
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/alsa-kernel/pci/atiixp.c
r612 r615 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * ALSA driver for ATI IXP 150/200/250/300 AC97 controllers 3 4 * 4 5 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> 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 22 #include <asm/io.h> 6 */ 7 8 #include <linux/io.h> 23 9 #include <linux/delay.h> 24 10 #include <linux/interrupt.h> … … 48 34 static int ac97_clock = 48000; 49 35 static char *ac97_quirk; 50 static intspdif_aclink = 1;36 static bool spdif_aclink = 1; 51 37 static int ac97_codec = -1; 52 38 … … 65 51 66 52 /* just for backward compatibility */ 67 //static intenable;53 //static bool enable; 68 54 module_param(enable, bool, 0444); 69 55 … … 212 198 213 199 struct atiixp_dma_desc { 214 u32 addr; /* DMA buffer address */200 __le32 addr; /* DMA buffer address */ 215 201 u16 status; /* status bits */ 216 202 u16 size; /* size of the packet in dwords */ 217 u32 next; /* address of the next packet descriptor */203 __le32 next; /* address of the next packet descriptor */ 218 204 }; 219 205 … … 291 277 /* 292 278 */ 293 static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids)= {279 static const struct pci_device_id snd_atiixp_ids[] = { 294 280 { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */ 295 281 { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */ … … 301 287 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); 302 288 303 static struct snd_pci_quirk atiixp_quirks[] __devinitdata= {289 static struct snd_pci_quirk atiixp_quirks[] = { 304 290 SND_PCI_QUIRK(0x105b, 0x0c81, "Foxconn RC4107MA-RS2", 0), 305 291 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0), … … 440 426 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) { 441 427 if (! timeout--) { 442 snd_printk(KERN_WARNING "atiixp:codec acquire timeout\n");428 dev_warn(chip->card->dev, "codec acquire timeout\n"); 443 429 return -EBUSY; 444 430 } … … 471 457 /* time out may happen during reset */ 472 458 if (reg < 0x7c) 473 snd_printk(KERN_WARNING "atiixp:codec read timeout (reg %x)\n", reg);459 dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg); 474 460 return 0xffff; 475 461 } … … 495 481 struct atiixp *chip = ac97->private_data; 496 482 return snd_atiixp_codec_read(chip, ac97->num, reg); 497 483 498 484 } 499 485 … … 532 518 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); 533 519 if (!--timeout) { 534 snd_printk(KERN_ERR "atiixp:codec reset timeout\n");520 dev_err(chip->card->dev, "codec reset timeout\n"); 535 521 break; 536 522 } … … 545 531 } 546 532 547 #ifdef CONFIG_PM 533 #ifdef CONFIG_PM_SLEEP 548 534 static int snd_atiixp_aclink_down(struct atiixp *chip) 549 535 { … … 571 557 #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) 572 558 573 static int __devinitac97_probing_bugs(struct pci_dev *pci)559 static int ac97_probing_bugs(struct pci_dev *pci) 574 560 { 575 561 const struct snd_pci_quirk *q; … … 577 563 q = snd_pci_quirk_lookup(pci, atiixp_quirks); 578 564 if (q) { 579 #ifndef TARGET_OS2 580 snd_printdd(KERN_INFO "Atiixp quirk for %s. " 581 "Forcing codec %d\n", q->name, q->value); 582 #endif 565 dev_dbg(&pci->dev, "atiixp quirk for %s. Forcing codec %d\n", 566 snd_pci_quirk_name(q), q->value); 567 583 568 return q->value; 584 569 } … … 587 572 } 588 573 589 static int __devinitsnd_atiixp_codec_detect(struct atiixp *chip)574 static int snd_atiixp_codec_detect(struct atiixp *chip) 590 575 { 591 576 int timeout; … … 611 596 612 597 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) { 613 snd_printk(KERN_ERR "atiixp:no codec detected!\n");598 dev_err(chip->card->dev, "no codec detected!\n"); 614 599 return -ENXIO; 615 600 } … … 687 672 return bytes_to_frames(runtime, curptr); 688 673 } 689 snd_printd("atiixp:invalid DMA pointer read 0x%x (buf=%x)\n",674 dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n", 690 675 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr); 691 676 return 0; … … 699 684 if (! dma->substream || ! dma->running) 700 685 return; 701 snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type); 702 snd_pcm_stream_lock(dma->substream); 703 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 704 snd_pcm_stream_unlock(dma->substream); 686 dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type); 687 snd_pcm_stop_xrun(dma->substream); 705 688 } 706 689 … … 747 730 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 748 731 case SNDRV_PCM_TRIGGER_RESUME: 732 if (dma->running && dma->suspended && 733 cmd == SNDRV_PCM_TRIGGER_RESUME) 734 writel(dma->saved_curptr, chip->remap_addr + 735 dma->ops->dt_cur); 749 736 dma->ops->enable_transfer(chip, 1); 750 737 dma->running = 1; … … 754 741 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 755 742 case SNDRV_PCM_TRIGGER_SUSPEND: 743 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND; 744 if (dma->running && dma->suspended) 745 dma->saved_curptr = readl(chip->remap_addr + 746 dma->ops->dt_cur); 756 747 dma->ops->enable_transfer(chip, 0); 757 748 dma->running = 0; 758 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;759 749 break; 760 750 default: … … 917 907 data |= ATI_REG_OUT_DMA_SLOT_BIT(10) | 918 908 ATI_REG_OUT_DMA_SLOT_BIT(11); 919 /* fall thru*/909 /* fall through */ 920 910 case 6: 921 911 data |= ATI_REG_OUT_DMA_SLOT_BIT(7) | 922 912 ATI_REG_OUT_DMA_SLOT_BIT(8); 923 /* fall thru*/913 /* fall through */ 924 914 case 4: 925 915 data |= ATI_REG_OUT_DMA_SLOT_BIT(6) | 926 916 ATI_REG_OUT_DMA_SLOT_BIT(9); 927 /* fall thru*/917 /* fall through */ 928 918 default: 929 919 data |= ATI_REG_OUT_DMA_SLOT_BIT(3) | … … 1023 1013 * pcm hardware definition, identical for all DMA types 1024 1014 */ 1025 static struct snd_pcm_hardware snd_atiixp_pcm_hw =1015 static const struct snd_pcm_hardware snd_atiixp_pcm_hw = 1026 1016 { 1027 1017 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1162 1152 1163 1153 /* AC97 playback */ 1164 static struct snd_pcm_ops snd_atiixp_playback_ops = {1154 static const struct snd_pcm_ops snd_atiixp_playback_ops = { 1165 1155 .open = snd_atiixp_playback_open, 1166 1156 .close = snd_atiixp_playback_close, … … 1174 1164 1175 1165 /* AC97 capture */ 1176 static struct snd_pcm_ops snd_atiixp_capture_ops = {1166 static const struct snd_pcm_ops snd_atiixp_capture_ops = { 1177 1167 .open = snd_atiixp_capture_open, 1178 1168 .close = snd_atiixp_capture_close, … … 1186 1176 1187 1177 /* SPDIF playback */ 1188 static struct snd_pcm_ops snd_atiixp_spdif_ops = {1178 static const struct snd_pcm_ops snd_atiixp_spdif_ops = { 1189 1179 .open = snd_atiixp_spdif_open, 1190 1180 .close = snd_atiixp_spdif_close, … … 1197 1187 }; 1198 1188 1199 static struct ac97_pcm atiixp_pcm_defs[] __devinitdata= {1189 static const struct ac97_pcm atiixp_pcm_defs[] = { 1200 1190 /* front PCM */ 1201 1191 { … … 1233 1223 }; 1234 1224 1235 static struct atiixp_dma_ops snd_atiixp_playback_dma_ops = {1225 static const struct atiixp_dma_ops snd_atiixp_playback_dma_ops = { 1236 1226 .type = ATI_DMA_PLAYBACK, 1237 1227 .llp_offset = ATI_REG_OUT_DMA_LINKPTR, … … 1242 1232 }; 1243 1233 1244 static struct atiixp_dma_ops snd_atiixp_capture_dma_ops = {1234 static const struct atiixp_dma_ops snd_atiixp_capture_dma_ops = { 1245 1235 .type = ATI_DMA_CAPTURE, 1246 1236 .llp_offset = ATI_REG_IN_DMA_LINKPTR, … … 1251 1241 }; 1252 1242 1253 static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = {1243 static const struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = { 1254 1244 .type = ATI_DMA_SPDIF, 1255 1245 .llp_offset = ATI_REG_SPDF_DMA_LINKPTR, … … 1261 1251 1262 1252 1263 static int __devinitsnd_atiixp_pcm_new(struct atiixp *chip)1253 static int snd_atiixp_pcm_new(struct atiixp *chip) 1264 1254 { 1265 1255 struct snd_pcm *pcm; 1256 struct snd_pcm_chmap *chmap; 1266 1257 struct snd_ac97_bus *pbus = chip->ac97_bus; 1267 1258 int err, i, num_pcms; … … 1306 1297 snd_dma_pci_data(chip->pci), 1307 1298 64*1024, 128*1024); 1299 1300 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1301 snd_pcm_alt_chmaps, chip->max_channels, 0, 1302 &chmap); 1303 if (err < 0) 1304 return err; 1305 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; 1306 chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; 1308 1307 1309 1308 /* no SPDIF support on codec? */ … … 1395 1394 */ 1396 1395 1397 static struct ac97_quirk ac97_quirks[] __devinitdata= {1396 static const struct ac97_quirk ac97_quirks[] = { 1398 1397 { 1399 1398 .subvendor = 0x103c, … … 1417 1416 }; 1418 1417 1419 static int __devinitsnd_atiixp_mixer_new(struct atiixp *chip, int clock,1420 1418 static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, 1419 const char *quirk_override) 1421 1420 { 1422 1421 struct snd_ac97_bus *pbus; … … 1455 1454 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 1456 1455 chip->ac97[i] = NULL; /* to be sure */ 1457 snd_printdd("atiixp: codec %d not available for audio\n", i); 1456 dev_dbg(chip->card->dev, 1457 "codec %d not available for audio\n", i); 1458 1458 continue; 1459 1459 } … … 1462 1462 1463 1463 if (! codec_count) { 1464 snd_printk(KERN_ERR "atiixp:no codec available\n");1464 dev_err(chip->card->dev, "no codec available\n"); 1465 1465 return -ENODEV; 1466 1466 } … … 1472 1472 1473 1473 1474 #ifdef CONFIG_PM 1474 #ifdef CONFIG_PM_SLEEP 1475 1475 /* 1476 1476 * power management 1477 1477 */ 1478 static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)1479 { 1480 struct snd_card *card = pci_get_drvdata(pci);1478 static int snd_atiixp_suspend(struct device *dev) 1479 { 1480 struct snd_card *card = dev_get_drvdata(dev); 1481 1481 struct atiixp *chip = card->private_data; 1482 1482 int i; 1483 1483 1484 1484 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1485 for (i = 0; i < NUM_ATI_PCMDEVS; i++)1486 if (chip->pcmdevs[i]) {1487 struct atiixp_dma *dma = &chip->dmas[i];1488 if (dma->substream && dma->running)1489 dma->saved_curptr = readl(chip->remap_addr +1490 dma->ops->dt_cur);1491 snd_pcm_suspend_all(chip->pcmdevs[i]);1492 }1493 1485 for (i = 0; i < NUM_ATI_CODECS; i++) 1494 1486 snd_ac97_suspend(chip->ac97[i]); 1495 1487 snd_atiixp_aclink_down(chip); 1496 1488 snd_atiixp_chip_stop(chip); 1497 1498 pci_disable_device(pci); 1499 pci_save_state(pci); 1500 pci_set_power_state(pci, pci_choose_state(pci, state)); 1501 return 0; 1502 } 1503 1504 static int snd_atiixp_resume(struct pci_dev *pci) 1505 { 1506 struct snd_card *card = pci_get_drvdata(pci); 1489 return 0; 1490 } 1491 1492 static int snd_atiixp_resume(struct device *dev) 1493 { 1494 struct snd_card *card = dev_get_drvdata(dev); 1507 1495 struct atiixp *chip = card->private_data; 1508 1496 int i; 1509 1510 pci_set_power_state(pci, PCI_D0);1511 pci_restore_state(pci);1512 if (pci_enable_device(pci) < 0) {1513 printk(KERN_ERR "atiixp: pci_enable_device failed, "1514 "disabling device\n");1515 snd_card_disconnect(card);1516 return -EIO;1517 }1518 pci_set_master(pci);1519 1497 1520 1498 snd_atiixp_aclink_reset(chip); … … 1532 1510 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1533 1511 chip->remap_addr + dma->ops->llp_offset); 1534 writel(dma->saved_curptr, chip->remap_addr +1535 dma->ops->dt_cur);1536 1512 } 1537 1513 } … … 1540 1516 return 0; 1541 1517 } 1542 #endif /* CONFIG_PM */ 1543 1544 1545 #ifdef CONFIG_PROC_FS 1518 1519 static SIMPLE_DEV_PM_OPS(snd_atiixp_pm, snd_atiixp_suspend, snd_atiixp_resume); 1520 #define SND_ATIIXP_PM_OPS &snd_atiixp_pm 1521 #else 1522 #define SND_ATIIXP_PM_OPS NULL 1523 #endif /* CONFIG_PM_SLEEP */ 1524 1525 1546 1526 /* 1547 1527 * proc interface for register dump … … 1558 1538 } 1559 1539 1560 static void __devinit snd_atiixp_proc_init(struct atiixp *chip) 1561 { 1562 struct snd_info_entry *entry; 1563 1564 if (! snd_card_proc_new(chip->card, "atiixp", &entry)) 1565 snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read); 1566 } 1567 #else /* !CONFIG_PROC_FS */ 1568 #define snd_atiixp_proc_init(chip) 1569 #endif 1540 static void snd_atiixp_proc_init(struct atiixp *chip) 1541 { 1542 snd_card_ro_proc_new(chip->card, "atiixp", chip, snd_atiixp_proc_read); 1543 } 1570 1544 1571 1545 … … 1583 1557 if (chip->irq >= 0) 1584 1558 free_irq(chip->irq, chip); 1585 if (chip->remap_addr) 1586 iounmap(chip->remap_addr); 1559 iounmap(chip->remap_addr); 1587 1560 pci_release_regions(chip->pci); 1588 1561 pci_disable_device(chip->pci); … … 1600 1573 * constructor for chip instance 1601 1574 */ 1602 static int __devinitsnd_atiixp_create(struct snd_card *card,1603 1604 1575 static int snd_atiixp_create(struct snd_card *card, 1576 struct pci_dev *pci, 1577 struct atiixp **r_chip) 1605 1578 { 1606 1579 static struct snd_device_ops ops = { … … 1632 1605 chip->remap_addr = pci_ioremap_bar(pci, 0); 1633 1606 if (chip->remap_addr == NULL) { 1634 snd_printk(KERN_ERR"AC'97 space ioremap problem\n");1607 dev_err(card->dev, "AC'97 space ioremap problem\n"); 1635 1608 snd_atiixp_free(chip); 1636 1609 return -EIO; … … 1639 1612 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED, 1640 1613 KBUILD_MODNAME, chip)) { 1641 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);1614 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1642 1615 snd_atiixp_free(chip); 1643 1616 return -EBUSY; … … 1652 1625 } 1653 1626 1654 snd_card_set_dev(card, &pci->dev);1655 1656 1627 *r_chip = chip; 1657 1628 return 0; … … 1659 1630 1660 1631 1661 static int __devinitsnd_atiixp_probe(struct pci_dev *pci,1662 1632 static int snd_atiixp_probe(struct pci_dev *pci, 1633 const struct pci_device_id *pci_id) 1663 1634 { 1664 1635 struct snd_card *card; … … 1666 1637 int err; 1667 1638 1668 err = snd_card_ create(index, id, THIS_MODULE, 0, &card);1639 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 1669 1640 if (err < 0) 1670 1641 return err; … … 1712 1683 } 1713 1684 1714 static void __devexitsnd_atiixp_remove(struct pci_dev *pci)1685 static void snd_atiixp_remove(struct pci_dev *pci) 1715 1686 { 1716 1687 snd_card_free(pci_get_drvdata(pci)); 1717 pci_set_drvdata(pci, NULL); 1718 } 1719 1720 static struct pci_driver driver = { 1688 } 1689 1690 static struct pci_driver atiixp_driver = { 1721 1691 .name = KBUILD_MODNAME, 1722 1692 .id_table = snd_atiixp_ids, 1723 1693 .probe = snd_atiixp_probe, 1724 .remove = __devexit_p(snd_atiixp_remove), 1725 #ifdef CONFIG_PM 1726 .suspend = snd_atiixp_suspend, 1727 .resume = snd_atiixp_resume, 1728 #endif 1694 .remove = snd_atiixp_remove, 1695 .driver = { 1696 .pm = SND_ATIIXP_PM_OPS, 1697 }, 1729 1698 }; 1730 1699 1731 1732 static int __init alsa_card_atiixp_init(void) 1733 { 1734 return pci_register_driver(&driver); 1735 } 1736 1737 static void __exit alsa_card_atiixp_exit(void) 1738 { 1739 pci_unregister_driver(&driver); 1740 } 1741 1742 module_init(alsa_card_atiixp_init) 1743 module_exit(alsa_card_atiixp_exit) 1700 module_pci_driver(atiixp_driver);
Note:
See TracChangeset
for help on using the changeset viewer.