snd_printk("Hmm, cannot find empty APU pair!?\n"); 
snd_printk(KERN_ERR "Hmm, cannot find empty APU pair!?\n"); 
static void __devinit es1968_measure_clock(es1968_t *chip){	int i, apu;	unsigned int pa, offset, t;	esm_memory_t *memory;	struct timeval start_time, stop_time;	if (chip->clock == 0)		chip->clock = 48000; /* default clock value */	/* search 2 APUs (although one apu is enough) */	if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) {		snd_printk("Hmm, cannot find empty APU pair!?\n");		return;	}	if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) {		snd_printk("cannot allocate dma buffer - using default clock %d\n", chip->clock);		snd_es1968_free_apu_pair(chip, apu);		return;	}	memset(memory->buf.area, 0, CLOCK_MEASURE_BUFSIZE);	wave_set_register(chip, apu << 3, (memory->buf.addr - 0x10) & 0xfff8);	pa = (unsigned int)((memory->buf.addr - chip->dma.addr) >> 1);	pa |= 0x00400000;	/* System RAM (Bit 22) */	/* initialize apu */	for (i = 0; i < 16; i++)		apu_set_register(chip, apu, i, 0x0000);	apu_set_register(chip, apu, 0, 0x400f);	apu_set_register(chip, apu, 4, ((pa >> 16) & 0xff) << 8);	apu_set_register(chip, apu, 5, pa & 0xffff);	apu_set_register(chip, apu, 6, (pa + CLOCK_MEASURE_BUFSIZE/2) & 0xffff);	apu_set_register(chip, apu, 7, CLOCK_MEASURE_BUFSIZE/2);	apu_set_register(chip, apu, 8, 0x0000);	apu_set_register(chip, apu, 9, 0xD000);	apu_set_register(chip, apu, 10, 0x8F08);	apu_set_register(chip, apu, 11, 0x0000);	spin_lock_irq(&chip->reg_lock);	outw(1, chip->io_port + 0x04); /* clear WP interrupts */	outw(inw(chip->io_port + ESM_PORT_HOST_IRQ) | ESM_HIRQ_DSIE, chip->io_port + ESM_PORT_HOST_IRQ); /* enable WP ints */	spin_unlock_irq(&chip->reg_lock);	snd_es1968_apu_set_freq(chip, apu, ((unsigned int)48000 << 16) / chip->clock); /* 48000 Hz */	chip->in_measurement = 1;	chip->measure_apu = apu;	spin_lock_irq(&chip->reg_lock);	snd_es1968_bob_inc(chip, ESM_BOB_FREQ);	__apu_set_register(chip, apu, 5, pa & 0xffff);	snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR);	do_gettimeofday(&start_time);	spin_unlock_irq(&chip->reg_lock);	msleep(50);	spin_lock_irq(&chip->reg_lock);	offset = __apu_get_register(chip, apu, 5);	do_gettimeofday(&stop_time);	snd_es1968_trigger_apu(chip, apu, 0); /* stop */	snd_es1968_bob_dec(chip);	chip->in_measurement = 0;	spin_unlock_irq(&chip->reg_lock);	/* check the current position */	offset -= (pa & 0xffff);	offset &= 0xfffe;	offset += chip->measure_count * (CLOCK_MEASURE_BUFSIZE/2);	t = stop_time.tv_sec - start_time.tv_sec;	t *= 1000000;	if (stop_time.tv_usec < start_time.tv_usec)		t -= start_time.tv_usec - stop_time.tv_usec;	else		t += stop_time.tv_usec - start_time.tv_usec;	if (t == 0) {		snd_printk("?? calculation error..\n");	} else {		offset *= 1000;		offset = (offset / t) * 1000 + ((offset % t) * 1000) / t;		if (offset < 47500 || offset > 48500) {			if (offset >= 40000 && offset <= 50000)				chip->clock = (chip->clock * offset) / 48000;		}		printk(KERN_INFO "es1968: clocking to %d\n", chip->clock);	}	snd_es1968_free_memory(chip, memory);	snd_es1968_free_apu_pair(chip, apu);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/99b359ba10a582148c6725f428a33ba5356dd993/es1968.c/buggy/sound/pci/es1968.c