wavefront.c 19 KB

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