source: GPL/branches/alsa-resync1/alsa-kernel/pci/trident/trident.c@ 212

Last change on this file since 212 was 212, checked in by Brendan Oakley, 18 years ago

Merged to Alsa 0.9.0rc5

File size: 7.3 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#include <sound/driver.h>
25#include <linux/init.h>
26#include <linux/pci.h>
27#include <linux/time.h>
28#include <sound/core.h>
29#include <sound/trident.h>
30#define SNDRV_GET_ID
31#include <sound/initval.h>
32
33MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, <audio@tridentmicro.com>");
34MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
35MODULE_LICENSE("GPL");
36MODULE_CLASSES("{sound}");
37MODULE_DEVICES("{{Trident,4DWave DX},"
38 "{Trident,4DWave NX},"
39 "{SiS,SI7018 PCI Audio},"
40 "{Best Union,Miss Melody 4DWave PCI},"
41 "{HIS,4DWave PCI},"
42 "{Warpspeed,ONSpeed 4DWave PCI},"
43 "{Aztech Systems,PCI 64-Q3D},"
44 "{Addonics,SV 750},"
45 "{CHIC,True Sound 4Dwave},"
46 "{Shark,Predator4D-PCI},"
47 "{Jaton,SonicWave 4D},"
48 "{Hoontech,SoundTrack Digital 4DWave NX}}");
49
50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
51static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
52static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
53static int pcm_channels[SNDRV_CARDS] = {REPEAT_SNDRV(32)};
54static int wavetable_size[SNDRV_CARDS] = {REPEAT_SNDRV(8192)};
55
56MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
57MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
58MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
59MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
60MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
61MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
62MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
63MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
64MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
65MODULE_PARM(pcm_channels, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
66MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
67MODULE_PARM_SYNTAX(pcm_channels, SNDRV_ENABLED ",default:32,allows:{{1,32}}");
68MODULE_PARM(wavetable_size, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
69MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
70MODULE_PARM_SYNTAX(wavetable_size, SNDRV_ENABLED ",default:8192,skill:advanced");
71
72
73static struct pci_device_id snd_trident_ids[] __devinitdata = {
74 { 0x1023, 0x2000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave DX PCI Audio */
75 { 0x1023, 0x2001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave NX PCI Audio */
76 { 0x1039, 0x7018, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* SiS SI7018 PCI Audio */
77 { 0, }
78};
79
80MODULE_DEVICE_TABLE(pci, snd_trident_ids);
81
82// 12 Jun 07 SHL fixme to be in some .h
83void __devinit snd_trident_gameport(struct snd_trident *chip);
84
85static int __devinit snd_trident_probe(struct pci_dev *pci,
86 const struct pci_device_id *pci_id)
87{
88 static int dev;
89 snd_card_t *card;
90 struct snd_trident *trident;
91 const char *str;
92 int err, pcm_dev = 0;
93
94 if (dev >= SNDRV_CARDS)
95 return -ENODEV;
96 if (!enable[dev]) {
97 dev++;
98 return -ENOENT;
99 }
100
101 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
102 if (card == NULL)
103 return -ENOMEM;
104
105 if ((err = snd_trident_create(card, pci,
106 pcm_channels[dev],
107 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
108 wavetable_size[dev],
109 &trident)) < 0) {
110 snd_card_free(card);
111 return err;
112 }
113
114 switch (trident->device) {
115 case TRIDENT_DEVICE_ID_DX:
116 str = "TRID4DWAVEDX";
117 break;
118 case TRIDENT_DEVICE_ID_NX:
119 str = "TRID4DWAVENX";
120 break;
121 case TRIDENT_DEVICE_ID_SI7018:
122 str = "SI7018";
123 break;
124 default:
125 str = "Unknown";
126 }
127 strcpy(card->driver, str);
128 if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
129 strcpy(card->shortname, "SiS ");
130 } else {
131 strcpy(card->shortname, "Trident ");
132 }
133 strcat(card->shortname, card->driver);
134 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
135 card->shortname, trident->port, trident->irq);
136
137 if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) {
138 snd_card_free(card);
139 return err;
140 }
141 switch (trident->device) {
142 case TRIDENT_DEVICE_ID_DX:
143 case TRIDENT_DEVICE_ID_NX:
144 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) {
145 snd_card_free(card);
146 return err;
147 }
148 break;
149 }
150 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
151 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) {
152 snd_card_free(card);
153 return err;
154 }
155 }
156 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
157 trident->midi_port,
158 MPU401_INFO_INTEGRATED,
159 trident->irq, 0, &trident->rmidi)) < 0) {
160 snd_card_free(card);
161 return err;
162 }
163
164#ifdef CONFIG_SND_SEQUENCER
165 if ((err = snd_trident_attach_synthesizer(trident)) < 0) {
166 snd_card_free(card);
167 return err;
168 }
169#endif
170
171 snd_trident_gameport(trident);
172
173 if ((err = snd_card_register(card)) < 0) {
174 snd_card_free(card);
175 return err;
176 }
177 pci_set_drvdata(pci, card);
178 dev++;
179 return 0;
180}
181
182static void __devexit snd_trident_remove(struct pci_dev *pci)
183{
184 snd_card_free(pci_get_drvdata(pci));
185 pci_set_drvdata(pci, NULL);
186}
187
188static struct pci_driver driver = {
189 .name = "Trident4DWaveAudio",
190 .id_table = snd_trident_ids,
191 .probe = snd_trident_probe,
192 .remove = __devexit_p(snd_trident_remove),
193#ifdef CONFIG_PM
194 .suspend = snd_trident_suspend,
195 .resume = snd_trident_resume,
196#endif
197};
198
199static int __init alsa_card_trident_init(void)
200{
201 int err;
202
203 if ((err = pci_module_init(&driver)) < 0) {
204#ifdef MODULE
205// snd_printk(KERN_ERR "Trident 4DWave PCI soundcard not found or device busy\n");
206#endif
207 return err;
208 }
209 return 0;
210}
211
212static void __exit alsa_card_trident_exit(void)
213{
214 pci_unregister_driver(&driver);
215}
216
217module_init(alsa_card_trident_init)
218module_exit(alsa_card_trident_exit)
219
220#ifndef MODULE
221
222/* format is: snd-trident=enable,index,id,
223 pcm_channels,wavetable_size */
224
225static int __init alsa_card_trident_setup(char *str)
226{
227 static unsigned __initdata nr_dev = 0;
228
229 if (nr_dev >= SNDRV_CARDS)
230 return 0;
231 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
232 get_option(&str,&index[nr_dev]) == 2 &&
233 get_id(&str,&id[nr_dev]) == 2 &&
234 get_option(&str,&pcm_channels[nr_dev]) == 2 &&
235 get_option(&str,&wavetable_size[nr_dev]) == 2);
236 nr_dev++;
237 return 1;
238}
239
240__setup("snd-trident=", alsa_card_trident_setup);
241
242#endif /* ifndef MODULE */
Note: See TracBrowser for help on using the repository browser.