forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/pci/mixart/mixart.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Digigram miXart soundcards
34 *
45 * main file with alsa callbacks
56 *
67 * 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
218 */
229
2310
....@@ -182,7 +169,7 @@
182169 case PIPE_RUNNING:
183170 if(rate != 0)
184171 break;
185
- /* fall through */
172
+ fallthrough;
186173 default:
187174 if(rate == 0)
188175 return 0; /* nothing to do */
....@@ -637,10 +624,7 @@
637624 return err;
638625 }
639626
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) {
644628 struct mixart_bufferinfo *bufferinfo;
645629 int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number;
646630 if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) {
....@@ -660,13 +644,12 @@
660644 }
661645 mutex_unlock(&mgr->setup_mutex);
662646
663
- return err;
647
+ return 0;
664648 }
665649
666650 static int snd_mixart_hw_free(struct snd_pcm_substream *subs)
667651 {
668652 struct snd_mixart *chip = snd_pcm_substream_chip(subs);
669
- snd_pcm_lib_free_pages(subs);
670653 mixart_sync_nonblock_events(chip->mgr);
671654 return 0;
672655 }
....@@ -926,7 +909,6 @@
926909 static const struct snd_pcm_ops snd_mixart_playback_ops = {
927910 .open = snd_mixart_playback_open,
928911 .close = snd_mixart_close,
929
- .ioctl = snd_pcm_lib_ioctl,
930912 .prepare = snd_mixart_prepare,
931913 .hw_params = snd_mixart_hw_params,
932914 .hw_free = snd_mixart_hw_free,
....@@ -937,7 +919,6 @@
937919 static const struct snd_pcm_ops snd_mixart_capture_ops = {
938920 .open = snd_mixart_capture_open,
939921 .close = snd_mixart_close,
940
- .ioctl = snd_pcm_lib_ioctl,
941922 .prepare = snd_mixart_prepare,
942923 .hw_params = snd_mixart_hw_params,
943924 .hw_free = snd_mixart_hw_free,
....@@ -960,8 +941,9 @@
960941 (chip->chip_idx + 1) << 24;
961942 }
962943 #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);
965947 }
966948
967949 /*
....@@ -1048,7 +1030,7 @@
10481030 {
10491031 int err;
10501032 struct snd_mixart *chip;
1051
- static struct snd_device_ops ops = {
1033
+ static const struct snd_device_ops ops = {
10521034 .dev_free = snd_mixart_chip_dev_free,
10531035 };
10541036
....@@ -1059,6 +1041,7 @@
10591041 chip->card = card;
10601042 chip->chip_idx = idx;
10611043 chip->mgr = mgr;
1044
+ card->sync_irq = mgr->irq;
10621045
10631046 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
10641047 snd_mixart_chip_free(chip);
....@@ -1170,11 +1153,11 @@
11701153 return count;
11711154 }
11721155
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 = {
11741157 .read = snd_mixart_BA0_read,
11751158 };
11761159
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 = {
11781161 .read = snd_mixart_BA1_read,
11791162 };
11801163
....@@ -1220,10 +1203,8 @@
12201203 struct snd_info_entry *entry;
12211204
12221205 /* 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);
12271208
12281209 if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) {
12291210 entry->content = SNDRV_INFO_CONTENT_DATA;
....@@ -1375,7 +1356,7 @@
13751356 /* create array of streaminfo */
13761357 size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
13771358 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,
13791360 size, &mgr->flowinfo) < 0) {
13801361 snd_mixart_free(mgr);
13811362 return -ENOMEM;
....@@ -1386,7 +1367,7 @@
13861367 /* create array of bufferinfo */
13871368 size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
13881369 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,
13901371 size, &mgr->bufferinfo) < 0) {
13911372 snd_mixart_free(mgr);
13921373 return -ENOMEM;