forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/fm801.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * The driver for the ForteMedia FM801 based soundcards
34 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
155 */
166
177 #include <linux/delay.h>
....@@ -154,6 +144,8 @@
154144
155145 /**
156146 * struct fm801 - describes FM801 chip
147
+ * @dev: device for this chio
148
+ * @irq: irq number
157149 * @port: I/O port number
158150 * @multichannel: multichannel support
159151 * @secondary: secondary codec
....@@ -161,6 +153,31 @@
161153 * @tea575x_tuner: tuner access method & flags
162154 * @ply_ctrl: playback control
163155 * @cap_ctrl: capture control
156
+ * @ply_buffer: playback buffer
157
+ * @ply_buf: playback buffer index
158
+ * @ply_count: playback buffer count
159
+ * @ply_size: playback buffer size
160
+ * @ply_pos: playback position
161
+ * @cap_buffer: capture buffer
162
+ * @cap_buf: capture buffer index
163
+ * @cap_count: capture buffer count
164
+ * @cap_size: capture buffer size
165
+ * @cap_pos: capture position
166
+ * @ac97_bus: ac97 bus handle
167
+ * @ac97: ac97 handle
168
+ * @ac97_sec: ac97 secondary handle
169
+ * @card: ALSA card
170
+ * @pcm: PCM devices
171
+ * @rmidi: rmidi device
172
+ * @playback_substream: substream for playback
173
+ * @capture_substream: substream for capture
174
+ * @p_dma_size: playback DMA size
175
+ * @c_dma_size: capture DMA size
176
+ * @reg_lock: lock
177
+ * @proc_entry: /proc entry
178
+ * @v4l2_dev: v4l2 device
179
+ * @tea: tea575a structure
180
+ * @saved_regs: context saved during suspend
164181 */
165182 struct fm801 {
166183 struct device *dev;
....@@ -445,17 +462,6 @@
445462 return 0;
446463 }
447464
448
-static int snd_fm801_hw_params(struct snd_pcm_substream *substream,
449
- struct snd_pcm_hw_params *hw_params)
450
-{
451
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
452
-}
453
-
454
-static int snd_fm801_hw_free(struct snd_pcm_substream *substream)
455
-{
456
- return snd_pcm_lib_free_pages(substream);
457
-}
458
-
459465 static int snd_fm801_playback_prepare(struct snd_pcm_substream *substream)
460466 {
461467 struct fm801 *chip = snd_pcm_substream_chip(substream);
....@@ -694,9 +700,6 @@
694700 static const struct snd_pcm_ops snd_fm801_playback_ops = {
695701 .open = snd_fm801_playback_open,
696702 .close = snd_fm801_playback_close,
697
- .ioctl = snd_pcm_lib_ioctl,
698
- .hw_params = snd_fm801_hw_params,
699
- .hw_free = snd_fm801_hw_free,
700703 .prepare = snd_fm801_playback_prepare,
701704 .trigger = snd_fm801_playback_trigger,
702705 .pointer = snd_fm801_playback_pointer,
....@@ -705,9 +708,6 @@
705708 static const struct snd_pcm_ops snd_fm801_capture_ops = {
706709 .open = snd_fm801_capture_open,
707710 .close = snd_fm801_capture_close,
708
- .ioctl = snd_pcm_lib_ioctl,
709
- .hw_params = snd_fm801_hw_params,
710
- .hw_free = snd_fm801_hw_free,
711711 .prepare = snd_fm801_capture_prepare,
712712 .trigger = snd_fm801_capture_trigger,
713713 .pointer = snd_fm801_capture_pointer,
....@@ -730,9 +730,8 @@
730730 strcpy(pcm->name, "FM801");
731731 chip->pcm = pcm;
732732
733
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
734
- snd_dma_pci_data(pdev),
735
- chip->multichannel ? 128*1024 : 64*1024, 128*1024);
733
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &pdev->dev,
734
+ chip->multichannel ? 128*1024 : 64*1024, 128*1024);
736735
737736 return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
738737 snd_pcm_alt_chmaps,
....@@ -752,7 +751,7 @@
752751 char *name;
753752 };
754753
755
-static struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = {
754
+static const struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = {
756755 { .data = 1, .clk = 3, .wren = 2, .most = 0, .name = "SF256-PCS" },
757756 { .data = 1, .clk = 0, .wren = 2, .most = 3, .name = "SF256-PCP" },
758757 { .data = 2, .clk = 0, .wren = 1, .most = 3, .name = "SF64-PCR" },
....@@ -997,7 +996,7 @@
997996
998997 #define FM801_CONTROLS ARRAY_SIZE(snd_fm801_controls)
999998
1000
-static struct snd_kcontrol_new snd_fm801_controls[] = {
999
+static const struct snd_kcontrol_new snd_fm801_controls[] = {
10011000 FM801_DOUBLE_TLV("Wave Playback Volume", FM801_PCM_VOL, 0, 8, 31, 1,
10021001 db_scale_dsp),
10031002 FM801_SINGLE("Wave Playback Switch", FM801_PCM_VOL, 15, 1, 1),
....@@ -1018,7 +1017,7 @@
10181017
10191018 #define FM801_CONTROLS_MULTI ARRAY_SIZE(snd_fm801_controls_multi)
10201019
1021
-static struct snd_kcontrol_new snd_fm801_controls_multi[] = {
1020
+static const struct snd_kcontrol_new snd_fm801_controls_multi[] = {
10221021 FM801_SINGLE("AC97 2ch->4ch Copy Switch", FM801_CODEC_CTRL, 7, 1, 0),
10231022 FM801_SINGLE("AC97 18-bit Switch", FM801_CODEC_CTRL, 10, 1, 0),
10241023 FM801_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), FM801_I2S_MODE, 8, 1, 0),
....@@ -1048,7 +1047,7 @@
10481047 struct snd_ac97_template ac97;
10491048 unsigned int i;
10501049 int err;
1051
- static struct snd_ac97_bus_ops ops = {
1050
+ static const struct snd_ac97_bus_ops ops = {
10521051 .write = snd_fm801_codec_write,
10531052 .read = snd_fm801_codec_read,
10541053 };
....@@ -1211,7 +1210,7 @@
12111210 {
12121211 struct fm801 *chip;
12131212 int err;
1214
- static struct snd_device_ops ops = {
1213
+ static const struct snd_device_ops ops = {
12151214 .dev_free = snd_fm801_dev_free,
12161215 };
12171216
....@@ -1251,6 +1250,7 @@
12511250 return -EBUSY;
12521251 }
12531252 chip->irq = pci->irq;
1253
+ card->sync_irq = chip->irq;
12541254 pci_set_master(pci);
12551255 }
12561256
....@@ -1387,7 +1387,7 @@
13871387 }
13881388
13891389 #ifdef CONFIG_PM_SLEEP
1390
-static unsigned char saved_regs[] = {
1390
+static const unsigned char saved_regs[] = {
13911391 FM801_PCM_VOL, FM801_I2S_VOL, FM801_FM_VOL, FM801_REC_SRC,
13921392 FM801_PLY_CTRL, FM801_PLY_COUNT, FM801_PLY_BUF1, FM801_PLY_BUF2,
13931393 FM801_CAP_CTRL, FM801_CAP_COUNT, FM801_CAP_BUF1, FM801_CAP_BUF2,
....@@ -1408,7 +1408,6 @@
14081408 if (chip->tea575x_tuner & TUNER_ONLY) {
14091409 /* FIXME: tea575x suspend */
14101410 } else {
1411
- snd_pcm_suspend_all(chip->pcm);
14121411 snd_ac97_suspend(chip->ac97);
14131412 snd_ac97_suspend(chip->ac97_sec);
14141413 }