static int __devinit snd_msnd_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { static int idx; struct pnp_dev *pnp_dev; struct pnp_dev *mpu_dev; struct snd_card *card; struct snd_msnd *chip; int ret; for ( ; idx < SNDRV_CARDS; idx++) { if (has_isapnp(idx)) break; } if (idx >= SNDRV_CARDS) return -ENODEV; /* * Check that we still have room for another sound card ... */ pnp_dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); if (!pnp_dev) return -ENODEV; mpu_dev = pnp_request_card_device(pcard, pid->devs[1].id, NULL); if (!mpu_dev) return -ENODEV; if (!pnp_is_active(pnp_dev) && pnp_activate_dev(pnp_dev) < 0) { printk(KERN_INFO "msnd_pinnacle: device is inactive\n"); return -EBUSY; } if (!pnp_is_active(mpu_dev) && pnp_activate_dev(mpu_dev) < 0) { printk(KERN_INFO "msnd_pinnacle: MPU device is inactive\n"); return -EBUSY; } /* * Create a new ALSA sound card entry, in anticipation * of detecting our hardware ... */ ret = snd_card_create(index[idx], id[idx], THIS_MODULE, sizeof(struct snd_msnd), &card); if (ret < 0) return ret; chip = card->private_data; chip->card = card; snd_card_set_dev(card, &pcard->card->dev); /* * Read the correct parameters off the ISA PnP bus ... */ io[idx] = pnp_port_start(pnp_dev, 0); irq[idx] = pnp_irq(pnp_dev, 0); mem[idx] = pnp_mem_start(pnp_dev, 0); mpu_io[idx] = pnp_port_start(mpu_dev, 0); mpu_irq[idx] = pnp_irq(mpu_dev, 0); set_default_audio_parameters(chip); #ifdef MSND_CLASSIC chip->type = msndClassic; #else chip->type = msndPinnacle; #endif chip->io = io[idx]; chip->irq = irq[idx]; chip->base = mem[idx]; chip->calibrate_signal = calibrate_signal ? 1 : 0; chip->recsrc = 0; chip->dspq_data_buff = DSPQ_DATA_BUFF; chip->dspq_buff_size = DSPQ_BUFF_SIZE; if (write_ndelay[idx]) clear_bit(F_DISABLE_WRITE_NDELAY, &chip->flags); else set_bit(F_DISABLE_WRITE_NDELAY, &chip->flags); #ifndef MSND_CLASSIC if (digital[idx]) set_bit(F_HAVEDIGITAL, &chip->flags); #endif spin_lock_init(&chip->lock); ret = snd_msnd_probe(card); if (ret < 0) { printk(KERN_ERR LOGNAME ": Probe failed\n"); goto _release_card; } ret = snd_msnd_attach(card); if (ret < 0) { printk(KERN_ERR LOGNAME ": Attach failed\n"); goto _release_card; } pnp_set_card_drvdata(pcard, card); ++idx; return 0; _release_card: snd_card_free(card); return ret; }
static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { static int idx = 0; struct pnp_dev *dev; struct snd_card *card; int ret; /* * Allow this function to fail *quietly* if all the ISA PnP * devices were configured using module parameters instead. */ if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) return -ENOSPC; /* * We have found a candidate ISA PnP card. Now we * have to check that it has the devices that we * expect it to have. * * We will NOT try and autoconfigure all of the resources * needed and then activate the card as we are assuming that * has already been done at boot-time using /proc/isapnp. * We shall simply try to give each active card the resources * that it wants. This is a sensible strategy for a modular * system where unused modules are unloaded regularly. * * This strategy is utterly useless if we compile the driver * into the kernel, of course. */ // printk(KERN_INFO "sscape: %s\n", card->name); /* * Check that we still have room for another sound card ... */ dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); if (! dev) return -ENODEV; if (!pnp_is_active(dev)) { if (pnp_activate_dev(dev) < 0) { printk(KERN_INFO "sscape: device is inactive\n"); return -EBUSY; } } /* * Read the correct parameters off the ISA PnP bus ... */ port[idx] = pnp_port_start(dev, 0); irq[idx] = pnp_irq(dev, 0); mpu_irq[idx] = pnp_irq(dev, 1); dma[idx] = pnp_dma(dev, 0) & 0x03; ret = create_sscape(idx, &card); if (ret < 0) return ret; snd_card_set_dev(card, &pcard->card->dev); if ((ret = snd_card_register(card)) < 0) { printk(KERN_ERR "sscape: Failed to register sound card\n"); snd_card_free(card); return ret; } pnp_set_card_drvdata(pcard, card); ++idx; return ret; }
static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { static int idx = 0; struct pnp_dev *dev; struct snd_card *card; struct soundscape *sscape; int ret; /* * Allow this function to fail *quietly* if all the ISA PnP * devices were configured using module parameters instead. */ if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) return -ENOSPC; /* * We have found a candidate ISA PnP card. Now we * have to check that it has the devices that we * expect it to have. * * We will NOT try and autoconfigure all of the resources * needed and then activate the card as we are assuming that * has already been done at boot-time using /proc/isapnp. * We shall simply try to give each active card the resources * that it wants. This is a sensible strategy for a modular * system where unused modules are unloaded regularly. * * This strategy is utterly useless if we compile the driver * into the kernel, of course. */ // printk(KERN_INFO "sscape: %s\n", card->name); /* * Check that we still have room for another sound card ... */ dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); if (! dev) return -ENODEV; if (!pnp_is_active(dev)) { if (pnp_activate_dev(dev) < 0) { printk(KERN_INFO "sscape: device is inactive\n"); return -EBUSY; } } /* * Create a new ALSA sound card entry, in anticipation * of detecting our hardware ... */ card = snd_card_new(index[idx], id[idx], THIS_MODULE, sizeof(struct soundscape)); if (!card) return -ENOMEM; sscape = get_card_soundscape(card); /* * Identify card model ... */ if (!strncmp("ENS4081", pid->id, 7)) sscape->type = SSCAPE_VIVO; else sscape->type = SSCAPE_PNP; /* * Read the correct parameters off the ISA PnP bus ... */ port[idx] = pnp_port_start(dev, 0); irq[idx] = pnp_irq(dev, 0); mpu_irq[idx] = pnp_irq(dev, 1); dma[idx] = pnp_dma(dev, 0) & 0x03; if (sscape->type == SSCAPE_PNP) { dma2[idx] = dma[idx]; wss_port[idx] = CODEC_IO(port[idx]); } else { wss_port[idx] = pnp_port_start(dev, 1); dma2[idx] = pnp_dma(dev, 1); } ret = create_sscape(idx, card); if (ret < 0) goto _release_card; snd_card_set_dev(card, &pcard->card->dev); if ((ret = snd_card_register(card)) < 0) { printk(KERN_ERR "sscape: Failed to register sound card\n"); goto _release_card; } pnp_set_card_drvdata(pcard, card); ++idx; return 0; _release_card: snd_card_free(card); return ret; }