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