Beispiel #1
0
void sound_unload_mididev(int dev)
{
    if (dev != -1) {
        midi_devs[dev] = NULL;
        unregister_sound_midi((dev<<4)+2);
    }
}
Beispiel #2
0
static void __devexit emu10k1_remove(struct pci_dev *pci_dev)
{
#if LINUX_VERSION_CODE > 0x020320
	struct emu10k1_card *card = pci_dev->driver_data;
#else
	struct emu10k1_card *card = list_entry(emu10k1_devs.next, struct emu10k1_card, list);
#endif
	midi_exit(card);
	audio_exit(card);
	emu10k1_exit(card);

	unregister_sound_midi(card->midi_num);
	unregister_sound_mixer(card->mixer_num);
	unregister_sound_dsp(card->audio2_num);
	unregister_sound_dsp(card->audio1_num);

	free_irq(card->irq, card);
	release_region(card->iobase, EMU10K1_EXTENT);

	list_del(&card->list);

	kfree(card);
	return;
}
Beispiel #3
0
/* Driver initialization routine */
static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
{
	struct emu10k1_card *card;

	if ((card = kmalloc(sizeof(struct emu10k1_card), GFP_KERNEL)) == NULL) {
		printk(KERN_ERR "emu10k1: out of memory\n");
		return -ENOMEM;
	}
	memset(card, 0, sizeof(struct emu10k1_card));

#if LINUX_VERSION_CODE > 0x020320
	if (!pci_dma_supported(pci_dev, EMU10K1_DMA_MASK)) {
		printk(KERN_ERR "emu10k1: architecture does not support 32bit PCI busmaster DMA\n");
		kfree(card);
		return -ENODEV;
	}

	if (pci_enable_device(pci_dev)) {
		printk(KERN_ERR "emu10k1: couldn't enable device\n");
		kfree(card);
		return -ENODEV;
	}

	pci_set_master(pci_dev);

	card->iobase = pci_dev->resource[0].start;

	if (request_region(card->iobase, EMU10K1_EXTENT, card_names[pci_id->driver_data]) == NULL) {
		printk(KERN_ERR "emu10k1: IO space in use\n");
		kfree(card);
		return -ENODEV;
	}
	pci_dev->driver_data = card;
	pci_dev->dma_mask = EMU10K1_DMA_MASK;
#else
	pci_set_master(pci_dev);

	card->iobase = pci_dev->base_address[0] & PCI_BASE_ADDRESS_IO_MASK;

	if (check_region(card->iobase, EMU10K1_EXTENT)) {
		printk(KERN_ERR "emu10k1: IO space in use\n");
		kfree(card);
		return -ENODEV;
	}

	request_region(card->iobase, EMU10K1_EXTENT, card_names[pci_id->driver_data]);
#endif
	card->irq = pci_dev->irq;
	card->pci_dev = pci_dev;

	/* Reserve IRQ Line */
	if (request_irq(card->irq, emu10k1_interrupt, SA_SHIRQ, card_names[pci_id->driver_data], card)) {
		printk(KERN_ERR "emu10k1: IRQ in use\n");
		goto err_irq;
	}

	pci_read_config_byte(pci_dev, PCI_REVISION_ID, &card->chiprev);

	printk(KERN_INFO "emu10k1: %s rev %d found at IO 0x%04lx, IRQ %d\n", card_names[pci_id->driver_data], card->chiprev, card->iobase, card->irq);

	spin_lock_init(&card->lock);
	card->mixeraddx = card->iobase + AC97DATA;
	init_MUTEX(&card->open_sem);
	card->open_mode = 0;
	init_waitqueue_head(&card->open_wait);

	/* Register devices */
	if ((card->audio1_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
		printk(KERN_ERR "emu10k1: cannot register first audio device!\n");
		goto err_dev0;
	}

	if ((card->audio2_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
		printk(KERN_ERR "emu10k1: cannot register second audio device!\n");
		goto err_dev1;
	}

	if ((card->mixer_num = register_sound_mixer(&emu10k1_mixer_fops, -1)) < 0) {
		printk(KERN_ERR "emu10k1: cannot register mixer device!\n");
		goto err_dev2;
	}

	if ((card->midi_num = register_sound_midi(&emu10k1_midi_fops, -1)) < 0) {
		printk(KERN_ERR "emu10k1: cannot register midi device!\n");
		goto err_dev3;
	}

	if (emu10k1_init(card) != CTSTATUS_SUCCESS) {
		printk(KERN_ERR "emu10k1: cannot initialize device!\n");
		goto err_emu10k1_init;
	}

	if (audio_init(card) != CTSTATUS_SUCCESS) {
		printk(KERN_ERR "emu10k1: cannot initialize audio!\n");
		goto err_audio_init;
	}

	if (midi_init(card) != CTSTATUS_SUCCESS) {
		printk(KERN_ERR "emu10k1: cannot initialize midi!\n");
		goto err_midi_init;
	}

	mixer_init(card);

	DPD(2, "Hardware initialized. TRAM allocated: %u bytes\n", (unsigned int) card->tmemsize);

	list_add(&card->list, &emu10k1_devs);

	return 0;

      err_midi_init:
	audio_exit(card);

      err_audio_init:
	emu10k1_exit(card);

      err_emu10k1_init:
	unregister_sound_midi(card->midi_num);

      err_dev3:
	unregister_sound_mixer(card->mixer_num);

      err_dev2:
	unregister_sound_dsp(card->audio2_num);

      err_dev1:
	unregister_sound_dsp(card->audio1_num);

      err_dev0:
	free_irq(card->irq, card);

      err_irq:
	release_region(card->iobase, EMU10K1_EXTENT);
	kfree(card);

	return -ENODEV;
}