Dword MT2260B0_set ( IN Demodulator* demodulator, IN Byte chip, IN Word bandwidth, IN Dword frequency ) { Dword error = Error_NO_ERROR; UData_t status = MT_OK; UData_t freq; UData_t bw; freq = frequency * 1000UL; bw = (UData_t) bandwidth * 1000UL; /** Change frequency */ status = MT2260_ChangeFreq (Microtune_MT2260B0_tunerHandles[chip], freq); if (MT_NO_ERROR (status)) status |= MT2260_SetParam (Microtune_MT2260B0_tunerHandles[chip], MT2260_OUTPUT_BW, bw); if (MT_IS_ERROR (status)) error = Error_MT_TUNE_FAIL; User_delay (demodulator, 100); return (error); }
/***************************************************************************** ** ** Name: MT_Sleep ** ** Description: Delay execution for "nMinDelayTime" milliseconds ** ** Parameters: handle - User-specific I/O parameter that was ** passed to tuner's Open function. ** nMinDelayTime - Delay time in milliseconds ** ** Returns: None. ** ** Notes: This is a callback function that is called from the ** the tuning algorithm. You MUST provide code that ** blocks execution for the specified period of time. ** ** Revision History: ** ** SCR Date Author Description ** ------------------------------------------------------------------------- ** N/A 03-25-2004 DAD Original ** *****************************************************************************/ void MT2260_Sleep(Handle_t handle, UData_t nMinDelayTime) { PUserData userData; /* ** ToDo: Add code here to implement a OS blocking ** for a period of "nMinDelayTime" milliseconds. */ userData = (PUserData)handle; User_delay (userData->demodulator, (unsigned long) nMinDelayTime); }
DWORD DL_MonitorReception(Bool *lock) { DWORD dwError = Error_NO_ERROR; BYTE ucSlaveDemod=0; Bool bLock = False; ChannelStatistic stat; deb_data("- Enter %s Function , OvrFlwChk=%d, UnLockCount=%d-\n",__FUNCTION__, PDC->fc[ucSlaveDemod].OvrFlwChk, PDC->fc[ucSlaveDemod].UnLockCount); down(&PDC->tunerLock); if( PDC->fc[ucSlaveDemod].ulDesiredFrequency==0 || PDC->fc[ucSlaveDemod].ucDesiredBandWidth==0 ) { if( lock ) *lock = False; deb_data("- %s Function skipping\n",__FUNCTION__); goto exit; } // check lock status dwError= Demodulator_isLocked((Demodulator*) &PDC->Demodulator, ucSlaveDemod, &bLock); if( dwError!=Error_NO_ERROR ) { goto exit; } // consider as unlock if UBC is not zero dwError = Demodulator_getChannelStatistic((Demodulator*) &PDC->Demodulator, ucSlaveDemod, &stat); if( dwError!=Error_NO_ERROR ) { goto exit; } //uncomment this because this causes instability in channel scan. // report lock status if( lock ) *lock = bLock; deb_data("- %s Function, LOCK = %d\n", __FUNCTION__, bLock); // stop monitoring if(PDC->fc[ucSlaveDemod].OvrFlwChk<1) { deb_data("- %s Function end of monitor cycle -\n",__FUNCTION__); // if lock is lost for a while, try to reacquire channel if( PDC->fc[ucSlaveDemod].UnLockCount >= CHECK_LOCK_LOOPS*2/3) { WORD bw = PDC->fc[ucSlaveDemod].ucDesiredBandWidth; DWORD freq = PDC->fc[ucSlaveDemod].ulDesiredFrequency; deb_data("- %s Function need to reacquire channel, freq=%d, bw=%d-\n",__FUNCTION__, freq, bw); // reacquire channel // first power off, then power on DRV_ApCtrl (PDC, 0, 0); User_delay(0, 500); DRV_ApCtrl (PDC, 0, 1); User_delay(0, 500); // switch to another frequency, say 500MHz deb_data("- %s Function switch to 500MHz first -\n",__FUNCTION__); Demodulator_acquireChannel ((Demodulator*) &PDC->Demodulator, ucSlaveDemod, bw, 500000); User_delay(0, 500); // now change to original frequency deb_data("- %s Function switch to %d KHz later -\n",__FUNCTION__, freq); Demodulator_acquireChannel ((Demodulator*) &PDC->Demodulator, ucSlaveDemod, bw, freq); } // restart monitor cycle PDC->fc[ucSlaveDemod].OvrFlwChk = CHECK_LOCK_LOOPS; PDC->fc[ucSlaveDemod].UnLockCount = 0; dwError = Error_NO_ERROR; goto exit; } PDC->fc[ucSlaveDemod].OvrFlwChk--; // maintain lock count if( !bLock ) PDC->fc[ucSlaveDemod].UnLockCount ++; deb_data("- Exit %s Function -\n",__FUNCTION__); // avoid race with setfreq exit: up(&PDC->tunerLock); return dwError; }