trident.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. #include <sound/driver.h>
  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. MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, <audio@tridentmicro.com>");
  32. MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
  33. MODULE_LICENSE("GPL");
  34. MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
  35. "{Trident,4DWave NX},"
  36. "{SiS,SI7018 PCI Audio},"
  37. "{Best Union,Miss Melody 4DWave PCI},"
  38. "{HIS,4DWave PCI},"
  39. "{Warpspeed,ONSpeed 4DWave PCI},"
  40. "{Aztech Systems,PCI 64-Q3D},"
  41. "{Addonics,SV 750},"
  42. "{CHIC,True Sound 4Dwave},"
  43. "{Shark,Predator4D-PCI},"
  44. "{Jaton,SonicWave 4D},"
  45. "{Hoontech,SoundTrack Digital 4DWave NX}}");
  46. static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
  47. static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
  48. static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
  49. static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
  50. static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
  51. module_param_array(index, int, NULL, 0444);
  52. MODULE_PARM_DESC(index, "Index value for Trident 4DWave PCI soundcard.");
  53. module_param_array(id, charp, NULL, 0444);
  54. MODULE_PARM_DESC(id, "ID string for Trident 4DWave PCI soundcard.");
  55. module_param_array(enable, bool, NULL, 0444);
  56. MODULE_PARM_DESC(enable, "Enable Trident 4DWave PCI soundcard.");
  57. module_param_array(pcm_channels, int, NULL, 0444);
  58. MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM.");
  59. module_param_array(wavetable_size, int, NULL, 0444);
  60. MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
  61. static struct pci_device_id snd_trident_ids[] = {
  62. {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX),
  63. PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0},
  64. {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX),
  65. 0, 0, 0},
  66. {PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7018), 0, 0, 0},
  67. { 0, }
  68. };
  69. MODULE_DEVICE_TABLE(pci, snd_trident_ids);
  70. static int __devinit snd_trident_probe(struct pci_dev *pci,
  71. const struct pci_device_id *pci_id)
  72. {
  73. static int dev;
  74. struct snd_card *card;
  75. struct snd_trident *trident;
  76. const char *str;
  77. int err, pcm_dev = 0;
  78. if (dev >= SNDRV_CARDS)
  79. return -ENODEV;
  80. if (!enable[dev]) {
  81. dev++;
  82. return -ENOENT;
  83. }
  84. card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
  85. if (card == NULL)
  86. return -ENOMEM;
  87. if ((err = snd_trident_create(card, pci,
  88. pcm_channels[dev],
  89. ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2,
  90. wavetable_size[dev],
  91. &trident)) < 0) {
  92. snd_card_free(card);
  93. return err;
  94. }
  95. card->private_data = trident;
  96. switch (trident->device) {
  97. case TRIDENT_DEVICE_ID_DX:
  98. str = "TRID4DWAVEDX";
  99. break;
  100. case TRIDENT_DEVICE_ID_NX:
  101. str = "TRID4DWAVENX";
  102. break;
  103. case TRIDENT_DEVICE_ID_SI7018:
  104. str = "SI7018";
  105. break;
  106. default:
  107. str = "Unknown";
  108. }
  109. strcpy(card->driver, str);
  110. if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
  111. strcpy(card->shortname, "SiS ");
  112. } else {
  113. strcpy(card->shortname, "Trident ");
  114. }
  115. strcat(card->shortname, card->driver);
  116. sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
  117. card->shortname, trident->port, trident->irq);
  118. if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) {
  119. snd_card_free(card);
  120. return err;
  121. }
  122. switch (trident->device) {
  123. case TRIDENT_DEVICE_ID_DX:
  124. case TRIDENT_DEVICE_ID_NX:
  125. if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) {
  126. snd_card_free(card);
  127. return err;
  128. }
  129. break;
  130. }
  131. if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) {
  132. if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) {
  133. snd_card_free(card);
  134. return err;
  135. }
  136. }
  137. if (trident->device != TRIDENT_DEVICE_ID_SI7018 &&
  138. (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
  139. trident->midi_port,
  140. MPU401_INFO_INTEGRATED,
  141. trident->irq, 0, &trident->rmidi)) < 0) {
  142. snd_card_free(card);
  143. return err;
  144. }
  145. #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
  146. if ((err = snd_trident_attach_synthesizer(trident)) < 0) {
  147. snd_card_free(card);
  148. return err;
  149. }
  150. #endif
  151. snd_trident_create_gameport(trident);
  152. if ((err = snd_card_register(card)) < 0) {
  153. snd_card_free(card);
  154. return err;
  155. }
  156. pci_set_drvdata(pci, card);
  157. dev++;
  158. return 0;
  159. }
  160. static void __devexit snd_trident_remove(struct pci_dev *pci)
  161. {
  162. snd_card_free(pci_get_drvdata(pci));
  163. pci_set_drvdata(pci, NULL);
  164. }
  165. static struct pci_driver driver = {
  166. .name = "Trident4DWaveAudio",
  167. .id_table = snd_trident_ids,
  168. .probe = snd_trident_probe,
  169. .remove = __devexit_p(snd_trident_remove),
  170. #ifdef CONFIG_PM
  171. .suspend = snd_trident_suspend,
  172. .resume = snd_trident_resume,
  173. #endif
  174. };
  175. static int __init alsa_card_trident_init(void)
  176. {
  177. return pci_register_driver(&driver);
  178. }
  179. static void __exit alsa_card_trident_exit(void)
  180. {
  181. pci_unregister_driver(&driver);
  182. }
  183. module_init(alsa_card_trident_init)
  184. module_exit(alsa_card_trident_exit)