i = pci_set_dma_mask(pcidev, 0xffffffff); 
i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); 
static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid){	struct es1370_state *s;	struct gameport *gp = NULL;	mm_segment_t fs;	int i, val, ret;	if ((ret=pci_enable_device(pcidev)))		return ret;	if ( !(pci_resource_flags(pcidev, 0) & IORESOURCE_IO) ||	     !pci_resource_start(pcidev, 0)	)		return -ENODEV;	if (pcidev->irq == 0) 		return -ENODEV;	i = pci_set_dma_mask(pcidev, 0xffffffff);	if (i) {		printk(KERN_WARNING "es1370: architecture does not support 32bit PCI busmaster DMA\n");		return i;	}	if (!(s = kmalloc(sizeof(struct es1370_state), GFP_KERNEL))) {		printk(KERN_WARNING "es1370: out of memory\n");		return -ENOMEM;	}	memset(s, 0, sizeof(struct es1370_state));	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 = ES1370_MAGIC;	s->dev = pcidev;	s->io = pci_resource_start(pcidev, 0);	s->irq = pcidev->irq;	if (!request_region(s->io, ES1370_EXTENT, "es1370")) {		printk(KERN_ERR "es1370: io ports %#lx-%#lx in use\n", s->io, s->io+ES1370_EXTENT-1);		ret = -EBUSY;		goto err_region;	}	if ((ret=request_irq(s->irq, es1370_interrupt, SA_SHIRQ, "es1370",s))) {		printk(KERN_ERR "es1370: irq %u in use\n", s->irq);		goto err_irq;	}	/* initialize codec registers */	/* note: setting CTRL_SERR_DIS is reported to break	 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */	s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);	if (!request_region(0x200, JOY_EXTENT, "es1370")) {		printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");	} else if (!(s->gameport = gp = gameport_allocate_port())) {		printk(KERN_ERR "es1370: can not allocate memory for gameport\n");		release_region(0x200, JOY_EXTENT);	} else {		gameport_set_name(gp, "ESS1370");		gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));		gp->dev.parent = &s->dev->dev;		gp->io = 0x200;		s->ctrl |= CTRL_JYSTK_EN;	}	if (lineout[devindex])		s->ctrl |= CTRL_XCTL0;	if (micbias[devindex])		s->ctrl |= CTRL_XCTL1;	s->sctrl = 0;	printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n"	       KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n",	       s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off",	       (s->ctrl & CTRL_XCTL0) ? "out" : "in",		       (s->ctrl & CTRL_XCTL1) ? "1" : "0");	/* register devices */	if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) {		ret = s->dev_audio;		goto err_dev1;	}	if ((s->dev_mixer = register_sound_mixer(&es1370_mixer_fops, -1)) < 0) {		ret = s->dev_mixer;		goto err_dev2;	}	if ((s->dev_dac = register_sound_dsp(&es1370_dac_fops, -1)) < 0) {		ret = s->dev_dac;		goto err_dev3;	}	if ((s->dev_midi = register_sound_midi(&es1370_midi_fops, -1)) < 0) {		ret = s->dev_midi;		goto err_dev4;	}	/* initialize the chips */	outl(s->ctrl, s->io+ES1370_REG_CONTROL);	outl(s->sctrl, s->io+ES1370_REG_SERIAL_CONTROL);	/* point phantom write channel to "bugbuf" */	s->bugbuf_cpu = pci_alloc_consistent(pcidev,16,&s->bugbuf_dma);	if (!s->bugbuf_cpu) {		ret = -ENOMEM;		goto err_dev5;	}	outl((ES1370_REG_PHANTOM_FRAMEADR >> 8) & 15, s->io+ES1370_REG_MEMPAGE);	outl(s->bugbuf_dma, s->io+(ES1370_REG_PHANTOM_FRAMEADR & 0xff));	outl(0, s->io+(ES1370_REG_PHANTOM_FRAMECNT & 0xff));	pci_set_master(pcidev);  /* enable bus mastering */	wrcodec(s, 0x16, 3); /* no RST, PD */	wrcodec(s, 0x17, 0); /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off the LRCLK2 PLL; program DAC_SYNC=0!!  */	wrcodec(s, 0x18, 0); /* recording source is mixer */	wrcodec(s, 0x19, s->mix.micpreamp = 1); /* turn on MIC preamp */	s->mix.imix = 1;	fs = get_fs();	set_fs(KERNEL_DS);	val = SOUND_MASK_LINE|SOUND_MASK_SYNTH|SOUND_MASK_CD;	mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long)&val);	for (i = 0; i < sizeof(initvol)/sizeof(initvol[0]); i++) {		val = initvol[i].vol;		mixer_ioctl(s, initvol[i].mixch, (unsigned long)&val);	}	set_fs(fs);	/* register gameport */	if (gp)		gameport_register_port(gp);	/* 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_dev5:	unregister_sound_midi(s->dev_midi); err_dev4:	unregister_sound_dsp(s->dev_dac); err_dev3:	unregister_sound_mixer(s->dev_mixer); err_dev2:	unregister_sound_dsp(s->dev_audio); err_dev1:	printk(KERN_ERR "es1370: cannot register misc device\n");	free_irq(s->irq, s);	if (s->gameport) {		release_region(s->gameport->io, JOY_EXTENT);		gameport_free_port(s->gameport);	} err_irq:	release_region(s->io, ES1370_EXTENT); err_region:	kfree(s);	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/738c7b4f7f36ce2c547d0a2c2aa397aae904510f/es1370.c/buggy/sound/oss/es1370.c