forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/isa/wss/wss_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 * Routines for control of CS4231(A)/CS4232/InterWave & compatible chips
....@@ -7,21 +8,6 @@
78 * Yamaha OPL3-SA3 chip
89 * - CS4231 (GUS MAX) - still trouble with occasional noises
910 * - broken initialization?
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
- *
2511 */
2612
2713 #include <linux/delay.h>
....@@ -52,7 +38,7 @@
5238 * Some variables
5339 */
5440
55
-static unsigned char freq_bits[14] = {
41
+static const unsigned char freq_bits[14] = {
5642 /* 5510 */ 0x00 | CS4231_XTAL2,
5743 /* 6620 */ 0x0E | CS4231_XTAL2,
5844 /* 8000 */ 0x00 | CS4231_XTAL1,
....@@ -86,7 +72,7 @@
8672 &hw_constraints_rates);
8773 }
8874
89
-static unsigned char snd_wss_original_image[32] =
75
+static const unsigned char snd_wss_original_image[32] =
9076 {
9177 0x00, /* 00/00 - lic */
9278 0x00, /* 01/01 - ric */
....@@ -122,7 +108,7 @@
122108 0x00, /* 1f/31 - cbrl */
123109 };
124110
125
-static unsigned char snd_opti93x_original_image[32] =
111
+static const unsigned char snd_opti93x_original_image[32] =
126112 {
127113 0x00, /* 00/00 - l_mixout_outctrl */
128114 0x00, /* 01/01 - r_mixout_outctrl */
....@@ -975,7 +961,7 @@
975961 return 0;
976962 }
977963
978
-static struct snd_timer_hardware snd_wss_timer_table =
964
+static const struct snd_timer_hardware snd_wss_timer_table =
979965 {
980966 .flags = SNDRV_TIMER_HW_AUTO,
981967 .resolution = 9945,
....@@ -996,20 +982,12 @@
996982 {
997983 struct snd_wss *chip = snd_pcm_substream_chip(substream);
998984 unsigned char new_pdfr;
999
- int err;
1000985
1001
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
1002
- return err;
1003986 new_pdfr = snd_wss_get_format(chip, params_format(hw_params),
1004987 params_channels(hw_params)) |
1005988 snd_wss_get_rate(params_rate(hw_params));
1006989 chip->set_playback_format(chip, hw_params, new_pdfr);
1007990 return 0;
1008
-}
1009
-
1010
-static int snd_wss_playback_hw_free(struct snd_pcm_substream *substream)
1011
-{
1012
- return snd_pcm_lib_free_pages(substream);
1013991 }
1014992
1015993 static int snd_wss_playback_prepare(struct snd_pcm_substream *substream)
....@@ -1039,20 +1017,12 @@
10391017 {
10401018 struct snd_wss *chip = snd_pcm_substream_chip(substream);
10411019 unsigned char new_cdfr;
1042
- int err;
10431020
1044
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
1045
- return err;
10461021 new_cdfr = snd_wss_get_format(chip, params_format(hw_params),
10471022 params_channels(hw_params)) |
10481023 snd_wss_get_rate(params_rate(hw_params));
10491024 chip->set_capture_format(chip, hw_params, new_cdfr);
10501025 return 0;
1051
-}
1052
-
1053
-static int snd_wss_capture_hw_free(struct snd_pcm_substream *substream)
1054
-{
1055
- return snd_pcm_lib_free_pages(substream);
10561026 }
10571027
10581028 static int snd_wss_capture_prepare(struct snd_pcm_substream *substream)
....@@ -1625,7 +1595,6 @@
16251595 int reg;
16261596 unsigned long flags;
16271597
1628
- snd_pcm_suspend_all(chip->pcm);
16291598 spin_lock_irqsave(&chip->reg_lock, flags);
16301599 for (reg = 0; reg < 32; reg++)
16311600 chip->image[reg] = snd_wss_in(chip, reg);
....@@ -1803,7 +1772,7 @@
18031772 unsigned short hwshare,
18041773 struct snd_wss **rchip)
18051774 {
1806
- static struct snd_device_ops ops = {
1775
+ static const struct snd_device_ops ops = {
18071776 .dev_free = snd_wss_dev_free,
18081777 };
18091778 struct snd_wss *chip;
....@@ -1842,6 +1811,7 @@
18421811 return -EBUSY;
18431812 }
18441813 chip->irq = irq;
1814
+ card->sync_irq = chip->irq;
18451815 if (!(hwshare & WSS_HWSHARE_DMA1) && request_dma(dma1, "WSS - 1")) {
18461816 snd_printk(KERN_ERR "wss: can't grab DMA1 %d\n", dma1);
18471817 snd_wss_free(chip);
....@@ -1902,9 +1872,7 @@
19021872 static const struct snd_pcm_ops snd_wss_playback_ops = {
19031873 .open = snd_wss_playback_open,
19041874 .close = snd_wss_playback_close,
1905
- .ioctl = snd_pcm_lib_ioctl,
19061875 .hw_params = snd_wss_playback_hw_params,
1907
- .hw_free = snd_wss_playback_hw_free,
19081876 .prepare = snd_wss_playback_prepare,
19091877 .trigger = snd_wss_trigger,
19101878 .pointer = snd_wss_playback_pointer,
....@@ -1913,9 +1881,7 @@
19131881 static const struct snd_pcm_ops snd_wss_capture_ops = {
19141882 .open = snd_wss_capture_open,
19151883 .close = snd_wss_capture_close,
1916
- .ioctl = snd_pcm_lib_ioctl,
19171884 .hw_params = snd_wss_capture_hw_params,
1918
- .hw_free = snd_wss_capture_hw_free,
19191885 .prepare = snd_wss_capture_prepare,
19201886 .trigger = snd_wss_trigger,
19211887 .pointer = snd_wss_capture_pointer,
....@@ -1942,9 +1908,8 @@
19421908 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX;
19431909 strcpy(pcm->name, snd_wss_chip_id(chip));
19441910
1945
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1946
- snd_dma_isa_data(),
1947
- 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
1911
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev,
1912
+ 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
19481913
19491914 chip->pcm = pcm;
19501915 return 0;
....@@ -2192,7 +2157,7 @@
21922157 static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
21932158 static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
21942159
2195
-static struct snd_kcontrol_new snd_wss_controls[] = {
2160
+static const struct snd_kcontrol_new snd_wss_controls[] = {
21962161 WSS_DOUBLE("PCM Playback Switch", 0,
21972162 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
21982163 WSS_DOUBLE_TLV("PCM Playback Volume", 0,