i = pci_set_dma_mask(pcidev, 0xffffffff); 
i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); 
static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid){	struct cm_state *s;	mm_segment_t fs;	int i, val, ret;	unsigned char reg_mask;	int timeout;	struct resource *ports;	struct {		unsigned short	deviceid;		char		*devicename;	} devicetable[] = {		{ PCI_DEVICE_ID_CMEDIA_CM8338A, "CM8338A" },		{ PCI_DEVICE_ID_CMEDIA_CM8338B, "CM8338B" },		{ PCI_DEVICE_ID_CMEDIA_CM8738,  "CM8738" },		{ PCI_DEVICE_ID_CMEDIA_CM8738B, "CM8738B" },	};	char	*devicename = "unknown";	char	options[256];	if ((ret = pci_enable_device(pcidev)))		return ret;	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 "cmpci: architecture does not support 32bit PCI busmaster DMA\n");		return i;	}	s = kmalloc(sizeof(*s), GFP_KERNEL);	if (!s) {		printk(KERN_WARNING "cmpci: out of memory\n");		return -ENOMEM;	}	/* search device name */	for (i = 0; i < sizeof(devicetable) / sizeof(devicetable[0]); i++) {		if (devicetable[i].deviceid == pcidev->device) {			devicename = devicetable[i].devicename;			break;		}	}	memset(s, 0, sizeof(struct cm_state));	init_waitqueue_head(&s->dma_adc.wait);	init_waitqueue_head(&s->dma_dac.wait);	init_waitqueue_head(&s->open_wait);	init_MUTEX(&s->open_sem);	spin_lock_init(&s->lock);	s->magic = CM_MAGIC;	s->dev = pcidev;	s->iobase = pci_resource_start(pcidev, 0);	s->iosynth = fmio;	s->iomidi = mpuio;#ifdef CONFIG_SOUND_CMPCI_MIDI	s->midi_devc = 0;#endif	s->status = 0;	if (s->iobase == 0)		return -ENODEV;	s->irq = pcidev->irq;	if (!request_region(s->iobase, CM_EXTENT_CODEC, "cmpci")) {		printk(KERN_ERR "cmpci: io ports %#x-%#x in use\n", s->iobase, s->iobase+CM_EXTENT_CODEC-1);		ret = -EBUSY;		goto err_region5;	}	/* dump parameters */	strcpy(options, "cmpci: ");	echo_option(joystick);	echo_option(spdif_inverse);	echo_option(spdif_loop);	echo_option(spdif_out);	echo_option(use_line_as_rear);	echo_option(use_line_as_bass);	echo_option(use_mic_as_bass);	echo_option(mic_boost);	echo_option(hw_copy);	printk(KERN_INFO "%s\n", options);	/* initialize codec registers */	outb(0, s->iobase + CODEC_CMI_INT_HLDCLR + 2);  /* disable ints */	outb(0, s->iobase + CODEC_CMI_FUNCTRL0 + 2); /* disable channels */	/* reset mixer */	wrmixer(s, DSP_MIX_DATARESETIDX, 0);	/* request irq */	if ((ret = request_irq(s->irq, cm_interrupt, SA_SHIRQ, "cmpci", s))) {		printk(KERN_ERR "cmpci: irq %u in use\n", s->irq);		goto err_irq;	}	printk(KERN_INFO "cmpci: found %s adapter at io %#x irq %u\n",	       devicename, s->iobase, s->irq);	/* register devices */	if ((s->dev_audio = register_sound_dsp(&cm_audio_fops, -1)) < 0) {		ret = s->dev_audio;		goto err_dev1;	}	if ((s->dev_mixer = register_sound_mixer(&cm_mixer_fops, -1)) < 0) {		ret = s->dev_mixer;		goto err_dev2;	}	pci_set_master(pcidev);	/* enable bus mastering */	/* initialize the chips */	fs = get_fs();	set_fs(KERNEL_DS);	/* set mixer output */	frobindir(s, DSP_MIX_OUTMIXIDX, 0x1f, 0x1f);	/* set mixer input */	val = SOUND_MASK_LINE|SOUND_MASK_SYNTH|SOUND_MASK_CD|SOUND_MASK_MIC;	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);	/* use channel 1 for playback, channel 0 for record */	maskb(s->iobase + CODEC_CMI_FUNCTRL0, ~CHADC1, CHADC0);	/* turn off VMIC3 - mic boost */	if (mic_boost)		maskb(s->iobase + CODEC_CMI_MIXER2, ~1, 0);	else		maskb(s->iobase + CODEC_CMI_MIXER2, ~0, 1);	s->deviceid = pcidev->device;	if (pcidev->device == PCI_DEVICE_ID_CMEDIA_CM8738	 || pcidev->device == PCI_DEVICE_ID_CMEDIA_CM8738B) {		/* chip version and hw capability check */		s->chip_version = query_chip(s);		printk(KERN_INFO "cmpci: chip version = 0%d\n", s->chip_version);		/* set SPDIF-in inverse before enable SPDIF loop */		set_spdifin_inverse(s, spdif_inverse);		/* use SPDIF in #1 */		set_spdifin_channel2(s, 0);	} else {		s->chip_version = 0;		/* 8338 will fall here */		s->max_channels = 4;		s->capability |= CAN_DUAL_DAC;		s->capability |= CAN_LINE_AS_REAR;	}	/* enable SPDIF loop */	set_spdif_loop(s, spdif_loop);	// enable 4 speaker mode (analog duplicate)	set_hw_copy(s, hw_copy);	reg_mask = 0;#ifdef CONFIG_SOUND_CMPCI_FM	/* disable FM */	maskb(s->iobase + CODEC_CMI_MISC_CTRL + 2, ~8, 0);	if (s->iosynth) {	    /* don't enable OPL3 if there is one */	    if (opl3_detect(s->iosynth, NULL)) {	    	s->iosynth = 0;	    } else {		/* set IO based at 0x388 */		switch (s->iosynth) {		    case 0x388:			reg_mask = 0;			break;		    case 0x3C8:			reg_mask = 0x01;			break;		    case 0x3E0:			reg_mask = 0x02;			break;		    case 0x3E8:			reg_mask = 0x03;			break;		    default:			s->iosynth = 0;			break;		}		maskb(s->iobase + CODEC_CMI_LEGACY_CTRL + 3, ~0x03, reg_mask);		/* enable FM */		if (s->iosynth) {			maskb(s->iobase + CODEC_CMI_MISC_CTRL + 2, ~0, 8);			if (opl3_detect(s->iosynth, NULL))				ret = opl3_init(s->iosynth, NULL, THIS_MODULE);			else {				maskb(s->iobase + CODEC_CMI_MISC_CTRL + 2, ~8, 0);				s->iosynth = 0;			}		}	    }	}#endif#ifdef CONFIG_SOUND_CMPCI_MIDI	switch (s->iomidi) {	    case 0x330:		reg_mask = 0;		break;	    case 0x320:		reg_mask = 0x20;		break;	    case 0x310:		reg_mask = 0x40;		break;	    case 0x300:		reg_mask = 0x60;		break;	    default:		s->iomidi = 0;		goto skip_mpu;	}	ports = request_region(s->iomidi, 2, "mpu401");	if (!ports)		goto skip_mpu;	/* disable MPU-401 */	maskb(s->iobase + CODEC_CMI_FUNCTRL1, ~0x04, 0);	s->mpu_data.name = "cmpci mpu";	s->mpu_data.io_base = s->iomidi;	s->mpu_data.irq = -s->irq;	// tell mpu401 to share irq	if (probe_mpu401(&s->mpu_data, ports)) {		release_region(s->iomidi, 2);		s->iomidi = 0;		goto skip_mpu;	}	maskb(s->iobase + CODEC_CMI_LEGACY_CTRL + 3, ~0x60, reg_mask);	/* enable MPU-401 */	maskb(s->iobase + CODEC_CMI_FUNCTRL1, ~0, 0x04);	/* clear all previously received interrupt */	for (timeout = 900000; timeout > 0; timeout--) {		if ((inb(s->iomidi + 1) && 0x80) == 0)			inb(s->iomidi);		else			break;	}	if (!probe_mpu401(&s->mpu_data, ports)) {		release_region(s->iomidi, 2);		s->iomidi = 0;		maskb(s->iobase + CODEC_CMI_FUNCTRL1, ~0, 0x04);	} else {		attach_mpu401(&s->mpu_data, THIS_MODULE);		s->midi_devc = s->mpu_data.slots[1];	}skip_mpu:#endif	/* disable joystick port */	maskb(s->iobase + CODEC_CMI_FUNCTRL1, ~0x02, 0);	if (joystick)		cm_create_gameport(s, 0x200);	/* 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_dev2:	unregister_sound_dsp(s->dev_audio);err_dev1:	printk(KERN_ERR "cmpci: cannot register misc device\n");	free_irq(s->irq, s);err_irq:	release_region(s->iobase, CM_EXTENT_CODEC);err_region5:	kfree(s);	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/4f11842ebbb3b98a88c38ef6c18345ccc792a54b/cmpci.c/buggy/sound/oss/cmpci.c