2 * card-als4000.c - driver for Avance Logic ALS4000 based soundcards.
3 * Copyright (C) 2000 by Bart Hartgers <bart@etpmod.phys.tue.nl>,
4 * Jaroslav Kysela <perex@suse.cz>
5 * Copyright (C) 2002 by Andreas Mohr <hw7oshyuv3001@sneakemail.com>
7 * Framework borrowed from Massimo Piccioni's card-als100.c.
11 * Since Avance does not provide any meaningful documentation, and I
12 * bought an ALS4000 based soundcard, I was forced to base this driver
13 * on reverse engineering.
15 * Note: this is no longer true. Pretty verbose chip docu (ALS4000a.PDF)
16 * can be found on the ALSA web site.
18 * The ALS4000 seems to be the PCI-cousin of the ALS100. It contains an
19 * ALS100-like SB DSP/mixer, an OPL3 synth, a MPU401 and a gameport
20 * interface. These subsystems can be mapped into ISA io-port space,
21 * using the PCI-interface. In addition, the PCI-bit provides DMA and IRQ
22 * services to the subsystems.
24 * While ALS4000 is very similar to a SoundBlaster, the differences in
25 * DMA and capturing require more changes to the SoundBlaster than
26 * desirable, so I made this separate driver.
28 * The ALS4000 can do real full duplex playback/capture.
34 * Enable/disable 3D sound:
36 * - change bit 6 (0x40) of port 0x15
41 * 0x3e (mode 3), 0x3c (mode 2), 0x3a (mode 1), 0x38 (mode 0)
44 * - value -> some port 0x0c0d
46 * This program is free software; you can redistribute it and/or modify
47 * it under the terms of the GNU General Public License as published by
48 * the Free Software Foundation; either version 2 of the License, or
49 * (at your option) any later version.
51 * This program is distributed in the hope that it will be useful,
52 * but WITHOUT ANY WARRANTY; without even the implied warranty of
53 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 * GNU General Public License for more details.
56 * You should have received a copy of the GNU General Public License
57 * along with this program; if not, write to the Free Software
58 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
61 #include <sound/driver.h>
63 #include <linux/init.h>
64 #include <linux/pci.h>
65 #include <linux/slab.h>
66 #include <linux/gameport.h>
67 #include <linux/moduleparam.h>
68 #include <sound/core.h>
69 #include <sound/pcm.h>
70 #include <sound/rawmidi.h>
71 #include <sound/mpu401.h>
72 #include <sound/opl3.h>
74 #include <sound/initval.h>
76 MODULE_AUTHOR("Bart Hartgers <bart@etpmod.phys.tue.nl>");
77 MODULE_DESCRIPTION("Avance Logic ALS4000");
78 MODULE_LICENSE("GPL");
79 MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");
81 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
82 #define SUPPORT_JOYSTICK 1
85 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
86 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
87 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
88 #ifdef SUPPORT_JOYSTICK
89 static int joystick_port[SNDRV_CARDS];
93 module_param_array(index, int, boot_devs, 0444);
94 MODULE_PARM_DESC(index, "Index value for ALS4000 soundcard.");
95 module_param_array(id, charp, boot_devs, 0444);
96 MODULE_PARM_DESC(id, "ID string for ALS4000 soundcard.");
97 module_param_array(enable, bool, boot_devs, 0444);
98 MODULE_PARM_DESC(enable, "Enable ALS4000 soundcard.");
99 #ifdef SUPPORT_JOYSTICK
100 module_param_array(joystick_port, int, boot_devs, 0444);
101 MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 = disabled)");
107 #ifdef SUPPORT_JOYSTICK
108 struct gameport gameport;
109 struct resource *res_joystick;
111 } snd_card_als4000_t;
113 static struct pci_device_id snd_als4000_ids[] = {
114 { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */
118 MODULE_DEVICE_TABLE(pci, snd_als4000_ids);
120 static inline void snd_als4000_gcr_write_addr(unsigned long port, u32 reg, u32 val)
122 outb(reg, port+0x0c);
123 outl(val, port+0x08);
126 static inline void snd_als4000_gcr_write(sb_t *sb, u32 reg, u32 val)
128 snd_als4000_gcr_write_addr(sb->alt_port, reg, val);
131 static inline u32 snd_als4000_gcr_read_addr(unsigned long port, u32 reg)
133 outb(reg, port+0x0c);
134 return inl(port+0x08);
137 static inline u32 snd_als4000_gcr_read(sb_t *sb, u32 reg)
139 return snd_als4000_gcr_read_addr(sb->alt_port, reg);
142 static void snd_als4000_set_rate(sb_t *chip, unsigned int rate)
144 if (!(chip->mode & SB_RATE_LOCK)) {
145 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_OUT);
146 snd_sbdsp_command(chip, rate>>8);
147 snd_sbdsp_command(chip, rate);
151 static void snd_als4000_set_capture_dma(sb_t *chip, dma_addr_t addr, unsigned size)
153 snd_als4000_gcr_write(chip, 0xa2, addr);
154 snd_als4000_gcr_write(chip, 0xa3, (size-1));
157 static void snd_als4000_set_playback_dma(sb_t *chip, dma_addr_t addr, unsigned size)
159 snd_als4000_gcr_write(chip, 0x91, addr);
160 snd_als4000_gcr_write(chip, 0x92, (size-1)|0x180000);
163 #define ALS4000_FORMAT_SIGNED (1<<0)
164 #define ALS4000_FORMAT_16BIT (1<<1)
165 #define ALS4000_FORMAT_STEREO (1<<2)
167 static int snd_als4000_get_format(snd_pcm_runtime_t *runtime)
172 if (snd_pcm_format_signed(runtime->format))
173 result |= ALS4000_FORMAT_SIGNED;
174 if (snd_pcm_format_physical_width(runtime->format) == 16)
175 result |= ALS4000_FORMAT_16BIT;
176 if (runtime->channels > 1)
177 result |= ALS4000_FORMAT_STEREO;
181 /* structure for setting up playback */
183 unsigned char dsp_cmd, dma_on, dma_off, format;
184 } playback_cmd_vals[]={
185 /* ALS4000_FORMAT_U8_MONO */
186 { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_UNS_MONO },
187 /* ALS4000_FORMAT_S8_MONO */
188 { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_SIGN_MONO },
189 /* ALS4000_FORMAT_U16L_MONO */
190 { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_UNS_MONO },
191 /* ALS4000_FORMAT_S16L_MONO */
192 { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_SIGN_MONO },
193 /* ALS4000_FORMAT_U8_STEREO */
194 { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_UNS_STEREO },
195 /* ALS4000_FORMAT_S8_STEREO */
196 { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_SIGN_STEREO },
197 /* ALS4000_FORMAT_U16L_STEREO */
198 { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_UNS_STEREO },
199 /* ALS4000_FORMAT_S16L_STEREO */
200 { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_SIGN_STEREO },
202 #define playback_cmd(chip) (playback_cmd_vals[(chip)->playback_format])
204 /* structure for setting up capture */
205 enum { CMD_WIDTH8=0x04, CMD_SIGNED=0x10, CMD_MONO=0x80, CMD_STEREO=0xA0 };
206 static unsigned char capture_cmd_vals[]=
208 CMD_WIDTH8|CMD_MONO, /* ALS4000_FORMAT_U8_MONO */
209 CMD_WIDTH8|CMD_SIGNED|CMD_MONO, /* ALS4000_FORMAT_S8_MONO */
210 CMD_MONO, /* ALS4000_FORMAT_U16L_MONO */
211 CMD_SIGNED|CMD_MONO, /* ALS4000_FORMAT_S16L_MONO */
212 CMD_WIDTH8|CMD_STEREO, /* ALS4000_FORMAT_U8_STEREO */
213 CMD_WIDTH8|CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S8_STEREO */
214 CMD_STEREO, /* ALS4000_FORMAT_U16L_STEREO */
215 CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S16L_STEREO */
217 #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format])
219 static int snd_als4000_hw_params(snd_pcm_substream_t * substream,
220 snd_pcm_hw_params_t * hw_params)
222 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
225 static int snd_als4000_hw_free(snd_pcm_substream_t * substream)
227 snd_pcm_lib_free_pages(substream);
231 static int snd_als4000_capture_prepare(snd_pcm_substream_t * substream)
234 sb_t *chip = snd_pcm_substream_chip(substream);
235 snd_pcm_runtime_t *runtime = substream->runtime;
239 chip->capture_format = snd_als4000_get_format(runtime);
241 size = snd_pcm_lib_buffer_bytes(substream);
242 count = snd_pcm_lib_period_bytes(substream);
244 if (chip->capture_format & ALS4000_FORMAT_16BIT)
248 spin_lock_irqsave(&chip->reg_lock, flags);
249 snd_als4000_set_rate(chip, runtime->rate);
250 snd_als4000_set_capture_dma(chip, runtime->dma_addr, size);
251 spin_unlock_irqrestore(&chip->reg_lock, flags);
252 spin_lock_irqsave(&chip->mixer_lock, flags );
253 snd_sbmixer_write(chip, 0xdc, count);
254 snd_sbmixer_write(chip, 0xdd, count>>8);
255 spin_unlock_irqrestore(&chip->mixer_lock, flags );
259 static int snd_als4000_playback_prepare(snd_pcm_substream_t *substream)
262 sb_t *chip = snd_pcm_substream_chip(substream);
263 snd_pcm_runtime_t *runtime = substream->runtime;
267 chip->playback_format = snd_als4000_get_format(runtime);
269 size = snd_pcm_lib_buffer_bytes(substream);
270 count = snd_pcm_lib_period_bytes(substream);
272 if (chip->playback_format & ALS4000_FORMAT_16BIT)
276 /* FIXME: from second playback on, there's a lot more clicks and pops
277 * involved here than on first playback. Fiddling with
278 * tons of different settings didn't help (DMA, speaker on/off,
279 * reordering, ...). Something seems to get enabled on playback
280 * that I haven't found out how to disable again, which then causes
281 * the switching pops to reach the speakers the next time here. */
282 spin_lock_irqsave(&chip->reg_lock, flags);
283 snd_als4000_set_rate(chip, runtime->rate);
284 snd_als4000_set_playback_dma(chip, runtime->dma_addr, size);
286 /* SPEAKER_ON not needed, since dma_on seems to also enable speaker */
287 /* snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); */
288 snd_sbdsp_command(chip, playback_cmd(chip).dsp_cmd);
289 snd_sbdsp_command(chip, playback_cmd(chip).format);
290 snd_sbdsp_command(chip, count);
291 snd_sbdsp_command(chip, count>>8);
292 snd_sbdsp_command(chip, playback_cmd(chip).dma_off);
293 spin_unlock_irqrestore(&chip->reg_lock, flags);
298 static int snd_als4000_capture_trigger(snd_pcm_substream_t * substream, int cmd)
300 sb_t *chip = snd_pcm_substream_chip(substream);
303 spin_lock(&chip->mixer_lock);
304 if (cmd == SNDRV_PCM_TRIGGER_START) {
305 chip->mode |= SB_RATE_LOCK_CAPTURE;
306 snd_sbmixer_write(chip, 0xde, capture_cmd(chip));
307 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
308 chip->mode &= ~SB_RATE_LOCK_CAPTURE;
309 snd_sbmixer_write(chip, 0xde, 0);
313 spin_unlock(&chip->mixer_lock);
317 static int snd_als4000_playback_trigger(snd_pcm_substream_t * substream, int cmd)
319 sb_t *chip = snd_pcm_substream_chip(substream);
322 spin_lock(&chip->reg_lock);
323 if (cmd == SNDRV_PCM_TRIGGER_START) {
324 chip->mode |= SB_RATE_LOCK_PLAYBACK;
325 snd_sbdsp_command(chip, playback_cmd(chip).dma_on);
326 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
327 snd_sbdsp_command(chip, playback_cmd(chip).dma_off);
328 chip->mode &= ~SB_RATE_LOCK_PLAYBACK;
332 spin_unlock(&chip->reg_lock);
336 static snd_pcm_uframes_t snd_als4000_capture_pointer(snd_pcm_substream_t * substream)
338 sb_t *chip = snd_pcm_substream_chip(substream);
341 spin_lock(&chip->reg_lock);
342 result = snd_als4000_gcr_read(chip, 0xa4) & 0xffff;
343 spin_unlock(&chip->reg_lock);
344 return bytes_to_frames( substream->runtime, result );
347 static snd_pcm_uframes_t snd_als4000_playback_pointer(snd_pcm_substream_t * substream)
349 sb_t *chip = snd_pcm_substream_chip(substream);
352 spin_lock(&chip->reg_lock);
353 result = snd_als4000_gcr_read(chip, 0xa0) & 0xffff;
354 spin_unlock(&chip->reg_lock);
355 return bytes_to_frames( substream->runtime, result );
358 static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
364 /* find out which bit of the ALS4000 produced the interrupt */
365 gcr_status = inb(chip->alt_port + 0xe);
367 if ((gcr_status & 0x80) && (chip->playback_substream)) /* playback */
368 snd_pcm_period_elapsed(chip->playback_substream);
369 if ((gcr_status & 0x40) && (chip->capture_substream)) /* capturing */
370 snd_pcm_period_elapsed(chip->capture_substream);
371 if ((gcr_status & 0x10) && (chip->rmidi)) /* MPU401 interrupt */
372 snd_mpu401_uart_interrupt(irq, chip->rmidi, regs);
373 /* release the gcr */
374 outb(gcr_status, chip->alt_port + 0xe);
376 spin_lock(&chip->mixer_lock);
377 sb_status = snd_sbmixer_read(chip, SB_DSP4_IRQSTATUS);
378 spin_unlock(&chip->mixer_lock);
380 if (sb_status & SB_IRQTYPE_8BIT)
381 snd_sb_ack_8bit(chip);
382 if (sb_status & SB_IRQTYPE_16BIT)
383 snd_sb_ack_16bit(chip);
384 if (sb_status & SB_IRQTYPE_MPUIN)
386 if (sb_status & 0x20)
387 inb(SBP(chip, RESET));
391 /*****************************************************************/
393 static snd_pcm_hardware_t snd_als4000_playback =
395 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
396 SNDRV_PCM_INFO_MMAP_VALID),
397 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
398 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE, /* formats */
399 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
404 .buffer_bytes_max = 65536,
405 .period_bytes_min = 64,
406 .period_bytes_max = 65536,
412 static snd_pcm_hardware_t snd_als4000_capture =
414 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
415 SNDRV_PCM_INFO_MMAP_VALID),
416 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
417 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE, /* formats */
418 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
423 .buffer_bytes_max = 65536,
424 .period_bytes_min = 64,
425 .period_bytes_max = 65536,
431 /*****************************************************************/
433 static int snd_als4000_playback_open(snd_pcm_substream_t * substream)
435 sb_t *chip = snd_pcm_substream_chip(substream);
436 snd_pcm_runtime_t *runtime = substream->runtime;
438 chip->playback_substream = substream;
439 runtime->hw = snd_als4000_playback;
443 static int snd_als4000_playback_close(snd_pcm_substream_t * substream)
445 sb_t *chip = snd_pcm_substream_chip(substream);
447 chip->playback_substream = NULL;
448 snd_pcm_lib_free_pages(substream);
452 static int snd_als4000_capture_open(snd_pcm_substream_t * substream)
454 sb_t *chip = snd_pcm_substream_chip(substream);
455 snd_pcm_runtime_t *runtime = substream->runtime;
457 chip->capture_substream = substream;
458 runtime->hw = snd_als4000_capture;
462 static int snd_als4000_capture_close(snd_pcm_substream_t * substream)
464 sb_t *chip = snd_pcm_substream_chip(substream);
466 chip->capture_substream = NULL;
467 snd_pcm_lib_free_pages(substream);
471 /******************************************************************/
473 static snd_pcm_ops_t snd_als4000_playback_ops = {
474 .open = snd_als4000_playback_open,
475 .close = snd_als4000_playback_close,
476 .ioctl = snd_pcm_lib_ioctl,
477 .hw_params = snd_als4000_hw_params,
478 .hw_free = snd_als4000_hw_free,
479 .prepare = snd_als4000_playback_prepare,
480 .trigger = snd_als4000_playback_trigger,
481 .pointer = snd_als4000_playback_pointer
484 static snd_pcm_ops_t snd_als4000_capture_ops = {
485 .open = snd_als4000_capture_open,
486 .close = snd_als4000_capture_close,
487 .ioctl = snd_pcm_lib_ioctl,
488 .hw_params = snd_als4000_hw_params,
489 .hw_free = snd_als4000_hw_free,
490 .prepare = snd_als4000_capture_prepare,
491 .trigger = snd_als4000_capture_trigger,
492 .pointer = snd_als4000_capture_pointer
495 static void snd_als4000_pcm_free(snd_pcm_t *pcm)
497 sb_t *chip = pcm->private_data;
499 snd_pcm_lib_preallocate_free_for_all(pcm);
502 static int __devinit snd_als4000_pcm(sb_t *chip, int device)
507 if ((err = snd_pcm_new(chip->card, "ALS4000 DSP", device, 1, 1, &pcm)) < 0)
509 pcm->private_free = snd_als4000_pcm_free;
510 pcm->private_data = chip;
511 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
512 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops);
513 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops);
515 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
523 /******************************************************************/
525 static void snd_als4000_set_addr(unsigned long gcr,
535 confB |= (mpu | 1) << 16;
539 confA |= (game | 1) << 16;
542 snd_als4000_gcr_write_addr(gcr, 0xa8, confA);
543 snd_als4000_gcr_write_addr(gcr, 0xa9, confB);
546 static void __devinit snd_als4000_configure(sb_t *chip)
551 /* do some more configuration */
552 spin_lock_irq(&chip->mixer_lock);
553 tmp = snd_sbmixer_read(chip, 0xc0);
554 snd_sbmixer_write(chip, 0xc0, tmp|0x80);
555 /* always select DMA channel 0, since we do not actually use DMA */
556 snd_sbmixer_write(chip, SB_DSP4_DMASETUP, SB_DMASETUP_DMA0);
557 snd_sbmixer_write(chip, 0xc0, tmp&0x7f);
558 spin_unlock_irq(&chip->mixer_lock);
560 spin_lock_irq(&chip->reg_lock);
561 /* magic number. Enables interrupts(?) */
562 snd_als4000_gcr_write(chip, 0x8c, 0x28000);
563 for(i = 0x91; i <= 0x96; ++i)
564 snd_als4000_gcr_write(chip, i, 0);
566 snd_als4000_gcr_write(chip, 0x99, snd_als4000_gcr_read(chip, 0x99));
567 spin_unlock_irq(&chip->reg_lock);
570 static void snd_card_als4000_free( snd_card_t *card )
572 snd_card_als4000_t * acard = (snd_card_als4000_t *)card->private_data;
573 /* make sure that interrupts are disabled */
574 snd_als4000_gcr_write_addr( acard->gcr, 0x8c, 0);
576 #ifdef SUPPORT_JOYSTICK
577 if (acard->res_joystick) {
578 if (acard->gameport.io)
579 gameport_unregister_port(&acard->gameport);
580 snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */
581 release_resource(acard->res_joystick);
582 kfree_nocheck(acard->res_joystick);
585 pci_release_regions(acard->pci);
588 static int __devinit snd_card_als4000_probe(struct pci_dev *pci,
589 const struct pci_device_id *pci_id)
593 snd_card_als4000_t *acard;
601 if (dev >= SNDRV_CARDS)
608 /* enable PCI device */
609 if ((err = pci_enable_device(pci)) < 0) {
612 /* check, if we can restrict PCI DMA transfers to 24 bits */
613 if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
614 pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
615 snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
619 if ((err = pci_request_regions(pci, "ALS4000")) < 0)
621 gcr = pci_resource_start(pci, 0);
623 pci_read_config_word(pci, PCI_COMMAND, &word);
624 pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO);
627 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
628 sizeof( snd_card_als4000_t ) );
630 pci_release_regions(pci);
634 acard = (snd_card_als4000_t *)card->private_data;
637 card->private_free = snd_card_als4000_free;
639 /* disable all legacy ISA stuff except for joystick */
640 #ifdef SUPPORT_JOYSTICK
641 if (joystick_port[dev] == 1) {
644 for (p = 0x200; p <= 0x218; p += 8) {
645 if ((acard->res_joystick = request_region(p, 8, "ALS4000 gameport")) != NULL) {
646 joystick_port[dev] = p;
650 } else if (joystick_port[dev] > 0)
651 acard->res_joystick = request_region(joystick_port[dev], 8, "ALS4000 gameport");
652 if (acard->res_joystick)
653 joystick = joystick_port[dev];
657 snd_als4000_set_addr(gcr, 0, 0, 0, joystick);
659 if ((err = snd_sbdsp_create(card,
662 snd_als4000_interrupt,
672 chip->alt_port = gcr;
673 snd_card_set_dev(card, &pci->dev);
675 snd_als4000_configure(chip);
677 strcpy(card->driver, "ALS4000");
678 strcpy(card->shortname, "Avance Logic ALS4000");
679 sprintf(card->longname, "%s at 0x%lx, irq %i",
680 card->shortname, chip->alt_port, chip->irq);
682 if ((err = snd_mpu401_uart_new( card, 0, MPU401_HW_ALS4000,
683 gcr+0x30, 1, pci->irq, 0,
684 &chip->rmidi)) < 0) {
686 printk(KERN_ERR "als4000: no MPU-401device at 0x%lx ?\n", gcr+0x30);
690 if ((err = snd_als4000_pcm(chip, 0)) < 0) {
694 if ((err = snd_sbmixer_new(chip)) < 0) {
699 if (snd_opl3_create(card, gcr+0x10, gcr+0x12,
700 OPL3_HW_AUTO, 1, &opl3) < 0) {
701 printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx ?\n",
702 gcr+0x10, gcr+0x12 );
704 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
710 #ifdef SUPPORT_JOYSTICK
711 if (acard->res_joystick) {
712 acard->gameport.io = joystick;
713 gameport_register_port(&acard->gameport);
717 if ((err = snd_card_register(card)) < 0) {
721 pci_set_drvdata(pci, card);
726 static void __devexit snd_card_als4000_remove(struct pci_dev *pci)
728 snd_card_free(pci_get_drvdata(pci));
729 pci_set_drvdata(pci, NULL);
732 static struct pci_driver driver = {
734 .id_table = snd_als4000_ids,
735 .probe = snd_card_als4000_probe,
736 .remove = __devexit_p(snd_card_als4000_remove),
739 static int __init alsa_card_als4000_init(void)
741 return pci_module_init(&driver);
744 static void __exit alsa_card_als4000_exit(void)
746 pci_unregister_driver(&driver);
749 module_init(alsa_card_als4000_init)
750 module_exit(alsa_card_als4000_exit)