wavefront.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * ALSA card-level driver for Turtle Beach Wavefront cards
  4. * (Maui,Tropez,Tropez+)
  5. *
  6. * Copyright (c) 1997-1999 by Paul Barton-Davis <[email protected]>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/err.h>
  11. #include <linux/isa.h>
  12. #include <linux/pnp.h>
  13. #include <linux/module.h>
  14. #include <sound/core.h>
  15. #include <sound/initval.h>
  16. #include <sound/opl3.h>
  17. #include <sound/wss.h>
  18. #include <sound/snd_wavefront.h>
  19. MODULE_AUTHOR("Paul Barton-Davis <[email protected]>");
  20. MODULE_DESCRIPTION("Turtle Beach Wavefront");
  21. MODULE_LICENSE("GPL");
  22. static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
  23. static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
  24. static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
  25. #ifdef CONFIG_PNP
  26. static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
  27. #endif
  28. static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
  29. static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
  30. static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
  31. static int cs4232_mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
  32. static long ics2115_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
  33. static int ics2115_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,9,11,12,15 */
  34. static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
  35. static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
  36. static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
  37. static bool use_cs4232_midi[SNDRV_CARDS];
  38. module_param_array(index, int, NULL, 0444);
  39. MODULE_PARM_DESC(index, "Index value for WaveFront soundcard.");
  40. module_param_array(id, charp, NULL, 0444);
  41. MODULE_PARM_DESC(id, "ID string for WaveFront soundcard.");
  42. module_param_array(enable, bool, NULL, 0444);
  43. MODULE_PARM_DESC(enable, "Enable WaveFront soundcard.");
  44. #ifdef CONFIG_PNP
  45. module_param_array(isapnp, bool, NULL, 0444);
  46. MODULE_PARM_DESC(isapnp, "ISA PnP detection for WaveFront soundcards.");
  47. #endif
  48. module_param_hw_array(cs4232_pcm_port, long, ioport, NULL, 0444);
  49. MODULE_PARM_DESC(cs4232_pcm_port, "Port # for CS4232 PCM interface.");
  50. module_param_hw_array(cs4232_pcm_irq, int, irq, NULL, 0444);
  51. MODULE_PARM_DESC(cs4232_pcm_irq, "IRQ # for CS4232 PCM interface.");
  52. module_param_hw_array(dma1, int, dma, NULL, 0444);
  53. MODULE_PARM_DESC(dma1, "DMA1 # for CS4232 PCM interface.");
  54. module_param_hw_array(dma2, int, dma, NULL, 0444);
  55. MODULE_PARM_DESC(dma2, "DMA2 # for CS4232 PCM interface.");
  56. module_param_hw_array(cs4232_mpu_port, long, ioport, NULL, 0444);
  57. MODULE_PARM_DESC(cs4232_mpu_port, "port # for CS4232 MPU-401 interface.");
  58. module_param_hw_array(cs4232_mpu_irq, int, irq, NULL, 0444);
  59. MODULE_PARM_DESC(cs4232_mpu_irq, "IRQ # for CS4232 MPU-401 interface.");
  60. module_param_hw_array(ics2115_irq, int, irq, NULL, 0444);
  61. MODULE_PARM_DESC(ics2115_irq, "IRQ # for ICS2115.");
  62. module_param_hw_array(ics2115_port, long, ioport, NULL, 0444);
  63. MODULE_PARM_DESC(ics2115_port, "Port # for ICS2115.");
  64. module_param_hw_array(fm_port, long, ioport, NULL, 0444);
  65. MODULE_PARM_DESC(fm_port, "FM port #.");
  66. module_param_array(use_cs4232_midi, bool, NULL, 0444);
  67. MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
  68. #ifdef CONFIG_PNP
  69. static int isa_registered;
  70. static int pnp_registered;
  71. static const struct pnp_card_device_id snd_wavefront_pnpids[] = {
  72. /* Tropez */
  73. { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } },
  74. /* Tropez+ */
  75. { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } },
  76. { .id = "" }
  77. };
  78. MODULE_DEVICE_TABLE(pnp_card, snd_wavefront_pnpids);
  79. static int
  80. snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *card,
  81. const struct pnp_card_device_id *id)
  82. {
  83. struct pnp_dev *pdev;
  84. int err;
  85. /* Check for each logical device. */
  86. /* CS4232 chip (aka "windows sound system") is logical device 0 */
  87. acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
  88. if (acard->wss == NULL)
  89. return -EBUSY;
  90. /* there is a game port at logical device 1, but we ignore it completely */
  91. /* the control interface is logical device 2, but we ignore it
  92. completely. in fact, nobody even seems to know what it
  93. does.
  94. */
  95. /* Only configure the CS4232 MIDI interface if its been
  96. specifically requested. It is logical device 3.
  97. */
  98. if (use_cs4232_midi[dev]) {
  99. acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
  100. if (acard->mpu == NULL)
  101. return -EBUSY;
  102. }
  103. /* The ICS2115 synth is logical device 4 */
  104. acard->synth = pnp_request_card_device(card, id->devs[3].id, NULL);
  105. if (acard->synth == NULL)
  106. return -EBUSY;
  107. /* PCM/FM initialization */
  108. pdev = acard->wss;
  109. /* An interesting note from the Tropez+ FAQ:
  110. Q. [Ports] Why is the base address of the WSS I/O ports off by 4?
  111. A. WSS I/O requires a block of 8 I/O addresses ("ports"). Of these, the first
  112. 4 are used to identify and configure the board. With the advent of PnP,
  113. these first 4 addresses have become obsolete, and software applications
  114. only use the last 4 addresses to control the codec chip. Therefore, the
  115. base address setting "skips past" the 4 unused addresses.
  116. */
  117. err = pnp_activate_dev(pdev);
  118. if (err < 0) {
  119. snd_printk(KERN_ERR "PnP WSS pnp configure failure\n");
  120. return err;
  121. }
  122. cs4232_pcm_port[dev] = pnp_port_start(pdev, 0);
  123. fm_port[dev] = pnp_port_start(pdev, 1);
  124. dma1[dev] = pnp_dma(pdev, 0);
  125. dma2[dev] = pnp_dma(pdev, 1);
  126. cs4232_pcm_irq[dev] = pnp_irq(pdev, 0);
  127. /* Synth initialization */
  128. pdev = acard->synth;
  129. err = pnp_activate_dev(pdev);
  130. if (err < 0) {
  131. snd_printk(KERN_ERR "PnP ICS2115 pnp configure failure\n");
  132. return err;
  133. }
  134. ics2115_port[dev] = pnp_port_start(pdev, 0);
  135. ics2115_irq[dev] = pnp_irq(pdev, 0);
  136. /* CS4232 MPU initialization. Configure this only if
  137. explicitly requested, since its physically inaccessible and
  138. consumes another IRQ.
  139. */
  140. if (use_cs4232_midi[dev]) {
  141. pdev = acard->mpu;
  142. err = pnp_activate_dev(pdev);
  143. if (err < 0) {
  144. snd_printk(KERN_ERR "PnP MPU401 pnp configure failure\n");
  145. cs4232_mpu_port[dev] = SNDRV_AUTO_PORT;
  146. } else {
  147. cs4232_mpu_port[dev] = pnp_port_start(pdev, 0);
  148. cs4232_mpu_irq[dev] = pnp_irq(pdev, 0);
  149. }
  150. snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n",
  151. cs4232_mpu_port[dev],
  152. cs4232_mpu_irq[dev]);
  153. }
  154. snd_printdd ("CS4232: pcm port=0x%lx, fm port=0x%lx, dma1=%i, dma2=%i, irq=%i\nICS2115: port=0x%lx, irq=%i\n",
  155. cs4232_pcm_port[dev],
  156. fm_port[dev],
  157. dma1[dev],
  158. dma2[dev],
  159. cs4232_pcm_irq[dev],
  160. ics2115_port[dev],
  161. ics2115_irq[dev]);
  162. return 0;
  163. }
  164. #endif /* CONFIG_PNP */
  165. static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, void *dev_id)
  166. {
  167. snd_wavefront_card_t *acard;
  168. acard = (snd_wavefront_card_t *) dev_id;
  169. if (acard == NULL)
  170. return IRQ_NONE;
  171. if (acard->wavefront.interrupts_are_midi) {
  172. snd_wavefront_midi_interrupt (acard);
  173. } else {
  174. snd_wavefront_internal_interrupt (acard);
  175. }
  176. return IRQ_HANDLED;
  177. }
  178. static struct snd_hwdep *snd_wavefront_new_synth(struct snd_card *card,
  179. int hw_dev,
  180. snd_wavefront_card_t *acard)
  181. {
  182. struct snd_hwdep *wavefront_synth;
  183. if (snd_wavefront_detect (acard) < 0) {
  184. return NULL;
  185. }
  186. if (snd_wavefront_start (&acard->wavefront) < 0) {
  187. return NULL;
  188. }
  189. if (snd_hwdep_new(card, "WaveFront", hw_dev, &wavefront_synth) < 0)
  190. return NULL;
  191. strcpy (wavefront_synth->name,
  192. "WaveFront (ICS2115) wavetable synthesizer");
  193. wavefront_synth->ops.open = snd_wavefront_synth_open;
  194. wavefront_synth->ops.release = snd_wavefront_synth_release;
  195. wavefront_synth->ops.ioctl = snd_wavefront_synth_ioctl;
  196. return wavefront_synth;
  197. }
  198. static struct snd_hwdep *snd_wavefront_new_fx(struct snd_card *card,
  199. int hw_dev,
  200. snd_wavefront_card_t *acard,
  201. unsigned long port)
  202. {
  203. struct snd_hwdep *fx_processor;
  204. if (snd_wavefront_fx_start (&acard->wavefront)) {
  205. snd_printk (KERN_ERR "cannot initialize YSS225 FX processor");
  206. return NULL;
  207. }
  208. if (snd_hwdep_new (card, "YSS225", hw_dev, &fx_processor) < 0)
  209. return NULL;
  210. sprintf (fx_processor->name, "YSS225 FX Processor at 0x%lx", port);
  211. fx_processor->ops.open = snd_wavefront_fx_open;
  212. fx_processor->ops.release = snd_wavefront_fx_release;
  213. fx_processor->ops.ioctl = snd_wavefront_fx_ioctl;
  214. return fx_processor;
  215. }
  216. static snd_wavefront_mpu_id internal_id = internal_mpu;
  217. static snd_wavefront_mpu_id external_id = external_mpu;
  218. static struct snd_rawmidi *snd_wavefront_new_midi(struct snd_card *card,
  219. int midi_dev,
  220. snd_wavefront_card_t *acard,
  221. unsigned long port,
  222. snd_wavefront_mpu_id mpu)
  223. {
  224. struct snd_rawmidi *rmidi;
  225. static int first = 1;
  226. if (first) {
  227. first = 0;
  228. acard->wavefront.midi.base = port;
  229. if (snd_wavefront_midi_start (acard)) {
  230. snd_printk (KERN_ERR "cannot initialize MIDI interface\n");
  231. return NULL;
  232. }
  233. }
  234. if (snd_rawmidi_new (card, "WaveFront MIDI", midi_dev, 1, 1, &rmidi) < 0)
  235. return NULL;
  236. if (mpu == internal_mpu) {
  237. strcpy(rmidi->name, "WaveFront MIDI (Internal)");
  238. rmidi->private_data = &internal_id;
  239. } else {
  240. strcpy(rmidi->name, "WaveFront MIDI (External)");
  241. rmidi->private_data = &external_id;
  242. }
  243. snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_wavefront_midi_output);
  244. snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_wavefront_midi_input);
  245. rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
  246. SNDRV_RAWMIDI_INFO_INPUT |
  247. SNDRV_RAWMIDI_INFO_DUPLEX;
  248. return rmidi;
  249. }
  250. static int snd_wavefront_card_new(struct device *pdev, int dev,
  251. struct snd_card **cardp)
  252. {
  253. struct snd_card *card;
  254. snd_wavefront_card_t *acard;
  255. int err;
  256. err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
  257. sizeof(snd_wavefront_card_t), &card);
  258. if (err < 0)
  259. return err;
  260. acard = card->private_data;
  261. acard->wavefront.irq = -1;
  262. spin_lock_init(&acard->wavefront.irq_lock);
  263. init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
  264. spin_lock_init(&acard->wavefront.midi.open);
  265. spin_lock_init(&acard->wavefront.midi.virtual);
  266. acard->wavefront.card = card;
  267. *cardp = card;
  268. return 0;
  269. }
  270. static int
  271. snd_wavefront_probe (struct snd_card *card, int dev)
  272. {
  273. snd_wavefront_card_t *acard = card->private_data;
  274. struct snd_wss *chip;
  275. struct snd_hwdep *wavefront_synth;
  276. struct snd_rawmidi *ics2115_internal_rmidi = NULL;
  277. struct snd_rawmidi *ics2115_external_rmidi = NULL;
  278. struct snd_hwdep *fx_processor;
  279. int hw_dev = 0, midi_dev = 0, err;
  280. /* --------- PCM --------------- */
  281. err = snd_wss_create(card, cs4232_pcm_port[dev], -1,
  282. cs4232_pcm_irq[dev], dma1[dev], dma2[dev],
  283. WSS_HW_DETECT, 0, &chip);
  284. if (err < 0) {
  285. snd_printk(KERN_ERR "can't allocate WSS device\n");
  286. return err;
  287. }
  288. err = snd_wss_pcm(chip, 0);
  289. if (err < 0)
  290. return err;
  291. err = snd_wss_timer(chip, 0);
  292. if (err < 0)
  293. return err;
  294. /* ---------- OPL3 synth --------- */
  295. if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
  296. struct snd_opl3 *opl3;
  297. err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
  298. OPL3_HW_OPL3_CS, 0, &opl3);
  299. if (err < 0) {
  300. snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n");
  301. return err;
  302. }
  303. err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL);
  304. if (err < 0)
  305. return err;
  306. hw_dev++;
  307. }
  308. /* ------- ICS2115 Wavetable synth ------- */
  309. acard->wavefront.res_base =
  310. devm_request_region(card->dev, ics2115_port[dev], 16,
  311. "ICS2115");
  312. if (acard->wavefront.res_base == NULL) {
  313. snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
  314. ics2115_port[dev], ics2115_port[dev] + 16 - 1);
  315. return -EBUSY;
  316. }
  317. if (devm_request_irq(card->dev, ics2115_irq[dev],
  318. snd_wavefront_ics2115_interrupt,
  319. 0, "ICS2115", acard)) {
  320. snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
  321. return -EBUSY;
  322. }
  323. acard->wavefront.irq = ics2115_irq[dev];
  324. card->sync_irq = acard->wavefront.irq;
  325. acard->wavefront.base = ics2115_port[dev];
  326. wavefront_synth = snd_wavefront_new_synth(card, hw_dev, acard);
  327. if (wavefront_synth == NULL) {
  328. snd_printk (KERN_ERR "can't create WaveFront synth device\n");
  329. return -ENOMEM;
  330. }
  331. strcpy (wavefront_synth->name, "ICS2115 Wavetable MIDI Synthesizer");
  332. wavefront_synth->iface = SNDRV_HWDEP_IFACE_ICS2115;
  333. hw_dev++;
  334. /* --------- Mixer ------------ */
  335. err = snd_wss_mixer(chip);
  336. if (err < 0) {
  337. snd_printk (KERN_ERR "can't allocate mixer device\n");
  338. return err;
  339. }
  340. /* -------- CS4232 MPU-401 interface -------- */
  341. if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
  342. err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
  343. cs4232_mpu_port[dev], 0,
  344. cs4232_mpu_irq[dev], NULL);
  345. if (err < 0) {
  346. snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n");
  347. return err;
  348. }
  349. midi_dev++;
  350. }
  351. /* ------ ICS2115 internal MIDI ------------ */
  352. if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
  353. ics2115_internal_rmidi =
  354. snd_wavefront_new_midi (card,
  355. midi_dev,
  356. acard,
  357. ics2115_port[dev],
  358. internal_mpu);
  359. if (ics2115_internal_rmidi == NULL) {
  360. snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n");
  361. return -ENOMEM;
  362. }
  363. midi_dev++;
  364. }
  365. /* ------ ICS2115 external MIDI ------------ */
  366. if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
  367. ics2115_external_rmidi =
  368. snd_wavefront_new_midi (card,
  369. midi_dev,
  370. acard,
  371. ics2115_port[dev],
  372. external_mpu);
  373. if (ics2115_external_rmidi == NULL) {
  374. snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n");
  375. return -ENOMEM;
  376. }
  377. midi_dev++;
  378. }
  379. /* FX processor for Tropez+ */
  380. if (acard->wavefront.has_fx) {
  381. fx_processor = snd_wavefront_new_fx (card,
  382. hw_dev,
  383. acard,
  384. ics2115_port[dev]);
  385. if (fx_processor == NULL) {
  386. snd_printk (KERN_ERR "can't setup FX device\n");
  387. return -ENOMEM;
  388. }
  389. hw_dev++;
  390. strcpy(card->driver, "Tropez+");
  391. strcpy(card->shortname, "Turtle Beach Tropez+");
  392. } else {
  393. /* Need a way to distinguish between Maui and Tropez */
  394. strcpy(card->driver, "WaveFront");
  395. strcpy(card->shortname, "Turtle Beach WaveFront");
  396. }
  397. /* ----- Register the card --------- */
  398. /* Not safe to include "Turtle Beach" in longname, due to
  399. length restrictions
  400. */
  401. sprintf(card->longname, "%s PCM 0x%lx irq %d dma %d",
  402. card->driver,
  403. chip->port,
  404. cs4232_pcm_irq[dev],
  405. dma1[dev]);
  406. if (dma2[dev] >= 0 && dma2[dev] < 8)
  407. sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
  408. if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
  409. sprintf (card->longname + strlen (card->longname),
  410. " MPU-401 0x%lx irq %d",
  411. cs4232_mpu_port[dev],
  412. cs4232_mpu_irq[dev]);
  413. }
  414. sprintf (card->longname + strlen (card->longname),
  415. " SYNTH 0x%lx irq %d",
  416. ics2115_port[dev],
  417. ics2115_irq[dev]);
  418. return snd_card_register(card);
  419. }
  420. static int snd_wavefront_isa_match(struct device *pdev,
  421. unsigned int dev)
  422. {
  423. if (!enable[dev])
  424. return 0;
  425. #ifdef CONFIG_PNP
  426. if (isapnp[dev])
  427. return 0;
  428. #endif
  429. if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
  430. snd_printk(KERN_ERR "specify CS4232 port\n");
  431. return 0;
  432. }
  433. if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
  434. snd_printk(KERN_ERR "specify ICS2115 port\n");
  435. return 0;
  436. }
  437. return 1;
  438. }
  439. static int snd_wavefront_isa_probe(struct device *pdev,
  440. unsigned int dev)
  441. {
  442. struct snd_card *card;
  443. int err;
  444. err = snd_wavefront_card_new(pdev, dev, &card);
  445. if (err < 0)
  446. return err;
  447. err = snd_wavefront_probe(card, dev);
  448. if (err < 0)
  449. return err;
  450. dev_set_drvdata(pdev, card);
  451. return 0;
  452. }
  453. #define DEV_NAME "wavefront"
  454. static struct isa_driver snd_wavefront_driver = {
  455. .match = snd_wavefront_isa_match,
  456. .probe = snd_wavefront_isa_probe,
  457. /* FIXME: suspend, resume */
  458. .driver = {
  459. .name = DEV_NAME
  460. },
  461. };
  462. #ifdef CONFIG_PNP
  463. static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
  464. const struct pnp_card_device_id *pid)
  465. {
  466. static int dev;
  467. struct snd_card *card;
  468. int res;
  469. for ( ; dev < SNDRV_CARDS; dev++) {
  470. if (enable[dev] && isapnp[dev])
  471. break;
  472. }
  473. if (dev >= SNDRV_CARDS)
  474. return -ENODEV;
  475. res = snd_wavefront_card_new(&pcard->card->dev, dev, &card);
  476. if (res < 0)
  477. return res;
  478. if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
  479. if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
  480. snd_printk (KERN_ERR "isapnp detection failed\n");
  481. return -ENODEV;
  482. }
  483. }
  484. res = snd_wavefront_probe(card, dev);
  485. if (res < 0)
  486. return res;
  487. pnp_set_card_drvdata(pcard, card);
  488. dev++;
  489. return 0;
  490. }
  491. static struct pnp_card_driver wavefront_pnpc_driver = {
  492. .flags = PNP_DRIVER_RES_DISABLE,
  493. .name = "wavefront",
  494. .id_table = snd_wavefront_pnpids,
  495. .probe = snd_wavefront_pnp_detect,
  496. /* FIXME: suspend,resume */
  497. };
  498. #endif /* CONFIG_PNP */
  499. static int __init alsa_card_wavefront_init(void)
  500. {
  501. int err;
  502. err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
  503. #ifdef CONFIG_PNP
  504. if (!err)
  505. isa_registered = 1;
  506. err = pnp_register_card_driver(&wavefront_pnpc_driver);
  507. if (!err)
  508. pnp_registered = 1;
  509. if (isa_registered)
  510. err = 0;
  511. #endif
  512. return err;
  513. }
  514. static void __exit alsa_card_wavefront_exit(void)
  515. {
  516. #ifdef CONFIG_PNP
  517. if (pnp_registered)
  518. pnp_unregister_card_driver(&wavefront_pnpc_driver);
  519. if (isa_registered)
  520. #endif
  521. isa_unregister_driver(&snd_wavefront_driver);
  522. }
  523. module_init(alsa_card_wavefront_init)
  524. module_exit(alsa_card_wavefront_exit)