wavefront.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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 <pbd@op.net>
  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 <pbd@op.net>");
  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. dev_err(&pdev->dev, "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. dev_err(&pdev->dev, "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. dev_err(&pdev->dev, "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. dev_info(&pdev->dev, "CS4232 MPU: port=0x%lx, irq=%i\n",
  151. cs4232_mpu_port[dev],
  152. cs4232_mpu_irq[dev]);
  153. }
  154. dev_dbg(&pdev->dev,
  155. "CS4232: pcm port=0x%lx, fm port=0x%lx, dma1=%i, dma2=%i, irq=%i\nICS2115: port=0x%lx, irq=%i\n",
  156. cs4232_pcm_port[dev],
  157. fm_port[dev],
  158. dma1[dev],
  159. dma2[dev],
  160. cs4232_pcm_irq[dev],
  161. ics2115_port[dev],
  162. ics2115_irq[dev]);
  163. return 0;
  164. }
  165. #endif /* CONFIG_PNP */
  166. static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, void *dev_id)
  167. {
  168. snd_wavefront_card_t *acard;
  169. acard = (snd_wavefront_card_t *) dev_id;
  170. if (acard == NULL)
  171. return IRQ_NONE;
  172. if (acard->wavefront.interrupts_are_midi) {
  173. snd_wavefront_midi_interrupt (acard);
  174. } else {
  175. snd_wavefront_internal_interrupt (acard);
  176. }
  177. return IRQ_HANDLED;
  178. }
  179. static struct snd_hwdep *snd_wavefront_new_synth(struct snd_card *card,
  180. int hw_dev,
  181. snd_wavefront_card_t *acard)
  182. {
  183. struct snd_hwdep *wavefront_synth;
  184. if (snd_wavefront_detect (acard) < 0) {
  185. return NULL;
  186. }
  187. if (snd_wavefront_start (&acard->wavefront) < 0) {
  188. return NULL;
  189. }
  190. if (snd_hwdep_new(card, "WaveFront", hw_dev, &wavefront_synth) < 0)
  191. return NULL;
  192. strscpy (wavefront_synth->name,
  193. "WaveFront (ICS2115) wavetable synthesizer");
  194. wavefront_synth->ops.open = snd_wavefront_synth_open;
  195. wavefront_synth->ops.release = snd_wavefront_synth_release;
  196. wavefront_synth->ops.ioctl = snd_wavefront_synth_ioctl;
  197. return wavefront_synth;
  198. }
  199. static struct snd_hwdep *snd_wavefront_new_fx(struct snd_card *card,
  200. int hw_dev,
  201. snd_wavefront_card_t *acard,
  202. unsigned long port)
  203. {
  204. struct snd_hwdep *fx_processor;
  205. if (snd_wavefront_fx_start (&acard->wavefront)) {
  206. dev_err(card->dev, "cannot initialize YSS225 FX processor");
  207. return NULL;
  208. }
  209. if (snd_hwdep_new (card, "YSS225", hw_dev, &fx_processor) < 0)
  210. return NULL;
  211. sprintf (fx_processor->name, "YSS225 FX Processor at 0x%lx", port);
  212. fx_processor->ops.open = snd_wavefront_fx_open;
  213. fx_processor->ops.release = snd_wavefront_fx_release;
  214. fx_processor->ops.ioctl = snd_wavefront_fx_ioctl;
  215. return fx_processor;
  216. }
  217. static snd_wavefront_mpu_id internal_id = internal_mpu;
  218. static snd_wavefront_mpu_id external_id = external_mpu;
  219. static struct snd_rawmidi *snd_wavefront_new_midi(struct snd_card *card,
  220. int midi_dev,
  221. snd_wavefront_card_t *acard,
  222. unsigned long port,
  223. snd_wavefront_mpu_id mpu)
  224. {
  225. struct snd_rawmidi *rmidi;
  226. static int first = 1;
  227. if (first) {
  228. first = 0;
  229. acard->wavefront.midi.base = port;
  230. if (snd_wavefront_midi_start (acard)) {
  231. dev_err(card->dev, "cannot initialize MIDI interface\n");
  232. return NULL;
  233. }
  234. }
  235. if (snd_rawmidi_new (card, "WaveFront MIDI", midi_dev, 1, 1, &rmidi) < 0)
  236. return NULL;
  237. if (mpu == internal_mpu) {
  238. strscpy(rmidi->name, "WaveFront MIDI (Internal)");
  239. rmidi->private_data = &internal_id;
  240. } else {
  241. strscpy(rmidi->name, "WaveFront MIDI (External)");
  242. rmidi->private_data = &external_id;
  243. }
  244. snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_wavefront_midi_output);
  245. snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_wavefront_midi_input);
  246. rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
  247. SNDRV_RAWMIDI_INFO_INPUT |
  248. SNDRV_RAWMIDI_INFO_DUPLEX;
  249. return rmidi;
  250. }
  251. static int snd_wavefront_card_new(struct device *pdev, int dev,
  252. struct snd_card **cardp)
  253. {
  254. struct snd_card *card;
  255. snd_wavefront_card_t *acard;
  256. int err;
  257. err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
  258. sizeof(snd_wavefront_card_t), &card);
  259. if (err < 0)
  260. return err;
  261. acard = card->private_data;
  262. acard->wavefront.irq = -1;
  263. spin_lock_init(&acard->wavefront.irq_lock);
  264. init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
  265. spin_lock_init(&acard->wavefront.midi.open);
  266. spin_lock_init(&acard->wavefront.midi.virtual);
  267. acard->wavefront.card = card;
  268. *cardp = card;
  269. return 0;
  270. }
  271. static int
  272. snd_wavefront_probe (struct snd_card *card, int dev)
  273. {
  274. snd_wavefront_card_t *acard = card->private_data;
  275. struct snd_wss *chip;
  276. struct snd_hwdep *wavefront_synth;
  277. struct snd_rawmidi *ics2115_internal_rmidi = NULL;
  278. struct snd_rawmidi *ics2115_external_rmidi = NULL;
  279. struct snd_hwdep *fx_processor;
  280. int hw_dev = 0, midi_dev = 0, err;
  281. /* --------- PCM --------------- */
  282. err = snd_wss_create(card, cs4232_pcm_port[dev], -1,
  283. cs4232_pcm_irq[dev], dma1[dev], dma2[dev],
  284. WSS_HW_DETECT, 0, &chip);
  285. if (err < 0) {
  286. dev_err(card->dev, "can't allocate WSS device\n");
  287. return err;
  288. }
  289. err = snd_wss_pcm(chip, 0);
  290. if (err < 0)
  291. return err;
  292. err = snd_wss_timer(chip, 0);
  293. if (err < 0)
  294. return err;
  295. /* ---------- OPL3 synth --------- */
  296. if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
  297. struct snd_opl3 *opl3;
  298. err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
  299. OPL3_HW_OPL3_CS, 0, &opl3);
  300. if (err < 0) {
  301. dev_err(card->dev, "can't allocate or detect OPL3 synth\n");
  302. return err;
  303. }
  304. err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL);
  305. if (err < 0)
  306. return err;
  307. hw_dev++;
  308. }
  309. /* ------- ICS2115 Wavetable synth ------- */
  310. acard->wavefront.res_base =
  311. devm_request_region(card->dev, ics2115_port[dev], 16,
  312. "ICS2115");
  313. if (acard->wavefront.res_base == NULL) {
  314. dev_err(card->dev, "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
  315. ics2115_port[dev], ics2115_port[dev] + 16 - 1);
  316. return -EBUSY;
  317. }
  318. if (devm_request_irq(card->dev, ics2115_irq[dev],
  319. snd_wavefront_ics2115_interrupt,
  320. 0, "ICS2115", acard)) {
  321. dev_err(card->dev, "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
  322. return -EBUSY;
  323. }
  324. acard->wavefront.irq = ics2115_irq[dev];
  325. card->sync_irq = acard->wavefront.irq;
  326. acard->wavefront.base = ics2115_port[dev];
  327. wavefront_synth = snd_wavefront_new_synth(card, hw_dev, acard);
  328. if (wavefront_synth == NULL) {
  329. dev_err(card->dev, "can't create WaveFront synth device\n");
  330. return -ENOMEM;
  331. }
  332. strscpy (wavefront_synth->name, "ICS2115 Wavetable MIDI Synthesizer");
  333. wavefront_synth->iface = SNDRV_HWDEP_IFACE_ICS2115;
  334. hw_dev++;
  335. /* --------- Mixer ------------ */
  336. err = snd_wss_mixer(chip);
  337. if (err < 0) {
  338. dev_err(card->dev, "can't allocate mixer device\n");
  339. return err;
  340. }
  341. /* -------- CS4232 MPU-401 interface -------- */
  342. if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
  343. err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
  344. cs4232_mpu_port[dev], 0,
  345. cs4232_mpu_irq[dev], NULL);
  346. if (err < 0) {
  347. dev_err(card->dev, "can't allocate CS4232 MPU-401 device\n");
  348. return err;
  349. }
  350. midi_dev++;
  351. }
  352. /* ------ ICS2115 internal MIDI ------------ */
  353. if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
  354. ics2115_internal_rmidi =
  355. snd_wavefront_new_midi (card,
  356. midi_dev,
  357. acard,
  358. ics2115_port[dev],
  359. internal_mpu);
  360. if (ics2115_internal_rmidi == NULL) {
  361. dev_err(card->dev, "can't setup ICS2115 internal MIDI device\n");
  362. return -ENOMEM;
  363. }
  364. midi_dev++;
  365. }
  366. /* ------ ICS2115 external MIDI ------------ */
  367. if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
  368. ics2115_external_rmidi =
  369. snd_wavefront_new_midi (card,
  370. midi_dev,
  371. acard,
  372. ics2115_port[dev],
  373. external_mpu);
  374. if (ics2115_external_rmidi == NULL) {
  375. dev_err(card->dev, "can't setup ICS2115 external MIDI device\n");
  376. return -ENOMEM;
  377. }
  378. midi_dev++;
  379. }
  380. /* FX processor for Tropez+ */
  381. if (acard->wavefront.has_fx) {
  382. fx_processor = snd_wavefront_new_fx (card,
  383. hw_dev,
  384. acard,
  385. ics2115_port[dev]);
  386. if (fx_processor == NULL) {
  387. dev_err(card->dev, "can't setup FX device\n");
  388. return -ENOMEM;
  389. }
  390. hw_dev++;
  391. strscpy(card->driver, "Tropez+");
  392. strscpy(card->shortname, "Turtle Beach Tropez+");
  393. } else {
  394. /* Need a way to distinguish between Maui and Tropez */
  395. strscpy(card->driver, "WaveFront");
  396. strscpy(card->shortname, "Turtle Beach WaveFront");
  397. }
  398. /* ----- Register the card --------- */
  399. /* Not safe to include "Turtle Beach" in longname, due to
  400. length restrictions
  401. */
  402. sprintf(card->longname, "%s PCM 0x%lx irq %d dma %d",
  403. card->driver,
  404. chip->port,
  405. cs4232_pcm_irq[dev],
  406. dma1[dev]);
  407. if (dma2[dev] >= 0 && dma2[dev] < 8)
  408. sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
  409. if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
  410. sprintf (card->longname + strlen (card->longname),
  411. " MPU-401 0x%lx irq %d",
  412. cs4232_mpu_port[dev],
  413. cs4232_mpu_irq[dev]);
  414. }
  415. sprintf (card->longname + strlen (card->longname),
  416. " SYNTH 0x%lx irq %d",
  417. ics2115_port[dev],
  418. ics2115_irq[dev]);
  419. return snd_card_register(card);
  420. }
  421. static int snd_wavefront_isa_match(struct device *pdev,
  422. unsigned int dev)
  423. {
  424. if (!enable[dev])
  425. return 0;
  426. #ifdef CONFIG_PNP
  427. if (isapnp[dev])
  428. return 0;
  429. #endif
  430. if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
  431. dev_err(pdev, "specify CS4232 port\n");
  432. return 0;
  433. }
  434. if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
  435. dev_err(pdev, "specify ICS2115 port\n");
  436. return 0;
  437. }
  438. return 1;
  439. }
  440. static int snd_wavefront_isa_probe(struct device *pdev,
  441. unsigned int dev)
  442. {
  443. struct snd_card *card;
  444. int err;
  445. err = snd_wavefront_card_new(pdev, dev, &card);
  446. if (err < 0)
  447. return err;
  448. err = snd_wavefront_probe(card, dev);
  449. if (err < 0)
  450. return err;
  451. dev_set_drvdata(pdev, card);
  452. return 0;
  453. }
  454. #define DEV_NAME "wavefront"
  455. static struct isa_driver snd_wavefront_driver = {
  456. .match = snd_wavefront_isa_match,
  457. .probe = snd_wavefront_isa_probe,
  458. /* FIXME: suspend, resume */
  459. .driver = {
  460. .name = DEV_NAME
  461. },
  462. };
  463. #ifdef CONFIG_PNP
  464. static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
  465. const struct pnp_card_device_id *pid)
  466. {
  467. static int dev;
  468. struct snd_card *card;
  469. int res;
  470. for ( ; dev < SNDRV_CARDS; dev++) {
  471. if (enable[dev] && isapnp[dev])
  472. break;
  473. }
  474. if (dev >= SNDRV_CARDS)
  475. return -ENODEV;
  476. res = snd_wavefront_card_new(&pcard->card->dev, dev, &card);
  477. if (res < 0)
  478. return res;
  479. if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
  480. if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
  481. dev_err(card->dev, "isapnp detection failed\n");
  482. return -ENODEV;
  483. }
  484. }
  485. res = snd_wavefront_probe(card, dev);
  486. if (res < 0)
  487. return res;
  488. pnp_set_card_drvdata(pcard, card);
  489. dev++;
  490. return 0;
  491. }
  492. static struct pnp_card_driver wavefront_pnpc_driver = {
  493. .flags = PNP_DRIVER_RES_DISABLE,
  494. .name = "wavefront",
  495. .id_table = snd_wavefront_pnpids,
  496. .probe = snd_wavefront_pnp_detect,
  497. /* FIXME: suspend,resume */
  498. };
  499. #endif /* CONFIG_PNP */
  500. static int __init alsa_card_wavefront_init(void)
  501. {
  502. int err;
  503. err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
  504. #ifdef CONFIG_PNP
  505. if (!err)
  506. isa_registered = 1;
  507. err = pnp_register_card_driver(&wavefront_pnpc_driver);
  508. if (!err)
  509. pnp_registered = 1;
  510. if (isa_registered)
  511. err = 0;
  512. #endif
  513. return err;
  514. }
  515. static void __exit alsa_card_wavefront_exit(void)
  516. {
  517. #ifdef CONFIG_PNP
  518. if (pnp_registered)
  519. pnp_unregister_card_driver(&wavefront_pnpc_driver);
  520. if (isa_registered)
  521. #endif
  522. isa_unregister_driver(&snd_wavefront_driver);
  523. }
  524. module_init(alsa_card_wavefront_init)
  525. module_exit(alsa_card_wavefront_exit)