forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/atiixp.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA driver for ATI IXP 150/200/250/300 AC97 controllers
34 *
45 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
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 #include <linux/io.h>
....@@ -296,7 +282,7 @@
296282
297283 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids);
298284
299
-static struct snd_pci_quirk atiixp_quirks[] = {
285
+static const struct snd_pci_quirk atiixp_quirks[] = {
300286 SND_PCI_QUIRK(0x105b, 0x0c81, "Foxconn RC4107MA-RS2", 0),
301287 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0),
302288 { } /* terminator */
....@@ -367,7 +353,7 @@
367353
368354 if (dma->desc_buf.area == NULL) {
369355 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
370
- snd_dma_pci_data(chip->pci),
356
+ &chip->pci->dev,
371357 ATI_DESC_LIST_SIZE,
372358 &dma->desc_buf) < 0)
373359 return -ENOMEM;
....@@ -733,6 +719,10 @@
733719 case SNDRV_PCM_TRIGGER_START:
734720 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
735721 case SNDRV_PCM_TRIGGER_RESUME:
722
+ if (dma->running && dma->suspended &&
723
+ cmd == SNDRV_PCM_TRIGGER_RESUME)
724
+ writel(dma->saved_curptr, chip->remap_addr +
725
+ dma->ops->dt_cur);
736726 dma->ops->enable_transfer(chip, 1);
737727 dma->running = 1;
738728 dma->suspended = 0;
....@@ -740,9 +730,12 @@
740730 case SNDRV_PCM_TRIGGER_STOP:
741731 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
742732 case SNDRV_PCM_TRIGGER_SUSPEND:
733
+ dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
734
+ if (dma->running && dma->suspended)
735
+ dma->saved_curptr = readl(chip->remap_addr +
736
+ dma->ops->dt_cur);
743737 dma->ops->enable_transfer(chip, 0);
744738 dma->running = 0;
745
- dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
746739 break;
747740 default:
748741 err = -EINVAL;
....@@ -903,15 +896,15 @@
903896 case 8:
904897 data |= ATI_REG_OUT_DMA_SLOT_BIT(10) |
905898 ATI_REG_OUT_DMA_SLOT_BIT(11);
906
- /* fallthru */
899
+ fallthrough;
907900 case 6:
908901 data |= ATI_REG_OUT_DMA_SLOT_BIT(7) |
909902 ATI_REG_OUT_DMA_SLOT_BIT(8);
910
- /* fallthru */
903
+ fallthrough;
911904 case 4:
912905 data |= ATI_REG_OUT_DMA_SLOT_BIT(6) |
913906 ATI_REG_OUT_DMA_SLOT_BIT(9);
914
- /* fallthru */
907
+ fallthrough;
915908 default:
916909 data |= ATI_REG_OUT_DMA_SLOT_BIT(3) |
917910 ATI_REG_OUT_DMA_SLOT_BIT(4);
....@@ -959,9 +952,6 @@
959952 struct atiixp_dma *dma = substream->runtime->private_data;
960953 int err;
961954
962
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
963
- if (err < 0)
964
- return err;
965955 dma->buf_addr = substream->runtime->dma_addr;
966956 dma->buf_bytes = params_buffer_bytes(hw_params);
967957
....@@ -1001,7 +991,6 @@
1001991 dma->pcm_open_flag = 0;
1002992 }
1003993 atiixp_clear_dma_packets(chip, dma, substream);
1004
- snd_pcm_lib_free_pages(substream);
1005994 return 0;
1006995 }
1007996
....@@ -1151,7 +1140,6 @@
11511140 static const struct snd_pcm_ops snd_atiixp_playback_ops = {
11521141 .open = snd_atiixp_playback_open,
11531142 .close = snd_atiixp_playback_close,
1154
- .ioctl = snd_pcm_lib_ioctl,
11551143 .hw_params = snd_atiixp_pcm_hw_params,
11561144 .hw_free = snd_atiixp_pcm_hw_free,
11571145 .prepare = snd_atiixp_playback_prepare,
....@@ -1163,7 +1151,6 @@
11631151 static const struct snd_pcm_ops snd_atiixp_capture_ops = {
11641152 .open = snd_atiixp_capture_open,
11651153 .close = snd_atiixp_capture_close,
1166
- .ioctl = snd_pcm_lib_ioctl,
11671154 .hw_params = snd_atiixp_pcm_hw_params,
11681155 .hw_free = snd_atiixp_pcm_hw_free,
11691156 .prepare = snd_atiixp_capture_prepare,
....@@ -1175,7 +1162,6 @@
11751162 static const struct snd_pcm_ops snd_atiixp_spdif_ops = {
11761163 .open = snd_atiixp_spdif_open,
11771164 .close = snd_atiixp_spdif_close,
1178
- .ioctl = snd_pcm_lib_ioctl,
11791165 .hw_params = snd_atiixp_pcm_hw_params,
11801166 .hw_free = snd_atiixp_pcm_hw_free,
11811167 .prepare = snd_atiixp_spdif_prepare,
....@@ -1290,9 +1276,8 @@
12901276 strcpy(pcm->name, "ATI IXP AC97");
12911277 chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm;
12921278
1293
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1294
- snd_dma_pci_data(chip->pci),
1295
- 64*1024, 128*1024);
1279
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1280
+ &chip->pci->dev, 64*1024, 128*1024);
12961281
12971282 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
12981283 snd_pcm_alt_chmaps, chip->max_channels, 0,
....@@ -1323,9 +1308,8 @@
13231308 strcpy(pcm->name, "ATI IXP IEC958 (Direct)");
13241309 chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm;
13251310
1326
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1327
- snd_dma_pci_data(chip->pci),
1328
- 64*1024, 128*1024);
1311
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1312
+ &chip->pci->dev, 64*1024, 128*1024);
13291313
13301314 /* pre-select AC97 SPDIF slots 10/11 */
13311315 for (i = 0; i < NUM_ATI_CODECS; i++) {
....@@ -1419,11 +1403,11 @@
14191403 struct snd_ac97_template ac97;
14201404 int i, err;
14211405 int codec_count;
1422
- static struct snd_ac97_bus_ops ops = {
1406
+ static const struct snd_ac97_bus_ops ops = {
14231407 .write = snd_atiixp_ac97_write,
14241408 .read = snd_atiixp_ac97_read,
14251409 };
1426
- static unsigned int codec_skip[NUM_ATI_CODECS] = {
1410
+ static const unsigned int codec_skip[NUM_ATI_CODECS] = {
14271411 ATI_REG_ISR_CODEC0_NOT_READY,
14281412 ATI_REG_ISR_CODEC1_NOT_READY,
14291413 ATI_REG_ISR_CODEC2_NOT_READY,
....@@ -1479,14 +1463,6 @@
14791463 int i;
14801464
14811465 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1482
- for (i = 0; i < NUM_ATI_PCMDEVS; i++)
1483
- if (chip->pcmdevs[i]) {
1484
- struct atiixp_dma *dma = &chip->dmas[i];
1485
- if (dma->substream && dma->running)
1486
- dma->saved_curptr = readl(chip->remap_addr +
1487
- dma->ops->dt_cur);
1488
- snd_pcm_suspend_all(chip->pcmdevs[i]);
1489
- }
14901466 for (i = 0; i < NUM_ATI_CODECS; i++)
14911467 snd_ac97_suspend(chip->ac97[i]);
14921468 snd_atiixp_aclink_down(chip);
....@@ -1514,8 +1490,6 @@
15141490 dma->substream->ops->prepare(dma->substream);
15151491 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
15161492 chip->remap_addr + dma->ops->llp_offset);
1517
- writel(dma->saved_curptr, chip->remap_addr +
1518
- dma->ops->dt_cur);
15191493 }
15201494 }
15211495
....@@ -1546,10 +1520,7 @@
15461520
15471521 static void snd_atiixp_proc_init(struct atiixp *chip)
15481522 {
1549
- struct snd_info_entry *entry;
1550
-
1551
- if (! snd_card_proc_new(chip->card, "atiixp", &entry))
1552
- snd_info_set_text_ops(entry, chip, snd_atiixp_proc_read);
1523
+ snd_card_ro_proc_new(chip->card, "atiixp", chip, snd_atiixp_proc_read);
15531524 }
15541525
15551526
....@@ -1586,7 +1557,7 @@
15861557 struct pci_dev *pci,
15871558 struct atiixp **r_chip)
15881559 {
1589
- static struct snd_device_ops ops = {
1560
+ static const struct snd_device_ops ops = {
15901561 .dev_free = snd_atiixp_dev_free,
15911562 };
15921563 struct atiixp *chip;
....@@ -1626,8 +1597,8 @@
16261597 return -EBUSY;
16271598 }
16281599 chip->irq = pci->irq;
1600
+ card->sync_irq = chip->irq;
16291601 pci_set_master(pci);
1630
- synchronize_irq(chip->irq);
16311602
16321603 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
16331604 snd_atiixp_free(chip);