forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/es1938.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for ESS Solo-1 (ES1938, ES1946, ES1969) soundcard
34 * Copyright (c) by Jaromir Koutek <miri@punknet.cz>,
....@@ -10,22 +11,6 @@
1011 *
1112 * TODO:
1213 * Rewrite better spinlocks
13
- *
14
- *
15
- * This program is free software; you can redistribute it and/or modify
16
- * it under the terms of the GNU General Public License as published by
17
- * the Free Software Foundation; either version 2 of the License, or
18
- * (at your option) any later version.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License
26
- * along with this program; if not, write to the Free Software
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
- *
2914 */
3015
3116 /*
....@@ -878,25 +863,6 @@
878863 return 0;
879864 }
880865
881
-/*
882
- * buffer management
883
- */
884
-static int snd_es1938_pcm_hw_params(struct snd_pcm_substream *substream,
885
- struct snd_pcm_hw_params *hw_params)
886
-
887
-{
888
- int err;
889
-
890
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
891
- return err;
892
- return 0;
893
-}
894
-
895
-static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream)
896
-{
897
- return snd_pcm_lib_free_pages(substream);
898
-}
899
-
900866 /* ----------------------------------------------------------------------
901867 * Audio1 Capture (ADC)
902868 * ----------------------------------------------------------------------*/
....@@ -1011,9 +977,6 @@
1011977 static const struct snd_pcm_ops snd_es1938_playback_ops = {
1012978 .open = snd_es1938_playback_open,
1013979 .close = snd_es1938_playback_close,
1014
- .ioctl = snd_pcm_lib_ioctl,
1015
- .hw_params = snd_es1938_pcm_hw_params,
1016
- .hw_free = snd_es1938_pcm_hw_free,
1017980 .prepare = snd_es1938_playback_prepare,
1018981 .trigger = snd_es1938_playback_trigger,
1019982 .pointer = snd_es1938_playback_pointer,
....@@ -1022,9 +985,6 @@
1022985 static const struct snd_pcm_ops snd_es1938_capture_ops = {
1023986 .open = snd_es1938_capture_open,
1024987 .close = snd_es1938_capture_close,
1025
- .ioctl = snd_pcm_lib_ioctl,
1026
- .hw_params = snd_es1938_pcm_hw_params,
1027
- .hw_free = snd_es1938_pcm_hw_free,
1028988 .prepare = snd_es1938_capture_prepare,
1029989 .trigger = snd_es1938_capture_trigger,
1030990 .pointer = snd_es1938_capture_pointer,
....@@ -1046,8 +1006,8 @@
10461006 pcm->info_flags = 0;
10471007 strcpy(pcm->name, "ESS Solo-1");
10481008
1049
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1050
- snd_dma_pci_data(chip->pci), 64*1024, 64*1024);
1009
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1010
+ &chip->pci->dev, 64*1024, 64*1024);
10511011
10521012 chip->pcm = pcm;
10531013 return 0;
....@@ -1347,7 +1307,7 @@
13471307
13481308 static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0);
13491309
1350
-static struct snd_kcontrol_new snd_es1938_controls[] = {
1310
+static const struct snd_kcontrol_new snd_es1938_controls[] = {
13511311 ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0,
13521312 db_scale_master),
13531313 ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1),
....@@ -1460,7 +1420,7 @@
14601420 * PM support
14611421 */
14621422
1463
-static unsigned char saved_regs[SAVED_REG_SIZE+1] = {
1423
+static const unsigned char saved_regs[SAVED_REG_SIZE+1] = {
14641424 0x14, 0x1a, 0x1c, 0x3a, 0x3c, 0x3e, 0x36, 0x38,
14651425 0x50, 0x52, 0x60, 0x61, 0x62, 0x63, 0x64, 0x68,
14661426 0x69, 0x6a, 0x6b, 0x6d, 0x6e, 0x6f, 0x7c, 0x7d,
....@@ -1472,10 +1432,10 @@
14721432 {
14731433 struct snd_card *card = dev_get_drvdata(dev);
14741434 struct es1938 *chip = card->private_data;
1475
- unsigned char *s, *d;
1435
+ const unsigned char *s;
1436
+ unsigned char *d;
14761437
14771438 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1478
- snd_pcm_suspend_all(chip->pcm);
14791439
14801440 /* save mixer-related registers */
14811441 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++)
....@@ -1485,6 +1445,7 @@
14851445 if (chip->irq >= 0) {
14861446 free_irq(chip->irq, chip);
14871447 chip->irq = -1;
1448
+ card->sync_irq = -1;
14881449 }
14891450 return 0;
14901451 }
....@@ -1494,7 +1455,8 @@
14941455 struct pci_dev *pci = to_pci_dev(dev);
14951456 struct snd_card *card = dev_get_drvdata(dev);
14961457 struct es1938 *chip = card->private_data;
1497
- unsigned char *s, *d;
1458
+ const unsigned char *s;
1459
+ unsigned char *d;
14981460
14991461 if (request_irq(pci->irq, snd_es1938_interrupt,
15001462 IRQF_SHARED, KBUILD_MODNAME, chip)) {
....@@ -1504,6 +1466,7 @@
15041466 return -EIO;
15051467 }
15061468 chip->irq = pci->irq;
1469
+ card->sync_irq = chip->irq;
15071470 snd_es1938_chip_init(chip);
15081471
15091472 /* restore mixer-related registers */
....@@ -1587,7 +1550,7 @@
15871550 {
15881551 struct es1938 *chip;
15891552 int err;
1590
- static struct snd_device_ops ops = {
1553
+ static const struct snd_device_ops ops = {
15911554 .dev_free = snd_es1938_dev_free,
15921555 };
15931556
....@@ -1632,6 +1595,7 @@
16321595 return -EBUSY;
16331596 }
16341597 chip->irq = pci->irq;
1598
+ card->sync_irq = chip->irq;
16351599 dev_dbg(card->dev,
16361600 "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
16371601 chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port);
....@@ -1655,7 +1619,8 @@
16551619 static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
16561620 {
16571621 struct es1938 *chip = dev_id;
1658
- unsigned char status, audiostatus;
1622
+ unsigned char status;
1623
+ __always_unused unsigned char audiostatus;
16591624 int handled = 0;
16601625
16611626 status = inb(SLIO_REG(chip, IRQCONTROL));