#ifdef DEBUG_LOCKLOSS /* first of all try setting the tone again if it was on - this * sometimes works around problems with noisy power supplies */ if (fe->ops->set_tone && (fepriv->tone == SEC_TONE_ON)) { fe->ops->set_tone(fe, fepriv->tone); mdelay(100); s = 0; fe->ops->read_status(fe, &s); if (s & FE_HAS_LOCK) { printk("DVB%i: Lock was lost, but regained by setting " "the tone. This may indicate your power supply " "is noisy/slightly incompatable with this DVB-S " "adapter\n", fe->dvb->num); fepriv->state = FESTATE_TUNED; continue; } } #endif /* some other reason for losing the lock - start zigzagging */ 
static int dvb_frontend_thread(void *data){	struct dvb_frontend *fe = data;	struct dvb_frontend_private *fepriv = fe->frontend_priv;	unsigned long timeout;	char name [15];	int quality = 0, delay = 3*HZ;	fe_status_t s;	int check_wrapped = 0;	dprintk("%s\n", __FUNCTION__);	snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num);        lock_kernel();        daemonize(name);        sigfillset(&current->blocked);        unlock_kernel();	fepriv->status = 0;	dvb_frontend_init(fe);	fepriv->wakeup = 0;	while (1) {		up(&fepriv->sem);	    /* is locked when we enter the thread... */		timeout = wait_event_interruptible_timeout(fepriv->wait_queue,							   dvb_frontend_should_wakeup(fe),							   delay);		if (0 != dvb_frontend_is_exiting(fe)) {			/* got signal or quitting */			break;		}		try_to_freeze();		if (down_interruptible(&fepriv->sem))			break;		/* if we've got no parameters, just keep idling */		if (fepriv->state & FESTATE_IDLE) {			delay = 3*HZ;			quality = 0;			continue;		}		/* get the frontend status */		if (fepriv->state & FESTATE_RETUNE) {			s = 0;		} else {			if (fe->ops->read_status)				fe->ops->read_status(fe, &s);			if (s != fepriv->status) {				dvb_frontend_add_event(fe, s);				fepriv->status = s;			}		}		/* if we're not tuned, and we have a lock, move to the TUNED state */		if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {			update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);			fepriv->state = FESTATE_TUNED;			/* if we're tuned, then we have determined the correct inversion */			if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&			    (fepriv->parameters.inversion == INVERSION_AUTO)) {				fepriv->parameters.inversion = fepriv->inversion;			}			continue;		}		/* if we are tuned already, check we're still locked */		if (fepriv->state & FESTATE_TUNED) {			update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);			/* we're tuned, and the lock is still good... */			if (s & FE_HAS_LOCK)				continue;			else { /* if we _WERE_ tuned, but now don't have a lock */#ifdef DEBUG_LOCKLOSS				/* first of all try setting the tone again if it was on - this				 * sometimes works around problems with noisy power supplies */				if (fe->ops->set_tone && (fepriv->tone == SEC_TONE_ON)) {					fe->ops->set_tone(fe, fepriv->tone);					mdelay(100);					s = 0;					fe->ops->read_status(fe, &s);					if (s & FE_HAS_LOCK) {						printk("DVB%i: Lock was lost, but regained by setting "						       "the tone. This may indicate your power supply "						       "is noisy/slightly incompatable with this DVB-S "						       "adapter\n", fe->dvb->num);						fepriv->state = FESTATE_TUNED;						continue;					}				}#endif				/* some other reason for losing the lock - start zigzagging */				fepriv->state = FESTATE_ZIGZAG_FAST;				fepriv->started_auto_step = fepriv->auto_step;				check_wrapped = 0;			}		}		/* don't actually do anything if we're in the LOSTLOCK state,		 * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */		if ((fepriv->state & FESTATE_LOSTLOCK) &&		    (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {			update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);			continue;		}		/* don't do anything if we're in the DISEQC state, since this		 * might be someone with a motorized dish controlled by DISEQC.		 * If its actually a re-tune, there will be a SET_FRONTEND soon enough.	*/		if (fepriv->state & FESTATE_DISEQC) {			update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);			continue;		}		/* if we're in the RETUNE state, set everything up for a brand		 * new scan, keeping the current inversion setting, as the next		 * tune is _very_ likely to require the same */		if (fepriv->state & FESTATE_RETUNE) {			fepriv->lnb_drift = 0;			fepriv->auto_step = 0;			fepriv->auto_sub_step = 0;			fepriv->started_auto_step = 0;			check_wrapped = 0;		}		/* fast zigzag. */		if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {			delay = fepriv->min_delay;			/* peform a tune */			if (dvb_frontend_autotune(fe, check_wrapped)) {				/* OK, if we've run out of trials at the fast speed.				 * Drop back to slow for the _next_ attempt */				fepriv->state = FESTATE_SEARCHING_SLOW;				fepriv->started_auto_step = fepriv->auto_step;				continue;			}			check_wrapped = 1;			/* if we've just retuned, enter the ZIGZAG_FAST state.			 * This ensures we cannot return from an			 * FE_SET_FRONTEND ioctl before the first frontend tune			 * occurs */			if (fepriv->state & FESTATE_RETUNE) {				fepriv->state = FESTATE_TUNING_FAST;			}		}		/* slow zigzag */		if (fepriv->state & FESTATE_SEARCHING_SLOW) {			update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);			/* Note: don't bother checking for wrapping; we stay in this			 * state until we get a lock */			dvb_frontend_autotune(fe, 0);		}	}	if (dvb_shutdown_timeout) {		if (dvb_powerdown_on_sleep)			if (fe->ops->set_voltage)				fe->ops->set_voltage(fe, SEC_VOLTAGE_OFF);		if (fe->ops->sleep)			fe->ops->sleep(fe);	}	fepriv->thread_pid = 0;	mb();	dvb_frontend_wakeup(fe);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/f7b67195ea571b8540ac79daf27f5932ec40c098/dvb_frontend.c/buggy/drivers/media/dvb/dvb-core/dvb_frontend.c