wavefront.c 19 KB

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