hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/sound/pci/trident/trident_main.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Maintained by Jaroslav Kysela <perex@perex.cz>
34 * Originated by audio@tridentmicro.com
....@@ -8,21 +9,6 @@
89 *
910 * TODO:
1011 * ---
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2 of the License, or
15
- * (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
- *
2612 *
2713 * SiS7018 S/PDIF support by Thomas Winischhofer <thomas@winischhofer.net>
2814 */
....@@ -782,29 +768,6 @@
782768 */
783769
784770 /*---------------------------------------------------------------------------
785
- snd_trident_ioctl
786
-
787
- Description: Device I/O control handler for playback/capture parameters.
788
-
789
- Parameters: substream - PCM substream class
790
- cmd - what ioctl message to process
791
- arg - additional message infoarg
792
-
793
- Returns: Error status
794
-
795
- ---------------------------------------------------------------------------*/
796
-
797
-static int snd_trident_ioctl(struct snd_pcm_substream *substream,
798
- unsigned int cmd,
799
- void *arg)
800
-{
801
- /* FIXME: it seems that with small periods the behaviour of
802
- trident hardware is unpredictable and interrupt generator
803
- is broken */
804
- return snd_pcm_lib_ioctl(substream, cmd, arg);
805
-}
806
-
807
-/*---------------------------------------------------------------------------
808771 snd_trident_allocate_pcm_mem
809772
810773 Description: Allocate PCM ring buffer for given substream
....@@ -822,12 +785,9 @@
822785 struct snd_trident *trident = snd_pcm_substream_chip(substream);
823786 struct snd_pcm_runtime *runtime = substream->runtime;
824787 struct snd_trident_voice *voice = runtime->private_data;
825
- int err;
826788
827
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
828
- return err;
829789 if (trident->tlb.entries) {
830
- if (err > 0) { /* change */
790
+ if (runtime->buffer_changed) {
831791 if (voice->memblk)
832792 snd_trident_free_pages(trident, voice->memblk);
833793 voice->memblk = snd_trident_alloc_pages(trident, substream);
....@@ -925,7 +885,6 @@
925885 voice->memblk = NULL;
926886 }
927887 }
928
- snd_pcm_lib_free_pages(substream);
929888 if (evoice != NULL) {
930889 snd_trident_free_voice(trident, evoice);
931890 voice->extra = NULL;
....@@ -1142,11 +1101,6 @@
11421101 static int snd_trident_si7018_capture_hw_params(struct snd_pcm_substream *substream,
11431102 struct snd_pcm_hw_params *hw_params)
11441103 {
1145
- int err;
1146
-
1147
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
1148
- return err;
1149
-
11501104 return snd_trident_allocate_evoice(substream, hw_params);
11511105 }
11521106
....@@ -1168,7 +1122,6 @@
11681122 struct snd_trident_voice *voice = runtime->private_data;
11691123 struct snd_trident_voice *evoice = voice ? voice->extra : NULL;
11701124
1171
- snd_pcm_lib_free_pages(substream);
11721125 if (evoice != NULL) {
11731126 snd_trident_free_voice(trident, evoice);
11741127 voice->extra = NULL;
....@@ -2073,7 +2026,6 @@
20732026 static const struct snd_pcm_ops snd_trident_playback_ops = {
20742027 .open = snd_trident_playback_open,
20752028 .close = snd_trident_playback_close,
2076
- .ioctl = snd_trident_ioctl,
20772029 .hw_params = snd_trident_hw_params,
20782030 .hw_free = snd_trident_hw_free,
20792031 .prepare = snd_trident_playback_prepare,
....@@ -2084,19 +2036,16 @@
20842036 static const struct snd_pcm_ops snd_trident_nx_playback_ops = {
20852037 .open = snd_trident_playback_open,
20862038 .close = snd_trident_playback_close,
2087
- .ioctl = snd_trident_ioctl,
20882039 .hw_params = snd_trident_hw_params,
20892040 .hw_free = snd_trident_hw_free,
20902041 .prepare = snd_trident_playback_prepare,
20912042 .trigger = snd_trident_trigger,
20922043 .pointer = snd_trident_playback_pointer,
2093
- .page = snd_pcm_sgbuf_ops_page,
20942044 };
20952045
20962046 static const struct snd_pcm_ops snd_trident_capture_ops = {
20972047 .open = snd_trident_capture_open,
20982048 .close = snd_trident_capture_close,
2099
- .ioctl = snd_trident_ioctl,
21002049 .hw_params = snd_trident_capture_hw_params,
21012050 .hw_free = snd_trident_hw_free,
21022051 .prepare = snd_trident_capture_prepare,
....@@ -2107,7 +2056,6 @@
21072056 static const struct snd_pcm_ops snd_trident_si7018_capture_ops = {
21082057 .open = snd_trident_capture_open,
21092058 .close = snd_trident_capture_close,
2110
- .ioctl = snd_trident_ioctl,
21112059 .hw_params = snd_trident_si7018_capture_hw_params,
21122060 .hw_free = snd_trident_si7018_capture_hw_free,
21132061 .prepare = snd_trident_si7018_capture_prepare,
....@@ -2118,7 +2066,6 @@
21182066 static const struct snd_pcm_ops snd_trident_foldback_ops = {
21192067 .open = snd_trident_foldback_open,
21202068 .close = snd_trident_foldback_close,
2121
- .ioctl = snd_trident_ioctl,
21222069 .hw_params = snd_trident_hw_params,
21232070 .hw_free = snd_trident_hw_free,
21242071 .prepare = snd_trident_foldback_prepare,
....@@ -2129,19 +2076,16 @@
21292076 static const struct snd_pcm_ops snd_trident_nx_foldback_ops = {
21302077 .open = snd_trident_foldback_open,
21312078 .close = snd_trident_foldback_close,
2132
- .ioctl = snd_trident_ioctl,
21332079 .hw_params = snd_trident_hw_params,
21342080 .hw_free = snd_trident_hw_free,
21352081 .prepare = snd_trident_foldback_prepare,
21362082 .trigger = snd_trident_trigger,
21372083 .pointer = snd_trident_playback_pointer,
2138
- .page = snd_pcm_sgbuf_ops_page,
21392084 };
21402085
21412086 static const struct snd_pcm_ops snd_trident_spdif_ops = {
21422087 .open = snd_trident_spdif_open,
21432088 .close = snd_trident_spdif_close,
2144
- .ioctl = snd_trident_ioctl,
21452089 .hw_params = snd_trident_spdif_hw_params,
21462090 .hw_free = snd_trident_hw_free,
21472091 .prepare = snd_trident_spdif_prepare,
....@@ -2152,7 +2096,6 @@
21522096 static const struct snd_pcm_ops snd_trident_spdif_7018_ops = {
21532097 .open = snd_trident_spdif_open,
21542098 .close = snd_trident_spdif_close,
2155
- .ioctl = snd_trident_ioctl,
21562099 .hw_params = snd_trident_spdif_hw_params,
21572100 .hw_free = snd_trident_hw_free,
21582101 .prepare = snd_trident_spdif_prepare,
....@@ -2199,15 +2142,17 @@
21992142 if (trident->tlb.entries) {
22002143 struct snd_pcm_substream *substream;
22012144 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
2202
- snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
2203
- snd_dma_pci_data(trident->pci),
2204
- 64*1024, 128*1024);
2205
- snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
2206
- SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
2207
- 64*1024, 128*1024);
2145
+ snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_SG,
2146
+ &trident->pci->dev,
2147
+ 64*1024, 128*1024);
2148
+ snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
2149
+ SNDRV_DMA_TYPE_DEV,
2150
+ &trident->pci->dev,
2151
+ 64*1024, 128*1024);
22082152 } else {
2209
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
2210
- snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
2153
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
2154
+ &trident->pci->dev,
2155
+ 64*1024, 128*1024);
22112156 }
22122157
22132158 return 0;
....@@ -2256,11 +2201,13 @@
22562201 trident->foldback = foldback;
22572202
22582203 if (trident->tlb.entries)
2259
- snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV_SG,
2260
- snd_dma_pci_data(trident->pci), 0, 128*1024);
2204
+ snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV_SG,
2205
+ &trident->pci->dev,
2206
+ 0, 128*1024);
22612207 else
2262
- snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV,
2263
- snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
2208
+ snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV,
2209
+ &trident->pci->dev,
2210
+ 64*1024, 128*1024);
22642211
22652212 return 0;
22662213 }
....@@ -2294,7 +2241,8 @@
22942241 strcpy(spdif->name, "Trident 4DWave IEC958");
22952242 trident->spdif = spdif;
22962243
2297
- snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 64*1024, 128*1024);
2244
+ snd_pcm_set_managed_buffer_all(spdif, SNDRV_DMA_TYPE_DEV,
2245
+ &trident->pci->dev, 64*1024, 128*1024);
22982246
22992247 return 0;
23002248 }
....@@ -2964,7 +2912,7 @@
29642912 struct snd_kcontrol *kctl;
29652913 struct snd_ctl_elem_value *uctl;
29662914 int idx, err, retries = 2;
2967
- static struct snd_ac97_bus_ops ops = {
2915
+ static const struct snd_ac97_bus_ops ops = {
29682916 .write = snd_trident_codec_write,
29692917 .read = snd_trident_codec_read,
29702918 };
....@@ -3320,13 +3268,11 @@
33203268
33213269 static void snd_trident_proc_init(struct snd_trident *trident)
33223270 {
3323
- struct snd_info_entry *entry;
33243271 const char *s = "trident";
33253272
33263273 if (trident->device == TRIDENT_DEVICE_ID_SI7018)
33273274 s = "sis7018";
3328
- if (! snd_card_proc_new(trident->card, s, &entry))
3329
- snd_info_set_text_ops(entry, trident, snd_trident_proc_read);
3275
+ snd_card_ro_proc_new(trident->card, s, trident, snd_trident_proc_read);
33303276 }
33313277
33323278 static int snd_trident_dev_free(struct snd_device *device)
....@@ -3354,7 +3300,7 @@
33543300 /* TLB array must be aligned to 16kB !!! so we allocate
33553301 32kB region and correct offset when necessary */
33563302
3357
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
3303
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev,
33583304 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
33593305 dev_err(trident->card->dev, "unable to allocate TLB buffer\n");
33603306 return -ENOMEM;
....@@ -3369,7 +3315,7 @@
33693315 return -ENOMEM;
33703316
33713317 /* allocate and setup silent page and initialise TLB entries */
3372
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
3318
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev,
33733319 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
33743320 dev_err(trident->card->dev, "unable to allocate silent page\n");
33753321 return -ENOMEM;
....@@ -3541,7 +3487,7 @@
35413487 int i, err;
35423488 struct snd_trident_voice *voice;
35433489 struct snd_trident_pcm_mixer *tmix;
3544
- static struct snd_device_ops ops = {
3490
+ static const struct snd_device_ops ops = {
35453491 .dev_free = snd_trident_dev_free,
35463492 };
35473493
....@@ -3597,6 +3543,7 @@
35973543 return -EBUSY;
35983544 }
35993545 trident->irq = pci->irq;
3546
+ card->sync_irq = trident->irq;
36003547
36013548 /* allocate 16k-aligned TLB for NX cards */
36023549 trident->tlb.entries = NULL;
....@@ -3915,10 +3862,6 @@
39153862
39163863 trident->in_suspend = 1;
39173864 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3918
- snd_pcm_suspend_all(trident->pcm);
3919
- snd_pcm_suspend_all(trident->foldback);
3920
- snd_pcm_suspend_all(trident->spdif);
3921
-
39223865 snd_ac97_suspend(trident->ac97);
39233866 snd_ac97_suspend(trident->ac97_sec);
39243867 return 0;