source: GPL/alsa-kernel/pci/trident/trident.c@ 1

Last change on this file since 1 was 1, checked in by vladest, 20 years ago

initial import

File size: 7.0 KB
Line 
1/*
2 * Driver for Trident 4DWave DX/NX & SiS SI7018 Audio PCI soundcard
3 *
4 * Driver was originated by Trident <audio@tridentmicro.com>
5 * Fri Feb 19 15:55:28 MST 1999
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#define SNDRV_MAIN_OBJECT_FILE
25#include <sound/driver.h>
26#include <sound/trident.h>
27#define SNDRV_GET_ID
28#include <sound/initval.h>
29
30EXPORT_NO_SYMBOLS;
31MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, <audio@tridentmicro.com>");
32MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
33MODULE_LICENSE("GPL");
34MODULE_CLASSES("{sound}");
35MODULE_DEVICES("{{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; /* Index 0-MAX */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
51static int pcm_channels[SNDRV_CARDS] = {REPEAT_SNDRV(32)};
52static int wavetable_size[SNDRV_CARDS] = {REPEAT_SNDRV(8192)};
53
54MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
55MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
56MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
57MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
58MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
59MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
60MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
61MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
62MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
63MODULE_PARM(pcm_channels, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
64MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
65MODULE_PARM_SYNTAX(pcm_channels, SNDRV_ENABLED ",default:32,allows:{{1,32}}");
66MODULE_PARM(wavetable_size, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
67MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
68MODULE_PARM_SYNTAX(wavetable_size, SNDRV_ENABLED ",default:8192,skill:advanced");
69
70
71static struct pci_device_id snd_trident_ids[] __devinitdata = {
72 { 0x1023, 0x2000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave DX PCI Audio */
73 { 0x1023, 0x2001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave NX PCI Audio */
74 { 0x1039, 0x7018, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* SiS SI7018 PCI Audio */
75 { 0, }
76};
77
78MODULE_DEVICE_TABLE(pci, snd_trident_ids);
79
80static int __devinit snd_trident_probe(struct pci_dev *pci,
81 const struct pci_device_id *pci_id)
82{
83 static int dev;
84 snd_card_t *card;
85 trident_t *trident;
86 const char *str;
87 int err, pcm_dev = 0;
88
89 if (dev >= SNDRV_CARDS)
90 return -ENODEV;
91 if (!enable[dev]) {
92 dev++;
93 return -ENOENT;
94 }
95
96 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
97 if (card == NULL)
98 return -ENOMEM;
99
100 if ((err = snd_trident_create(card, pci,
101 pcm_channels[dev],
102 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
103 wavetable_size[dev],
104 &trident)) < 0) {
105 snd_card_free(card);
106 return err;
107 }
108
109 switch (trident->device) {
110 case TRIDENT_DEVICE_ID_DX:
111 str = "TRID4DWAVEDX";
112 break;
113 case TRIDENT_DEVICE_ID_NX:
114 str = "TRID4DWAVENX";
115 break;
116 case TRIDENT_DEVICE_ID_SI7018:
117 str = "SI7018";
118 break;
119 default:
120 str = "Unknown";
121 }
122 strcpy(card->driver, str);
123 if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
124 strcpy(card->shortname, "SiS ");
125 } else {
126 strcpy(card->shortname, "Trident ");
127 }
128 strcat(card->shortname, card->driver);
129 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
130 card->shortname, trident->port, trident->irq);
131
132 if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) {
133 snd_card_free(card);
134 return err;
135 }
136 switch (trident->device) {
137 case TRIDENT_DEVICE_ID_DX:
138 case TRIDENT_DEVICE_ID_NX:
139 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) {
140 snd_card_free(card);
141 return err;
142 }
143 break;
144 }
145 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
146 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) {
147 snd_card_free(card);
148 return err;
149 }
150 }
151 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
152 trident->midi_port, 1,
153 trident->irq, 0, &trident->rmidi)) < 0) {
154 snd_card_free(card);
155 return err;
156 }
157
158#ifdef CONFIG_SND_SEQUENCER
159 if ((err = snd_trident_attach_synthesizer(trident)) < 0) {
160 snd_card_free(card);
161 return err;
162 }
163#endif
164
165 snd_trident_gameport(trident);
166
167 if ((err = snd_card_register(card)) < 0) {
168 snd_card_free(card);
169 return err;
170 }
171 pci_set_drvdata(pci, card);
172 dev++;
173 return 0;
174}
175
176static void __devexit snd_trident_remove(struct pci_dev *pci)
177{
178 snd_card_free(pci_get_drvdata(pci));
179 pci_set_drvdata(pci, NULL);
180}
181
182static struct pci_driver driver = {
183 0, 0, 0, "Trident4DWaveAudio",
184 snd_trident_ids,
185 snd_trident_probe,
186 snd_trident_remove,
187 SND_PCI_PM_CALLBACKS
188};
189
190static int __init alsa_card_trident_init(void)
191{
192 int err;
193
194 if ((err = pci_module_init(&driver)) < 0) {
195#ifdef MODULE
196// snd_printk("Trident 4DWave PCI soundcard not found or device busy\n");
197#endif
198 return err;
199 }
200 return 0;
201}
202
203static void __exit alsa_card_trident_exit(void)
204{
205 pci_unregister_driver(&driver);
206}
207
208module_init(alsa_card_trident_init)
209module_exit(alsa_card_trident_exit)
210
211#ifndef MODULE
212
213/* format is: snd-card-trident=snd_enable,snd_index,snd_id,
214 snd_pcm_channels,snd_wavetable_size */
215
216static int __init alsa_card_trident_setup(char *str)
217{
218 static unsigned __initdata nr_dev = 0;
219
220 if (nr_dev >= SNDRV_CARDS)
221 return 0;
222 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
223 get_option(&str,&index[nr_dev]) == 2 &&
224 get_id(&str,&id[nr_dev]) == 2 &&
225 get_option(&str,&pcm_channels[nr_dev]) == 2 &&
226 get_option(&str,&wavetable_size[nr_dev]) == 2);
227 nr_dev++;
228 return 1;
229}
230
231__setup("snd-trident=", alsa_card_trident_setup);
232
233#endif /* ifndef MODULE */
Note: See TracBrowser for help on using the repository browser.