static int __init snd_gusmax_probe(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; snd_card_t *card; snd_gus_card_t *gus = NULL; cs4231_t *cs4231; 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_card_free(card); snd_printk("unable to find a free IRQ\n"); return -EBUSY; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_card_free(card); snd_printk("unable to find a free DMA1\n"); return -EBUSY; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_card_free(card); snd_printk("unable to find a free DMA2\n"); return -EBUSY; } } if ((err = snd_gus_create(card, port[dev], -xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], 0, &gus)) < 0) { snd_card_free(card); return err; } if ((err = snd_gusmax_detect(gus)) < 0) { snd_card_free(card); return 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) { snd_card_free(card); return err; } if (!gus->max_flag) { printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); snd_card_free(card); return -ENODEV; } if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { snd_card_free(card); printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); return -EBUSY; } maxcard->irq = xirq; if ((err = snd_cs4231_create(card, gus->gf1.port + 0x10c, -1, xirq, xdma2 < 0 ? xdma1 : xdma2, xdma1, CS4231_HW_DETECT, CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, &cs4231)) < 0) { snd_card_free(card); return err; } if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { snd_card_free(card); return err; } if ((err = snd_cs4231_mixer(cs4231)) < 0) { snd_card_free(card); return err; } if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { snd_card_free(card); return err; } if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { snd_card_free(card); return err; } } if ((err = snd_gusmax_mixer(cs4231)) < 0) { snd_card_free(card); return err; } if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { snd_card_free(card); return 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); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; } maxcard->gus = gus; maxcard->cs4231 = cs4231; snd_gusmax_cards[dev] = card; return 0; }
static int __init snd_gusclassic_probe(int dev) { static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2; snd_card_t *card; struct snd_gusclassic *guscard; snd_gus_card_t *gus = NULL; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; guscard = (struct snd_gusclassic *)card->private_data; if (pcm_channels[dev] < 2) pcm_channels[dev] = 2; xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { snd_card_free(card); snd_printk("unable to find a free IRQ\n"); return -EBUSY; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_card_free(card); snd_printk("unable to find a free DMA1\n"); return -EBUSY; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { snd_card_free(card); snd_printk("unable to find a free DMA2\n"); return -EBUSY; } } if ((err = snd_gus_create(card, port[dev], xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], 0, &gus)) < 0) { snd_card_free(card); return err; } if ((err = snd_gusclassic_detect(gus)) < 0) { snd_card_free(card); return err; } snd_gusclassic_init(dev, gus); if ((err = snd_gus_initialize(gus)) < 0) { snd_card_free(card); return err; } if (gus->max_flag || gus->ess_flag) { snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); snd_card_free(card); return -ENODEV; } if ((err = snd_gf1_new_mixer(gus)) < 0) { snd_card_free(card); return err; } if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) { snd_card_free(card); return err; } if (!gus->ace_flag) { if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { snd_card_free(card); return err; } } sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; } snd_gusclassic_cards[dev] = card; return 0; }
static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_gus_card *gus; int error; card = snd_card_new(index[n], id[n], THIS_MODULE, 0); if (!card) return -EINVAL; if (pcm_channels[n] < 2) pcm_channels[n] = 2; error = snd_gusclassic_create(card, dev, n, &gus); if (error < 0) goto out; error = snd_gusclassic_detect(gus); if (error < 0) goto out; gus->joystick_dac = joystick_dac[n]; error = snd_gus_initialize(gus); if (error < 0) goto out; error = -ENODEV; if (gus->max_flag || gus->ess_flag) { dev_err(dev, "GUS Classic or ACE soundcard was " "not detected at 0x%lx\n", gus->gf1.port); goto out; } error = snd_gf1_new_mixer(gus); if (error < 0) goto out; error = snd_gf1_pcm_new(gus, 0, 0, NULL); if (error < 0) goto out; if (!gus->ace_flag) { error = snd_gf1_rawmidi_new(gus, 0, NULL); if (error < 0) goto out; } sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, gus->gf1.irq, gus->gf1.dma1); if (gus->gf1.dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", gus->gf1.dma2); 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 __init snd_gusextreme_probe(int dev) { static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; static int possible_ess_dmas[] = {1, 3, 0, -1}; static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; snd_card_t *card; struct snd_gusextreme *acard; snd_gus_card_t *gus; es1688_t *es1688; opl3_t *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; acard = (struct snd_gusextreme *)card->private_data; xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { snd_printk("unable to find a free IRQ for GF1\n"); err = -EBUSY; goto out; } } xess_irq = irq[dev]; if (xess_irq == SNDRV_AUTO_IRQ) { if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { snd_printk("unable to find a free IRQ for ES1688\n"); err = -EBUSY; goto out; } } if (mpu_port[dev] == SNDRV_AUTO_PORT) mpu_port[dev] = 0; xmpu_irq = mpu_irq[dev]; if (xmpu_irq > 15) xmpu_irq = -1; xgf1_dma = dma1[dev]; if (xgf1_dma == SNDRV_AUTO_DMA) { if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { snd_printk("unable to find a free DMA for GF1\n"); err = -EBUSY; goto out; } } xess_dma = dma8[dev]; if (xess_dma == SNDRV_AUTO_DMA) { if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { snd_printk("unable to find a free DMA for ES1688\n"); err = -EBUSY; goto out; } } if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], xess_irq, xmpu_irq, xess_dma, ES1688_HW_1688, &es1688)) < 0) goto out; if (gf1_port[dev] < 0) gf1_port[dev] = port[dev] + 0x20; if ((err = snd_gus_create(card, gf1_port[dev], xgf1_irq, xgf1_dma, -1, 0, channels[dev], pcm_channels[dev], 0, &gus)) < 0) goto out; if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) goto out; snd_gusextreme_init(dev, gus); if ((err = snd_gus_initialize(gus)) < 0) goto out; if (!gus->ess_flag) { snd_printdd("GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); err = -ENODEV; goto out; } if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) goto out; if ((err = snd_es1688_mixer(es1688)) < 0) goto out; snd_component_add(card, "ES1688"); if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) goto out; } if ((err = snd_gf1_new_mixer(gus)) < 0) goto out; if ((err = snd_gusextreme_mixer(es1688)) < 0) goto out; if (snd_opl3_create(card, es1688->port, es1688->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) goto out; } if (es1688->mpu_port >= 0x300 && (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, es1688->mpu_port, 0, xmpu_irq, SA_INTERRUPT, NULL)) < 0) goto out; sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); if ((err = snd_card_register(card)) < 0) goto out; snd_gusextreme_cards[dev] = card; return 0; out: snd_card_free(card); return err; }
static int __init snd_gusmax_probe(struct platform_device *pdev) { int dev = pdev->id; 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_cs4231 *cs4231; 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; if ((err = snd_cs4231_create(card, gus->gf1.port + 0x10c, -1, xirq, xdma2 < 0 ? xdma1 : xdma2, xdma1, CS4231_HW_DETECT, CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, &cs4231)) < 0) goto _err; if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) goto _err; if ((err = snd_cs4231_mixer(cs4231)) < 0) goto _err; if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) goto _err; if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) goto _err; } if ((err = snd_gusmax_mixer(cs4231)) < 0) goto _err; if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 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->dev); if ((err = snd_card_register(card)) < 0) goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; platform_set_drvdata(pdev, card); return 0; _err: snd_card_free(card); return err; }
static int __init snd_gusextreme_probe(struct platform_device *pdev) { int dev = pdev->id; static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; static int possible_ess_dmas[] = {1, 3, 0, -1}; static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; struct snd_card *card; struct snd_gus_card *gus; struct snd_es1688 *es1688; struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n"); err = -EBUSY; goto out; } } xess_irq = irq[dev]; if (xess_irq == SNDRV_AUTO_IRQ) { if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n"); err = -EBUSY; goto out; } } if (mpu_port[dev] == SNDRV_AUTO_PORT) mpu_port[dev] = 0; xmpu_irq = mpu_irq[dev]; if (xmpu_irq > 15) xmpu_irq = -1; xgf1_dma = dma1[dev]; if (xgf1_dma == SNDRV_AUTO_DMA) { if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n"); err = -EBUSY; goto out; } } xess_dma = dma8[dev]; if (xess_dma == SNDRV_AUTO_DMA) { if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n"); err = -EBUSY; goto out; } } if (port[dev] != SNDRV_AUTO_PORT) { err = snd_es1688_create(card, port[dev], mpu_port[dev], xess_irq, xmpu_irq, xess_dma, ES1688_HW_1688, &es1688); } else { /* auto-probe legacy ports */ static unsigned long possible_ports[] = {0x220, 0x240, 0x260}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { err = snd_es1688_create(card, possible_ports[i], mpu_port[dev], xess_irq, xmpu_irq, xess_dma, ES1688_HW_1688, &es1688); if (err >= 0) { port[dev] = possible_ports[i]; break; } } } if (err < 0) goto out; if (gf1_port[dev] < 0) gf1_port[dev] = port[dev] + 0x20; if ((err = snd_gus_create(card, gf1_port[dev], xgf1_irq, xgf1_dma, -1, 0, channels[dev], pcm_channels[dev], 0, &gus)) < 0) goto out; if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) goto out; snd_gusextreme_init(dev, gus); if ((err = snd_gus_initialize(gus)) < 0) goto out; if (!gus->ess_flag) { snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); err = -ENODEV; goto out; } if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) goto out; if ((err = snd_es1688_mixer(es1688)) < 0) goto out; snd_component_add(card, "ES1688"); if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) goto out; } if ((err = snd_gf1_new_mixer(gus)) < 0) goto out; if ((err = snd_gusextreme_mixer(es1688)) < 0) goto out; if (snd_opl3_create(card, es1688->port, es1688->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) goto out; } if (es1688->mpu_port >= 0x300 && (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, es1688->mpu_port, 0, xmpu_irq, IRQF_DISABLED, NULL)) < 0) goto out; sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto out; platform_set_drvdata(pdev, card); return 0; out: snd_card_free(card); return err; }
static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_gus_card *gus; struct snd_es1688 *es1688; struct snd_opl3 *opl3; int error; error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); if (error < 0) return error; if (mpu_port[n] == SNDRV_AUTO_PORT) mpu_port[n] = 0; if (mpu_irq[n] > 15) mpu_irq[n] = -1; error = snd_gusextreme_es1688_create(card, dev, n, &es1688); if (error < 0) goto out; if (gf1_port[n] < 0) gf1_port[n] = es1688->port + 0x20; error = snd_gusextreme_gus_card_create(card, dev, n, &gus); if (error < 0) goto out; error = snd_gusextreme_detect(gus, es1688); if (error < 0) goto out; gus->joystick_dac = joystick_dac[n]; error = snd_gus_initialize(gus); if (error < 0) goto out; error = -ENODEV; if (!gus->ess_flag) { dev_err(dev, "GUS Extreme soundcard was not " "detected at 0x%lx\n", gus->gf1.port); goto out; } gus->codec_flag = 1; error = snd_es1688_pcm(es1688, 0, NULL); if (error < 0) goto out; error = snd_es1688_mixer(es1688); if (error < 0) goto out; snd_component_add(card, "ES1688"); if (pcm_channels[n] > 0) { error = snd_gf1_pcm_new(gus, 1, 1, NULL); if (error < 0) goto out; } error = snd_gf1_new_mixer(gus); if (error < 0) goto out; error = snd_gusextreme_mixer(es1688); if (error < 0) goto out; if (snd_opl3_create(card, es1688->port, es1688->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) dev_warn(dev, "opl3 not detected at 0x%lx\n", es1688->port); else { error = snd_opl3_hwdep_new(opl3, 0, 2, NULL); if (error < 0) goto out; } if (es1688->mpu_port >= 0x300) { error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, es1688->mpu_port, 0, mpu_irq[n], IRQF_DISABLED, NULL); if (error < 0) goto out; } sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, " "irq %i&%i, dma %i&%i", es1688->port, gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8); 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; }