forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/pci/ice1712/ice1712.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA driver for ICEnsemble ICE1712 (Envy24)
34 *
45 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
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
- *
206 */
217
228 /*
....@@ -494,21 +480,6 @@
494480
495481
496482 /*
497
- * PCM part - misc
498
- */
499
-
500
-static int snd_ice1712_hw_params(struct snd_pcm_substream *substream,
501
- struct snd_pcm_hw_params *hw_params)
502
-{
503
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
504
-}
505
-
506
-static int snd_ice1712_hw_free(struct snd_pcm_substream *substream)
507
-{
508
- return snd_pcm_lib_free_pages(substream);
509
-}
510
-
511
-/*
512483 * PCM part - consumer I/O
513484 */
514485
....@@ -850,9 +821,6 @@
850821 static const struct snd_pcm_ops snd_ice1712_playback_ops = {
851822 .open = snd_ice1712_playback_open,
852823 .close = snd_ice1712_playback_close,
853
- .ioctl = snd_pcm_lib_ioctl,
854
- .hw_params = snd_ice1712_hw_params,
855
- .hw_free = snd_ice1712_hw_free,
856824 .prepare = snd_ice1712_playback_prepare,
857825 .trigger = snd_ice1712_playback_trigger,
858826 .pointer = snd_ice1712_playback_pointer,
....@@ -861,9 +829,6 @@
861829 static const struct snd_pcm_ops snd_ice1712_playback_ds_ops = {
862830 .open = snd_ice1712_playback_ds_open,
863831 .close = snd_ice1712_playback_ds_close,
864
- .ioctl = snd_pcm_lib_ioctl,
865
- .hw_params = snd_ice1712_hw_params,
866
- .hw_free = snd_ice1712_hw_free,
867832 .prepare = snd_ice1712_playback_ds_prepare,
868833 .trigger = snd_ice1712_playback_ds_trigger,
869834 .pointer = snd_ice1712_playback_ds_pointer,
....@@ -872,9 +837,6 @@
872837 static const struct snd_pcm_ops snd_ice1712_capture_ops = {
873838 .open = snd_ice1712_capture_open,
874839 .close = snd_ice1712_capture_close,
875
- .ioctl = snd_pcm_lib_ioctl,
876
- .hw_params = snd_ice1712_hw_params,
877
- .hw_free = snd_ice1712_hw_free,
878840 .prepare = snd_ice1712_capture_prepare,
879841 .trigger = snd_ice1712_capture_trigger,
880842 .pointer = snd_ice1712_capture_pointer,
....@@ -897,8 +859,8 @@
897859 strcpy(pcm->name, "ICE1712 consumer");
898860 ice->pcm = pcm;
899861
900
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
901
- snd_dma_pci_data(ice->pci), 64*1024, 64*1024);
862
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
863
+ &ice->pci->dev, 64*1024, 64*1024);
902864
903865 dev_warn(ice->card->dev,
904866 "Consumer PCM code does not work well at the moment --jk\n");
....@@ -922,8 +884,8 @@
922884 strcpy(pcm->name, "ICE1712 consumer (DS)");
923885 ice->pcm_ds = pcm;
924886
925
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
926
- snd_dma_pci_data(ice->pci), 64*1024, 128*1024);
887
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
888
+ &ice->pci->dev, 64*1024, 128*1024);
927889
928890 return 0;
929891 }
....@@ -1075,7 +1037,7 @@
10751037 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
10761038
10771039 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1078
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1040
+ return 0;
10791041 }
10801042
10811043 static int snd_ice1712_capture_pro_prepare(struct snd_pcm_substream *substream)
....@@ -1097,7 +1059,7 @@
10971059 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
10981060
10991061 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1100
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1062
+ return 0;
11011063 }
11021064
11031065 static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substream *substream)
....@@ -1231,9 +1193,7 @@
12311193 static const struct snd_pcm_ops snd_ice1712_playback_pro_ops = {
12321194 .open = snd_ice1712_playback_pro_open,
12331195 .close = snd_ice1712_playback_pro_close,
1234
- .ioctl = snd_pcm_lib_ioctl,
12351196 .hw_params = snd_ice1712_playback_pro_hw_params,
1236
- .hw_free = snd_ice1712_hw_free,
12371197 .prepare = snd_ice1712_playback_pro_prepare,
12381198 .trigger = snd_ice1712_pro_trigger,
12391199 .pointer = snd_ice1712_playback_pro_pointer,
....@@ -1242,9 +1202,7 @@
12421202 static const struct snd_pcm_ops snd_ice1712_capture_pro_ops = {
12431203 .open = snd_ice1712_capture_pro_open,
12441204 .close = snd_ice1712_capture_pro_close,
1245
- .ioctl = snd_pcm_lib_ioctl,
12461205 .hw_params = snd_ice1712_capture_pro_hw_params,
1247
- .hw_free = snd_ice1712_hw_free,
12481206 .prepare = snd_ice1712_capture_pro_prepare,
12491207 .trigger = snd_ice1712_pro_trigger,
12501208 .pointer = snd_ice1712_capture_pro_pointer,
....@@ -1266,8 +1224,8 @@
12661224 pcm->info_flags = 0;
12671225 strcpy(pcm->name, "ICE1712 multi");
12681226
1269
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1270
- snd_dma_pci_data(ice->pci), 256*1024, 256*1024);
1227
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1228
+ &ice->pci->dev, 256*1024, 256*1024);
12711229
12721230 ice->pcm_pro = pcm;
12731231
....@@ -1377,7 +1335,7 @@
13771335
13781336 static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
13791337
1380
-static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] = {
1338
+static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] = {
13811339 {
13821340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13831341 .name = "Multi Playback Switch",
....@@ -1506,11 +1464,11 @@
15061464 int err, bus_num = 0;
15071465 struct snd_ac97_template ac97;
15081466 struct snd_ac97_bus *pbus;
1509
- static struct snd_ac97_bus_ops con_ops = {
1467
+ static const struct snd_ac97_bus_ops con_ops = {
15101468 .write = snd_ice1712_ac97_write,
15111469 .read = snd_ice1712_ac97_read,
15121470 };
1513
- static struct snd_ac97_bus_ops pro_ops = {
1471
+ static const struct snd_ac97_bus_ops pro_ops = {
15141472 .write = snd_ice1712_pro_ac97_write,
15151473 .read = snd_ice1712_pro_ac97_read,
15161474 };
....@@ -1603,10 +1561,7 @@
16031561
16041562 static void snd_ice1712_proc_init(struct snd_ice1712 *ice)
16051563 {
1606
- struct snd_info_entry *entry;
1607
-
1608
- if (!snd_card_proc_new(ice->card, "ice1712", &entry))
1609
- snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
1564
+ snd_card_ro_proc_new(ice->card, "ice1712", ice, snd_ice1712_proc_read);
16101565 }
16111566
16121567 /*
....@@ -2263,7 +2218,7 @@
22632218 /*
22642219 * list of available boards
22652220 */
2266
-static struct snd_ice1712_card_info *card_tables[] = {
2221
+static const struct snd_ice1712_card_info *card_tables[] = {
22672222 snd_ice1712_hoontech_cards,
22682223 snd_ice1712_delta_cards,
22692224 snd_ice1712_ews_cards,
....@@ -2287,7 +2242,7 @@
22872242 {
22882243 int dev = ICE_I2C_EEPROM_ADDR; /* I2C EEPROM device address */
22892244 unsigned int i, size;
2290
- struct snd_ice1712_card_info * const *tbl, *c;
2245
+ const struct snd_ice1712_card_info * const *tbl, *c;
22912246
22922247 if (!modelname || !*modelname) {
22932248 ice->eeprom.subvendor = 0;
....@@ -2520,7 +2475,7 @@
25202475 {
25212476 struct snd_ice1712 *ice;
25222477 int err;
2523
- static struct snd_device_ops ops = {
2478
+ static const struct snd_device_ops ops = {
25242479 .dev_free = snd_ice1712_dev_free,
25252480 };
25262481
....@@ -2574,7 +2529,6 @@
25742529 pci_write_config_word(ice->pci, 0x40, 0x807f);
25752530 pci_write_config_word(ice->pci, 0x42, 0x0006);
25762531 snd_ice1712_proc_init(ice);
2577
- synchronize_irq(pci->irq);
25782532
25792533 card->private_data = ice;
25802534
....@@ -2597,6 +2551,7 @@
25972551 }
25982552
25992553 ice->irq = pci->irq;
2554
+ card->sync_irq = ice->irq;
26002555
26012556 if (snd_ice1712_read_eeprom(ice, modelname) < 0) {
26022557 snd_ice1712_free(ice);
....@@ -2633,7 +2588,7 @@
26332588 struct snd_card *card;
26342589 struct snd_ice1712 *ice;
26352590 int pcm_dev = 0, err;
2636
- struct snd_ice1712_card_info * const *tbl, *c;
2591
+ const struct snd_ice1712_card_info * const *tbl, *c;
26372592
26382593 if (dev >= SNDRV_CARDS)
26392594 return -ENODEV;
....@@ -2793,9 +2748,6 @@
27932748
27942749 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
27952750
2796
- snd_pcm_suspend_all(ice->pcm);
2797
- snd_pcm_suspend_all(ice->pcm_pro);
2798
- snd_pcm_suspend_all(ice->pcm_ds);
27992751 snd_ac97_suspend(ice->ac97);
28002752
28012753 spin_lock_irq(&ice->reg_lock);