18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  ALSA card-level driver for Turtle Beach Wavefront cards
48c2ecf20Sopenharmony_ci *						(Maui,Tropez,Tropez+)
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci *  Copyright (c) 1997-1999 by Paul Barton-Davis <pbd@op.net>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/init.h>
108c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
118c2ecf20Sopenharmony_ci#include <linux/err.h>
128c2ecf20Sopenharmony_ci#include <linux/isa.h>
138c2ecf20Sopenharmony_ci#include <linux/pnp.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <sound/core.h>
168c2ecf20Sopenharmony_ci#include <sound/initval.h>
178c2ecf20Sopenharmony_ci#include <sound/opl3.h>
188c2ecf20Sopenharmony_ci#include <sound/wss.h>
198c2ecf20Sopenharmony_ci#include <sound/snd_wavefront.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciMODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
228c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Turtle Beach Wavefront");
238c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
248c2ecf20Sopenharmony_ciMODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}");
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	    /* Index 0-MAX */
278c2ecf20Sopenharmony_cistatic char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	    /* ID for this card */
288c2ecf20Sopenharmony_cistatic bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;	    /* Enable this card */
298c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
308c2ecf20Sopenharmony_cistatic bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
318c2ecf20Sopenharmony_ci#endif
328c2ecf20Sopenharmony_cistatic long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	/* PnP setup */
338c2ecf20Sopenharmony_cistatic int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
348c2ecf20Sopenharmony_cistatic long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
358c2ecf20Sopenharmony_cistatic int cs4232_mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
368c2ecf20Sopenharmony_cistatic long ics2115_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
378c2ecf20Sopenharmony_cistatic int ics2115_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;    /* 2,9,11,12,15 */
388c2ecf20Sopenharmony_cistatic long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;	    /* PnP setup */
398c2ecf20Sopenharmony_cistatic int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	    /* 0,1,3,5,6,7 */
408c2ecf20Sopenharmony_cistatic int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;	    /* 0,1,3,5,6,7 */
418c2ecf20Sopenharmony_cistatic bool use_cs4232_midi[SNDRV_CARDS];
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cimodule_param_array(index, int, NULL, 0444);
448c2ecf20Sopenharmony_ciMODULE_PARM_DESC(index, "Index value for WaveFront soundcard.");
458c2ecf20Sopenharmony_cimodule_param_array(id, charp, NULL, 0444);
468c2ecf20Sopenharmony_ciMODULE_PARM_DESC(id, "ID string for WaveFront soundcard.");
478c2ecf20Sopenharmony_cimodule_param_array(enable, bool, NULL, 0444);
488c2ecf20Sopenharmony_ciMODULE_PARM_DESC(enable, "Enable WaveFront soundcard.");
498c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
508c2ecf20Sopenharmony_cimodule_param_array(isapnp, bool, NULL, 0444);
518c2ecf20Sopenharmony_ciMODULE_PARM_DESC(isapnp, "ISA PnP detection for WaveFront soundcards.");
528c2ecf20Sopenharmony_ci#endif
538c2ecf20Sopenharmony_cimodule_param_hw_array(cs4232_pcm_port, long, ioport, NULL, 0444);
548c2ecf20Sopenharmony_ciMODULE_PARM_DESC(cs4232_pcm_port, "Port # for CS4232 PCM interface.");
558c2ecf20Sopenharmony_cimodule_param_hw_array(cs4232_pcm_irq, int, irq, NULL, 0444);
568c2ecf20Sopenharmony_ciMODULE_PARM_DESC(cs4232_pcm_irq, "IRQ # for CS4232 PCM interface.");
578c2ecf20Sopenharmony_cimodule_param_hw_array(dma1, int, dma, NULL, 0444);
588c2ecf20Sopenharmony_ciMODULE_PARM_DESC(dma1, "DMA1 # for CS4232 PCM interface.");
598c2ecf20Sopenharmony_cimodule_param_hw_array(dma2, int, dma, NULL, 0444);
608c2ecf20Sopenharmony_ciMODULE_PARM_DESC(dma2, "DMA2 # for CS4232 PCM interface.");
618c2ecf20Sopenharmony_cimodule_param_hw_array(cs4232_mpu_port, long, ioport, NULL, 0444);
628c2ecf20Sopenharmony_ciMODULE_PARM_DESC(cs4232_mpu_port, "port # for CS4232 MPU-401 interface.");
638c2ecf20Sopenharmony_cimodule_param_hw_array(cs4232_mpu_irq, int, irq, NULL, 0444);
648c2ecf20Sopenharmony_ciMODULE_PARM_DESC(cs4232_mpu_irq, "IRQ # for CS4232 MPU-401 interface.");
658c2ecf20Sopenharmony_cimodule_param_hw_array(ics2115_irq, int, irq, NULL, 0444);
668c2ecf20Sopenharmony_ciMODULE_PARM_DESC(ics2115_irq, "IRQ # for ICS2115.");
678c2ecf20Sopenharmony_cimodule_param_hw_array(ics2115_port, long, ioport, NULL, 0444);
688c2ecf20Sopenharmony_ciMODULE_PARM_DESC(ics2115_port, "Port # for ICS2115.");
698c2ecf20Sopenharmony_cimodule_param_hw_array(fm_port, long, ioport, NULL, 0444);
708c2ecf20Sopenharmony_ciMODULE_PARM_DESC(fm_port, "FM port #.");
718c2ecf20Sopenharmony_cimodule_param_array(use_cs4232_midi, bool, NULL, 0444);
728c2ecf20Sopenharmony_ciMODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
758c2ecf20Sopenharmony_cistatic int isa_registered;
768c2ecf20Sopenharmony_cistatic int pnp_registered;
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic const struct pnp_card_device_id snd_wavefront_pnpids[] = {
798c2ecf20Sopenharmony_ci	/* Tropez */
808c2ecf20Sopenharmony_ci	{ .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } },
818c2ecf20Sopenharmony_ci	/* Tropez+ */
828c2ecf20Sopenharmony_ci	{ .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } },
838c2ecf20Sopenharmony_ci	{ .id = "" }
848c2ecf20Sopenharmony_ci};
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pnp_card, snd_wavefront_pnpids);
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_cistatic int
898c2ecf20Sopenharmony_cisnd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *card,
908c2ecf20Sopenharmony_ci		   const struct pnp_card_device_id *id)
918c2ecf20Sopenharmony_ci{
928c2ecf20Sopenharmony_ci	struct pnp_dev *pdev;
938c2ecf20Sopenharmony_ci	int err;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	/* Check for each logical device. */
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* CS4232 chip (aka "windows sound system") is logical device 0 */
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci	acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
1008c2ecf20Sopenharmony_ci	if (acard->wss == NULL)
1018c2ecf20Sopenharmony_ci		return -EBUSY;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	/* there is a game port at logical device 1, but we ignore it completely */
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	/* the control interface is logical device 2, but we ignore it
1068c2ecf20Sopenharmony_ci	   completely. in fact, nobody even seems to know what it
1078c2ecf20Sopenharmony_ci	   does.
1088c2ecf20Sopenharmony_ci	*/
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	/* Only configure the CS4232 MIDI interface if its been
1118c2ecf20Sopenharmony_ci	   specifically requested. It is logical device 3.
1128c2ecf20Sopenharmony_ci	*/
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	if (use_cs4232_midi[dev]) {
1158c2ecf20Sopenharmony_ci		acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
1168c2ecf20Sopenharmony_ci		if (acard->mpu == NULL)
1178c2ecf20Sopenharmony_ci			return -EBUSY;
1188c2ecf20Sopenharmony_ci	}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	/* The ICS2115 synth is logical device 4 */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	acard->synth = pnp_request_card_device(card, id->devs[3].id, NULL);
1238c2ecf20Sopenharmony_ci	if (acard->synth == NULL)
1248c2ecf20Sopenharmony_ci		return -EBUSY;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	/* PCM/FM initialization */
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	pdev = acard->wss;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	/* An interesting note from the Tropez+ FAQ:
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	   Q. [Ports] Why is the base address of the WSS I/O ports off by 4?
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	   A. WSS I/O requires a block of 8 I/O addresses ("ports"). Of these, the first
1358c2ecf20Sopenharmony_ci	   4 are used to identify and configure the board. With the advent of PnP,
1368c2ecf20Sopenharmony_ci	   these first 4 addresses have become obsolete, and software applications
1378c2ecf20Sopenharmony_ci	   only use the last 4 addresses to control the codec chip. Therefore, the
1388c2ecf20Sopenharmony_ci	   base address setting "skips past" the 4 unused addresses.
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	*/
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	err = pnp_activate_dev(pdev);
1438c2ecf20Sopenharmony_ci	if (err < 0) {
1448c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "PnP WSS pnp configure failure\n");
1458c2ecf20Sopenharmony_ci		return err;
1468c2ecf20Sopenharmony_ci	}
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	cs4232_pcm_port[dev] = pnp_port_start(pdev, 0);
1498c2ecf20Sopenharmony_ci	fm_port[dev] = pnp_port_start(pdev, 1);
1508c2ecf20Sopenharmony_ci	dma1[dev] = pnp_dma(pdev, 0);
1518c2ecf20Sopenharmony_ci	dma2[dev] = pnp_dma(pdev, 1);
1528c2ecf20Sopenharmony_ci	cs4232_pcm_irq[dev] = pnp_irq(pdev, 0);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	/* Synth initialization */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	pdev = acard->synth;
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	err = pnp_activate_dev(pdev);
1598c2ecf20Sopenharmony_ci	if (err < 0) {
1608c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "PnP ICS2115 pnp configure failure\n");
1618c2ecf20Sopenharmony_ci		return err;
1628c2ecf20Sopenharmony_ci	}
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	ics2115_port[dev] = pnp_port_start(pdev, 0);
1658c2ecf20Sopenharmony_ci	ics2115_irq[dev] = pnp_irq(pdev, 0);
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	/* CS4232 MPU initialization. Configure this only if
1688c2ecf20Sopenharmony_ci	   explicitly requested, since its physically inaccessible and
1698c2ecf20Sopenharmony_ci	   consumes another IRQ.
1708c2ecf20Sopenharmony_ci	*/
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	if (use_cs4232_midi[dev]) {
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci		pdev = acard->mpu;
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci		err = pnp_activate_dev(pdev);
1778c2ecf20Sopenharmony_ci		if (err < 0) {
1788c2ecf20Sopenharmony_ci			snd_printk(KERN_ERR "PnP MPU401 pnp configure failure\n");
1798c2ecf20Sopenharmony_ci			cs4232_mpu_port[dev] = SNDRV_AUTO_PORT;
1808c2ecf20Sopenharmony_ci		} else {
1818c2ecf20Sopenharmony_ci			cs4232_mpu_port[dev] = pnp_port_start(pdev, 0);
1828c2ecf20Sopenharmony_ci			cs4232_mpu_irq[dev] = pnp_irq(pdev, 0);
1838c2ecf20Sopenharmony_ci		}
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci		snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n",
1868c2ecf20Sopenharmony_ci			    cs4232_mpu_port[dev],
1878c2ecf20Sopenharmony_ci			    cs4232_mpu_irq[dev]);
1888c2ecf20Sopenharmony_ci	}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci	snd_printdd ("CS4232: pcm port=0x%lx, fm port=0x%lx, dma1=%i, dma2=%i, irq=%i\nICS2115: port=0x%lx, irq=%i\n",
1918c2ecf20Sopenharmony_ci		    cs4232_pcm_port[dev],
1928c2ecf20Sopenharmony_ci		    fm_port[dev],
1938c2ecf20Sopenharmony_ci		    dma1[dev],
1948c2ecf20Sopenharmony_ci		    dma2[dev],
1958c2ecf20Sopenharmony_ci		    cs4232_pcm_irq[dev],
1968c2ecf20Sopenharmony_ci		    ics2115_port[dev],
1978c2ecf20Sopenharmony_ci		    ics2115_irq[dev]);
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	return 0;
2008c2ecf20Sopenharmony_ci}
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci#endif /* CONFIG_PNP */
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistatic irqreturn_t snd_wavefront_ics2115_interrupt(int irq, void *dev_id)
2058c2ecf20Sopenharmony_ci{
2068c2ecf20Sopenharmony_ci	snd_wavefront_card_t *acard;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	acard = (snd_wavefront_card_t *) dev_id;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	if (acard == NULL)
2118c2ecf20Sopenharmony_ci		return IRQ_NONE;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	if (acard->wavefront.interrupts_are_midi) {
2148c2ecf20Sopenharmony_ci		snd_wavefront_midi_interrupt (acard);
2158c2ecf20Sopenharmony_ci	} else {
2168c2ecf20Sopenharmony_ci		snd_wavefront_internal_interrupt (acard);
2178c2ecf20Sopenharmony_ci	}
2188c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
2198c2ecf20Sopenharmony_ci}
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistatic struct snd_hwdep *snd_wavefront_new_synth(struct snd_card *card,
2228c2ecf20Sopenharmony_ci						 int hw_dev,
2238c2ecf20Sopenharmony_ci						 snd_wavefront_card_t *acard)
2248c2ecf20Sopenharmony_ci{
2258c2ecf20Sopenharmony_ci	struct snd_hwdep *wavefront_synth;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	if (snd_wavefront_detect (acard) < 0) {
2288c2ecf20Sopenharmony_ci		return NULL;
2298c2ecf20Sopenharmony_ci	}
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	if (snd_wavefront_start (&acard->wavefront) < 0) {
2328c2ecf20Sopenharmony_ci		return NULL;
2338c2ecf20Sopenharmony_ci	}
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	if (snd_hwdep_new(card, "WaveFront", hw_dev, &wavefront_synth) < 0)
2368c2ecf20Sopenharmony_ci		return NULL;
2378c2ecf20Sopenharmony_ci	strcpy (wavefront_synth->name,
2388c2ecf20Sopenharmony_ci		"WaveFront (ICS2115) wavetable synthesizer");
2398c2ecf20Sopenharmony_ci	wavefront_synth->ops.open = snd_wavefront_synth_open;
2408c2ecf20Sopenharmony_ci	wavefront_synth->ops.release = snd_wavefront_synth_release;
2418c2ecf20Sopenharmony_ci	wavefront_synth->ops.ioctl = snd_wavefront_synth_ioctl;
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	return wavefront_synth;
2448c2ecf20Sopenharmony_ci}
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic struct snd_hwdep *snd_wavefront_new_fx(struct snd_card *card,
2478c2ecf20Sopenharmony_ci					      int hw_dev,
2488c2ecf20Sopenharmony_ci					      snd_wavefront_card_t *acard,
2498c2ecf20Sopenharmony_ci					      unsigned long port)
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci{
2528c2ecf20Sopenharmony_ci	struct snd_hwdep *fx_processor;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	if (snd_wavefront_fx_start (&acard->wavefront)) {
2558c2ecf20Sopenharmony_ci		snd_printk (KERN_ERR "cannot initialize YSS225 FX processor");
2568c2ecf20Sopenharmony_ci		return NULL;
2578c2ecf20Sopenharmony_ci	}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	if (snd_hwdep_new (card, "YSS225", hw_dev, &fx_processor) < 0)
2608c2ecf20Sopenharmony_ci		return NULL;
2618c2ecf20Sopenharmony_ci	sprintf (fx_processor->name, "YSS225 FX Processor at 0x%lx", port);
2628c2ecf20Sopenharmony_ci	fx_processor->ops.open = snd_wavefront_fx_open;
2638c2ecf20Sopenharmony_ci	fx_processor->ops.release = snd_wavefront_fx_release;
2648c2ecf20Sopenharmony_ci	fx_processor->ops.ioctl = snd_wavefront_fx_ioctl;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	return fx_processor;
2678c2ecf20Sopenharmony_ci}
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic snd_wavefront_mpu_id internal_id = internal_mpu;
2708c2ecf20Sopenharmony_cistatic snd_wavefront_mpu_id external_id = external_mpu;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic struct snd_rawmidi *snd_wavefront_new_midi(struct snd_card *card,
2738c2ecf20Sopenharmony_ci						  int midi_dev,
2748c2ecf20Sopenharmony_ci						  snd_wavefront_card_t *acard,
2758c2ecf20Sopenharmony_ci						  unsigned long port,
2768c2ecf20Sopenharmony_ci						  snd_wavefront_mpu_id mpu)
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci	struct snd_rawmidi *rmidi;
2808c2ecf20Sopenharmony_ci	static int first = 1;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	if (first) {
2838c2ecf20Sopenharmony_ci		first = 0;
2848c2ecf20Sopenharmony_ci		acard->wavefront.midi.base = port;
2858c2ecf20Sopenharmony_ci		if (snd_wavefront_midi_start (acard)) {
2868c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "cannot initialize MIDI interface\n");
2878c2ecf20Sopenharmony_ci			return NULL;
2888c2ecf20Sopenharmony_ci		}
2898c2ecf20Sopenharmony_ci	}
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	if (snd_rawmidi_new (card, "WaveFront MIDI", midi_dev, 1, 1, &rmidi) < 0)
2928c2ecf20Sopenharmony_ci		return NULL;
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	if (mpu == internal_mpu) {
2958c2ecf20Sopenharmony_ci		strcpy(rmidi->name, "WaveFront MIDI (Internal)");
2968c2ecf20Sopenharmony_ci		rmidi->private_data = &internal_id;
2978c2ecf20Sopenharmony_ci	} else {
2988c2ecf20Sopenharmony_ci		strcpy(rmidi->name, "WaveFront MIDI (External)");
2998c2ecf20Sopenharmony_ci		rmidi->private_data = &external_id;
3008c2ecf20Sopenharmony_ci	}
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_wavefront_midi_output);
3038c2ecf20Sopenharmony_ci	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_wavefront_midi_input);
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
3068c2ecf20Sopenharmony_ci			     SNDRV_RAWMIDI_INFO_INPUT |
3078c2ecf20Sopenharmony_ci			     SNDRV_RAWMIDI_INFO_DUPLEX;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	return rmidi;
3108c2ecf20Sopenharmony_ci}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic void
3138c2ecf20Sopenharmony_cisnd_wavefront_free(struct snd_card *card)
3148c2ecf20Sopenharmony_ci{
3158c2ecf20Sopenharmony_ci	snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	if (acard) {
3188c2ecf20Sopenharmony_ci		release_and_free_resource(acard->wavefront.res_base);
3198c2ecf20Sopenharmony_ci		if (acard->wavefront.irq > 0)
3208c2ecf20Sopenharmony_ci			free_irq(acard->wavefront.irq, (void *)acard);
3218c2ecf20Sopenharmony_ci	}
3228c2ecf20Sopenharmony_ci}
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_cistatic int snd_wavefront_card_new(struct device *pdev, int dev,
3258c2ecf20Sopenharmony_ci				  struct snd_card **cardp)
3268c2ecf20Sopenharmony_ci{
3278c2ecf20Sopenharmony_ci	struct snd_card *card;
3288c2ecf20Sopenharmony_ci	snd_wavefront_card_t *acard;
3298c2ecf20Sopenharmony_ci	int err;
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
3328c2ecf20Sopenharmony_ci			   sizeof(snd_wavefront_card_t), &card);
3338c2ecf20Sopenharmony_ci	if (err < 0)
3348c2ecf20Sopenharmony_ci		return err;
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	acard = card->private_data;
3378c2ecf20Sopenharmony_ci	acard->wavefront.irq = -1;
3388c2ecf20Sopenharmony_ci	spin_lock_init(&acard->wavefront.irq_lock);
3398c2ecf20Sopenharmony_ci	init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
3408c2ecf20Sopenharmony_ci	spin_lock_init(&acard->wavefront.midi.open);
3418c2ecf20Sopenharmony_ci	spin_lock_init(&acard->wavefront.midi.virtual);
3428c2ecf20Sopenharmony_ci	acard->wavefront.card = card;
3438c2ecf20Sopenharmony_ci	card->private_free = snd_wavefront_free;
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	*cardp = card;
3468c2ecf20Sopenharmony_ci	return 0;
3478c2ecf20Sopenharmony_ci}
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_cistatic int
3508c2ecf20Sopenharmony_cisnd_wavefront_probe (struct snd_card *card, int dev)
3518c2ecf20Sopenharmony_ci{
3528c2ecf20Sopenharmony_ci	snd_wavefront_card_t *acard = card->private_data;
3538c2ecf20Sopenharmony_ci	struct snd_wss *chip;
3548c2ecf20Sopenharmony_ci	struct snd_hwdep *wavefront_synth;
3558c2ecf20Sopenharmony_ci	struct snd_rawmidi *ics2115_internal_rmidi = NULL;
3568c2ecf20Sopenharmony_ci	struct snd_rawmidi *ics2115_external_rmidi = NULL;
3578c2ecf20Sopenharmony_ci	struct snd_hwdep *fx_processor;
3588c2ecf20Sopenharmony_ci	int hw_dev = 0, midi_dev = 0, err;
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	/* --------- PCM --------------- */
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci	err = snd_wss_create(card, cs4232_pcm_port[dev], -1,
3638c2ecf20Sopenharmony_ci			     cs4232_pcm_irq[dev], dma1[dev], dma2[dev],
3648c2ecf20Sopenharmony_ci			     WSS_HW_DETECT, 0, &chip);
3658c2ecf20Sopenharmony_ci	if (err < 0) {
3668c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "can't allocate WSS device\n");
3678c2ecf20Sopenharmony_ci		return err;
3688c2ecf20Sopenharmony_ci	}
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	err = snd_wss_pcm(chip, 0);
3718c2ecf20Sopenharmony_ci	if (err < 0)
3728c2ecf20Sopenharmony_ci		return err;
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	err = snd_wss_timer(chip, 0);
3758c2ecf20Sopenharmony_ci	if (err < 0)
3768c2ecf20Sopenharmony_ci		return err;
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci	/* ---------- OPL3 synth --------- */
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci	if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
3818c2ecf20Sopenharmony_ci		struct snd_opl3 *opl3;
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci		err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
3848c2ecf20Sopenharmony_ci				      OPL3_HW_OPL3_CS, 0, &opl3);
3858c2ecf20Sopenharmony_ci		if (err < 0) {
3868c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n");
3878c2ecf20Sopenharmony_ci			return err;
3888c2ecf20Sopenharmony_ci		}
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci		err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL);
3918c2ecf20Sopenharmony_ci		if (err < 0)
3928c2ecf20Sopenharmony_ci			return err;
3938c2ecf20Sopenharmony_ci		hw_dev++;
3948c2ecf20Sopenharmony_ci	}
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci	/* ------- ICS2115 Wavetable synth ------- */
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci	acard->wavefront.res_base = request_region(ics2115_port[dev], 16,
3998c2ecf20Sopenharmony_ci						   "ICS2115");
4008c2ecf20Sopenharmony_ci	if (acard->wavefront.res_base == NULL) {
4018c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
4028c2ecf20Sopenharmony_ci			   ics2115_port[dev], ics2115_port[dev] + 16 - 1);
4038c2ecf20Sopenharmony_ci		return -EBUSY;
4048c2ecf20Sopenharmony_ci	}
4058c2ecf20Sopenharmony_ci	if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt,
4068c2ecf20Sopenharmony_ci			0, "ICS2115", acard)) {
4078c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
4088c2ecf20Sopenharmony_ci		return -EBUSY;
4098c2ecf20Sopenharmony_ci	}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci	acard->wavefront.irq = ics2115_irq[dev];
4128c2ecf20Sopenharmony_ci	card->sync_irq = acard->wavefront.irq;
4138c2ecf20Sopenharmony_ci	acard->wavefront.base = ics2115_port[dev];
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	wavefront_synth = snd_wavefront_new_synth(card, hw_dev, acard);
4168c2ecf20Sopenharmony_ci	if (wavefront_synth == NULL) {
4178c2ecf20Sopenharmony_ci		snd_printk (KERN_ERR "can't create WaveFront synth device\n");
4188c2ecf20Sopenharmony_ci		return -ENOMEM;
4198c2ecf20Sopenharmony_ci	}
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci	strcpy (wavefront_synth->name, "ICS2115 Wavetable MIDI Synthesizer");
4228c2ecf20Sopenharmony_ci	wavefront_synth->iface = SNDRV_HWDEP_IFACE_ICS2115;
4238c2ecf20Sopenharmony_ci	hw_dev++;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	/* --------- Mixer ------------ */
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	err = snd_wss_mixer(chip);
4288c2ecf20Sopenharmony_ci	if (err < 0) {
4298c2ecf20Sopenharmony_ci		snd_printk (KERN_ERR "can't allocate mixer device\n");
4308c2ecf20Sopenharmony_ci		return err;
4318c2ecf20Sopenharmony_ci	}
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	/* -------- CS4232 MPU-401 interface -------- */
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
4368c2ecf20Sopenharmony_ci		err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
4378c2ecf20Sopenharmony_ci					  cs4232_mpu_port[dev], 0,
4388c2ecf20Sopenharmony_ci					  cs4232_mpu_irq[dev], NULL);
4398c2ecf20Sopenharmony_ci		if (err < 0) {
4408c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n");
4418c2ecf20Sopenharmony_ci			return err;
4428c2ecf20Sopenharmony_ci		}
4438c2ecf20Sopenharmony_ci		midi_dev++;
4448c2ecf20Sopenharmony_ci	}
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	/* ------ ICS2115 internal MIDI ------------ */
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci	if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
4498c2ecf20Sopenharmony_ci		ics2115_internal_rmidi =
4508c2ecf20Sopenharmony_ci			snd_wavefront_new_midi (card,
4518c2ecf20Sopenharmony_ci						midi_dev,
4528c2ecf20Sopenharmony_ci						acard,
4538c2ecf20Sopenharmony_ci						ics2115_port[dev],
4548c2ecf20Sopenharmony_ci						internal_mpu);
4558c2ecf20Sopenharmony_ci		if (ics2115_internal_rmidi == NULL) {
4568c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n");
4578c2ecf20Sopenharmony_ci			return -ENOMEM;
4588c2ecf20Sopenharmony_ci		}
4598c2ecf20Sopenharmony_ci		midi_dev++;
4608c2ecf20Sopenharmony_ci	}
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci	/* ------ ICS2115 external MIDI ------------ */
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci	if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) {
4658c2ecf20Sopenharmony_ci		ics2115_external_rmidi =
4668c2ecf20Sopenharmony_ci			snd_wavefront_new_midi (card,
4678c2ecf20Sopenharmony_ci						midi_dev,
4688c2ecf20Sopenharmony_ci						acard,
4698c2ecf20Sopenharmony_ci						ics2115_port[dev],
4708c2ecf20Sopenharmony_ci						external_mpu);
4718c2ecf20Sopenharmony_ci		if (ics2115_external_rmidi == NULL) {
4728c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n");
4738c2ecf20Sopenharmony_ci			return -ENOMEM;
4748c2ecf20Sopenharmony_ci		}
4758c2ecf20Sopenharmony_ci		midi_dev++;
4768c2ecf20Sopenharmony_ci	}
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci	/* FX processor for Tropez+ */
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci	if (acard->wavefront.has_fx) {
4818c2ecf20Sopenharmony_ci		fx_processor = snd_wavefront_new_fx (card,
4828c2ecf20Sopenharmony_ci						     hw_dev,
4838c2ecf20Sopenharmony_ci						     acard,
4848c2ecf20Sopenharmony_ci						     ics2115_port[dev]);
4858c2ecf20Sopenharmony_ci		if (fx_processor == NULL) {
4868c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "can't setup FX device\n");
4878c2ecf20Sopenharmony_ci			return -ENOMEM;
4888c2ecf20Sopenharmony_ci		}
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci		hw_dev++;
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci		strcpy(card->driver, "Tropez+");
4938c2ecf20Sopenharmony_ci		strcpy(card->shortname, "Turtle Beach Tropez+");
4948c2ecf20Sopenharmony_ci	} else {
4958c2ecf20Sopenharmony_ci		/* Need a way to distinguish between Maui and Tropez */
4968c2ecf20Sopenharmony_ci		strcpy(card->driver, "WaveFront");
4978c2ecf20Sopenharmony_ci		strcpy(card->shortname, "Turtle Beach WaveFront");
4988c2ecf20Sopenharmony_ci	}
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci	/* ----- Register the card --------- */
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci	/* Not safe to include "Turtle Beach" in longname, due to
5038c2ecf20Sopenharmony_ci	   length restrictions
5048c2ecf20Sopenharmony_ci	*/
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci	sprintf(card->longname, "%s PCM 0x%lx irq %d dma %d",
5078c2ecf20Sopenharmony_ci		card->driver,
5088c2ecf20Sopenharmony_ci		chip->port,
5098c2ecf20Sopenharmony_ci		cs4232_pcm_irq[dev],
5108c2ecf20Sopenharmony_ci		dma1[dev]);
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	if (dma2[dev] >= 0 && dma2[dev] < 8)
5138c2ecf20Sopenharmony_ci		sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
5168c2ecf20Sopenharmony_ci		sprintf (card->longname + strlen (card->longname),
5178c2ecf20Sopenharmony_ci			 " MPU-401 0x%lx irq %d",
5188c2ecf20Sopenharmony_ci			 cs4232_mpu_port[dev],
5198c2ecf20Sopenharmony_ci			 cs4232_mpu_irq[dev]);
5208c2ecf20Sopenharmony_ci	}
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci	sprintf (card->longname + strlen (card->longname),
5238c2ecf20Sopenharmony_ci		 " SYNTH 0x%lx irq %d",
5248c2ecf20Sopenharmony_ci		 ics2115_port[dev],
5258c2ecf20Sopenharmony_ci		 ics2115_irq[dev]);
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci	return snd_card_register(card);
5288c2ecf20Sopenharmony_ci}
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_cistatic int snd_wavefront_isa_match(struct device *pdev,
5318c2ecf20Sopenharmony_ci				   unsigned int dev)
5328c2ecf20Sopenharmony_ci{
5338c2ecf20Sopenharmony_ci	if (!enable[dev])
5348c2ecf20Sopenharmony_ci		return 0;
5358c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
5368c2ecf20Sopenharmony_ci	if (isapnp[dev])
5378c2ecf20Sopenharmony_ci		return 0;
5388c2ecf20Sopenharmony_ci#endif
5398c2ecf20Sopenharmony_ci	if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
5408c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "specify CS4232 port\n");
5418c2ecf20Sopenharmony_ci		return 0;
5428c2ecf20Sopenharmony_ci	}
5438c2ecf20Sopenharmony_ci	if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
5448c2ecf20Sopenharmony_ci		snd_printk(KERN_ERR "specify ICS2115 port\n");
5458c2ecf20Sopenharmony_ci		return 0;
5468c2ecf20Sopenharmony_ci	}
5478c2ecf20Sopenharmony_ci	return 1;
5488c2ecf20Sopenharmony_ci}
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_cistatic int snd_wavefront_isa_probe(struct device *pdev,
5518c2ecf20Sopenharmony_ci				   unsigned int dev)
5528c2ecf20Sopenharmony_ci{
5538c2ecf20Sopenharmony_ci	struct snd_card *card;
5548c2ecf20Sopenharmony_ci	int err;
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci	err = snd_wavefront_card_new(pdev, dev, &card);
5578c2ecf20Sopenharmony_ci	if (err < 0)
5588c2ecf20Sopenharmony_ci		return err;
5598c2ecf20Sopenharmony_ci	if ((err = snd_wavefront_probe(card, dev)) < 0) {
5608c2ecf20Sopenharmony_ci		snd_card_free(card);
5618c2ecf20Sopenharmony_ci		return err;
5628c2ecf20Sopenharmony_ci	}
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci	dev_set_drvdata(pdev, card);
5658c2ecf20Sopenharmony_ci	return 0;
5668c2ecf20Sopenharmony_ci}
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_cistatic int snd_wavefront_isa_remove(struct device *devptr,
5698c2ecf20Sopenharmony_ci				    unsigned int dev)
5708c2ecf20Sopenharmony_ci{
5718c2ecf20Sopenharmony_ci	snd_card_free(dev_get_drvdata(devptr));
5728c2ecf20Sopenharmony_ci	return 0;
5738c2ecf20Sopenharmony_ci}
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci#define DEV_NAME "wavefront"
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_cistatic struct isa_driver snd_wavefront_driver = {
5788c2ecf20Sopenharmony_ci	.match		= snd_wavefront_isa_match,
5798c2ecf20Sopenharmony_ci	.probe		= snd_wavefront_isa_probe,
5808c2ecf20Sopenharmony_ci	.remove		= snd_wavefront_isa_remove,
5818c2ecf20Sopenharmony_ci	/* FIXME: suspend, resume */
5828c2ecf20Sopenharmony_ci	.driver		= {
5838c2ecf20Sopenharmony_ci		.name	= DEV_NAME
5848c2ecf20Sopenharmony_ci	},
5858c2ecf20Sopenharmony_ci};
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
5898c2ecf20Sopenharmony_cistatic int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
5908c2ecf20Sopenharmony_ci				    const struct pnp_card_device_id *pid)
5918c2ecf20Sopenharmony_ci{
5928c2ecf20Sopenharmony_ci	static int dev;
5938c2ecf20Sopenharmony_ci	struct snd_card *card;
5948c2ecf20Sopenharmony_ci	int res;
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci	for ( ; dev < SNDRV_CARDS; dev++) {
5978c2ecf20Sopenharmony_ci		if (enable[dev] && isapnp[dev])
5988c2ecf20Sopenharmony_ci			break;
5998c2ecf20Sopenharmony_ci	}
6008c2ecf20Sopenharmony_ci	if (dev >= SNDRV_CARDS)
6018c2ecf20Sopenharmony_ci		return -ENODEV;
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	res = snd_wavefront_card_new(&pcard->card->dev, dev, &card);
6048c2ecf20Sopenharmony_ci	if (res < 0)
6058c2ecf20Sopenharmony_ci		return res;
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
6088c2ecf20Sopenharmony_ci		if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
6098c2ecf20Sopenharmony_ci			snd_printk (KERN_ERR "isapnp detection failed\n");
6108c2ecf20Sopenharmony_ci			snd_card_free (card);
6118c2ecf20Sopenharmony_ci			return -ENODEV;
6128c2ecf20Sopenharmony_ci		}
6138c2ecf20Sopenharmony_ci	}
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	if ((res = snd_wavefront_probe(card, dev)) < 0)
6168c2ecf20Sopenharmony_ci		return res;
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci	pnp_set_card_drvdata(pcard, card);
6198c2ecf20Sopenharmony_ci	dev++;
6208c2ecf20Sopenharmony_ci	return 0;
6218c2ecf20Sopenharmony_ci}
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_cistatic void snd_wavefront_pnp_remove(struct pnp_card_link *pcard)
6248c2ecf20Sopenharmony_ci{
6258c2ecf20Sopenharmony_ci	snd_card_free(pnp_get_card_drvdata(pcard));
6268c2ecf20Sopenharmony_ci	pnp_set_card_drvdata(pcard, NULL);
6278c2ecf20Sopenharmony_ci}
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_cistatic struct pnp_card_driver wavefront_pnpc_driver = {
6308c2ecf20Sopenharmony_ci	.flags		= PNP_DRIVER_RES_DISABLE,
6318c2ecf20Sopenharmony_ci	.name		= "wavefront",
6328c2ecf20Sopenharmony_ci	.id_table	= snd_wavefront_pnpids,
6338c2ecf20Sopenharmony_ci	.probe		= snd_wavefront_pnp_detect,
6348c2ecf20Sopenharmony_ci	.remove		= snd_wavefront_pnp_remove,
6358c2ecf20Sopenharmony_ci	/* FIXME: suspend,resume */
6368c2ecf20Sopenharmony_ci};
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci#endif /* CONFIG_PNP */
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_cistatic int __init alsa_card_wavefront_init(void)
6418c2ecf20Sopenharmony_ci{
6428c2ecf20Sopenharmony_ci	int err;
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ci	err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
6458c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
6468c2ecf20Sopenharmony_ci	if (!err)
6478c2ecf20Sopenharmony_ci		isa_registered = 1;
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci	err = pnp_register_card_driver(&wavefront_pnpc_driver);
6508c2ecf20Sopenharmony_ci	if (!err)
6518c2ecf20Sopenharmony_ci		pnp_registered = 1;
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_ci	if (isa_registered)
6548c2ecf20Sopenharmony_ci		err = 0;
6558c2ecf20Sopenharmony_ci#endif
6568c2ecf20Sopenharmony_ci	return err;
6578c2ecf20Sopenharmony_ci}
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_cistatic void __exit alsa_card_wavefront_exit(void)
6608c2ecf20Sopenharmony_ci{
6618c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
6628c2ecf20Sopenharmony_ci	if (pnp_registered)
6638c2ecf20Sopenharmony_ci		pnp_unregister_card_driver(&wavefront_pnpc_driver);
6648c2ecf20Sopenharmony_ci	if (isa_registered)
6658c2ecf20Sopenharmony_ci#endif
6668c2ecf20Sopenharmony_ci		isa_unregister_driver(&snd_wavefront_driver);
6678c2ecf20Sopenharmony_ci}
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_cimodule_init(alsa_card_wavefront_init)
6708c2ecf20Sopenharmony_cimodule_exit(alsa_card_wavefront_exit)
671