snd_printk("Primary AC'97 codec not responding\n"); 
snd_printk(KERN_ERR "Primary AC'97 codec not responding\n"); 
static int __devinit snd_fm801_create(snd_card_t * card,				      struct pci_dev * pci,				      int tea575x_tuner,				      fm801_t ** rchip){	fm801_t *chip;	unsigned char rev, id;	unsigned short cmdw;	unsigned long timeout;	int err;	static snd_device_ops_t ops = {		.dev_free =	snd_fm801_dev_free,	};	*rchip = NULL;	if ((err = pci_enable_device(pci)) < 0)		return err;	chip = kzalloc(sizeof(*chip), GFP_KERNEL);	if (chip == NULL) {		pci_disable_device(pci);		return -ENOMEM;	}	spin_lock_init(&chip->reg_lock);	chip->card = card;	chip->pci = pci;	chip->irq = -1;	if ((err = pci_request_regions(pci, "FM801")) < 0) {		kfree(chip);		pci_disable_device(pci);		return err;	}	chip->port = pci_resource_start(pci, 0);	if (request_irq(pci->irq, snd_fm801_interrupt, SA_INTERRUPT|SA_SHIRQ, "FM801", (void *)chip)) {		snd_printk("unable to grab IRQ %d\n", chip->irq);		snd_fm801_free(chip);		return -EBUSY;	}	chip->irq = pci->irq;	pci_set_master(pci);	pci_read_config_byte(pci, PCI_REVISION_ID, &rev);	if (rev >= 0xb1)	/* FM801-AU */		chip->multichannel = 1;	/* codec cold reset + AC'97 warm reset */	outw((1<<5)|(1<<6), FM801_REG(chip, CODEC_CTRL));	inw(FM801_REG(chip, CODEC_CTRL)); /* flush posting data */	udelay(100);	outw(0, FM801_REG(chip, CODEC_CTRL));	timeout = (jiffies + (3 * HZ) / 4) + 1;		/* min 750ms */	outw((1<<7) | (0 << FM801_AC97_ADDR_SHIFT), FM801_REG(chip, AC97_CMD));	udelay(5);	do {		if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8))			goto __ac97_secondary;		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(1);	} while (time_after(timeout, jiffies));	snd_printk("Primary AC'97 codec not found\n");	snd_fm801_free(chip);	return -EIO;      __ac97_secondary:      	if (!chip->multichannel)	/* lookup is not required */      		goto __ac97_ok;	for (id = 3; id > 0; id--) {	/* my card has the secondary codec */					/* at address #3, so the loop is inverted */		timeout = jiffies + HZ / 20;		outw((1<<7) | (id << FM801_AC97_ADDR_SHIFT) | AC97_VENDOR_ID1, FM801_REG(chip, AC97_CMD));		udelay(5);		do {			if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8)) {				cmdw = inw(FM801_REG(chip, AC97_DATA));				if (cmdw != 0xffff && cmdw != 0) {					chip->secondary = 1;					chip->secondary_addr = id;					goto __ac97_ok;				}			}			set_current_state(TASK_UNINTERRUPTIBLE);			schedule_timeout(1);		} while (time_after(timeout, jiffies));	}	/* the recovery phase, it seems that probing for non-existing codec might */	/* cause timeout problems */	timeout = (jiffies + (3 * HZ) / 4) + 1;		/* min 750ms */	outw((1<<7) | (0 << FM801_AC97_ADDR_SHIFT), FM801_REG(chip, AC97_CMD));	udelay(5);	do {		if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8))			goto __ac97_ok;		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(1);	} while (time_after(timeout, jiffies));	snd_printk("Primary AC'97 codec not responding\n");	snd_fm801_free(chip);	return -EIO;      __ac97_ok:	/* init volume */	outw(0x0808, FM801_REG(chip, PCM_VOL));	outw(0x9f1f, FM801_REG(chip, FM_VOL));	outw(0x8808, FM801_REG(chip, I2S_VOL));	/* I2S control - I2S mode */	outw(0x0003, FM801_REG(chip, I2S_MODE));	/* interrupt setup - unmask MPU, PLAYBACK & CAPTURE */	cmdw = inw(FM801_REG(chip, IRQ_MASK));	cmdw &= ~0x0083;	outw(cmdw, FM801_REG(chip, IRQ_MASK));	/* interrupt clear */	outw(FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU, FM801_REG(chip, IRQ_STATUS));	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {		snd_fm801_free(chip);		return err;	}	snd_card_set_dev(card, &pci->dev);#ifdef TEA575X_RADIO	if (tea575x_tuner > 0 && (tea575x_tuner & 0xffff) < 4) {		chip->tea.dev_nr = tea575x_tuner >> 16;		chip->tea.card = card;		chip->tea.freq_fixup = 10700;		chip->tea.private_data = chip;		chip->tea.ops = &snd_fm801_tea_ops[(tea575x_tuner & 0xffff) - 1];		snd_tea575x_init(&chip->tea);	}#endif	*rchip = chip;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/99b359ba10a582148c6725f428a33ba5356dd993/fm801.c/buggy/sound/pci/fm801.c