blob: cedf13b64803acd167c704a2281ba340ffb1e044 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/init.h>
25#include <linux/pci.h>
26#include <linux/time.h>
Paul Gortmaker65a77212011-07-15 13:13:37 -040027#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <sound/core.h>
Takashi Iwai81fcb172012-07-02 16:37:05 +020029#include "trident.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <sound/initval.h>
31
Jaroslav Kyselac1017a42007-10-15 09:50:19 +020032MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>");
Linus Torvalds1da177e2005-04-16 15:20:36 -070033MODULE_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; /* Index 0-MAX */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
Rusty Russella67ff6a2011-12-15 13:49:36 +103050static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static 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
Benoit Taine9baa3c32014-08-08 15:56:03 +020065static const struct pci_device_id snd_trident_ids[] = {
Jon Masone3183ec2006-01-13 13:14:53 +010066 {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},
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 { 0, }
72};
73
74MODULE_DEVICE_TABLE(pci, snd_trident_ids);
75
Bill Pembertone23e7a12012-12-06 12:35:10 -050076static int snd_trident_probe(struct pci_dev *pci,
77 const struct pci_device_id *pci_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
79 static int dev;
Takashi Iwaibee1a5b2005-11-17 14:53:15 +010080 struct snd_card *card;
81 struct snd_trident *trident;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 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
Takashi Iwai60c57722014-01-29 14:20:19 +010092 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
93 0, &card);
Takashi Iwaie58de7b2008-12-28 16:44:30 +010094 if (err < 0)
95 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 if ((err = snd_trident_create(card, pci,
98 pcm_channels[dev],
99 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
100 wavetable_size[dev],
101 &trident)) < 0) {
102 snd_card_free(card);
103 return err;
104 }
Takashi Iwaifb0700b2005-11-17 16:09:25 +0100105 card->private_data = trident;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107 switch (trident->device) {
108 case TRIDENT_DEVICE_ID_DX:
109 str = "TRID4DWAVEDX";
110 break;
111 case TRIDENT_DEVICE_ID_NX:
112 str = "TRID4DWAVENX";
113 break;
114 case TRIDENT_DEVICE_ID_SI7018:
115 str = "SI7018";
116 break;
117 default:
118 str = "Unknown";
119 }
120 strcpy(card->driver, str);
121 if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
122 strcpy(card->shortname, "SiS ");
123 } else {
124 strcpy(card->shortname, "Trident ");
125 }
126 strcat(card->shortname, card->driver);
127 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
128 card->shortname, trident->port, trident->irq);
129
Lars-Peter Clausen1b164162015-01-02 12:24:54 +0100130 if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 snd_card_free(card);
132 return err;
133 }
134 switch (trident->device) {
135 case TRIDENT_DEVICE_ID_DX:
136 case TRIDENT_DEVICE_ID_NX:
Lars-Peter Clausen1b164162015-01-02 12:24:54 +0100137 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 snd_card_free(card);
139 return err;
140 }
141 break;
142 }
143 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
Lars-Peter Clausen1b164162015-01-02 12:24:54 +0100144 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 snd_card_free(card);
146 return err;
147 }
148 }
Takashi Iwai1ccc67d2005-06-08 14:49:31 +0200149 if (trident->device != TRIDENT_DEVICE_ID_SI7018 &&
150 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
Takashi Iwai302e4c22006-05-23 13:24:30 +0200151 trident->midi_port,
Clemens Ladischdba8b462011-09-13 11:24:41 +0200152 MPU401_INFO_INTEGRATED |
153 MPU401_INFO_IRQ_HOOK,
154 -1, &trident->rmidi)) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 snd_card_free(card);
156 return err;
157 }
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 snd_trident_create_gameport(trident);
160
161 if ((err = snd_card_register(card)) < 0) {
162 snd_card_free(card);
163 return err;
164 }
165 pci_set_drvdata(pci, card);
166 dev++;
167 return 0;
168}
169
Bill Pembertone23e7a12012-12-06 12:35:10 -0500170static void snd_trident_remove(struct pci_dev *pci)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
172 snd_card_free(pci_get_drvdata(pci));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173}
174
Takashi Iwaie9f66d92012-04-24 12:25:00 +0200175static struct pci_driver trident_driver = {
Takashi Iwai3733e422011-06-10 16:20:20 +0200176 .name = KBUILD_MODNAME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 .id_table = snd_trident_ids,
178 .probe = snd_trident_probe,
Bill Pembertone23e7a12012-12-06 12:35:10 -0500179 .remove = snd_trident_remove,
Takashi Iwaic7561cd2012-08-14 18:12:04 +0200180#ifdef CONFIG_PM_SLEEP
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200181 .driver = {
182 .pm = &snd_trident_pm,
183 },
Takashi Iwaifb0700b2005-11-17 16:09:25 +0100184#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185};
186
Takashi Iwaie9f66d92012-04-24 12:25:00 +0200187module_pci_driver(trident_driver);