| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for Digigram miXart soundcards |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * main file with alsa callbacks |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (c) 2003 by Digigram <alsa@digigram.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 10 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | | - * (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, write to the Free Software |
|---|
| 20 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | 8 | */ |
|---|
| 22 | 9 | |
|---|
| 23 | 10 | |
|---|
| .. | .. |
|---|
| 182 | 169 | case PIPE_RUNNING: |
|---|
| 183 | 170 | if(rate != 0) |
|---|
| 184 | 171 | break; |
|---|
| 185 | | - /* fall through */ |
|---|
| 172 | + fallthrough; |
|---|
| 186 | 173 | default: |
|---|
| 187 | 174 | if(rate == 0) |
|---|
| 188 | 175 | return 0; /* nothing to do */ |
|---|
| .. | .. |
|---|
| 637 | 624 | return err; |
|---|
| 638 | 625 | } |
|---|
| 639 | 626 | |
|---|
| 640 | | - /* allocate buffer */ |
|---|
| 641 | | - err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); |
|---|
| 642 | | - |
|---|
| 643 | | - if (err > 0) { |
|---|
| 627 | + if (subs->runtime->buffer_changed) { |
|---|
| 644 | 628 | struct mixart_bufferinfo *bufferinfo; |
|---|
| 645 | 629 | int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number; |
|---|
| 646 | 630 | if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) { |
|---|
| .. | .. |
|---|
| 660 | 644 | } |
|---|
| 661 | 645 | mutex_unlock(&mgr->setup_mutex); |
|---|
| 662 | 646 | |
|---|
| 663 | | - return err; |
|---|
| 647 | + return 0; |
|---|
| 664 | 648 | } |
|---|
| 665 | 649 | |
|---|
| 666 | 650 | static int snd_mixart_hw_free(struct snd_pcm_substream *subs) |
|---|
| 667 | 651 | { |
|---|
| 668 | 652 | struct snd_mixart *chip = snd_pcm_substream_chip(subs); |
|---|
| 669 | | - snd_pcm_lib_free_pages(subs); |
|---|
| 670 | 653 | mixart_sync_nonblock_events(chip->mgr); |
|---|
| 671 | 654 | return 0; |
|---|
| 672 | 655 | } |
|---|
| .. | .. |
|---|
| 926 | 909 | static const struct snd_pcm_ops snd_mixart_playback_ops = { |
|---|
| 927 | 910 | .open = snd_mixart_playback_open, |
|---|
| 928 | 911 | .close = snd_mixart_close, |
|---|
| 929 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 930 | 912 | .prepare = snd_mixart_prepare, |
|---|
| 931 | 913 | .hw_params = snd_mixart_hw_params, |
|---|
| 932 | 914 | .hw_free = snd_mixart_hw_free, |
|---|
| .. | .. |
|---|
| 937 | 919 | static const struct snd_pcm_ops snd_mixart_capture_ops = { |
|---|
| 938 | 920 | .open = snd_mixart_capture_open, |
|---|
| 939 | 921 | .close = snd_mixart_close, |
|---|
| 940 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 941 | 922 | .prepare = snd_mixart_prepare, |
|---|
| 942 | 923 | .hw_params = snd_mixart_hw_params, |
|---|
| 943 | 924 | .hw_free = snd_mixart_hw_free, |
|---|
| .. | .. |
|---|
| 960 | 941 | (chip->chip_idx + 1) << 24; |
|---|
| 961 | 942 | } |
|---|
| 962 | 943 | #endif |
|---|
| 963 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 964 | | - snd_dma_pci_data(chip->mgr->pci), 32*1024, 32*1024); |
|---|
| 944 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 945 | + &chip->mgr->pci->dev, |
|---|
| 946 | + 32*1024, 32*1024); |
|---|
| 965 | 947 | } |
|---|
| 966 | 948 | |
|---|
| 967 | 949 | /* |
|---|
| .. | .. |
|---|
| 1048 | 1030 | { |
|---|
| 1049 | 1031 | int err; |
|---|
| 1050 | 1032 | struct snd_mixart *chip; |
|---|
| 1051 | | - static struct snd_device_ops ops = { |
|---|
| 1033 | + static const struct snd_device_ops ops = { |
|---|
| 1052 | 1034 | .dev_free = snd_mixart_chip_dev_free, |
|---|
| 1053 | 1035 | }; |
|---|
| 1054 | 1036 | |
|---|
| .. | .. |
|---|
| 1059 | 1041 | chip->card = card; |
|---|
| 1060 | 1042 | chip->chip_idx = idx; |
|---|
| 1061 | 1043 | chip->mgr = mgr; |
|---|
| 1044 | + card->sync_irq = mgr->irq; |
|---|
| 1062 | 1045 | |
|---|
| 1063 | 1046 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
|---|
| 1064 | 1047 | snd_mixart_chip_free(chip); |
|---|
| .. | .. |
|---|
| 1170 | 1153 | return count; |
|---|
| 1171 | 1154 | } |
|---|
| 1172 | 1155 | |
|---|
| 1173 | | -static struct snd_info_entry_ops snd_mixart_proc_ops_BA0 = { |
|---|
| 1156 | +static const struct snd_info_entry_ops snd_mixart_proc_ops_BA0 = { |
|---|
| 1174 | 1157 | .read = snd_mixart_BA0_read, |
|---|
| 1175 | 1158 | }; |
|---|
| 1176 | 1159 | |
|---|
| 1177 | | -static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { |
|---|
| 1160 | +static const struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { |
|---|
| 1178 | 1161 | .read = snd_mixart_BA1_read, |
|---|
| 1179 | 1162 | }; |
|---|
| 1180 | 1163 | |
|---|
| .. | .. |
|---|
| 1220 | 1203 | struct snd_info_entry *entry; |
|---|
| 1221 | 1204 | |
|---|
| 1222 | 1205 | /* text interface to read perf and temp meters */ |
|---|
| 1223 | | - if (! snd_card_proc_new(chip->card, "board_info", &entry)) { |
|---|
| 1224 | | - entry->private_data = chip; |
|---|
| 1225 | | - entry->c.text.read = snd_mixart_proc_read; |
|---|
| 1226 | | - } |
|---|
| 1206 | + snd_card_ro_proc_new(chip->card, "board_info", chip, |
|---|
| 1207 | + snd_mixart_proc_read); |
|---|
| 1227 | 1208 | |
|---|
| 1228 | 1209 | if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) { |
|---|
| 1229 | 1210 | entry->content = SNDRV_INFO_CONTENT_DATA; |
|---|
| .. | .. |
|---|
| 1375 | 1356 | /* create array of streaminfo */ |
|---|
| 1376 | 1357 | size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * |
|---|
| 1377 | 1358 | sizeof(struct mixart_flowinfo)) ); |
|---|
| 1378 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
|---|
| 1359 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, |
|---|
| 1379 | 1360 | size, &mgr->flowinfo) < 0) { |
|---|
| 1380 | 1361 | snd_mixart_free(mgr); |
|---|
| 1381 | 1362 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 1386 | 1367 | /* create array of bufferinfo */ |
|---|
| 1387 | 1368 | size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * |
|---|
| 1388 | 1369 | sizeof(struct mixart_bufferinfo)) ); |
|---|
| 1389 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
|---|
| 1370 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, |
|---|
| 1390 | 1371 | size, &mgr->bufferinfo) < 0) { |
|---|
| 1391 | 1372 | snd_mixart_free(mgr); |
|---|
| 1392 | 1373 | return -ENOMEM; |
|---|