wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); 
if (FW_VERSION(av7110->arm_app) <= 0x261f) wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); 
static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length){	int i;	unsigned long start;	char *type = NULL;	u16 flags[2] = {0, 0};	u32 stat;	int err;//	dprintk(4, "%p\n", av7110);	if (!av7110->arm_ready) {		dprintk(1, "arm not ready.\n");		return -ENXIO;	}	start = jiffies;	while (1) {		err = time_after(jiffies, start + ARM_WAIT_FREE);		if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)			break;		if (err) {			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__);			return -ETIMEDOUT;		}		msleep(1);	}	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);#ifndef _NOHANDSHAKE	start = jiffies;	while (1) {		err = time_after(jiffies, start + ARM_WAIT_SHAKE);		if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)			break;		if (err) {			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);			return -ETIMEDOUT;		}		msleep(1);	}#endif	switch ((buf[0] >> 8) & 0xff) {	case COMTYPE_PIDFILTER:	case COMTYPE_ENCODER:	case COMTYPE_REC_PLAY:	case COMTYPE_MPEGDECODER:		type = "MSG";		flags[0] = GPMQOver;		flags[1] = GPMQFull;		break;	case COMTYPE_OSD:		type = "OSD";		flags[0] = OSDQOver;		flags[1] = OSDQFull;		break;	case COMTYPE_MISC:		if (FW_VERSION(av7110->arm_app) >= 0x261d) {			type = "MSG";			flags[0] = GPMQOver;			flags[1] = GPMQBusy;		}		break;	default:		break;	}	if (type != NULL) {		/* non-immediate COMMAND type */		start = jiffies;		for (;;) {			err = time_after(jiffies, start + ARM_WAIT_FREE);			stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);			if (stat & flags[0]) {				printk(KERN_ERR "%s: %s QUEUE overflow\n",					__FUNCTION__, type);				return -1;			}			if ((stat & flags[1]) == 0)				break;			if (err) {				printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n",					__FUNCTION__, type);				return -ETIMEDOUT;			}			msleep(1);		}	}	for (i = 2; i < length; i++)		wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2);	if (length)		wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2);	else		wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2);	wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);#ifdef COM_DEBUG	start = jiffies;	while (1) {		err = time_after(jiffies, start + ARM_WAIT_FREE);		if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)			break;		if (err) {			printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n",			       __FUNCTION__, (buf[0] >> 8) & 0xff);			return -ETIMEDOUT;		}		msleep(1);	}	stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);	if (stat & GPMQOver) {		printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __FUNCTION__);		return -ENOSPC;	}	else if (stat & OSDQOver) {		printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __FUNCTION__);		return -ENOSPC;	}#endif	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/9a7b102e7f5ccb2826a81315abc89f95adaf4421/av7110_hw.c/buggy/drivers/media/dvb/ttpci/av7110_hw.c