.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for the Conexant Riptide Soundchip |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2004 Peter Gruber <nokos@gmx.net> |
---|
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 | 6 | */ |
---|
21 | 7 | /* |
---|
22 | 8 | History: |
---|
.. | .. |
---|
375 | 361 | enum { SB_CMD = 0, MODEM_CMD, I2S_CMD0, I2S_CMD1, FM_CMD, MAX_CMD }; |
---|
376 | 362 | |
---|
377 | 363 | struct lbuspath { |
---|
378 | | - unsigned char *noconv; |
---|
379 | | - unsigned char *stereo; |
---|
380 | | - unsigned char *mono; |
---|
| 364 | + const unsigned char *noconv; |
---|
| 365 | + const unsigned char *stereo; |
---|
| 366 | + const unsigned char *mono; |
---|
381 | 367 | }; |
---|
382 | 368 | |
---|
383 | 369 | struct cmdport { |
---|
.. | .. |
---|
459 | 445 | union firmware_version firmware; |
---|
460 | 446 | |
---|
461 | 447 | spinlock_t lock; |
---|
462 | | - struct tasklet_struct riptide_tq; |
---|
463 | 448 | struct snd_info_entry *proc_entry; |
---|
464 | 449 | |
---|
465 | 450 | unsigned long received_irqs; |
---|
.. | .. |
---|
478 | 463 | |
---|
479 | 464 | struct pcmhw { /* pcm descriptor */ |
---|
480 | 465 | struct lbuspath paths; |
---|
481 | | - unsigned char *lbuspath; |
---|
| 466 | + const unsigned char *lbuspath; |
---|
482 | 467 | unsigned char source; |
---|
483 | 468 | unsigned char intdec[2]; |
---|
484 | 469 | unsigned char mixer; |
---|
.. | .. |
---|
531 | 516 | /* |
---|
532 | 517 | */ |
---|
533 | 518 | |
---|
534 | | -static unsigned char lbusin2out[E2SINK_MAX + 1][2] = { |
---|
| 519 | +static const unsigned char lbusin2out[E2SINK_MAX + 1][2] = { |
---|
535 | 520 | {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT, |
---|
536 | 521 | LS_NONE2}, |
---|
537 | 522 | {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT, |
---|
.. | .. |
---|
571 | 556 | LS_NONE2}, |
---|
572 | 557 | }; |
---|
573 | 558 | |
---|
574 | | -static unsigned char lbus_play_opl3[] = { |
---|
| 559 | +static const unsigned char lbus_play_opl3[] = { |
---|
575 | 560 | DIGITAL_MIXER_IN0 + FM_MIXER, 0xff |
---|
576 | 561 | }; |
---|
577 | | -static unsigned char lbus_play_modem[] = { |
---|
| 562 | +static const unsigned char lbus_play_modem[] = { |
---|
578 | 563 | DIGITAL_MIXER_IN0 + MODEM_MIXER, 0xff |
---|
579 | 564 | }; |
---|
580 | | -static unsigned char lbus_play_i2s[] = { |
---|
| 565 | +static const unsigned char lbus_play_i2s[] = { |
---|
581 | 566 | INTER0_IN + I2S_INTDEC, DIGITAL_MIXER_IN0 + I2S_MIXER, 0xff |
---|
582 | 567 | }; |
---|
583 | | -static unsigned char lbus_play_out[] = { |
---|
| 568 | +static const unsigned char lbus_play_out[] = { |
---|
584 | 569 | PDAC2ACLNK, 0xff |
---|
585 | 570 | }; |
---|
586 | | -static unsigned char lbus_play_outhp[] = { |
---|
| 571 | +static const unsigned char lbus_play_outhp[] = { |
---|
587 | 572 | HNDSPK2ACLNK, 0xff |
---|
588 | 573 | }; |
---|
589 | | -static unsigned char lbus_play_noconv1[] = { |
---|
| 574 | +static const unsigned char lbus_play_noconv1[] = { |
---|
590 | 575 | DIGITAL_MIXER_IN0, 0xff |
---|
591 | 576 | }; |
---|
592 | | -static unsigned char lbus_play_stereo1[] = { |
---|
| 577 | +static const unsigned char lbus_play_stereo1[] = { |
---|
593 | 578 | INTER0_IN, DIGITAL_MIXER_IN0, 0xff |
---|
594 | 579 | }; |
---|
595 | | -static unsigned char lbus_play_mono1[] = { |
---|
| 580 | +static const unsigned char lbus_play_mono1[] = { |
---|
596 | 581 | INTERM0_IN, DIGITAL_MIXER_IN0, 0xff |
---|
597 | 582 | }; |
---|
598 | | -static unsigned char lbus_play_noconv2[] = { |
---|
| 583 | +static const unsigned char lbus_play_noconv2[] = { |
---|
599 | 584 | DIGITAL_MIXER_IN1, 0xff |
---|
600 | 585 | }; |
---|
601 | | -static unsigned char lbus_play_stereo2[] = { |
---|
| 586 | +static const unsigned char lbus_play_stereo2[] = { |
---|
602 | 587 | INTER1_IN, DIGITAL_MIXER_IN1, 0xff |
---|
603 | 588 | }; |
---|
604 | | -static unsigned char lbus_play_mono2[] = { |
---|
| 589 | +static const unsigned char lbus_play_mono2[] = { |
---|
605 | 590 | INTERM1_IN, DIGITAL_MIXER_IN1, 0xff |
---|
606 | 591 | }; |
---|
607 | | -static unsigned char lbus_play_noconv3[] = { |
---|
| 592 | +static const unsigned char lbus_play_noconv3[] = { |
---|
608 | 593 | DIGITAL_MIXER_IN2, 0xff |
---|
609 | 594 | }; |
---|
610 | | -static unsigned char lbus_play_stereo3[] = { |
---|
| 595 | +static const unsigned char lbus_play_stereo3[] = { |
---|
611 | 596 | INTER2_IN, DIGITAL_MIXER_IN2, 0xff |
---|
612 | 597 | }; |
---|
613 | | -static unsigned char lbus_play_mono3[] = { |
---|
| 598 | +static const unsigned char lbus_play_mono3[] = { |
---|
614 | 599 | INTERM2_IN, DIGITAL_MIXER_IN2, 0xff |
---|
615 | 600 | }; |
---|
616 | | -static unsigned char lbus_rec_noconv1[] = { |
---|
| 601 | +static const unsigned char lbus_rec_noconv1[] = { |
---|
617 | 602 | LBUS2ARM_FIFO5, 0xff |
---|
618 | 603 | }; |
---|
619 | | -static unsigned char lbus_rec_stereo1[] = { |
---|
| 604 | +static const unsigned char lbus_rec_stereo1[] = { |
---|
620 | 605 | DECIM0_IN, LBUS2ARM_FIFO5, 0xff |
---|
621 | 606 | }; |
---|
622 | | -static unsigned char lbus_rec_mono1[] = { |
---|
| 607 | +static const unsigned char lbus_rec_mono1[] = { |
---|
623 | 608 | DECIMM3_IN, LBUS2ARM_FIFO5, 0xff |
---|
624 | 609 | }; |
---|
625 | 610 | |
---|
626 | | -static unsigned char play_ids[] = { 4, 1, 2, }; |
---|
627 | | -static unsigned char play_sources[] = { |
---|
| 611 | +static const unsigned char play_ids[] = { 4, 1, 2, }; |
---|
| 612 | +static const unsigned char play_sources[] = { |
---|
628 | 613 | ARM2LBUS_FIFO4, ARM2LBUS_FIFO1, ARM2LBUS_FIFO2, |
---|
629 | 614 | }; |
---|
630 | | -static struct lbuspath lbus_play_paths[] = { |
---|
| 615 | +static const struct lbuspath lbus_play_paths[] = { |
---|
631 | 616 | { |
---|
632 | 617 | .noconv = lbus_play_noconv1, |
---|
633 | 618 | .stereo = lbus_play_stereo1, |
---|
.. | .. |
---|
751 | 736 | |
---|
752 | 737 | static void |
---|
753 | 738 | alloclbuspath(struct cmdif *cif, unsigned char source, |
---|
754 | | - unsigned char *path, unsigned char *mixer, unsigned char *s) |
---|
| 739 | + const unsigned char *path, unsigned char *mixer, unsigned char *s) |
---|
755 | 740 | { |
---|
756 | 741 | while (*path != 0xff) { |
---|
757 | 742 | unsigned char sink, type; |
---|
.. | .. |
---|
779 | 764 | } |
---|
780 | 765 | } |
---|
781 | 766 | if (*path++ & SPLIT_PATH) { |
---|
782 | | - unsigned char *npath = path; |
---|
| 767 | + const unsigned char *npath = path; |
---|
783 | 768 | |
---|
784 | 769 | while (*npath != 0xff) |
---|
785 | 770 | npath++; |
---|
.. | .. |
---|
789 | 774 | } |
---|
790 | 775 | |
---|
791 | 776 | static void |
---|
792 | | -freelbuspath(struct cmdif *cif, unsigned char source, unsigned char *path) |
---|
| 777 | +freelbuspath(struct cmdif *cif, unsigned char source, const unsigned char *path) |
---|
793 | 778 | { |
---|
794 | 779 | while (*path != 0xff) { |
---|
795 | 780 | unsigned char sink; |
---|
.. | .. |
---|
801 | 786 | source = lbusin2out[sink][0]; |
---|
802 | 787 | } |
---|
803 | 788 | if (*path++ & SPLIT_PATH) { |
---|
804 | | - unsigned char *npath = path; |
---|
| 789 | + const unsigned char *npath = path; |
---|
805 | 790 | |
---|
806 | 791 | while (*npath != 0xff) |
---|
807 | 792 | npath++; |
---|
.. | .. |
---|
1084 | 1069 | return 0; |
---|
1085 | 1070 | } |
---|
1086 | 1071 | |
---|
1087 | | -static void riptide_handleirq(unsigned long dev_id) |
---|
| 1072 | +static irqreturn_t riptide_handleirq(int irq, void *dev_id) |
---|
1088 | 1073 | { |
---|
1089 | | - struct snd_riptide *chip = (void *)dev_id; |
---|
| 1074 | + struct snd_riptide *chip = dev_id; |
---|
1090 | 1075 | struct cmdif *cif = chip->cif; |
---|
1091 | 1076 | struct snd_pcm_substream *substream[PLAYBACK_SUBSTREAMS + 1]; |
---|
1092 | 1077 | struct snd_pcm_runtime *runtime; |
---|
.. | .. |
---|
1097 | 1082 | unsigned int flag; |
---|
1098 | 1083 | |
---|
1099 | 1084 | if (!cif) |
---|
1100 | | - return; |
---|
| 1085 | + return IRQ_HANDLED; |
---|
1101 | 1086 | |
---|
1102 | 1087 | for (i = 0; i < PLAYBACK_SUBSTREAMS; i++) |
---|
1103 | 1088 | substream[i] = chip->playback_substream[i]; |
---|
.. | .. |
---|
1148 | 1133 | } |
---|
1149 | 1134 | } |
---|
1150 | 1135 | } |
---|
| 1136 | + |
---|
| 1137 | + return IRQ_HANDLED; |
---|
1151 | 1138 | } |
---|
1152 | 1139 | |
---|
1153 | 1140 | #ifdef CONFIG_PM_SLEEP |
---|
.. | .. |
---|
1158 | 1145 | |
---|
1159 | 1146 | chip->in_suspend = 1; |
---|
1160 | 1147 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
1161 | | - snd_pcm_suspend_all(chip->pcm); |
---|
1162 | 1148 | snd_ac97_suspend(chip->ac97); |
---|
1163 | 1149 | return 0; |
---|
1164 | 1150 | } |
---|
.. | .. |
---|
1456 | 1442 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
1457 | 1443 | struct pcmhw *data = get_pcmhwdev(substream); |
---|
1458 | 1444 | struct cmdif *cif = chip->cif; |
---|
1459 | | - unsigned char *lbuspath = NULL; |
---|
| 1445 | + const unsigned char *lbuspath = NULL; |
---|
1460 | 1446 | unsigned int rate, channels; |
---|
1461 | 1447 | int err = 0; |
---|
1462 | 1448 | snd_pcm_format_t format; |
---|
.. | .. |
---|
1565 | 1551 | if (sgdlist->area) |
---|
1566 | 1552 | snd_dma_free_pages(sgdlist); |
---|
1567 | 1553 | if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, |
---|
1568 | | - snd_dma_pci_data(chip->pci), |
---|
| 1554 | + &chip->pci->dev, |
---|
1569 | 1555 | sizeof(struct sgd) * (DESC_MAX_MASK + 1), |
---|
1570 | 1556 | sgdlist)) < 0) { |
---|
1571 | 1557 | snd_printk(KERN_ERR "Riptide: failed to alloc %d dma bytes\n", |
---|
.. | .. |
---|
1573 | 1559 | return err; |
---|
1574 | 1560 | } |
---|
1575 | 1561 | data->sgdbuf = (struct sgd *)sgdlist->area; |
---|
1576 | | - return snd_pcm_lib_malloc_pages(substream, |
---|
1577 | | - params_buffer_bytes(hw_params)); |
---|
| 1562 | + return 0; |
---|
1578 | 1563 | } |
---|
1579 | 1564 | |
---|
1580 | 1565 | static int snd_riptide_hw_free(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
1596 | 1581 | data->sgdlist.area = NULL; |
---|
1597 | 1582 | } |
---|
1598 | 1583 | } |
---|
1599 | | - return snd_pcm_lib_free_pages(substream); |
---|
| 1584 | + return 0; |
---|
1600 | 1585 | } |
---|
1601 | 1586 | |
---|
1602 | 1587 | static int snd_riptide_playback_open(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
1672 | 1657 | static const struct snd_pcm_ops snd_riptide_playback_ops = { |
---|
1673 | 1658 | .open = snd_riptide_playback_open, |
---|
1674 | 1659 | .close = snd_riptide_playback_close, |
---|
1675 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1676 | 1660 | .hw_params = snd_riptide_hw_params, |
---|
1677 | 1661 | .hw_free = snd_riptide_hw_free, |
---|
1678 | 1662 | .prepare = snd_riptide_prepare, |
---|
1679 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1680 | 1663 | .trigger = snd_riptide_trigger, |
---|
1681 | 1664 | .pointer = snd_riptide_pointer, |
---|
1682 | 1665 | }; |
---|
1683 | 1666 | static const struct snd_pcm_ops snd_riptide_capture_ops = { |
---|
1684 | 1667 | .open = snd_riptide_capture_open, |
---|
1685 | 1668 | .close = snd_riptide_capture_close, |
---|
1686 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1687 | 1669 | .hw_params = snd_riptide_hw_params, |
---|
1688 | 1670 | .hw_free = snd_riptide_hw_free, |
---|
1689 | 1671 | .prepare = snd_riptide_prepare, |
---|
1690 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1691 | 1672 | .trigger = snd_riptide_trigger, |
---|
1692 | 1673 | .pointer = snd_riptide_pointer, |
---|
1693 | 1674 | }; |
---|
.. | .. |
---|
1709 | 1690 | pcm->info_flags = 0; |
---|
1710 | 1691 | strcpy(pcm->name, "RIPTIDE"); |
---|
1711 | 1692 | chip->pcm = pcm; |
---|
1712 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, |
---|
1713 | | - snd_dma_pci_data(chip->pci), |
---|
1714 | | - 64 * 1024, 128 * 1024); |
---|
| 1693 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, |
---|
| 1694 | + &chip->pci->dev, 64 * 1024, 128 * 1024); |
---|
1715 | 1695 | return 0; |
---|
1716 | 1696 | } |
---|
1717 | 1697 | |
---|
.. | .. |
---|
1720 | 1700 | { |
---|
1721 | 1701 | struct snd_riptide *chip = dev_id; |
---|
1722 | 1702 | struct cmdif *cif = chip->cif; |
---|
| 1703 | + irqreturn_t ret = IRQ_HANDLED; |
---|
1723 | 1704 | |
---|
1724 | 1705 | if (cif) { |
---|
1725 | 1706 | chip->received_irqs++; |
---|
1726 | 1707 | if (IS_EOBIRQ(cif->hwport) || IS_EOSIRQ(cif->hwport) || |
---|
1727 | 1708 | IS_EOCIRQ(cif->hwport)) { |
---|
1728 | 1709 | chip->handled_irqs++; |
---|
1729 | | - tasklet_schedule(&chip->riptide_tq); |
---|
| 1710 | + ret = IRQ_WAKE_THREAD; |
---|
1730 | 1711 | } |
---|
1731 | 1712 | if (chip->rmidi && IS_MPUIRQ(cif->hwport)) { |
---|
1732 | 1713 | chip->handled_irqs++; |
---|
.. | .. |
---|
1735 | 1716 | } |
---|
1736 | 1717 | SET_AIACK(cif->hwport); |
---|
1737 | 1718 | } |
---|
1738 | | - return IRQ_HANDLED; |
---|
| 1719 | + return ret; |
---|
1739 | 1720 | } |
---|
1740 | 1721 | |
---|
1741 | 1722 | static void |
---|
.. | .. |
---|
1845 | 1826 | struct snd_riptide *chip; |
---|
1846 | 1827 | struct riptideport *hwport; |
---|
1847 | 1828 | int err; |
---|
1848 | | - static struct snd_device_ops ops = { |
---|
| 1829 | + static const struct snd_device_ops ops = { |
---|
1849 | 1830 | .dev_free = snd_riptide_dev_free, |
---|
1850 | 1831 | }; |
---|
1851 | 1832 | |
---|
.. | .. |
---|
1864 | 1845 | chip->received_irqs = 0; |
---|
1865 | 1846 | chip->handled_irqs = 0; |
---|
1866 | 1847 | chip->cif = NULL; |
---|
1867 | | - tasklet_init(&chip->riptide_tq, riptide_handleirq, (unsigned long)chip); |
---|
1868 | 1848 | |
---|
1869 | 1849 | if ((chip->res_port = |
---|
1870 | 1850 | request_region(chip->port, 64, "RIPTIDE")) == NULL) { |
---|
.. | .. |
---|
1877 | 1857 | hwport = (struct riptideport *)chip->port; |
---|
1878 | 1858 | UNSET_AIE(hwport); |
---|
1879 | 1859 | |
---|
1880 | | - if (request_irq(pci->irq, snd_riptide_interrupt, IRQF_SHARED, |
---|
1881 | | - KBUILD_MODNAME, chip)) { |
---|
| 1860 | + if (request_threaded_irq(pci->irq, snd_riptide_interrupt, |
---|
| 1861 | + riptide_handleirq, IRQF_SHARED, |
---|
| 1862 | + KBUILD_MODNAME, chip)) { |
---|
1882 | 1863 | snd_printk(KERN_ERR "Riptide: unable to grab IRQ %d\n", |
---|
1883 | 1864 | pci->irq); |
---|
1884 | 1865 | snd_riptide_free(chip); |
---|
1885 | 1866 | return -EBUSY; |
---|
1886 | 1867 | } |
---|
1887 | 1868 | chip->irq = pci->irq; |
---|
| 1869 | + card->sync_irq = chip->irq; |
---|
1888 | 1870 | chip->device_id = pci->device; |
---|
1889 | 1871 | pci_set_master(pci); |
---|
1890 | 1872 | if ((err = snd_riptide_initialize(chip)) < 0) { |
---|
.. | .. |
---|
1974 | 1956 | |
---|
1975 | 1957 | static void snd_riptide_proc_init(struct snd_riptide *chip) |
---|
1976 | 1958 | { |
---|
1977 | | - struct snd_info_entry *entry; |
---|
1978 | | - |
---|
1979 | | - if (!snd_card_proc_new(chip->card, "riptide", &entry)) |
---|
1980 | | - snd_info_set_text_ops(entry, chip, snd_riptide_proc_read); |
---|
| 1959 | + snd_card_ro_proc_new(chip->card, "riptide", chip, |
---|
| 1960 | + snd_riptide_proc_read); |
---|
1981 | 1961 | } |
---|
1982 | 1962 | |
---|
1983 | 1963 | static int snd_riptide_mixer(struct snd_riptide *chip) |
---|
.. | .. |
---|
1985 | 1965 | struct snd_ac97_bus *pbus; |
---|
1986 | 1966 | struct snd_ac97_template ac97; |
---|
1987 | 1967 | int err = 0; |
---|
1988 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1968 | + static const struct snd_ac97_bus_ops ops = { |
---|
1989 | 1969 | .write = snd_riptide_codec_write, |
---|
1990 | 1970 | .read = snd_riptide_codec_read, |
---|
1991 | 1971 | }; |
---|