i = pci_set_dma_mask(pcidev, 0xffffffff); 
i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); 
static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid){	struct es1371_state *s;	struct gameport *gp;	mm_segment_t fs;	int i, gpio, val, res = -1;	int idx;	unsigned long tmo;	signed long tmo2;	unsigned int cssr;	if ((res=pci_enable_device(pcidev)))		return res;	if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_IO))		return -ENODEV;	if (pcidev->irq == 0) 		return -ENODEV;	i = pci_set_dma_mask(pcidev, 0xffffffff);	if (i) {		printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n");		return i;	}	if (!(s = kmalloc(sizeof(struct es1371_state), GFP_KERNEL))) {		printk(KERN_WARNING PFX "out of memory\n");		return -ENOMEM;	}	memset(s, 0, sizeof(struct es1371_state));		s->codec = ac97_alloc_codec();	if(s->codec == NULL)		goto err_codec;			init_waitqueue_head(&s->dma_adc.wait);	init_waitqueue_head(&s->dma_dac1.wait);	init_waitqueue_head(&s->dma_dac2.wait);	init_waitqueue_head(&s->open_wait);	init_waitqueue_head(&s->midi.iwait);	init_waitqueue_head(&s->midi.owait);	init_MUTEX(&s->open_sem);	spin_lock_init(&s->lock);	s->magic = ES1371_MAGIC;	s->dev = pcidev;	s->io = pci_resource_start(pcidev, 0);	s->irq = pcidev->irq;	s->vendor = pcidev->vendor;	s->device = pcidev->device;	pci_read_config_byte(pcidev, PCI_REVISION_ID, &s->rev);	s->codec->private_data = s;	s->codec->id = 0;	s->codec->codec_read = rdcodec;	s->codec->codec_write = wrcodec;	printk(KERN_INFO PFX "found chip, vendor id 0x%04x device id 0x%04x revision 0x%02x\n",	       s->vendor, s->device, s->rev);	if (!request_region(s->io, ES1371_EXTENT, "es1371")) {		printk(KERN_ERR PFX "io ports %#lx-%#lx in use\n", s->io, s->io+ES1371_EXTENT-1);		res = -EBUSY;		goto err_region;	}	if ((res=request_irq(s->irq, es1371_interrupt, SA_SHIRQ, "es1371",s))) {		printk(KERN_ERR PFX "irq %u in use\n", s->irq);		goto err_irq;	}	printk(KERN_INFO PFX "found es1371 rev %d at io %#lx irq %u\n",	       s->rev, s->io, s->irq);	/* register devices */	if ((res=(s->dev_audio = register_sound_dsp(&es1371_audio_fops,-1)))<0)		goto err_dev1;	if ((res=(s->codec->dev_mixer = register_sound_mixer(&es1371_mixer_fops, -1))) < 0)		goto err_dev2;	if ((res=(s->dev_dac = register_sound_dsp(&es1371_dac_fops, -1))) < 0)		goto err_dev3;	if ((res=(s->dev_midi = register_sound_midi(&es1371_midi_fops, -1)))<0 )		goto err_dev4;#ifdef ES1371_DEBUG	/* initialize the debug proc device */	s->ps = create_proc_read_entry("es1371",0,NULL,proc_es1371_dump,NULL);#endif /* ES1371_DEBUG */		/* initialize codec registers */	s->ctrl = 0;	/* Check amplifier requirements */		if (amplifier[devindex])		s->ctrl |= CTRL_GPIO_OUT0;	else for(idx = 0; amplifier_needed[idx].svid != PCI_ANY_ID; idx++)	{		if(pcidev->subsystem_vendor == amplifier_needed[idx].svid &&		   pcidev->subsystem_device == amplifier_needed[idx].sdid)		{                    	s->ctrl |= CTRL_GPIO_OUT0;   /* turn internal amplifier on */                    	printk(KERN_INFO PFX "Enabling internal amplifier.\n");		}	}	for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08)		if (request_region(gpio, JOY_EXTENT, "es1371"))			break;	if (gpio < 0x200) {		printk(KERN_ERR PFX "no free joystick address found\n");	} else if (!(s->gameport = gp = gameport_allocate_port())) {		printk(KERN_ERR PFX "can not allocate memory for gameport\n");		release_region(gpio, JOY_EXTENT);	} else {		gameport_set_name(gp, "ESS1371 Gameport");		gameport_set_phys(gp, "isa%04x/gameport0", gpio);		gp->dev.parent = &s->dev->dev;		gp->io = gpio;		s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT);	}	s->sctrl = 0;	cssr = 0;	s->spdif_volume = -1;	/* check to see if s/pdif mode is being requested */	if (spdif[devindex]) {		if (s->rev >= 4) {			printk(KERN_INFO PFX "enabling S/PDIF output\n");			s->spdif_volume = 0;			cssr |= STAT_EN_SPDIF;			s->ctrl |= CTRL_SPDIFEN_B;			if (nomix[devindex]) /* don't mix analog inputs to s/pdif output */				s->ctrl |= CTRL_RECEN_B;		} else {			printk(KERN_ERR PFX "revision %d does not support S/PDIF\n", s->rev);		}	}	/* initialize the chips */	outl(s->ctrl, s->io+ES1371_REG_CONTROL);	outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);	outl(LEGACY_JFAST, s->io+ES1371_REG_LEGACY);	pci_set_master(pcidev);  /* enable bus mastering */	/* if we are a 5880 turn on the AC97 */	if (s->vendor == PCI_VENDOR_ID_ENSONIQ &&	    ((s->device == PCI_DEVICE_ID_ENSONIQ_CT5880 && s->rev >= CT5880REV_CT5880_C) || 	     (s->device == PCI_DEVICE_ID_ENSONIQ_ES1371 && s->rev == ES1371REV_CT5880_A) || 	     (s->device == PCI_DEVICE_ID_ENSONIQ_ES1371 && s->rev == ES1371REV_ES1373_8))) { 		cssr |= CSTAT_5880_AC97_RST;		outl(cssr, s->io+ES1371_REG_STATUS);		/* need to delay around 20ms(bleech) to give		   some CODECs enough time to wakeup */		tmo = jiffies + (HZ / 50) + 1;		for (;;) {			tmo2 = tmo - jiffies;			if (tmo2 <= 0)				break;			schedule_timeout(tmo2);		}	}	/* AC97 warm reset to start the bitclk */	outl(s->ctrl | CTRL_SYNCRES, s->io+ES1371_REG_CONTROL);	udelay(2);	outl(s->ctrl, s->io+ES1371_REG_CONTROL);	/* init the sample rate converter */	src_init(s);	/* codec init */	if (!ac97_probe_codec(s->codec)) {		res = -ENODEV;		goto err_gp;	}	/* set default values */	fs = get_fs();	set_fs(KERNEL_DS);	val = SOUND_MASK_LINE;	mixdev_ioctl(s->codec, SOUND_MIXER_WRITE_RECSRC, (unsigned long)&val);	for (i = 0; i < sizeof(initvol)/sizeof(initvol[0]); i++) {		val = initvol[i].vol;		mixdev_ioctl(s->codec, initvol[i].mixch, (unsigned long)&val);	}	/* mute master and PCM when in S/PDIF mode */	if (s->spdif_volume != -1) {		val = 0x0000;		s->codec->mixer_ioctl(s->codec, SOUND_MIXER_WRITE_VOLUME, (unsigned long)&val);		s->codec->mixer_ioctl(s->codec, SOUND_MIXER_WRITE_PCM, (unsigned long)&val);	}	set_fs(fs);	/* turn on S/PDIF output driver if requested */	outl(cssr, s->io+ES1371_REG_STATUS);	/* register gameport */	if (s->gameport)		gameport_register_port(s->gameport);	/* store it in the driver field */	pci_set_drvdata(pcidev, s);	/* put it into driver list */	list_add_tail(&s->devs, &devs);	/* increment devindex */	if (devindex < NR_DEVICE-1)		devindex++;       	return 0; err_gp:	if (s->gameport) {		release_region(s->gameport->io, JOY_EXTENT);		gameport_free_port(s->gameport);	}#ifdef ES1371_DEBUG	if (s->ps)		remove_proc_entry("es1371", NULL);#endif	unregister_sound_midi(s->dev_midi); err_dev4:	unregister_sound_dsp(s->dev_dac); err_dev3:	unregister_sound_mixer(s->codec->dev_mixer); err_dev2:	unregister_sound_dsp(s->dev_audio); err_dev1:	printk(KERN_ERR PFX "cannot register misc device\n");	free_irq(s->irq, s); err_irq:	release_region(s->io, ES1371_EXTENT); err_region: err_codec:	ac97_release_codec(s->codec);	kfree(s);	return res;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/3ee538a2e867c7fbdb2a5940b610682d5d08e8be/es1371.c/buggy/sound/oss/es1371.c