} else if (emu->card_capabilities->ca_cardbus_chip) { if ((err = snd_emu10k1_cardbus_init(emu)) < 0) { snd_emu10k1_free(emu); return err; } 
int __devinit snd_emu10k1_create(snd_card_t * card,		       struct pci_dev * pci,		       unsigned short extin_mask,		       unsigned short extout_mask,		       long max_cache_bytes,		       int enable_ir,		       uint subsystem,		       emu10k1_t ** remu){	emu10k1_t *emu;	int err;	int is_audigy;	unsigned char revision;	const emu_chip_details_t *c;	static snd_device_ops_t ops = {		.dev_free =	snd_emu10k1_dev_free,	};		*remu = NULL;	/* enable PCI device */	if ((err = pci_enable_device(pci)) < 0)		return err;	emu = kzalloc(sizeof(*emu), GFP_KERNEL);	if (emu == NULL) {		pci_disable_device(pci);		return -ENOMEM;	}	emu->card = card;	spin_lock_init(&emu->reg_lock);	spin_lock_init(&emu->emu_lock);	spin_lock_init(&emu->voice_lock);	spin_lock_init(&emu->synth_lock);	spin_lock_init(&emu->memblk_lock);	init_MUTEX(&emu->ptb_lock);	init_MUTEX(&emu->fx8010.lock);	INIT_LIST_HEAD(&emu->mapped_link_head);	INIT_LIST_HEAD(&emu->mapped_order_link_head);	emu->pci = pci;	emu->irq = -1;	emu->synth = NULL;	emu->get_synth_voice = NULL;	/* read revision & serial */	pci_read_config_byte(pci, PCI_REVISION_ID, &revision);	emu->revision = revision;	pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);	pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);	snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model);	for (c = emu_chip_details; c->vendor; c++) {		if (c->vendor == pci->vendor && c->device == pci->device) {			if (subsystem) {				if (c->subsystem && (c->subsystem == subsystem) ) {					break;				} else continue;			} else {				if (c->subsystem && (c->subsystem != emu->serial) )					continue;				if (c->revision && c->revision != emu->revision)					continue;			}			break;		}	}	if (c->vendor == 0) {		snd_printk(KERN_ERR "emu10k1: Card not recognised\n");		kfree(emu);		pci_disable_device(pci);		return -ENOENT;	}	emu->card_capabilities = c;	if (c->subsystem && !subsystem)		snd_printdd("Sound card name=%s\n", c->name);	else if (subsystem) 		snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n",		       	c->name, pci->vendor, pci->device, emu->serial, c->subsystem);	else 		snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n",		      	c->name, pci->vendor, pci->device, emu->serial);		if (!*card->id && c->id) {		int i, n = 0;		strlcpy(card->id, c->id, sizeof(card->id));		for (;;) {			for (i = 0; i < snd_ecards_limit; i++) {				if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id))					break;			}			if (i >= snd_ecards_limit)				break;			n++;			if (n >= SNDRV_CARDS)				break;			snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n);		}	}	is_audigy = emu->audigy = c->emu10k2_chip;	/* set the DMA transfer mask */	emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;	if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||	    pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {		snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);		kfree(emu);		pci_disable_device(pci);		return -ENXIO;	}	if (is_audigy)		emu->gpr_base = A_FXGPREGBASE;	else		emu->gpr_base = FXGPREGBASE;	if ((err = pci_request_regions(pci, "EMU10K1")) < 0) {		kfree(emu);		pci_disable_device(pci);		return err;	}	emu->port = pci_resource_start(pci, 0);	if (request_irq(pci->irq, snd_emu10k1_interrupt, SA_INTERRUPT|SA_SHIRQ, "EMU10K1", (void *)emu)) {		snd_emu10k1_free(emu);		return -EBUSY;	}	emu->irq = pci->irq;	emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT;	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),				32 * 1024, &emu->ptb_pages) < 0) {		snd_emu10k1_free(emu);		return -ENOMEM;	}	emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*));	emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long));	if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {		snd_emu10k1_free(emu);		return -ENOMEM;	}	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),				EMUPAGESIZE, &emu->silent_page) < 0) {		snd_emu10k1_free(emu);		return -ENOMEM;	}	emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE);	if (emu->memhdr == NULL) {		snd_emu10k1_free(emu);		return -ENOMEM;	}	emu->memhdr->block_extra_size = sizeof(emu10k1_memblk_t) - sizeof(snd_util_memblk_t);	pci_set_master(pci);	emu->fx8010.fxbus_mask = 0x303f;	if (extin_mask == 0)		extin_mask = 0x3fcf;	if (extout_mask == 0)		extout_mask = 0x7fff;	emu->fx8010.extin_mask = extin_mask;	emu->fx8010.extout_mask = extout_mask;	if (emu->card_capabilities->ecard) {		if ((err = snd_emu10k1_ecard_init(emu)) < 0) {			snd_emu10k1_free(emu);			return err;		}	} else {		/* 5.1: Enable the additional AC97 Slots. If the emu10k1 version			does not support this, it shouldn't do any harm */		snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);	}	if ((err = snd_emu10k1_init(emu, enable_ir)) < 0) {		snd_emu10k1_free(emu);		return err;	}	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) {		snd_emu10k1_free(emu);		return err;	}	snd_emu10k1_proc_init(emu);	snd_card_set_dev(card, &pci->dev);	*remu = emu;	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/d83c671fb7023f69a9582e622d01525054f23b66/emu10k1_main.c/clean/sound/pci/emu10k1/emu10k1_main.c