aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/trident/trident.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/pci/trident/trident.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'sound/pci/trident/trident.c')
-rw-r--r--sound/pci/trident/trident.c196
1 files changed, 196 insertions, 0 deletions
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
new file mode 100644
index 000000000000..ad58e08d66e2
--- /dev/null
+++ b/sound/pci/trident/trident.c
@@ -0,0 +1,196 @@
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 <linux/moduleparam.h>
29#include <sound/core.h>
30#include <sound/trident.h>
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_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
37 "{Trident,4DWave NX},"
38 "{SiS,SI7018 PCI Audio},"
39 "{Best Union,Miss Melody 4DWave PCI},"
40 "{HIS,4DWave PCI},"
41 "{Warpspeed,ONSpeed 4DWave PCI},"
42 "{Aztech Systems,PCI 64-Q3D},"
43 "{Addonics,SV 750},"
44 "{CHIC,True Sound 4Dwave},"
45 "{Shark,Predator4D-PCI},"
46 "{Jaton,SonicWave 4D},"
47 "{Hoontech,SoundTrack Digital 4DWave NX}}");
48
49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
52static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
53static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
54
55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
57module_param_array(id, charp, NULL, 0444);
58MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
59module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
61module_param_array(pcm_channels, int, NULL, 0444);
62MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
63module_param_array(wavetable_size, int, NULL, 0444);
64MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
65
66static struct pci_device_id snd_trident_ids[] = {
67 { 0x1023, 0x2000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave DX PCI Audio */
68 { 0x1023, 0x2001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave NX PCI Audio */
69 { 0x1039, 0x7018, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* SiS SI7018 PCI Audio */
70 { 0, }
71};
72
73MODULE_DEVICE_TABLE(pci, snd_trident_ids);
74
75static int __devinit snd_trident_probe(struct pci_dev *pci,
76 const struct pci_device_id *pci_id)
77{
78 static int dev;
79 snd_card_t *card;
80 trident_t *trident;
81 const char *str;
82 int err, pcm_dev = 0;
83
84 if (dev >= SNDRV_CARDS)
85 return -ENODEV;
86 if (!enable[dev]) {
87 dev++;
88 return -ENOENT;
89 }
90
91 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
92 if (card == NULL)
93 return -ENOMEM;
94
95 if ((err = snd_trident_create(card, pci,
96 pcm_channels[dev],
97 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
98 wavetable_size[dev],
99 &trident)) < 0) {
100 snd_card_free(card);
101 return err;
102 }
103
104 switch (trident->device) {
105 case TRIDENT_DEVICE_ID_DX:
106 str = "TRID4DWAVEDX";
107 break;
108 case TRIDENT_DEVICE_ID_NX:
109 str = "TRID4DWAVENX";
110 break;
111 case TRIDENT_DEVICE_ID_SI7018:
112 str = "SI7018";
113 break;
114 default:
115 str = "Unknown";
116 }
117 strcpy(card->driver, str);
118 if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
119 strcpy(card->shortname, "SiS ");
120 } else {
121 strcpy(card->shortname, "Trident ");
122 }
123 strcat(card->shortname, card->driver);
124 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
125 card->shortname, trident->port, trident->irq);
126
127 if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) {
128 snd_card_free(card);
129 return err;
130 }
131 switch (trident->device) {
132 case TRIDENT_DEVICE_ID_DX:
133 case TRIDENT_DEVICE_ID_NX:
134 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) {
135 snd_card_free(card);
136 return err;
137 }
138 break;
139 }
140 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
141 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) {
142 snd_card_free(card);
143 return err;
144 }
145 }
146 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
147 trident->midi_port, 1,
148 trident->irq, 0, &trident->rmidi)) < 0) {
149 snd_card_free(card);
150 return err;
151 }
152
153#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
154 if ((err = snd_trident_attach_synthesizer(trident)) < 0) {
155 snd_card_free(card);
156 return err;
157 }
158#endif
159
160 snd_trident_create_gameport(trident);
161
162 if ((err = snd_card_register(card)) < 0) {
163 snd_card_free(card);
164 return err;
165 }
166 pci_set_drvdata(pci, card);
167 dev++;
168 return 0;
169}
170
171static void __devexit snd_trident_remove(struct pci_dev *pci)
172{
173 snd_card_free(pci_get_drvdata(pci));
174 pci_set_drvdata(pci, NULL);
175}
176
177static struct pci_driver driver = {
178 .name = "Trident4DWaveAudio",
179 .id_table = snd_trident_ids,
180 .probe = snd_trident_probe,
181 .remove = __devexit_p(snd_trident_remove),
182 SND_PCI_PM_CALLBACKS
183};
184
185static int __init alsa_card_trident_init(void)
186{
187 return pci_module_init(&driver);
188}
189
190static void __exit alsa_card_trident_exit(void)
191{
192 pci_unregister_driver(&driver);
193}
194
195module_init(alsa_card_trident_init)
196module_exit(alsa_card_trident_exit)