.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for Ensoniq ES1370/ES1371 AudioPCI soundcard |
---|
3 | 4 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, |
---|
4 | 5 | * Thomas Sailer <sailer@ife.ee.ethz.ch> |
---|
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 | /* Power-Management-Code ( CONFIG_PM ) |
---|
.. | .. |
---|
870 | 856 | * PCM part |
---|
871 | 857 | */ |
---|
872 | 858 | |
---|
873 | | -static int snd_ensoniq_hw_params(struct snd_pcm_substream *substream, |
---|
874 | | - struct snd_pcm_hw_params *hw_params) |
---|
875 | | -{ |
---|
876 | | - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
---|
877 | | -} |
---|
878 | | - |
---|
879 | | -static int snd_ensoniq_hw_free(struct snd_pcm_substream *substream) |
---|
880 | | -{ |
---|
881 | | - return snd_pcm_lib_free_pages(substream); |
---|
882 | | -} |
---|
883 | | - |
---|
884 | 859 | static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) |
---|
885 | 860 | { |
---|
886 | 861 | struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); |
---|
.. | .. |
---|
1229 | 1204 | static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { |
---|
1230 | 1205 | .open = snd_ensoniq_playback1_open, |
---|
1231 | 1206 | .close = snd_ensoniq_playback1_close, |
---|
1232 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1233 | | - .hw_params = snd_ensoniq_hw_params, |
---|
1234 | | - .hw_free = snd_ensoniq_hw_free, |
---|
1235 | 1207 | .prepare = snd_ensoniq_playback1_prepare, |
---|
1236 | 1208 | .trigger = snd_ensoniq_trigger, |
---|
1237 | 1209 | .pointer = snd_ensoniq_playback1_pointer, |
---|
.. | .. |
---|
1240 | 1212 | static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { |
---|
1241 | 1213 | .open = snd_ensoniq_playback2_open, |
---|
1242 | 1214 | .close = snd_ensoniq_playback2_close, |
---|
1243 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1244 | | - .hw_params = snd_ensoniq_hw_params, |
---|
1245 | | - .hw_free = snd_ensoniq_hw_free, |
---|
1246 | 1215 | .prepare = snd_ensoniq_playback2_prepare, |
---|
1247 | 1216 | .trigger = snd_ensoniq_trigger, |
---|
1248 | 1217 | .pointer = snd_ensoniq_playback2_pointer, |
---|
.. | .. |
---|
1251 | 1220 | static const struct snd_pcm_ops snd_ensoniq_capture_ops = { |
---|
1252 | 1221 | .open = snd_ensoniq_capture_open, |
---|
1253 | 1222 | .close = snd_ensoniq_capture_close, |
---|
1254 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1255 | | - .hw_params = snd_ensoniq_hw_params, |
---|
1256 | | - .hw_free = snd_ensoniq_hw_free, |
---|
1257 | 1223 | .prepare = snd_ensoniq_capture_prepare, |
---|
1258 | 1224 | .trigger = snd_ensoniq_trigger, |
---|
1259 | 1225 | .pointer = snd_ensoniq_capture_pointer, |
---|
.. | .. |
---|
1288 | 1254 | strcpy(pcm->name, CHIP_NAME " DAC2/ADC"); |
---|
1289 | 1255 | ensoniq->pcm1 = pcm; |
---|
1290 | 1256 | |
---|
1291 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1292 | | - snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); |
---|
| 1257 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1258 | + &ensoniq->pci->dev, 64*1024, 128*1024); |
---|
1293 | 1259 | |
---|
1294 | 1260 | #ifdef CHIP1370 |
---|
1295 | 1261 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
.. | .. |
---|
1320 | 1286 | strcpy(pcm->name, CHIP_NAME " DAC1"); |
---|
1321 | 1287 | ensoniq->pcm2 = pcm; |
---|
1322 | 1288 | |
---|
1323 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1324 | | - snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); |
---|
| 1289 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1290 | + &ensoniq->pci->dev, 64*1024, 128*1024); |
---|
1325 | 1291 | |
---|
1326 | 1292 | #ifdef CHIP1370 |
---|
1327 | 1293 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
.. | .. |
---|
1467 | 1433 | |
---|
1468 | 1434 | |
---|
1469 | 1435 | /* spdif controls */ |
---|
1470 | | -static struct snd_kcontrol_new snd_es1371_mixer_spdif[] = { |
---|
| 1436 | +static const struct snd_kcontrol_new snd_es1371_mixer_spdif[] = { |
---|
1471 | 1437 | ES1371_SPDIF(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH)), |
---|
1472 | 1438 | { |
---|
1473 | 1439 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
---|
.. | .. |
---|
1596 | 1562 | }; |
---|
1597 | 1563 | |
---|
1598 | 1564 | static int es1371_quirk_lookup(struct ensoniq *ensoniq, |
---|
1599 | | - struct es1371_quirk *list) |
---|
| 1565 | + const struct es1371_quirk *list) |
---|
1600 | 1566 | { |
---|
1601 | 1567 | while (list->vid != (unsigned short)PCI_ANY_ID) { |
---|
1602 | 1568 | if (ensoniq->pci->vendor == list->vid && |
---|
.. | .. |
---|
1608 | 1574 | return 0; |
---|
1609 | 1575 | } |
---|
1610 | 1576 | |
---|
1611 | | -static struct es1371_quirk es1371_spdif_present[] = { |
---|
| 1577 | +static const struct es1371_quirk es1371_spdif_present[] = { |
---|
1612 | 1578 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, |
---|
1613 | 1579 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, |
---|
1614 | 1580 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, |
---|
.. | .. |
---|
1617 | 1583 | { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } |
---|
1618 | 1584 | }; |
---|
1619 | 1585 | |
---|
1620 | | -static struct snd_pci_quirk ens1373_line_quirk[] = { |
---|
| 1586 | +static const struct snd_pci_quirk ens1373_line_quirk[] = { |
---|
1621 | 1587 | SND_PCI_QUIRK_ID(0x1274, 0x2000), /* GA-7DXR */ |
---|
1622 | 1588 | SND_PCI_QUIRK_ID(0x1458, 0xa000), /* GA-8IEXP */ |
---|
1623 | 1589 | { } /* end */ |
---|
.. | .. |
---|
1630 | 1596 | struct snd_ac97_bus *pbus; |
---|
1631 | 1597 | struct snd_ac97_template ac97; |
---|
1632 | 1598 | int err; |
---|
1633 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1599 | + static const struct snd_ac97_bus_ops ops = { |
---|
1634 | 1600 | .write = snd_es1371_codec_write, |
---|
1635 | 1601 | .read = snd_es1371_codec_read, |
---|
1636 | 1602 | .wait = snd_es1371_codec_wait, |
---|
.. | .. |
---|
1732 | 1698 | * ENS1370 mixer |
---|
1733 | 1699 | */ |
---|
1734 | 1700 | |
---|
1735 | | -static struct snd_kcontrol_new snd_es1370_controls[2] = { |
---|
| 1701 | +static const struct snd_kcontrol_new snd_es1370_controls[2] = { |
---|
1736 | 1702 | ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0), |
---|
1737 | 1703 | ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1) |
---|
1738 | 1704 | }; |
---|
.. | .. |
---|
1902 | 1868 | |
---|
1903 | 1869 | static void snd_ensoniq_proc_init(struct ensoniq *ensoniq) |
---|
1904 | 1870 | { |
---|
1905 | | - struct snd_info_entry *entry; |
---|
1906 | | - |
---|
1907 | | - if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry)) |
---|
1908 | | - snd_info_set_text_ops(entry, ensoniq, snd_ensoniq_proc_read); |
---|
| 1871 | + snd_card_ro_proc_new(ensoniq->card, "audiopci", ensoniq, |
---|
| 1872 | + snd_ensoniq_proc_read); |
---|
1909 | 1873 | } |
---|
1910 | 1874 | |
---|
1911 | 1875 | /* |
---|
.. | .. |
---|
1924 | 1888 | outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */ |
---|
1925 | 1889 | outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ |
---|
1926 | 1890 | #endif |
---|
1927 | | - if (ensoniq->irq >= 0) |
---|
1928 | | - synchronize_irq(ensoniq->irq); |
---|
1929 | 1891 | pci_set_power_state(ensoniq->pci, PCI_D3hot); |
---|
1930 | 1892 | __hw_end: |
---|
1931 | 1893 | #ifdef CHIP1370 |
---|
.. | .. |
---|
1947 | 1909 | } |
---|
1948 | 1910 | |
---|
1949 | 1911 | #ifdef CHIP1371 |
---|
1950 | | -static struct snd_pci_quirk es1371_amplifier_hack[] = { |
---|
| 1912 | +static const struct snd_pci_quirk es1371_amplifier_hack[] = { |
---|
1951 | 1913 | SND_PCI_QUIRK_ID(0x107b, 0x2150), /* Gateway Solo 2150 */ |
---|
1952 | 1914 | SND_PCI_QUIRK_ID(0x13bd, 0x100c), /* EV1938 on Mebius PC-MJ100V */ |
---|
1953 | 1915 | SND_PCI_QUIRK_ID(0x1102, 0x5938), /* Targa Xtender300 */ |
---|
.. | .. |
---|
1955 | 1917 | { } /* end */ |
---|
1956 | 1918 | }; |
---|
1957 | 1919 | |
---|
1958 | | -static struct es1371_quirk es1371_ac97_reset_hack[] = { |
---|
| 1920 | +static const struct es1371_quirk es1371_ac97_reset_hack[] = { |
---|
1959 | 1921 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, |
---|
1960 | 1922 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, |
---|
1961 | 1923 | { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, |
---|
.. | .. |
---|
2026 | 1988 | outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL)); |
---|
2027 | 1989 | outb(0x00, ES_REG(ensoniq, UART_RES)); |
---|
2028 | 1990 | outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); |
---|
2029 | | - synchronize_irq(ensoniq->irq); |
---|
2030 | 1991 | } |
---|
2031 | 1992 | |
---|
2032 | 1993 | #ifdef CONFIG_PM_SLEEP |
---|
.. | .. |
---|
2037 | 1998 | |
---|
2038 | 1999 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
2039 | 2000 | |
---|
2040 | | - snd_pcm_suspend_all(ensoniq->pcm1); |
---|
2041 | | - snd_pcm_suspend_all(ensoniq->pcm2); |
---|
2042 | | - |
---|
2043 | 2001 | #ifdef CHIP1371 |
---|
2044 | 2002 | snd_ac97_suspend(ensoniq->u.es1371.ac97); |
---|
2045 | 2003 | #else |
---|
.. | .. |
---|
2083 | 2041 | { |
---|
2084 | 2042 | struct ensoniq *ensoniq; |
---|
2085 | 2043 | int err; |
---|
2086 | | - static struct snd_device_ops ops = { |
---|
| 2044 | + static const struct snd_device_ops ops = { |
---|
2087 | 2045 | .dev_free = snd_ensoniq_dev_free, |
---|
2088 | 2046 | }; |
---|
2089 | 2047 | |
---|
.. | .. |
---|
2113 | 2071 | return -EBUSY; |
---|
2114 | 2072 | } |
---|
2115 | 2073 | ensoniq->irq = pci->irq; |
---|
| 2074 | + card->sync_irq = ensoniq->irq; |
---|
2116 | 2075 | #ifdef CHIP1370 |
---|
2117 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
---|
| 2076 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, |
---|
2118 | 2077 | 16, &ensoniq->dma_bug) < 0) { |
---|
2119 | 2078 | dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n"); |
---|
2120 | 2079 | snd_ensoniq_free(ensoniq); |
---|