forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/pci/ice1712/ice1724.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA driver for VT1724 ICEnsemble ICE1724 / VIA VT1724 (Envy24HT)
34 * VIA VT1720 (Envy24PT)
....@@ -5,21 +6,6 @@
56 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
67 * 2002 James Stafford <jstafford@ampltd.com>
78 * 2003 Takashi Iwai <tiwai@suse.de>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
- *
239 */
2410
2511 #include <linux/delay.h>
....@@ -721,7 +707,7 @@
721707 struct snd_pcm_hw_params *hw_params)
722708 {
723709 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
724
- int i, chs, err;
710
+ int i, chs;
725711
726712 chs = params_channels(hw_params);
727713 mutex_lock(&ice->open_mutex);
....@@ -757,11 +743,7 @@
757743 }
758744 mutex_unlock(&ice->open_mutex);
759745
760
- err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0);
761
- if (err < 0)
762
- return err;
763
-
764
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
746
+ return snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0);
765747 }
766748
767749 static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream)
....@@ -775,7 +757,7 @@
775757 if (ice->pcm_reserved[i] == substream)
776758 ice->pcm_reserved[i] = NULL;
777759 mutex_unlock(&ice->open_mutex);
778
- return snd_pcm_lib_free_pages(substream);
760
+ return 0;
779761 }
780762
781763 static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
....@@ -1117,7 +1099,6 @@
11171099 static const struct snd_pcm_ops snd_vt1724_playback_pro_ops = {
11181100 .open = snd_vt1724_playback_pro_open,
11191101 .close = snd_vt1724_playback_pro_close,
1120
- .ioctl = snd_pcm_lib_ioctl,
11211102 .hw_params = snd_vt1724_pcm_hw_params,
11221103 .hw_free = snd_vt1724_pcm_hw_free,
11231104 .prepare = snd_vt1724_playback_pro_prepare,
....@@ -1128,7 +1109,6 @@
11281109 static const struct snd_pcm_ops snd_vt1724_capture_pro_ops = {
11291110 .open = snd_vt1724_capture_pro_open,
11301111 .close = snd_vt1724_capture_pro_close,
1131
- .ioctl = snd_pcm_lib_ioctl,
11321112 .hw_params = snd_vt1724_pcm_hw_params,
11331113 .hw_free = snd_vt1724_pcm_hw_free,
11341114 .prepare = snd_vt1724_pcm_prepare,
....@@ -1159,9 +1139,8 @@
11591139 pcm->info_flags = 0;
11601140 strcpy(pcm->name, "ICE1724");
11611141
1162
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1163
- snd_dma_pci_data(ice->pci),
1164
- 256*1024, 256*1024);
1142
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1143
+ &ice->pci->dev, 256*1024, 256*1024);
11651144
11661145 ice->pcm_pro = pcm;
11671146
....@@ -1296,7 +1275,6 @@
12961275 static const struct snd_pcm_ops snd_vt1724_playback_spdif_ops = {
12971276 .open = snd_vt1724_playback_spdif_open,
12981277 .close = snd_vt1724_playback_spdif_close,
1299
- .ioctl = snd_pcm_lib_ioctl,
13001278 .hw_params = snd_vt1724_pcm_hw_params,
13011279 .hw_free = snd_vt1724_pcm_hw_free,
13021280 .prepare = snd_vt1724_playback_spdif_prepare,
....@@ -1307,7 +1285,6 @@
13071285 static const struct snd_pcm_ops snd_vt1724_capture_spdif_ops = {
13081286 .open = snd_vt1724_capture_spdif_open,
13091287 .close = snd_vt1724_capture_spdif_close,
1310
- .ioctl = snd_pcm_lib_ioctl,
13111288 .hw_params = snd_vt1724_pcm_hw_params,
13121289 .hw_free = snd_vt1724_pcm_hw_free,
13131290 .prepare = snd_vt1724_pcm_prepare,
....@@ -1357,9 +1334,8 @@
13571334 pcm->info_flags = 0;
13581335 strcpy(pcm->name, name);
13591336
1360
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1361
- snd_dma_pci_data(ice->pci),
1362
- 256*1024, 256*1024);
1337
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1338
+ &ice->pci->dev, 256*1024, 256*1024);
13631339
13641340 ice->pcm = pcm;
13651341
....@@ -1441,7 +1417,6 @@
14411417 static const struct snd_pcm_ops snd_vt1724_playback_indep_ops = {
14421418 .open = snd_vt1724_playback_indep_open,
14431419 .close = snd_vt1724_playback_indep_close,
1444
- .ioctl = snd_pcm_lib_ioctl,
14451420 .hw_params = snd_vt1724_pcm_hw_params,
14461421 .hw_free = snd_vt1724_pcm_hw_free,
14471422 .prepare = snd_vt1724_playback_indep_prepare,
....@@ -1471,9 +1446,8 @@
14711446 pcm->info_flags = 0;
14721447 strcpy(pcm->name, "ICE1724 Surround PCM");
14731448
1474
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1475
- snd_dma_pci_data(ice->pci),
1476
- 256*1024, 256*1024);
1449
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1450
+ &ice->pci->dev, 256*1024, 256*1024);
14771451
14781452 ice->pcm_ds = pcm;
14791453
....@@ -1492,7 +1466,7 @@
14921466 if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) {
14931467 struct snd_ac97_bus *pbus;
14941468 struct snd_ac97_template ac97;
1495
- static struct snd_ac97_bus_ops ops = {
1469
+ static const struct snd_ac97_bus_ops ops = {
14961470 .write = snd_vt1724_ac97_write,
14971471 .read = snd_vt1724_ac97_read,
14981472 };
....@@ -1574,10 +1548,7 @@
15741548
15751549 static void snd_vt1724_proc_init(struct snd_ice1712 *ice)
15761550 {
1577
- struct snd_info_entry *entry;
1578
-
1579
- if (!snd_card_proc_new(ice->card, "ice1724", &entry))
1580
- snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
1551
+ snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read);
15811552 }
15821553
15831554 /*
....@@ -2202,13 +2173,13 @@
22022173 *
22032174 */
22042175
2205
-static struct snd_ice1712_card_info no_matched;
2176
+static const struct snd_ice1712_card_info no_matched;
22062177
22072178
22082179 /*
22092180 ooAoo cards with no controls
22102181 */
2211
-static unsigned char ooaoo_sq210_eeprom[] = {
2182
+static const unsigned char ooaoo_sq210_eeprom[] = {
22122183 [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC,
22132184 1xDACs */
22142185 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
....@@ -2228,7 +2199,7 @@
22282199 };
22292200
22302201
2231
-static struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = {
2202
+static const struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = {
22322203 {
22332204 .name = "ooAoo SQ210a",
22342205 .model = "sq210a",
....@@ -2238,7 +2209,7 @@
22382209 { } /* terminator */
22392210 };
22402211
2241
-static struct snd_ice1712_card_info *card_tables[] = {
2212
+static const struct snd_ice1712_card_info *card_tables[] = {
22422213 snd_vt1724_revo_cards,
22432214 snd_vt1724_amp_cards,
22442215 snd_vt1724_aureon_cards,
....@@ -2308,7 +2279,7 @@
23082279 {
23092280 const int dev = 0xa0; /* EEPROM device address */
23102281 unsigned int i, size;
2311
- struct snd_ice1712_card_info * const *tbl, *c;
2282
+ const struct snd_ice1712_card_info * const *tbl, *c;
23122283
23132284 if (!modelname || !*modelname) {
23142285 ice->eeprom.subvendor = 0;
....@@ -2534,7 +2505,7 @@
25342505 {
25352506 struct snd_ice1712 *ice;
25362507 int err;
2537
- static struct snd_device_ops ops = {
2508
+ static const struct snd_device_ops ops = {
25382509 .dev_free = snd_vt1724_dev_free,
25392510 };
25402511
....@@ -2566,7 +2537,6 @@
25662537 ice->irq = -1;
25672538 pci_set_master(pci);
25682539 snd_vt1724_proc_init(ice);
2569
- synchronize_irq(pci->irq);
25702540
25712541 card->private_data = ice;
25722542
....@@ -2587,6 +2557,7 @@
25872557 }
25882558
25892559 ice->irq = pci->irq;
2560
+ card->sync_irq = ice->irq;
25902561
25912562 snd_vt1724_chip_reset(ice);
25922563 if (snd_vt1724_read_eeprom(ice, modelname) < 0) {
....@@ -2622,7 +2593,7 @@
26222593 struct snd_card *card;
26232594 struct snd_ice1712 *ice;
26242595 int pcm_dev = 0, err;
2625
- struct snd_ice1712_card_info * const *tbl, *c;
2596
+ const struct snd_ice1712_card_info * const *tbl, *c;
26262597
26272598 if (dev >= SNDRV_CARDS)
26282599 return -ENODEV;
....@@ -2807,9 +2778,6 @@
28072778
28082779 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
28092780
2810
- snd_pcm_suspend_all(ice->pcm);
2811
- snd_pcm_suspend_all(ice->pcm_pro);
2812
- snd_pcm_suspend_all(ice->pcm_ds);
28132781 snd_ac97_suspend(ice->ac97);
28142782
28152783 spin_lock_irq(&ice->reg_lock);