forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/via82xx_modem.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA modem driver for VIA VT82xx (South Bridge)
34 *
....@@ -6,21 +7,6 @@
67 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
78 * Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com>
89 * 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
- *
2410 */
2511
2612 /*
....@@ -281,12 +267,13 @@
281267 {
282268 unsigned int i, idx, ofs, rest;
283269 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
270
+ __le32 *pgtbl;
284271
285272 if (dev->table.area == NULL) {
286273 /* the start of each lists must be aligned to 8 bytes,
287274 * but the kernel pages are much bigger, so we don't care
288275 */
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,
290277 PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8),
291278 &dev->table) < 0)
292279 return -ENOMEM;
....@@ -302,6 +289,7 @@
302289 /* fill the entries */
303290 idx = 0;
304291 ofs = 0;
292
+ pgtbl = (__le32 *)dev->table.area;
305293 for (i = 0; i < periods; i++) {
306294 rest = fragsize;
307295 /* fill descriptors for a period.
....@@ -318,7 +306,7 @@
318306 return -EINVAL;
319307 }
320308 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);
322310 r = PAGE_SIZE - (ofs % PAGE_SIZE);
323311 if (rest < r)
324312 r = rest;
....@@ -335,7 +323,7 @@
335323 "tbl %d: at %d size %d (rest %d)\n",
336324 idx, ofs, r, rest);
337325 */
338
- ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
326
+ pgtbl[(idx<<1) + 1] = cpu_to_le32(r | flag);
339327 dev->idx_table[idx].offset = ofs;
340328 dev->idx_table[idx].size = r;
341329 ofs += r;
....@@ -410,7 +398,7 @@
410398 static void snd_via82xx_codec_wait(struct snd_ac97 *ac97)
411399 {
412400 struct via82xx_modem *chip = ac97->private_data;
413
- int err;
401
+ __always_unused int err;
414402 err = snd_via82xx_codec_ready(chip, ac97->num);
415403 /* here we need to wait fairly for long time.. */
416404 msleep(500);
....@@ -656,9 +644,6 @@
656644 struct viadev *viadev = substream->runtime->private_data;
657645 int err;
658646
659
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
660
- if (err < 0)
661
- return err;
662647 err = build_via_table(viadev, substream, chip->pci,
663648 params_periods(hw_params),
664649 params_period_bytes(hw_params));
....@@ -681,7 +666,6 @@
681666 struct viadev *viadev = substream->runtime->private_data;
682667
683668 clean_via_table(viadev, substream, chip->pci);
684
- snd_pcm_lib_free_pages(substream);
685669 return 0;
686670 }
687671
....@@ -809,26 +793,22 @@
809793 static const struct snd_pcm_ops snd_via686_playback_ops = {
810794 .open = snd_via82xx_playback_open,
811795 .close = snd_via82xx_pcm_close,
812
- .ioctl = snd_pcm_lib_ioctl,
813796 .hw_params = snd_via82xx_hw_params,
814797 .hw_free = snd_via82xx_hw_free,
815798 .prepare = snd_via82xx_pcm_prepare,
816799 .trigger = snd_via82xx_pcm_trigger,
817800 .pointer = snd_via686_pcm_pointer,
818
- .page = snd_pcm_sgbuf_ops_page,
819801 };
820802
821803 /* via686 capture callbacks */
822804 static const struct snd_pcm_ops snd_via686_capture_ops = {
823805 .open = snd_via82xx_capture_open,
824806 .close = snd_via82xx_pcm_close,
825
- .ioctl = snd_pcm_lib_ioctl,
826807 .hw_params = snd_via82xx_hw_params,
827808 .hw_free = snd_via82xx_hw_free,
828809 .prepare = snd_via82xx_pcm_prepare,
829810 .trigger = snd_via82xx_pcm_trigger,
830811 .pointer = snd_via686_pcm_pointer,
831
- .page = snd_pcm_sgbuf_ops_page,
832812 };
833813
834814
....@@ -865,11 +845,8 @@
865845 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
866846 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
867847
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);
873850 return 0;
874851 }
875852
....@@ -896,7 +873,7 @@
896873 {
897874 struct snd_ac97_template ac97;
898875 int err;
899
- static struct snd_ac97_bus_ops ops = {
876
+ static const struct snd_ac97_bus_ops ops = {
900877 .write = snd_via82xx_codec_write,
901878 .read = snd_via82xx_codec_read,
902879 .wait = snd_via82xx_codec_wait,
....@@ -937,10 +914,8 @@
937914
938915 static void snd_via82xx_proc_init(struct via82xx_modem *chip)
939916 {
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);
944919 }
945920
946921 /*
....@@ -1038,11 +1013,8 @@
10381013 int i;
10391014
10401015 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1041
- for (i = 0; i < 2; i++)
1042
- snd_pcm_suspend_all(chip->pcms[i]);
10431016 for (i = 0; i < chip->num_devs; i++)
10441017 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1045
- synchronize_irq(chip->irq);
10461018 snd_ac97_suspend(chip->ac97);
10471019 return 0;
10481020 }
....@@ -1104,7 +1076,7 @@
11041076 {
11051077 struct via82xx_modem *chip;
11061078 int err;
1107
- static struct snd_device_ops ops = {
1079
+ static const struct snd_device_ops ops = {
11081080 .dev_free = snd_via82xx_dev_free,
11091081 };
11101082
....@@ -1134,9 +1106,9 @@
11341106 return -EBUSY;
11351107 }
11361108 chip->irq = pci->irq;
1109
+ card->sync_irq = chip->irq;
11371110 if (ac97_clock >= 8000 && ac97_clock <= 48000)
11381111 chip->ac97_clock = ac97_clock;
1139
- synchronize_irq(chip->irq);
11401112
11411113 if ((err = snd_via82xx_chip_init(chip)) < 0) {
11421114 snd_via82xx_free(chip);