.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for Cirrus Logic CS4281 based PCI soundcard |
---|
3 | 4 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, |
---|
4 | | - * |
---|
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 | 5 | */ |
---|
21 | 6 | |
---|
22 | 7 | #include <linux/io.h> |
---|
.. | .. |
---|
709 | 694 | |
---|
710 | 695 | static unsigned int snd_cs4281_rate(unsigned int rate, unsigned int *real_rate) |
---|
711 | 696 | { |
---|
712 | | - unsigned int val = ~0; |
---|
| 697 | + unsigned int val; |
---|
713 | 698 | |
---|
714 | 699 | if (real_rate) |
---|
715 | 700 | *real_rate = rate; |
---|
.. | .. |
---|
722 | 707 | case 44100: return 1; |
---|
723 | 708 | case 48000: return 0; |
---|
724 | 709 | default: |
---|
725 | | - goto __variable; |
---|
| 710 | + break; |
---|
726 | 711 | } |
---|
727 | | - __variable: |
---|
728 | 712 | val = 1536000 / rate; |
---|
729 | 713 | if (real_rate) |
---|
730 | 714 | *real_rate = 1536000 / val; |
---|
.. | .. |
---|
794 | 778 | snd_cs4281_pokeBA0(chip, dma->regFCR, dma->valFCR | BA0_FCR_FEN); |
---|
795 | 779 | /* Clear FIFO Status and Interrupt Control Register */ |
---|
796 | 780 | snd_cs4281_pokeBA0(chip, dma->regFSIC, 0); |
---|
797 | | -} |
---|
798 | | - |
---|
799 | | -static int snd_cs4281_hw_params(struct snd_pcm_substream *substream, |
---|
800 | | - struct snd_pcm_hw_params *hw_params) |
---|
801 | | -{ |
---|
802 | | - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
---|
803 | | -} |
---|
804 | | - |
---|
805 | | -static int snd_cs4281_hw_free(struct snd_pcm_substream *substream) |
---|
806 | | -{ |
---|
807 | | - return snd_pcm_lib_free_pages(substream); |
---|
808 | 781 | } |
---|
809 | 782 | |
---|
810 | 783 | static int snd_cs4281_playback_prepare(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
954 | 927 | static const struct snd_pcm_ops snd_cs4281_playback_ops = { |
---|
955 | 928 | .open = snd_cs4281_playback_open, |
---|
956 | 929 | .close = snd_cs4281_playback_close, |
---|
957 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
958 | | - .hw_params = snd_cs4281_hw_params, |
---|
959 | | - .hw_free = snd_cs4281_hw_free, |
---|
960 | 930 | .prepare = snd_cs4281_playback_prepare, |
---|
961 | 931 | .trigger = snd_cs4281_trigger, |
---|
962 | 932 | .pointer = snd_cs4281_pointer, |
---|
.. | .. |
---|
965 | 935 | static const struct snd_pcm_ops snd_cs4281_capture_ops = { |
---|
966 | 936 | .open = snd_cs4281_capture_open, |
---|
967 | 937 | .close = snd_cs4281_capture_close, |
---|
968 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
969 | | - .hw_params = snd_cs4281_hw_params, |
---|
970 | | - .hw_free = snd_cs4281_hw_free, |
---|
971 | 938 | .prepare = snd_cs4281_capture_prepare, |
---|
972 | 939 | .trigger = snd_cs4281_trigger, |
---|
973 | 940 | .pointer = snd_cs4281_pointer, |
---|
.. | .. |
---|
990 | 957 | strcpy(pcm->name, "CS4281"); |
---|
991 | 958 | chip->pcm = pcm; |
---|
992 | 959 | |
---|
993 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
994 | | - snd_dma_pci_data(chip->pci), 64*1024, 512*1024); |
---|
| 960 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, |
---|
| 961 | + 64*1024, 512*1024); |
---|
995 | 962 | |
---|
996 | 963 | return 0; |
---|
997 | 964 | } |
---|
.. | .. |
---|
1097 | 1064 | struct snd_card *card = chip->card; |
---|
1098 | 1065 | struct snd_ac97_template ac97; |
---|
1099 | 1066 | int err; |
---|
1100 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1067 | + static const struct snd_ac97_bus_ops ops = { |
---|
1101 | 1068 | .write = snd_cs4281_ac97_write, |
---|
1102 | 1069 | .read = snd_cs4281_ac97_read, |
---|
1103 | 1070 | }; |
---|
.. | .. |
---|
1162 | 1129 | return count; |
---|
1163 | 1130 | } |
---|
1164 | 1131 | |
---|
1165 | | -static struct snd_info_entry_ops snd_cs4281_proc_ops_BA0 = { |
---|
| 1132 | +static const struct snd_info_entry_ops snd_cs4281_proc_ops_BA0 = { |
---|
1166 | 1133 | .read = snd_cs4281_BA0_read, |
---|
1167 | 1134 | }; |
---|
1168 | 1135 | |
---|
1169 | | -static struct snd_info_entry_ops snd_cs4281_proc_ops_BA1 = { |
---|
| 1136 | +static const struct snd_info_entry_ops snd_cs4281_proc_ops_BA1 = { |
---|
1170 | 1137 | .read = snd_cs4281_BA1_read, |
---|
1171 | 1138 | }; |
---|
1172 | 1139 | |
---|
.. | .. |
---|
1174 | 1141 | { |
---|
1175 | 1142 | struct snd_info_entry *entry; |
---|
1176 | 1143 | |
---|
1177 | | - if (! snd_card_proc_new(chip->card, "cs4281", &entry)) |
---|
1178 | | - snd_info_set_text_ops(entry, chip, snd_cs4281_proc_read); |
---|
| 1144 | + snd_card_ro_proc_new(chip->card, "cs4281", chip, snd_cs4281_proc_read); |
---|
1179 | 1145 | if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) { |
---|
1180 | 1146 | entry->content = SNDRV_INFO_CONTENT_DATA; |
---|
1181 | 1147 | entry->private_data = chip; |
---|
.. | .. |
---|
1302 | 1268 | { |
---|
1303 | 1269 | snd_cs4281_free_gameport(chip); |
---|
1304 | 1270 | |
---|
1305 | | - if (chip->irq >= 0) |
---|
1306 | | - synchronize_irq(chip->irq); |
---|
1307 | | - |
---|
1308 | 1271 | /* Mask interrupts */ |
---|
1309 | 1272 | snd_cs4281_pokeBA0(chip, BA0_HIMR, 0x7fffffff); |
---|
1310 | 1273 | /* Stop the DLL Clock logic. */ |
---|
.. | .. |
---|
1341 | 1304 | struct cs4281 *chip; |
---|
1342 | 1305 | unsigned int tmp; |
---|
1343 | 1306 | int err; |
---|
1344 | | - static struct snd_device_ops ops = { |
---|
| 1307 | + static const struct snd_device_ops ops = { |
---|
1345 | 1308 | .dev_free = snd_cs4281_dev_free, |
---|
1346 | 1309 | }; |
---|
1347 | 1310 | |
---|
.. | .. |
---|
1386 | 1349 | return -ENOMEM; |
---|
1387 | 1350 | } |
---|
1388 | 1351 | chip->irq = pci->irq; |
---|
| 1352 | + card->sync_irq = chip->irq; |
---|
1389 | 1353 | |
---|
1390 | 1354 | tmp = snd_cs4281_chip_init(chip); |
---|
1391 | 1355 | if (tmp) { |
---|
.. | .. |
---|
1634 | 1598 | BA0_HISR_DMA(1) | |
---|
1635 | 1599 | BA0_HISR_DMA(2) | |
---|
1636 | 1600 | BA0_HISR_DMA(3))); |
---|
1637 | | - synchronize_irq(chip->irq); |
---|
1638 | 1601 | |
---|
1639 | 1602 | return 0; |
---|
1640 | 1603 | } |
---|
.. | .. |
---|
1976 | 1939 | */ |
---|
1977 | 1940 | #ifdef CONFIG_PM_SLEEP |
---|
1978 | 1941 | |
---|
1979 | | -static int saved_regs[SUSPEND_REGISTERS] = { |
---|
| 1942 | +static const int saved_regs[SUSPEND_REGISTERS] = { |
---|
1980 | 1943 | BA0_JSCTL, |
---|
1981 | 1944 | BA0_GPIOR, |
---|
1982 | 1945 | BA0_SSCR, |
---|
.. | .. |
---|
2002 | 1965 | unsigned int i; |
---|
2003 | 1966 | |
---|
2004 | 1967 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
2005 | | - snd_pcm_suspend_all(chip->pcm); |
---|
2006 | | - |
---|
2007 | 1968 | snd_ac97_suspend(chip->ac97); |
---|
2008 | 1969 | snd_ac97_suspend(chip->ac97_secondary); |
---|
2009 | 1970 | |
---|