forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/cs46xx/cs46xx_lib.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
34 * Abramo Bagnara <abramo@alsa-project.org>
....@@ -28,21 +29,6 @@
2829 * references to be able to implement all fancy feutures
2930 * supported by the cs46xx DSP's.
3031 * Benny <benny@hostmobility.com>
31
- *
32
- * This program is free software; you can redistribute it and/or modify
33
- * it under the terms of the GNU General Public License as published by
34
- * the Free Software Foundation; either version 2 of the License, or
35
- * (at your option) any later version.
36
- *
37
- * This program is distributed in the hope that it will be useful,
38
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
- * GNU General Public License for more details.
41
- *
42
- * You should have received a copy of the GNU General Public License
43
- * along with this program; if not, write to the Free Software
44
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45
- *
4632 */
4733
4834 #include <linux/delay.h>
....@@ -1443,7 +1429,8 @@
14431429 .info = (SNDRV_PCM_INFO_MMAP |
14441430 SNDRV_PCM_INFO_INTERLEAVED |
14451431 SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/
1446
- /*SNDRV_PCM_INFO_RESUME*/),
1432
+ /*SNDRV_PCM_INFO_RESUME*/ |
1433
+ SNDRV_PCM_INFO_SYNC_APPLPTR),
14471434 .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
14481435 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
14491436 SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE),
....@@ -1465,7 +1452,8 @@
14651452 .info = (SNDRV_PCM_INFO_MMAP |
14661453 SNDRV_PCM_INFO_INTERLEAVED |
14671454 SNDRV_PCM_INFO_BLOCK_TRANSFER /*|*/
1468
- /*SNDRV_PCM_INFO_RESUME*/),
1455
+ /*SNDRV_PCM_INFO_RESUME*/ |
1456
+ SNDRV_PCM_INFO_SYNC_APPLPTR),
14691457 .formats = SNDRV_PCM_FMTBIT_S16_LE,
14701458 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
14711459 .rate_min = 5500,
....@@ -1506,7 +1494,7 @@
15061494 cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL);
15071495 if (cpcm == NULL)
15081496 return -ENOMEM;
1509
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1497
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
15101498 PAGE_SIZE, &cpcm->hw_buf) < 0) {
15111499 kfree(cpcm);
15121500 return -ENOMEM;
....@@ -1594,7 +1582,7 @@
15941582 {
15951583 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
15961584
1597
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1585
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
15981586 PAGE_SIZE, &chip->capt.hw_buf) < 0)
15991587 return -ENOMEM;
16001588 chip->capt.substream = substream;
....@@ -1657,7 +1645,6 @@
16571645 static const struct snd_pcm_ops snd_cs46xx_playback_rear_ops = {
16581646 .open = snd_cs46xx_playback_open_rear,
16591647 .close = snd_cs46xx_playback_close,
1660
- .ioctl = snd_pcm_lib_ioctl,
16611648 .hw_params = snd_cs46xx_playback_hw_params,
16621649 .hw_free = snd_cs46xx_playback_hw_free,
16631650 .prepare = snd_cs46xx_playback_prepare,
....@@ -1668,7 +1655,6 @@
16681655 static const struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = {
16691656 .open = snd_cs46xx_playback_open_rear,
16701657 .close = snd_cs46xx_playback_close,
1671
- .ioctl = snd_pcm_lib_ioctl,
16721658 .hw_params = snd_cs46xx_playback_hw_params,
16731659 .hw_free = snd_cs46xx_playback_hw_free,
16741660 .prepare = snd_cs46xx_playback_prepare,
....@@ -1680,7 +1666,6 @@
16801666 static const struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = {
16811667 .open = snd_cs46xx_playback_open_clfe,
16821668 .close = snd_cs46xx_playback_close,
1683
- .ioctl = snd_pcm_lib_ioctl,
16841669 .hw_params = snd_cs46xx_playback_hw_params,
16851670 .hw_free = snd_cs46xx_playback_hw_free,
16861671 .prepare = snd_cs46xx_playback_prepare,
....@@ -1691,7 +1676,6 @@
16911676 static const struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = {
16921677 .open = snd_cs46xx_playback_open_clfe,
16931678 .close = snd_cs46xx_playback_close,
1694
- .ioctl = snd_pcm_lib_ioctl,
16951679 .hw_params = snd_cs46xx_playback_hw_params,
16961680 .hw_free = snd_cs46xx_playback_hw_free,
16971681 .prepare = snd_cs46xx_playback_prepare,
....@@ -1703,7 +1687,6 @@
17031687 static const struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = {
17041688 .open = snd_cs46xx_playback_open_iec958,
17051689 .close = snd_cs46xx_playback_close_iec958,
1706
- .ioctl = snd_pcm_lib_ioctl,
17071690 .hw_params = snd_cs46xx_playback_hw_params,
17081691 .hw_free = snd_cs46xx_playback_hw_free,
17091692 .prepare = snd_cs46xx_playback_prepare,
....@@ -1714,7 +1697,6 @@
17141697 static const struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = {
17151698 .open = snd_cs46xx_playback_open_iec958,
17161699 .close = snd_cs46xx_playback_close_iec958,
1717
- .ioctl = snd_pcm_lib_ioctl,
17181700 .hw_params = snd_cs46xx_playback_hw_params,
17191701 .hw_free = snd_cs46xx_playback_hw_free,
17201702 .prepare = snd_cs46xx_playback_prepare,
....@@ -1728,7 +1710,6 @@
17281710 static const struct snd_pcm_ops snd_cs46xx_playback_ops = {
17291711 .open = snd_cs46xx_playback_open,
17301712 .close = snd_cs46xx_playback_close,
1731
- .ioctl = snd_pcm_lib_ioctl,
17321713 .hw_params = snd_cs46xx_playback_hw_params,
17331714 .hw_free = snd_cs46xx_playback_hw_free,
17341715 .prepare = snd_cs46xx_playback_prepare,
....@@ -1739,7 +1720,6 @@
17391720 static const struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = {
17401721 .open = snd_cs46xx_playback_open,
17411722 .close = snd_cs46xx_playback_close,
1742
- .ioctl = snd_pcm_lib_ioctl,
17431723 .hw_params = snd_cs46xx_playback_hw_params,
17441724 .hw_free = snd_cs46xx_playback_hw_free,
17451725 .prepare = snd_cs46xx_playback_prepare,
....@@ -1751,7 +1731,6 @@
17511731 static const struct snd_pcm_ops snd_cs46xx_capture_ops = {
17521732 .open = snd_cs46xx_capture_open,
17531733 .close = snd_cs46xx_capture_close,
1754
- .ioctl = snd_pcm_lib_ioctl,
17551734 .hw_params = snd_cs46xx_capture_hw_params,
17561735 .hw_free = snd_cs46xx_capture_hw_free,
17571736 .prepare = snd_cs46xx_capture_prepare,
....@@ -1762,7 +1741,6 @@
17621741 static const struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = {
17631742 .open = snd_cs46xx_capture_open,
17641743 .close = snd_cs46xx_capture_close,
1765
- .ioctl = snd_pcm_lib_ioctl,
17661744 .hw_params = snd_cs46xx_capture_hw_params,
17671745 .hw_free = snd_cs46xx_capture_hw_free,
17681746 .prepare = snd_cs46xx_capture_prepare,
....@@ -1796,7 +1774,8 @@
17961774 chip->pcm = pcm;
17971775
17981776 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1799
- snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
1777
+ &chip->pci->dev,
1778
+ 64*1024, 256*1024);
18001779
18011780 return 0;
18021781 }
....@@ -1821,7 +1800,8 @@
18211800 chip->pcm_rear = pcm;
18221801
18231802 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1824
- snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
1803
+ &chip->pci->dev,
1804
+ 64*1024, 256*1024);
18251805
18261806 return 0;
18271807 }
....@@ -1844,7 +1824,8 @@
18441824 chip->pcm_center_lfe = pcm;
18451825
18461826 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1847
- snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
1827
+ &chip->pci->dev,
1828
+ 64*1024, 256*1024);
18481829
18491830 return 0;
18501831 }
....@@ -1867,7 +1848,8 @@
18671848 chip->pcm_iec958 = pcm;
18681849
18691850 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1870
- snd_dma_pci_data(chip->pci), 64*1024, 256*1024);
1851
+ &chip->pci->dev,
1852
+ 64*1024, 256*1024);
18711853
18721854 return 0;
18731855 }
....@@ -2256,7 +2238,7 @@
22562238 #endif /* CONFIG_SND_CS46XX_NEW_DSP */
22572239
22582240
2259
-static struct snd_kcontrol_new snd_cs46xx_controls[] = {
2241
+static const struct snd_kcontrol_new snd_cs46xx_controls[] = {
22602242 {
22612243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
22622244 .name = "DAC Volume",
....@@ -2382,7 +2364,7 @@
23822364
23832365 #ifdef CONFIG_SND_CS46XX_NEW_DSP
23842366 /* Only available on the Hercules Game Theater XP soundcard */
2385
-static struct snd_kcontrol_new snd_hercules_controls[] = {
2367
+static const struct snd_kcontrol_new snd_hercules_controls[] = {
23862368 {
23872369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
23882370 .name = "Optical/Coaxial SPDIF Input Switch",
....@@ -2483,7 +2465,7 @@
24832465 struct snd_ctl_elem_id id;
24842466 int err;
24852467 unsigned int idx;
2486
- static struct snd_ac97_bus_ops ops = {
2468
+ static const struct snd_ac97_bus_ops ops = {
24872469 #ifdef CONFIG_SND_CS46XX_NEW_DSP
24882470 .reset = snd_cs46xx_codec_reset,
24892471 #endif
....@@ -2833,7 +2815,7 @@
28332815 return count;
28342816 }
28352817
2836
-static struct snd_info_entry_ops snd_cs46xx_proc_io_ops = {
2818
+static const struct snd_info_entry_ops snd_cs46xx_proc_io_ops = {
28372819 .read = snd_cs46xx_io_read,
28382820 };
28392821
....@@ -3763,7 +3745,7 @@
37633745 * APM support
37643746 */
37653747 #ifdef CONFIG_PM_SLEEP
3766
-static unsigned int saved_regs[] = {
3748
+static const unsigned int saved_regs[] = {
37673749 BA0_ACOSV,
37683750 /*BA0_ASER_FADDR,*/
37693751 BA0_ASER_MASTER,
....@@ -3779,12 +3761,6 @@
37793761
37803762 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
37813763 chip->in_suspend = 1;
3782
- snd_pcm_suspend_all(chip->pcm);
3783
-#ifdef CONFIG_SND_CS46XX_NEW_DSP
3784
- snd_pcm_suspend_all(chip->pcm_rear);
3785
- snd_pcm_suspend_all(chip->pcm_center_lfe);
3786
- snd_pcm_suspend_all(chip->pcm_iec958);
3787
-#endif
37883764 // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL);
37893765 // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE);
37903766
....@@ -3888,7 +3864,7 @@
38883864 struct snd_cs46xx_region *region;
38893865 struct cs_card_type *cp;
38903866 u16 ss_card, ss_vendor;
3891
- static struct snd_device_ops ops = {
3867
+ static const struct snd_device_ops ops = {
38923868 .dev_free = snd_cs46xx_dev_free,
38933869 };
38943870
....@@ -3997,7 +3973,7 @@
39973973 snd_cs46xx_free(chip);
39983974 return -EBUSY;
39993975 }
4000
- region->remap_addr = ioremap_nocache(region->base, region->size);
3976
+ region->remap_addr = ioremap(region->base, region->size);
40013977 if (region->remap_addr == NULL) {
40023978 dev_err(chip->card->dev,
40033979 "%s ioremap problem\n", region->name);
....@@ -4013,6 +3989,7 @@
40133989 return -EBUSY;
40143990 }
40153991 chip->irq = pci->irq;
3992
+ card->sync_irq = chip->irq;
40163993
40173994 #ifdef CONFIG_SND_CS46XX_NEW_DSP
40183995 chip->dsp_spos_instance = cs46xx_dsp_spos_create(chip);