snd_printk("unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1); 
snd_printk(KERN_ERR "unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1); 
static int __devinit snd_sonicvibes_create(snd_card_t * card,					struct pci_dev *pci,					int reverb,					int mge,					sonicvibes_t ** rsonic){	sonicvibes_t *sonic;	unsigned int dmaa, dmac;	int err;	static snd_device_ops_t ops = {		.dev_free =	snd_sonicvibes_dev_free,	};	*rsonic = NULL;	/* enable PCI device */	if ((err = pci_enable_device(pci)) < 0)		return err;	/* check, if we can restrict PCI DMA transfers to 24 bits */        if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||	    pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {                snd_printk("architecture does not support 24bit PCI busmaster DMA\n");		pci_disable_device(pci);                return -ENXIO;        }	sonic = kzalloc(sizeof(*sonic), GFP_KERNEL);	if (sonic == NULL) {		pci_disable_device(pci);		return -ENOMEM;	}	spin_lock_init(&sonic->reg_lock);	sonic->card = card;	sonic->pci = pci;	sonic->irq = -1;	if ((err = pci_request_regions(pci, "S3 SonicVibes")) < 0) {		kfree(sonic);		pci_disable_device(pci);		return err;	}	sonic->sb_port = pci_resource_start(pci, 0);	sonic->enh_port = pci_resource_start(pci, 1);	sonic->synth_port = pci_resource_start(pci, 2);	sonic->midi_port = pci_resource_start(pci, 3);	sonic->game_port = pci_resource_start(pci, 4);	if (request_irq(pci->irq, snd_sonicvibes_interrupt, SA_INTERRUPT|SA_SHIRQ, "S3 SonicVibes", (void *)sonic)) {		snd_printk("unable to grab IRQ %d\n", pci->irq);		snd_sonicvibes_free(sonic);		return -EBUSY;	}	sonic->irq = pci->irq;	pci_read_config_dword(pci, 0x40, &dmaa);	pci_read_config_dword(pci, 0x48, &dmac);	dmaio &= ~0x0f;	dmaa &= ~0x0f;	dmac &= ~0x0f;	if (!dmaa) {		dmaa = dmaio;		dmaio += 0x10;		snd_printk("BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa);	}	if (!dmac) {		dmac = dmaio;		dmaio += 0x10;		snd_printk("BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac);	}	pci_write_config_dword(pci, 0x40, dmaa);	pci_write_config_dword(pci, 0x48, dmac);	if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) {		snd_sonicvibes_free(sonic);		snd_printk("unable to grab DDMA-A port at 0x%x-0x%x\n", dmaa, dmaa + 0x10 - 1);		return -EBUSY;	}	if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) {		snd_sonicvibes_free(sonic);		snd_printk("unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1);		return -EBUSY;	}	pci_read_config_dword(pci, 0x40, &sonic->dmaa_port);	pci_read_config_dword(pci, 0x48, &sonic->dmac_port);	sonic->dmaa_port &= ~0x0f;	sonic->dmac_port &= ~0x0f;	pci_write_config_dword(pci, 0x40, sonic->dmaa_port | 9);	/* enable + enhanced */	pci_write_config_dword(pci, 0x48, sonic->dmac_port | 9);	/* enable */	/* ok.. initialize S3 SonicVibes chip */	outb(SV_RESET, SV_REG(sonic, CONTROL));		/* reset chip */	udelay(100);	outb(0, SV_REG(sonic, CONTROL));	/* release reset */	udelay(100);	outb(SV_ENHANCED | SV_INTA | (reverb ? SV_REVERB : 0), SV_REG(sonic, CONTROL));	inb(SV_REG(sonic, STATUS));	/* clear IRQs */#if 1	snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0);	/* drive current 16mA */#else	snd_sonicvibes_out(sonic, SV_IREG_DRIVE_CTRL, 0x40);	/* drive current 8mA */#endif	snd_sonicvibes_out(sonic, SV_IREG_PC_ENABLE, sonic->enable = 0);	/* disable playback & capture */	outb(sonic->irqmask = ~(SV_DMAA_MASK | SV_DMAC_MASK | SV_UD_MASK), SV_REG(sonic, IRQMASK));	inb(SV_REG(sonic, STATUS));	/* clear IRQs */	snd_sonicvibes_out(sonic, SV_IREG_ADC_CLOCK, 0);	/* use PLL as clock source */	snd_sonicvibes_out(sonic, SV_IREG_ANALOG_POWER, 0);	/* power up analog parts */	snd_sonicvibes_out(sonic, SV_IREG_DIGITAL_POWER, 0);	/* power up digital parts */	snd_sonicvibes_setpll(sonic, SV_IREG_ADC_PLL, 8000);	snd_sonicvibes_out(sonic, SV_IREG_SRS_SPACE, sonic->srs_space = 0x80);	/* SRS space off */	snd_sonicvibes_out(sonic, SV_IREG_SRS_CENTER, sonic->srs_center = 0x00);/* SRS center off */	snd_sonicvibes_out(sonic, SV_IREG_MPU401, sonic->mpu_switch = 0x05);	/* MPU-401 switch */	snd_sonicvibes_out(sonic, SV_IREG_WAVE_SOURCE, sonic->wave_source = 0x00);	/* onboard ROM */	snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_LOW, (8000 * 65536 / SV_FULLRATE) & 0xff);	snd_sonicvibes_out(sonic, SV_IREG_PCM_RATE_HIGH, ((8000 * 65536 / SV_FULLRATE) >> 8) & 0xff);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_ADC, mge ? 0xd0 : 0xc0);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ADC, 0xc0);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX1, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX1, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_CD, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_CD, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_LINE, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_LINE, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_MIC, 0x8f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_SYNTH, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_SYNTH, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_AUX2, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_AUX2, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_ANALOG, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_ANALOG, 0x9f);	snd_sonicvibes_out(sonic, SV_IREG_LEFT_PCM, 0xbf);	snd_sonicvibes_out(sonic, SV_IREG_RIGHT_PCM, 0xbf);	snd_sonicvibes_out(sonic, SV_IREG_ADC_OUTPUT_CTRL, 0xfc);#if 0	snd_sonicvibes_debug(sonic);#endif	sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION);	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) {		snd_sonicvibes_free(sonic);		return err;	}	snd_sonicvibes_proc_init(sonic);	snd_card_set_dev(card, &pci->dev);	*rsonic = sonic;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/99b359ba10a582148c6725f428a33ba5356dd993/sonicvibes.c/buggy/sound/pci/sonicvibes.c