static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_wss *chip; struct snd_pcm *pcm; int error; error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); if (error < 0) return error; error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], dma2[n], WSS_HW_DETECT, 0, &chip); if (error < 0) goto out; card->private_data = chip; error = snd_wss_pcm(chip, 0, &pcm); if (error < 0) goto out; strcpy(card->driver, "CS4231"); strcpy(card->shortname, pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", pcm->name, chip->port, irq[n], dma1[n]); if (dma2[n] >= 0) sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); error = snd_wss_mixer(chip); if (error < 0) goto out; error = snd_wss_timer(chip, 0, NULL); if (error < 0) goto out; if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) { if (mpu_irq[n] == SNDRV_AUTO_IRQ) mpu_irq[n] = -1; if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, mpu_port[n], 0, mpu_irq[n], NULL) < 0) dev_warn(dev, "MPU401 not detected\n"); } snd_card_set_dev(card, dev); error = snd_card_register(card); if (error < 0) goto out; dev_set_drvdata(dev, card); return 0; out: snd_card_free(card); return error; }
static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_wss *chip; struct snd_pcm *pcm; int error; error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); if (error < 0) return error; error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], -1, thinkpad[n] ? WSS_HW_THINKPAD : WSS_HW_DETECT, 0, &chip); if (error < 0) goto out; card->private_data = chip; error = snd_wss_pcm(chip, 0, &pcm); if (error < 0) goto out; error = snd_wss_mixer(chip); if (error < 0) goto out; strcpy(card->driver, "AD1848"); strcpy(card->shortname, pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", pcm->name, chip->port, irq[n], dma1[n]); if (thinkpad[n]) strcat(card->longname, " [Thinkpad]"); snd_card_set_dev(card, dev); error = snd_card_register(card); if (error < 0) goto out; dev_set_drvdata(dev, card); return 0; out: snd_card_free(card); return error; }
static int snd_wavefront_probe (struct snd_card *card, int dev) { snd_wavefront_card_t *acard = card->private_data; struct snd_wss *chip; struct snd_hwdep *wavefront_synth; struct snd_rawmidi *ics2115_internal_rmidi = NULL; struct snd_rawmidi *ics2115_external_rmidi = NULL; struct snd_hwdep *fx_processor; int hw_dev = 0, midi_dev = 0, err; /* --------- PCM --------------- */ err = snd_wss_create(card, cs4232_pcm_port[dev], -1, cs4232_pcm_irq[dev], dma1[dev], dma2[dev], WSS_HW_DETECT, 0, &chip); if (err < 0) { snd_printk(KERN_ERR "can't allocate WSS device\n"); return err; } err = snd_wss_pcm(chip, 0, NULL); if (err < 0) return err; err = snd_wss_timer(chip, 0, NULL); if (err < 0) return err; /* ---------- OPL3 synth --------- */ if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { struct snd_opl3 *opl3; err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, OPL3_HW_OPL3_CS, 0, &opl3); if (err < 0) { snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n"); return err; } err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL); if (err < 0) return err; hw_dev++; } /* ------- ICS2115 Wavetable synth ------- */ acard->wavefront.res_base = request_region(ics2115_port[dev], 16, "ICS2115"); if (acard->wavefront.res_base == NULL) { snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", ics2115_port[dev], ics2115_port[dev] + 16 - 1); return -EBUSY; } if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, 0, "ICS2115", acard)) { snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); return -EBUSY; } acard->wavefront.irq = ics2115_irq[dev]; acard->wavefront.base = ics2115_port[dev]; wavefront_synth = snd_wavefront_new_synth(card, hw_dev, acard); if (wavefront_synth == NULL) { snd_printk (KERN_ERR "can't create WaveFront synth device\n"); return -ENOMEM; } strcpy (wavefront_synth->name, "ICS2115 Wavetable MIDI Synthesizer"); wavefront_synth->iface = SNDRV_HWDEP_IFACE_ICS2115; hw_dev++; /* --------- Mixer ------------ */ err = snd_wss_mixer(chip); if (err < 0) { snd_printk (KERN_ERR "can't allocate mixer device\n"); return err; } /* -------- CS4232 MPU-401 interface -------- */ if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) { err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232, cs4232_mpu_port[dev], 0, cs4232_mpu_irq[dev], NULL); if (err < 0) { snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n"); return err; } midi_dev++; } /* ------ ICS2115 internal MIDI ------------ */ if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) { ics2115_internal_rmidi = snd_wavefront_new_midi (card, midi_dev, acard, ics2115_port[dev], internal_mpu); if (ics2115_internal_rmidi == NULL) { snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n"); return -ENOMEM; } midi_dev++; } /* ------ ICS2115 external MIDI ------------ */ if (ics2115_port[dev] > 0 && ics2115_port[dev] != SNDRV_AUTO_PORT) { ics2115_external_rmidi = snd_wavefront_new_midi (card, midi_dev, acard, ics2115_port[dev], external_mpu); if (ics2115_external_rmidi == NULL) { snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n"); return -ENOMEM; } midi_dev++; } /* FX processor for Tropez+ */ if (acard->wavefront.has_fx) { fx_processor = snd_wavefront_new_fx (card, hw_dev, acard, ics2115_port[dev]); if (fx_processor == NULL) { snd_printk (KERN_ERR "can't setup FX device\n"); return -ENOMEM; } hw_dev++; strcpy(card->driver, "Tropez+"); strcpy(card->shortname, "Turtle Beach Tropez+"); } else { /* Need a way to distinguish between Maui and Tropez */ strcpy(card->driver, "WaveFront"); strcpy(card->shortname, "Turtle Beach WaveFront"); } /* ----- Register the card --------- */ /* Not safe to include "Turtle Beach" in longname, due to length restrictions */ sprintf(card->longname, "%s PCM 0x%lx irq %d dma %d", card->driver, chip->port, cs4232_pcm_irq[dev], dma1[dev]); if (dma2[dev] >= 0 && dma2[dev] < 8) sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) { sprintf (card->longname + strlen (card->longname), " MPU-401 0x%lx irq %d", cs4232_mpu_port[dev], cs4232_mpu_irq[dev]); } sprintf (card->longname + strlen (card->longname), " SYNTH 0x%lx irq %d", ics2115_port[dev], ics2115_irq[dev]); return snd_card_register(card); }
static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev) { struct snd_card *card; struct snd_opl3 *opl3; struct snd_cmi8328 *cmi; #ifdef SUPPORT_JOYSTICK struct resource *res; #endif int err, pos; static long mpu_ports[] = { 0x330, 0x300, 0x310, 0x320, 0x332, 0x334, 0x336, -1 }; static u8 mpu_port_bits[] = { 3, 0, 1, 2, 4, 5, 6 }; static int mpu_irqs[] = { 9, 7, 5, 3, -1 }; static u8 mpu_irq_bits[] = { 3, 2, 1, 0 }; static int irqs[] = { 9, 10, 11, 7, -1 }; static u8 irq_bits[] = { 2, 3, 4, 1 }; static int dma1s[] = { 3, 1, 0, -1 }; static u8 dma_bits[] = { 3, 2, 1 }; static int dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, {0, -1} }; u16 port = cmi8328_ports[ndev]; u8 val; /* 0xff is invalid configuration (but settable - hope it isn't set) */ if (snd_cmi8328_cfg_read(port, CFG1) == 0xff) return -ENODEV; /* the SB disable bit must NEVER EVER be cleared or the WSS dies */ snd_cmi8328_cfg_write(port, CFG1, CFG1_SB_DISABLE); if (snd_cmi8328_cfg_read(port, CFG1) != CFG1_SB_DISABLE) return -ENODEV; /* disable everything first */ snd_cmi8328_cfg_write(port, CFG2, 0); /* disable CDROM and MPU401 */ snd_cmi8328_cfg_write(port, CFG3, 0); /* disable CDROM IRQ and DMA */ if (irq[ndev] == SNDRV_AUTO_IRQ) { irq[ndev] = snd_legacy_find_free_irq(irqs); if (irq[ndev] < 0) { snd_printk(KERN_ERR "unable to find a free IRQ\n"); return -EBUSY; } } if (dma1[ndev] == SNDRV_AUTO_DMA) { dma1[ndev] = snd_legacy_find_free_dma(dma1s); if (dma1[ndev] < 0) { snd_printk(KERN_ERR "unable to find a free DMA1\n"); return -EBUSY; } } if (dma2[ndev] == SNDRV_AUTO_DMA) { dma2[ndev] = snd_legacy_find_free_dma(dma2s[dma1[ndev] % 4]); if (dma2[ndev] < 0) { snd_printk(KERN_WARNING "unable to find a free DMA2, full-duplex will not work\n"); dma2[ndev] = -1; } } /* configure WSS IRQ... */ pos = array_find(irqs, irq[ndev]); if (pos < 0) { snd_printk(KERN_ERR "invalid IRQ %d\n", irq[ndev]); return -EINVAL; } val = irq_bits[pos] << 3; /* ...and DMA... */ pos = array_find(dma1s, dma1[ndev]); if (pos < 0) { snd_printk(KERN_ERR "invalid DMA1 %d\n", dma1[ndev]); return -EINVAL; } val |= dma_bits[pos]; /* ...and DMA2 */ if (dma2[ndev] >= 0 && dma1[ndev] != dma2[ndev]) { pos = array_find(dma2s[dma1[ndev]], dma2[ndev]); if (pos < 0) { snd_printk(KERN_ERR "invalid DMA2 %d\n", dma2[ndev]); return -EINVAL; } val |= 0x04; /* enable separate capture DMA */ } outb(val, port); err = snd_card_create(index[ndev], id[ndev], THIS_MODULE, sizeof(struct snd_cmi8328), &card); if (err < 0) return err; cmi = card->private_data; cmi->card = card; cmi->port = port; cmi->wss_cfg = val; snd_card_set_dev(card, pdev); err = snd_wss_create(card, port + 4, -1, irq[ndev], dma1[ndev], dma2[ndev], WSS_HW_DETECT, 0, &cmi->wss); if (err < 0) goto error; err = snd_wss_pcm(cmi->wss, 0, NULL); if (err < 0) goto error; err = snd_wss_mixer(cmi->wss); if (err < 0) goto error; err = snd_cmi8328_mixer(cmi->wss); if (err < 0) goto error; if (snd_wss_timer(cmi->wss, 0, NULL) < 0) snd_printk(KERN_WARNING "error initializing WSS timer\n"); if (mpuport[ndev] == SNDRV_AUTO_PORT) { mpuport[ndev] = snd_legacy_find_free_ioport(mpu_ports, 2); if (mpuport[ndev] < 0) snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); } if (mpuirq[ndev] == SNDRV_AUTO_IRQ) { mpuirq[ndev] = snd_legacy_find_free_irq(mpu_irqs); if (mpuirq[ndev] < 0) snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); } /* enable and configure MPU401 */ if (mpuport[ndev] > 0 && mpuirq[ndev] > 0) { val = CFG2_MPU_ENABLE; pos = array_find_l(mpu_ports, mpuport[ndev]); if (pos < 0) snd_printk(KERN_WARNING "invalid MPU401 port 0x%lx\n", mpuport[ndev]); else { val |= mpu_port_bits[pos] << 5; pos = array_find(mpu_irqs, mpuirq[ndev]); if (pos < 0) snd_printk(KERN_WARNING "invalid MPU401 IRQ %d\n", mpuirq[ndev]); else { val |= mpu_irq_bits[pos] << 3; snd_cmi8328_cfg_write(port, CFG2, val); if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, mpuport[ndev], 0, mpuirq[ndev], NULL) < 0) snd_printk(KERN_ERR "error initializing MPU401\n"); } } } /* OPL3 is hardwired to 0x388 and cannot be disabled */ if (snd_opl3_create(card, 0x388, 0x38a, OPL3_HW_AUTO, 0, &opl3) < 0) snd_printk(KERN_ERR "error initializing OPL3\n"); else if (snd_opl3_hwdep_new(opl3, 0, 1, NULL) < 0) snd_printk(KERN_WARNING "error initializing OPL3 hwdep\n"); strcpy(card->driver, "CMI8328"); strcpy(card->shortname, "C-Media CMI8328"); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d,%d", card->shortname, cmi->wss->port, irq[ndev], dma1[ndev], (dma2[ndev] >= 0) ? dma2[ndev] : dma1[ndev]); dev_set_drvdata(pdev, card); err = snd_card_register(card); if (err < 0) goto error; #ifdef SUPPORT_JOYSTICK if (!gameport[ndev]) return 0; /* gameport is hardwired to 0x200 */ res = request_region(0x200, 8, "CMI8328 gameport"); if (!res) snd_printk(KERN_WARNING "unable to allocate gameport I/O port\n"); else { struct gameport *gp = cmi->gameport = gameport_allocate_port(); if (!cmi->gameport) release_and_free_resource(res); else { gameport_set_name(gp, "CMI8328 Gameport"); gameport_set_phys(gp, "%s/gameport0", dev_name(pdev)); gameport_set_dev_parent(gp, pdev); gp->io = 0x200; gameport_set_port_data(gp, res); /* Enable gameport */ snd_cmi8328_cfg_write(port, CFG1, CFG1_SB_DISABLE | CFG1_GAMEPORT); gameport_register_port(gp); } } #endif return 0; error: snd_card_free(card); return err; }
static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev) { static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; struct snd_card *card; struct snd_gus_card *gus = NULL; struct snd_wss *wss; struct snd_gusmax *maxcard; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_gusmax)); if (card == NULL) return -ENOMEM; card->private_free = snd_gusmax_free; maxcard = (struct snd_gusmax *)card->private_data; maxcard->card = card; maxcard->irq = -1; xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); err = -EBUSY; goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); err = -EBUSY; goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); err = -EBUSY; goto _err; } } if (port[dev] != SNDRV_AUTO_PORT) { err = snd_gus_create(card, port[dev], -xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], 0, &gus); } else { static unsigned long possible_ports[] = { 0x220, 0x230, 0x240, 0x250, 0x260 }; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { err = snd_gus_create(card, possible_ports[i], -xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], 0, &gus); if (err >= 0) { port[dev] = possible_ports[i]; break; } } } if (err < 0) goto _err; if ((err = snd_gusmax_detect(gus)) < 0) goto _err; maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_gusmax_init(dev, card, gus); if ((err = snd_gus_initialize(gus)) < 0) goto _err; if (!gus->max_flag) { snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); err = -ENODEV; goto _err; } if (request_irq(xirq, snd_gusmax_interrupt, IRQF_DISABLED, "GUS MAX", (void *)maxcard)) { snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); err = -EBUSY; goto _err; } maxcard->irq = xirq; err = snd_wss_create(card, gus->gf1.port + 0x10c, -1, xirq, xdma2 < 0 ? xdma1 : xdma2, xdma1, WSS_HW_DETECT, WSS_HWSHARE_IRQ | WSS_HWSHARE_DMA1 | WSS_HWSHARE_DMA2, &wss); if (err < 0) goto _err; err = snd_wss_pcm(wss, 0, NULL); if (err < 0) goto _err; err = snd_wss_mixer(wss); if (err < 0) goto _err; err = snd_wss_timer(wss, 2, NULL); if (err < 0) goto _err; if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) goto _err; } err = snd_gusmax_mixer(wss); if (err < 0) goto _err; err = snd_gf1_rawmidi_new(gus, 0, NULL); if (err < 0) goto _err; sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); snd_card_set_dev(card, pdev); err = snd_card_register(card); if (err < 0) goto _err; maxcard->gus = gus; maxcard->wss = wss; dev_set_drvdata(pdev, card); return 0; _err: snd_card_free(card); return err; }
static int __devinit snd_galaxy_probe(struct device *dev, unsigned int n) { struct snd_galaxy *galaxy; struct snd_wss *chip; struct snd_card *card; u8 type; int err; err = snd_card_create(index[n], id[n], THIS_MODULE, sizeof *galaxy, &card); if (err < 0) return err; snd_card_set_dev(card, dev); card->private_free = snd_galaxy_free; galaxy = card->private_data; galaxy->res_port = request_region(port[n], 16, DRV_NAME); if (!galaxy->res_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", port[n], port[n] + 15); err = -EBUSY; goto error; } galaxy->port = ioport_map(port[n], 16); err = galaxy_init(galaxy, &type); if (err < 0) { dev_err(dev, "did not find a Sound Galaxy at %#lx\n", port[n]); goto error; } dev_info(dev, "Sound Galaxy (type %d) found at %#lx\n", type, port[n]); galaxy->res_config_port = request_region(port[n] + GALAXY_PORT_CONFIG, 16, DRV_NAME); if (!galaxy->res_config_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", port[n] + GALAXY_PORT_CONFIG, port[n] + GALAXY_PORT_CONFIG + 15); err = -EBUSY; goto error; } galaxy->config_port = ioport_map(port[n] + GALAXY_PORT_CONFIG, 16); galaxy_config(galaxy, config[n]); galaxy->res_wss_port = request_region(wss_port[n], 4, DRV_NAME); if (!galaxy->res_wss_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", wss_port[n], wss_port[n] + 3); err = -EBUSY; goto error; } galaxy->wss_port = ioport_map(wss_port[n], 4); err = galaxy_wss_config(galaxy, wss_config[n]); if (err < 0) { dev_err(dev, "could not configure WSS\n"); goto error; } strcpy(card->driver, DRV_NAME); strcpy(card->shortname, DRV_NAME); sprintf(card->longname, "%s at %#lx/%#lx, irq %d, dma %d/%d", card->shortname, port[n], wss_port[n], irq[n], dma1[n], dma2[n]); err = snd_wss_create(card, wss_port[n] + 4, -1, irq[n], dma1[n], dma2[n], WSS_HW_DETECT, 0, &chip); if (err < 0) goto error; err = snd_wss_pcm(chip, 0, NULL); if (err < 0) goto error; err = snd_wss_mixer(chip); if (err < 0) goto error; err = snd_wss_timer(chip, 0, NULL); if (err < 0) goto error; if (mpu_port[n] >= 0) { err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, mpu_port[n], 0, mpu_irq[n], NULL); if (err < 0) goto error; } if (fm_port[n] >= 0) { struct snd_opl3 *opl3; err = snd_opl3_create(card, fm_port[n], fm_port[n] + 2, OPL3_HW_AUTO, 0, &opl3); if (err < 0) { dev_err(dev, "no OPL device at %#lx\n", fm_port[n]); goto error; } err = snd_opl3_timer_new(opl3, 1, 2); if (err < 0) goto error; err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); if (err < 0) goto error; } err = snd_card_register(card); if (err < 0) goto error; dev_set_drvdata(dev, card); return 0; error: snd_card_free(card); return err; }
static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) { static int possible_irqs[] = {7, 9, 10, 11, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int err, xirq, xdma1; struct snd_card *card; struct snd_wss *chip; err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); if (err < 0) return err; xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); err = -EBUSY; goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); err = -EBUSY; goto _err; } } if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) goto _err; err = snd_wss_create(card, wssport[dev] + 4, -1, xirq, xdma1, -1, WSS_HW_DETECT, 0, &chip); if (err < 0) goto _err; card->private_data = chip; err = snd_wss_pcm(chip, 0, NULL); if (err < 0) { snd_printdd(PFX "error creating new WSS PCM device\n"); goto _err; } err = snd_wss_mixer(chip); if (err < 0) { snd_printdd(PFX "error creating new WSS mixer\n"); goto _err; } if ((err = snd_sgalaxy_mixer(chip)) < 0) { snd_printdd(PFX "the mixer rewrite failed\n"); goto _err; } strcpy(card->driver, "Sound Galaxy"); strcpy(card->shortname, "Sound Galaxy"); sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", wssport[dev], xirq, xdma1); snd_card_set_dev(card, devptr); if ((err = snd_card_register(card)) < 0) goto _err; dev_set_drvdata(devptr, card); return 0; _err: snd_card_free(card); return err; }
static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) { static int possible_irqs[] = { 5, 7, 9, 10, 11, -1 }; static int possible_dmas[] = { 1, 3, 0, -1 }; int err; int xirq = irq[dev]; int xdma = dma[dev]; struct snd_card *card; struct snd_wss *chip; struct snd_opl3 *opl3; char __iomem *vport; char __iomem *vmss_port; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (!card) return -ENOMEM; if (xirq == SNDRV_AUTO_IRQ) { xirq = snd_legacy_find_free_irq(possible_irqs); if (xirq < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); err = -EBUSY; goto err_exit; } } if (xdma == SNDRV_AUTO_DMA) { xdma = snd_legacy_find_free_dma(possible_dmas); if (xdma < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); err = -EBUSY; goto err_exit; } } if (!request_region(port[dev], 0x10, DRV_NAME)) { snd_printk(KERN_ERR PFX "I/O port region is already in use.\n"); err = -EBUSY; goto err_exit; } vport = devm_ioport_map(devptr, port[dev], 0x10); if (!vport) { snd_printk(KERN_ERR PFX "I/O port cannot be iomaped.\n"); err = -EBUSY; goto err_unmap1; } /* to make it marked as used */ if (!request_region(mss_port[dev], 4, DRV_NAME)) { snd_printk(KERN_ERR PFX "SC-6000 port I/O port region is already in use.\n"); err = -EBUSY; goto err_unmap1; } vmss_port = devm_ioport_map(devptr, mss_port[dev], 4); if (!vport) { snd_printk(KERN_ERR PFX "MSS port I/O cannot be iomaped.\n"); err = -EBUSY; goto err_unmap2; } snd_printd("Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n", port[dev], xirq, xdma, mpu_irq[dev] == SNDRV_AUTO_IRQ ? 0 : mpu_irq[dev]); err = sc6000_init_board(vport, xirq, xdma, vmss_port, mpu_irq[dev]); if (err < 0) goto err_unmap2; err = snd_wss_create(card, mss_port[dev] + 4, -1, xirq, xdma, -1, WSS_HW_DETECT, 0, &chip); if (err < 0) goto err_unmap2; card->private_data = chip; err = snd_wss_pcm(chip, 0, NULL); if (err < 0) { snd_printk(KERN_ERR PFX "error creating new WSS PCM device\n"); goto err_unmap2; } err = snd_wss_mixer(chip); if (err < 0) { snd_printk(KERN_ERR PFX "error creating new WSS mixer\n"); goto err_unmap2; } err = snd_sc6000_mixer(chip); if (err < 0) { snd_printk(KERN_ERR PFX "the mixer rewrite failed\n"); goto err_unmap2; } if (snd_opl3_create(card, 0x388, 0x388 + 2, OPL3_HW_AUTO, 0, &opl3) < 0) { snd_printk(KERN_ERR PFX "no OPL device at 0x%x-0x%x ?\n", 0x388, 0x388 + 2); } else { err = snd_opl3_timer_new(opl3, 0, 1); if (err < 0) goto err_unmap2; err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); if (err < 0) goto err_unmap2; } if (mpu_port[dev] != SNDRV_AUTO_PORT) { if (mpu_irq[dev] == SNDRV_AUTO_IRQ) mpu_irq[dev] = -1; if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, mpu_port[dev], 0, mpu_irq[dev], IRQF_DISABLED, NULL) < 0) snd_printk(KERN_ERR "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); } strcpy(card->driver, DRV_NAME); strcpy(card->shortname, "SC-6000"); sprintf(card->longname, "Gallant SC-6000 at 0x%lx, irq %d, dma %d", mss_port[dev], xirq, xdma); snd_card_set_dev(card, devptr); err = snd_card_register(card); if (err < 0) goto err_unmap2; dev_set_drvdata(devptr, card); return 0; err_unmap2: release_region(mss_port[dev], 4); err_unmap1: release_region(port[dev], 0x10); err_exit: snd_card_free(card); return err; }
/* * Create an AD1845 PCM subdevice on the SoundScape. The AD1845 * is very much like a CS4231, with a few extra bits. We will * try to support at least some of the extra bits by overriding * some of the CS4231 callback. */ static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq, int dma1, int dma2) { register struct soundscape *sscape = get_card_soundscape(card); struct snd_wss *chip; int err; if (sscape->type == SSCAPE_VIVO) port += 4; if (dma1 == dma2) dma2 = -1; err = snd_wss_create(card, port, -1, irq, dma1, dma2, WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); if (!err) { unsigned long flags; struct snd_pcm *pcm; #define AD1845_FREQ_SEL_ENABLE 0x08 #define AD1845_PWR_DOWN_CTRL 0x1b #define AD1845_CRYS_CLOCK_SEL 0x1d /* * It turns out that the PLAYBACK_ENABLE bit is set * by the lowlevel driver ... * #define AD1845_IFACE_CONFIG \ (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE) snd_wss_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG); spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); */ if (sscape->type != SSCAPE_VIVO) { int val; /* * The input clock frequency on the SoundScape must * be 14.31818 MHz, because we must set this register * to get the playback to sound correct ... */ snd_wss_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); snd_wss_out(chip, AD1845_CRYS_CLOCK_SEL, 0x20); spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); /* * More custom configuration: * a) select "mode 2" and provide a current drive of 8mA * b) enable frequency selection (for capture/playback) */ spin_lock_irqsave(&chip->reg_lock, flags); snd_wss_out(chip, CS4231_MISC_INFO, CS4231_MODE2 | 0x10); val = snd_wss_in(chip, AD1845_PWR_DOWN_CTRL); snd_wss_out(chip, AD1845_PWR_DOWN_CTRL, val | AD1845_FREQ_SEL_ENABLE); spin_unlock_irqrestore(&chip->reg_lock, flags); } err = snd_wss_pcm(chip, 0, &pcm); if (err < 0) { snd_printk(KERN_ERR "sscape: No PCM device " "for AD1845 chip\n"); goto _error; } err = snd_wss_mixer(chip); if (err < 0) { snd_printk(KERN_ERR "sscape: No mixer device " "for AD1845 chip\n"); goto _error; } err = snd_wss_timer(chip, 0, NULL); if (err < 0) { snd_printk(KERN_ERR "sscape: No timer device " "for AD1845 chip\n"); goto _error; } if (sscape->type != SSCAPE_VIVO) { err = snd_ctl_add(card, snd_ctl_new1(&midi_mixer_ctl, chip)); if (err < 0) { snd_printk(KERN_ERR "sscape: Could not create " "MIDI mixer control\n"); goto _error; } chip->set_playback_format = ad1845_playback_format; chip->set_capture_format = ad1845_capture_format; } strcpy(card->driver, "SoundScape"); strcpy(card->shortname, pcm->name); snprintf(card->longname, sizeof(card->longname), "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", pcm->name, chip->port, chip->irq, chip->dma1, chip->dma2); sscape->chip = chip; } _error: return err; }
/* * Create an AD1845 PCM subdevice on the SoundScape. The AD1845 * is very much like a CS4231, with a few extra bits. We will * try to support at least some of the extra bits by overriding * some of the CS4231 callback. */ static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq, int dma1, int dma2) { register struct soundscape *sscape = get_card_soundscape(card); struct snd_wss *chip; int err; if (sscape->type == SSCAPE_VIVO) port += 4; if (dma1 == dma2) dma2 = -1; err = snd_wss_create(card, port, -1, irq, dma1, dma2, WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); if (!err) { unsigned long flags; struct snd_pcm *pcm; /* * It turns out that the PLAYBACK_ENABLE bit is set * by the lowlevel driver ... * #define AD1845_IFACE_CONFIG \ (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE) snd_wss_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG); spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); */ if (sscape->type != SSCAPE_VIVO) { /* * The input clock frequency on the SoundScape must * be 14.31818 MHz, because we must set this register * to get the playback to sound correct ... */ snd_wss_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); snd_wss_out(chip, AD1845_CLOCK, 0x20); spin_unlock_irqrestore(&chip->reg_lock, flags); snd_wss_mce_down(chip); } err = snd_wss_pcm(chip, 0, &pcm); if (err < 0) { snd_printk(KERN_ERR "sscape: No PCM device " "for AD1845 chip\n"); goto _error; } err = snd_wss_mixer(chip); if (err < 0) { snd_printk(KERN_ERR "sscape: No mixer device " "for AD1845 chip\n"); goto _error; } if (chip->hardware != WSS_HW_AD1848) { err = snd_wss_timer(chip, 0, NULL); if (err < 0) { snd_printk(KERN_ERR "sscape: No timer device " "for AD1845 chip\n"); goto _error; } } if (sscape->type != SSCAPE_VIVO) { err = snd_ctl_add(card, snd_ctl_new1(&midi_mixer_ctl, chip)); if (err < 0) { snd_printk(KERN_ERR "sscape: Could not create " "MIDI mixer control\n"); goto _error; } } strcpy(card->driver, "SoundScape"); strcpy(card->shortname, pcm->name); snprintf(card->longname, sizeof(card->longname), "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", pcm->name, chip->port, chip->irq, chip->dma1, chip->dma2); sscape->chip = chip; } _error: return err; }