]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4 LT |
2 | /* |
3 | * Driver for Trident 4DWave DX/NX & SiS SI7018 Audio PCI soundcard | |
4 | * | |
5 | * Driver was originated by Trident <audio@tridentmicro.com> | |
6 | * Fri Feb 19 15:55:28 MST 1999 | |
1da177e4 LT |
7 | */ |
8 | ||
1da177e4 LT |
9 | #include <linux/init.h> |
10 | #include <linux/pci.h> | |
11 | #include <linux/time.h> | |
65a77217 | 12 | #include <linux/module.h> |
1da177e4 | 13 | #include <sound/core.h> |
81fcb170 | 14 | #include "trident.h" |
1da177e4 LT |
15 | #include <sound/initval.h> |
16 | ||
c1017a4c | 17 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>"); |
1da177e4 LT |
18 | MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018"); |
19 | MODULE_LICENSE("GPL"); | |
20 | MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX}," | |
21 | "{Trident,4DWave NX}," | |
22 | "{SiS,SI7018 PCI Audio}," | |
23 | "{Best Union,Miss Melody 4DWave PCI}," | |
24 | "{HIS,4DWave PCI}," | |
25 | "{Warpspeed,ONSpeed 4DWave PCI}," | |
26 | "{Aztech Systems,PCI 64-Q3D}," | |
27 | "{Addonics,SV 750}," | |
28 | "{CHIC,True Sound 4Dwave}," | |
29 | "{Shark,Predator4D-PCI}," | |
30 | "{Jaton,SonicWave 4D}," | |
31 | "{Hoontech,SoundTrack Digital 4DWave NX}}"); | |
32 | ||
33 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | |
34 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | |
a67ff6a5 | 35 | static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ |
1da177e4 LT |
36 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; |
37 | static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192}; | |
38 | ||
39 | module_param_array(index, int, NULL, 0444); | |
40 | MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard."); | |
41 | module_param_array(id, charp, NULL, 0444); | |
42 | MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard."); | |
43 | module_param_array(enable, bool, NULL, 0444); | |
44 | MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard."); | |
45 | module_param_array(pcm_channels, int, NULL, 0444); | |
46 | MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM."); | |
47 | module_param_array(wavetable_size, int, NULL, 0444); | |
48 | MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); | |
49 | ||
9baa3c34 | 50 | static const struct pci_device_id snd_trident_ids[] = { |
e3183ec9 JM |
51 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX), |
52 | PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, | |
53 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX), | |
54 | 0, 0, 0}, | |
55 | {PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7018), 0, 0, 0}, | |
1da177e4 LT |
56 | { 0, } |
57 | }; | |
58 | ||
59 | MODULE_DEVICE_TABLE(pci, snd_trident_ids); | |
60 | ||
e23e7a14 BP |
61 | static int snd_trident_probe(struct pci_dev *pci, |
62 | const struct pci_device_id *pci_id) | |
1da177e4 LT |
63 | { |
64 | static int dev; | |
bee1a5be TI |
65 | struct snd_card *card; |
66 | struct snd_trident *trident; | |
1da177e4 LT |
67 | const char *str; |
68 | int err, pcm_dev = 0; | |
69 | ||
70 | if (dev >= SNDRV_CARDS) | |
71 | return -ENODEV; | |
72 | if (!enable[dev]) { | |
73 | dev++; | |
74 | return -ENOENT; | |
75 | } | |
76 | ||
60c5772b TI |
77 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
78 | 0, &card); | |
e58de7ba TI |
79 | if (err < 0) |
80 | return err; | |
1da177e4 LT |
81 | |
82 | if ((err = snd_trident_create(card, pci, | |
83 | pcm_channels[dev], | |
84 | ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2, | |
85 | wavetable_size[dev], | |
86 | &trident)) < 0) { | |
87 | snd_card_free(card); | |
88 | return err; | |
89 | } | |
fb0700b4 | 90 | card->private_data = trident; |
1da177e4 LT |
91 | |
92 | switch (trident->device) { | |
93 | case TRIDENT_DEVICE_ID_DX: | |
94 | str = "TRID4DWAVEDX"; | |
95 | break; | |
96 | case TRIDENT_DEVICE_ID_NX: | |
97 | str = "TRID4DWAVENX"; | |
98 | break; | |
99 | case TRIDENT_DEVICE_ID_SI7018: | |
100 | str = "SI7018"; | |
101 | break; | |
102 | default: | |
103 | str = "Unknown"; | |
104 | } | |
105 | strcpy(card->driver, str); | |
106 | if (trident->device == TRIDENT_DEVICE_ID_SI7018) { | |
107 | strcpy(card->shortname, "SiS "); | |
108 | } else { | |
109 | strcpy(card->shortname, "Trident "); | |
110 | } | |
d6b340d7 | 111 | strcat(card->shortname, str); |
1da177e4 LT |
112 | sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d", |
113 | card->shortname, trident->port, trident->irq); | |
114 | ||
1b16416f | 115 | if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) { |
1da177e4 LT |
116 | snd_card_free(card); |
117 | return err; | |
118 | } | |
119 | switch (trident->device) { | |
120 | case TRIDENT_DEVICE_ID_DX: | |
121 | case TRIDENT_DEVICE_ID_NX: | |
1b16416f | 122 | if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) { |
1da177e4 LT |
123 | snd_card_free(card); |
124 | return err; | |
125 | } | |
126 | break; | |
127 | } | |
128 | if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { | |
1b16416f | 129 | if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) { |
1da177e4 LT |
130 | snd_card_free(card); |
131 | return err; | |
132 | } | |
133 | } | |
1ccc67d6 TI |
134 | if (trident->device != TRIDENT_DEVICE_ID_SI7018 && |
135 | (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, | |
302e4c2f | 136 | trident->midi_port, |
dba8b469 CL |
137 | MPU401_INFO_INTEGRATED | |
138 | MPU401_INFO_IRQ_HOOK, | |
139 | -1, &trident->rmidi)) < 0) { | |
1da177e4 LT |
140 | snd_card_free(card); |
141 | return err; | |
142 | } | |
143 | ||
1da177e4 LT |
144 | snd_trident_create_gameport(trident); |
145 | ||
146 | if ((err = snd_card_register(card)) < 0) { | |
147 | snd_card_free(card); | |
148 | return err; | |
149 | } | |
150 | pci_set_drvdata(pci, card); | |
151 | dev++; | |
152 | return 0; | |
153 | } | |
154 | ||
e23e7a14 | 155 | static void snd_trident_remove(struct pci_dev *pci) |
1da177e4 LT |
156 | { |
157 | snd_card_free(pci_get_drvdata(pci)); | |
1da177e4 LT |
158 | } |
159 | ||
e9f66d9b | 160 | static struct pci_driver trident_driver = { |
3733e424 | 161 | .name = KBUILD_MODNAME, |
1da177e4 LT |
162 | .id_table = snd_trident_ids, |
163 | .probe = snd_trident_probe, | |
e23e7a14 | 164 | .remove = snd_trident_remove, |
c7561cd8 | 165 | #ifdef CONFIG_PM_SLEEP |
68cb2b55 TI |
166 | .driver = { |
167 | .pm = &snd_trident_pm, | |
168 | }, | |
fb0700b4 | 169 | #endif |
1da177e4 LT |
170 | }; |
171 | ||
e9f66d9b | 172 | module_pci_driver(trident_driver); |