.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * ALSA modem driver for VIA VT82xx (South Bridge) |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
---|
7 | 8 | * Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com> |
---|
8 | 9 | * 2002 Takashi Iwai <tiwai@suse.de> |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
13 | | - * (at your option) any later version. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | | - * GNU General Public License for more details. |
---|
19 | | - * |
---|
20 | | - * You should have received a copy of the GNU General Public License |
---|
21 | | - * along with this program; if not, write to the Free Software |
---|
22 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
23 | | - * |
---|
24 | 10 | */ |
---|
25 | 11 | |
---|
26 | 12 | /* |
---|
.. | .. |
---|
281 | 267 | { |
---|
282 | 268 | unsigned int i, idx, ofs, rest; |
---|
283 | 269 | struct via82xx_modem *chip = snd_pcm_substream_chip(substream); |
---|
| 270 | + __le32 *pgtbl; |
---|
284 | 271 | |
---|
285 | 272 | if (dev->table.area == NULL) { |
---|
286 | 273 | /* the start of each lists must be aligned to 8 bytes, |
---|
287 | 274 | * but the kernel pages are much bigger, so we don't care |
---|
288 | 275 | */ |
---|
289 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), |
---|
| 276 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, |
---|
290 | 277 | PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), |
---|
291 | 278 | &dev->table) < 0) |
---|
292 | 279 | return -ENOMEM; |
---|
.. | .. |
---|
302 | 289 | /* fill the entries */ |
---|
303 | 290 | idx = 0; |
---|
304 | 291 | ofs = 0; |
---|
| 292 | + pgtbl = (__le32 *)dev->table.area; |
---|
305 | 293 | for (i = 0; i < periods; i++) { |
---|
306 | 294 | rest = fragsize; |
---|
307 | 295 | /* fill descriptors for a period. |
---|
.. | .. |
---|
318 | 306 | return -EINVAL; |
---|
319 | 307 | } |
---|
320 | 308 | addr = snd_pcm_sgbuf_get_addr(substream, ofs); |
---|
321 | | - ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32(addr); |
---|
| 309 | + pgtbl[idx << 1] = cpu_to_le32(addr); |
---|
322 | 310 | r = PAGE_SIZE - (ofs % PAGE_SIZE); |
---|
323 | 311 | if (rest < r) |
---|
324 | 312 | r = rest; |
---|
.. | .. |
---|
335 | 323 | "tbl %d: at %d size %d (rest %d)\n", |
---|
336 | 324 | idx, ofs, r, rest); |
---|
337 | 325 | */ |
---|
338 | | - ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); |
---|
| 326 | + pgtbl[(idx<<1) + 1] = cpu_to_le32(r | flag); |
---|
339 | 327 | dev->idx_table[idx].offset = ofs; |
---|
340 | 328 | dev->idx_table[idx].size = r; |
---|
341 | 329 | ofs += r; |
---|
.. | .. |
---|
410 | 398 | static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) |
---|
411 | 399 | { |
---|
412 | 400 | struct via82xx_modem *chip = ac97->private_data; |
---|
413 | | - int err; |
---|
| 401 | + __always_unused int err; |
---|
414 | 402 | err = snd_via82xx_codec_ready(chip, ac97->num); |
---|
415 | 403 | /* here we need to wait fairly for long time.. */ |
---|
416 | 404 | msleep(500); |
---|
.. | .. |
---|
656 | 644 | struct viadev *viadev = substream->runtime->private_data; |
---|
657 | 645 | int err; |
---|
658 | 646 | |
---|
659 | | - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
---|
660 | | - if (err < 0) |
---|
661 | | - return err; |
---|
662 | 647 | err = build_via_table(viadev, substream, chip->pci, |
---|
663 | 648 | params_periods(hw_params), |
---|
664 | 649 | params_period_bytes(hw_params)); |
---|
.. | .. |
---|
681 | 666 | struct viadev *viadev = substream->runtime->private_data; |
---|
682 | 667 | |
---|
683 | 668 | clean_via_table(viadev, substream, chip->pci); |
---|
684 | | - snd_pcm_lib_free_pages(substream); |
---|
685 | 669 | return 0; |
---|
686 | 670 | } |
---|
687 | 671 | |
---|
.. | .. |
---|
809 | 793 | static const struct snd_pcm_ops snd_via686_playback_ops = { |
---|
810 | 794 | .open = snd_via82xx_playback_open, |
---|
811 | 795 | .close = snd_via82xx_pcm_close, |
---|
812 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
813 | 796 | .hw_params = snd_via82xx_hw_params, |
---|
814 | 797 | .hw_free = snd_via82xx_hw_free, |
---|
815 | 798 | .prepare = snd_via82xx_pcm_prepare, |
---|
816 | 799 | .trigger = snd_via82xx_pcm_trigger, |
---|
817 | 800 | .pointer = snd_via686_pcm_pointer, |
---|
818 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
819 | 801 | }; |
---|
820 | 802 | |
---|
821 | 803 | /* via686 capture callbacks */ |
---|
822 | 804 | static const struct snd_pcm_ops snd_via686_capture_ops = { |
---|
823 | 805 | .open = snd_via82xx_capture_open, |
---|
824 | 806 | .close = snd_via82xx_pcm_close, |
---|
825 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
826 | 807 | .hw_params = snd_via82xx_hw_params, |
---|
827 | 808 | .hw_free = snd_via82xx_hw_free, |
---|
828 | 809 | .prepare = snd_via82xx_pcm_prepare, |
---|
829 | 810 | .trigger = snd_via82xx_pcm_trigger, |
---|
830 | 811 | .pointer = snd_via686_pcm_pointer, |
---|
831 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
832 | 812 | }; |
---|
833 | 813 | |
---|
834 | 814 | |
---|
.. | .. |
---|
865 | 845 | init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); |
---|
866 | 846 | init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); |
---|
867 | 847 | |
---|
868 | | - if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, |
---|
869 | | - snd_dma_pci_data(chip->pci), |
---|
870 | | - 64*1024, 128*1024)) < 0) |
---|
871 | | - return err; |
---|
872 | | - |
---|
| 848 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, |
---|
| 849 | + &chip->pci->dev, 64*1024, 128*1024); |
---|
873 | 850 | return 0; |
---|
874 | 851 | } |
---|
875 | 852 | |
---|
.. | .. |
---|
896 | 873 | { |
---|
897 | 874 | struct snd_ac97_template ac97; |
---|
898 | 875 | int err; |
---|
899 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 876 | + static const struct snd_ac97_bus_ops ops = { |
---|
900 | 877 | .write = snd_via82xx_codec_write, |
---|
901 | 878 | .read = snd_via82xx_codec_read, |
---|
902 | 879 | .wait = snd_via82xx_codec_wait, |
---|
.. | .. |
---|
937 | 914 | |
---|
938 | 915 | static void snd_via82xx_proc_init(struct via82xx_modem *chip) |
---|
939 | 916 | { |
---|
940 | | - struct snd_info_entry *entry; |
---|
941 | | - |
---|
942 | | - if (! snd_card_proc_new(chip->card, "via82xx", &entry)) |
---|
943 | | - snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read); |
---|
| 917 | + snd_card_ro_proc_new(chip->card, "via82xx", chip, |
---|
| 918 | + snd_via82xx_proc_read); |
---|
944 | 919 | } |
---|
945 | 920 | |
---|
946 | 921 | /* |
---|
.. | .. |
---|
1038 | 1013 | int i; |
---|
1039 | 1014 | |
---|
1040 | 1015 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
1041 | | - for (i = 0; i < 2; i++) |
---|
1042 | | - snd_pcm_suspend_all(chip->pcms[i]); |
---|
1043 | 1016 | for (i = 0; i < chip->num_devs; i++) |
---|
1044 | 1017 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
---|
1045 | | - synchronize_irq(chip->irq); |
---|
1046 | 1018 | snd_ac97_suspend(chip->ac97); |
---|
1047 | 1019 | return 0; |
---|
1048 | 1020 | } |
---|
.. | .. |
---|
1104 | 1076 | { |
---|
1105 | 1077 | struct via82xx_modem *chip; |
---|
1106 | 1078 | int err; |
---|
1107 | | - static struct snd_device_ops ops = { |
---|
| 1079 | + static const struct snd_device_ops ops = { |
---|
1108 | 1080 | .dev_free = snd_via82xx_dev_free, |
---|
1109 | 1081 | }; |
---|
1110 | 1082 | |
---|
.. | .. |
---|
1134 | 1106 | return -EBUSY; |
---|
1135 | 1107 | } |
---|
1136 | 1108 | chip->irq = pci->irq; |
---|
| 1109 | + card->sync_irq = chip->irq; |
---|
1137 | 1110 | if (ac97_clock >= 8000 && ac97_clock <= 48000) |
---|
1138 | 1111 | chip->ac97_clock = ac97_clock; |
---|
1139 | | - synchronize_irq(chip->irq); |
---|
1140 | 1112 | |
---|
1141 | 1113 | if ((err = snd_via82xx_chip_init(chip)) < 0) { |
---|
1142 | 1114 | snd_via82xx_free(chip); |
---|