forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/cs4281.c
....@@ -1,22 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Cirrus Logic CS4281 based PCI soundcard
34 * 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
- *
205 */
216
227 #include <linux/io.h>
....@@ -709,7 +694,7 @@
709694
710695 static unsigned int snd_cs4281_rate(unsigned int rate, unsigned int *real_rate)
711696 {
712
- unsigned int val = ~0;
697
+ unsigned int val;
713698
714699 if (real_rate)
715700 *real_rate = rate;
....@@ -722,9 +707,8 @@
722707 case 44100: return 1;
723708 case 48000: return 0;
724709 default:
725
- goto __variable;
710
+ break;
726711 }
727
- __variable:
728712 val = 1536000 / rate;
729713 if (real_rate)
730714 *real_rate = 1536000 / val;
....@@ -794,17 +778,6 @@
794778 snd_cs4281_pokeBA0(chip, dma->regFCR, dma->valFCR | BA0_FCR_FEN);
795779 /* Clear FIFO Status and Interrupt Control Register */
796780 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);
808781 }
809782
810783 static int snd_cs4281_playback_prepare(struct snd_pcm_substream *substream)
....@@ -954,9 +927,6 @@
954927 static const struct snd_pcm_ops snd_cs4281_playback_ops = {
955928 .open = snd_cs4281_playback_open,
956929 .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,
960930 .prepare = snd_cs4281_playback_prepare,
961931 .trigger = snd_cs4281_trigger,
962932 .pointer = snd_cs4281_pointer,
....@@ -965,9 +935,6 @@
965935 static const struct snd_pcm_ops snd_cs4281_capture_ops = {
966936 .open = snd_cs4281_capture_open,
967937 .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,
971938 .prepare = snd_cs4281_capture_prepare,
972939 .trigger = snd_cs4281_trigger,
973940 .pointer = snd_cs4281_pointer,
....@@ -990,8 +957,8 @@
990957 strcpy(pcm->name, "CS4281");
991958 chip->pcm = pcm;
992959
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);
995962
996963 return 0;
997964 }
....@@ -1097,7 +1064,7 @@
10971064 struct snd_card *card = chip->card;
10981065 struct snd_ac97_template ac97;
10991066 int err;
1100
- static struct snd_ac97_bus_ops ops = {
1067
+ static const struct snd_ac97_bus_ops ops = {
11011068 .write = snd_cs4281_ac97_write,
11021069 .read = snd_cs4281_ac97_read,
11031070 };
....@@ -1162,11 +1129,11 @@
11621129 return count;
11631130 }
11641131
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 = {
11661133 .read = snd_cs4281_BA0_read,
11671134 };
11681135
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 = {
11701137 .read = snd_cs4281_BA1_read,
11711138 };
11721139
....@@ -1174,8 +1141,7 @@
11741141 {
11751142 struct snd_info_entry *entry;
11761143
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);
11791145 if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) {
11801146 entry->content = SNDRV_INFO_CONTENT_DATA;
11811147 entry->private_data = chip;
....@@ -1302,9 +1268,6 @@
13021268 {
13031269 snd_cs4281_free_gameport(chip);
13041270
1305
- if (chip->irq >= 0)
1306
- synchronize_irq(chip->irq);
1307
-
13081271 /* Mask interrupts */
13091272 snd_cs4281_pokeBA0(chip, BA0_HIMR, 0x7fffffff);
13101273 /* Stop the DLL Clock logic. */
....@@ -1341,7 +1304,7 @@
13411304 struct cs4281 *chip;
13421305 unsigned int tmp;
13431306 int err;
1344
- static struct snd_device_ops ops = {
1307
+ static const struct snd_device_ops ops = {
13451308 .dev_free = snd_cs4281_dev_free,
13461309 };
13471310
....@@ -1386,6 +1349,7 @@
13861349 return -ENOMEM;
13871350 }
13881351 chip->irq = pci->irq;
1352
+ card->sync_irq = chip->irq;
13891353
13901354 tmp = snd_cs4281_chip_init(chip);
13911355 if (tmp) {
....@@ -1634,7 +1598,6 @@
16341598 BA0_HISR_DMA(1) |
16351599 BA0_HISR_DMA(2) |
16361600 BA0_HISR_DMA(3)));
1637
- synchronize_irq(chip->irq);
16381601
16391602 return 0;
16401603 }
....@@ -1976,7 +1939,7 @@
19761939 */
19771940 #ifdef CONFIG_PM_SLEEP
19781941
1979
-static int saved_regs[SUSPEND_REGISTERS] = {
1942
+static const int saved_regs[SUSPEND_REGISTERS] = {
19801943 BA0_JSCTL,
19811944 BA0_GPIOR,
19821945 BA0_SSCR,
....@@ -2002,8 +1965,6 @@
20021965 unsigned int i;
20031966
20041967 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005
- snd_pcm_suspend_all(chip->pcm);
2006
-
20071968 snd_ac97_suspend(chip->ac97);
20081969 snd_ac97_suspend(chip->ac97_secondary);
20091970