Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/init.h> |
| 25 | #include <linux/pci.h> |
| 26 | #include <linux/time.h> |
| 27 | #include <linux/moduleparam.h> |
| 28 | #include <sound/core.h> |
| 29 | #include <sound/trident.h> |
| 30 | #include <sound/initval.h> |
| 31 | |
Jaroslav Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 32 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018"); |
| 34 | MODULE_LICENSE("GPL"); |
| 35 | MODULE_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 | |
| 48 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 49 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 50 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ |
| 51 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; |
| 52 | static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192}; |
| 53 | |
| 54 | module_param_array(index, int, NULL, 0444); |
| 55 | MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard."); |
| 56 | module_param_array(id, charp, NULL, 0444); |
| 57 | MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard."); |
| 58 | module_param_array(enable, bool, NULL, 0444); |
| 59 | MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard."); |
| 60 | module_param_array(pcm_channels, int, NULL, 0444); |
| 61 | MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM."); |
| 62 | module_param_array(wavetable_size, int, NULL, 0444); |
| 63 | MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); |
| 64 | |
Takashi Iwai | f40b689 | 2006-07-05 16:51:05 +0200 | [diff] [blame] | 65 | static struct pci_device_id snd_trident_ids[] = { |
Jon Mason | e3183ec | 2006-01-13 13:14:53 +0100 | [diff] [blame] | 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}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { 0, } |
| 72 | }; |
| 73 | |
| 74 | MODULE_DEVICE_TABLE(pci, snd_trident_ids); |
| 75 | |
| 76 | static int __devinit snd_trident_probe(struct pci_dev *pci, |
| 77 | const struct pci_device_id *pci_id) |
| 78 | { |
| 79 | static int dev; |
Takashi Iwai | bee1a5b | 2005-11-17 14:53:15 +0100 | [diff] [blame] | 80 | struct snd_card *card; |
| 81 | struct snd_trident *trident; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); |
| 93 | if (card == NULL) |
| 94 | return -ENOMEM; |
| 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 | } |
Takashi Iwai | fb0700b | 2005-11-17 16:09:25 +0100 | [diff] [blame] | 104 | card->private_data = trident; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | } |
Takashi Iwai | 1ccc67d | 2005-06-08 14:49:31 +0200 | [diff] [blame] | 148 | if (trident->device != TRIDENT_DEVICE_ID_SI7018 && |
| 149 | (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, |
Takashi Iwai | 302e4c2 | 2006-05-23 13:24:30 +0200 | [diff] [blame] | 150 | trident->midi_port, |
| 151 | MPU401_INFO_INTEGRATED, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | trident->irq, 0, &trident->rmidi)) < 0) { |
| 153 | snd_card_free(card); |
| 154 | return err; |
| 155 | } |
| 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | snd_trident_create_gameport(trident); |
| 158 | |
| 159 | if ((err = snd_card_register(card)) < 0) { |
| 160 | snd_card_free(card); |
| 161 | return err; |
| 162 | } |
| 163 | pci_set_drvdata(pci, card); |
| 164 | dev++; |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static void __devexit snd_trident_remove(struct pci_dev *pci) |
| 169 | { |
| 170 | snd_card_free(pci_get_drvdata(pci)); |
| 171 | pci_set_drvdata(pci, NULL); |
| 172 | } |
| 173 | |
| 174 | static struct pci_driver driver = { |
| 175 | .name = "Trident4DWaveAudio", |
| 176 | .id_table = snd_trident_ids, |
| 177 | .probe = snd_trident_probe, |
| 178 | .remove = __devexit_p(snd_trident_remove), |
Takashi Iwai | fb0700b | 2005-11-17 16:09:25 +0100 | [diff] [blame] | 179 | #ifdef CONFIG_PM |
| 180 | .suspend = snd_trident_suspend, |
| 181 | .resume = snd_trident_resume, |
| 182 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | static int __init alsa_card_trident_init(void) |
| 186 | { |
Takashi Iwai | 01d25d4 | 2005-04-11 16:58:24 +0200 | [diff] [blame] | 187 | return pci_register_driver(&driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | static void __exit alsa_card_trident_exit(void) |
| 191 | { |
| 192 | pci_unregister_driver(&driver); |
| 193 | } |
| 194 | |
| 195 | module_init(alsa_card_trident_init) |
| 196 | module_exit(alsa_card_trident_exit) |