static int ite9173_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{
	struct aml_fe *afe = fe->demodulator_priv;
	struct aml_fe_dev *dev = afe->dtv_demod;

	pr_dbg("ite9173_set_frontend\n");
	Dword ret;
	Word bandwidth=8;
	int freq;

	bandwidth=p->u.ofdm.bandwidth;
	if(bandwidth==0)
		bandwidth=8;
	else if(bandwidth==1)
		bandwidth=7;
	else if(bandwidth==2)
		bandwidth=6;
	else
		bandwidth=8;	

	freq=p->frequency/1000;

	pr_dbg("p->frequency ==== %d \n", p->frequency);
	if(freq>0&&freq!=-1) {
		mutex_lock(&ite_lock);
		ret = Demodulator_acquireChannel(pdemod, bandwidth*1000,freq);
		mutex_unlock(&ite_lock);
	}else
		printk("\n--[xsw]: Invalidate Fre!!!!!!!!!!!!!--\n");
	afe->params = *p;
	pr_dbg("ite9173_set_frontend--\n");
	return  0;
}
示例#2
0
static int ite9133_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{

	pr_dbg("ite9133_set_frontend\n");

	struct ite9133_state *state = fe->demodulator_priv;

	Dword ret;
	Word bandwidth=8;

	bandwidth=p->u.ofdm.bandwidth;
	if(bandwidth==0)
		bandwidth=8;
	else if(bandwidth==1)
		bandwidth=7;
	else if(bandwidth==2)
		bandwidth=6;
	else
		bandwidth=8;	

	state->freq=(p->frequency/1000);

	pr_dbg("state->freq ==== %d \n", state->freq);
	if(state->freq>0&&state->freq!=-1) {
		mutex_lock(&ite_lock);
		ret = Demodulator_acquireChannel(pdemod, bandwidth*1000,state->freq);
		mutex_unlock(&ite_lock);
	}else
		printk("\n--[xsw]: Invalidate Fre!!!!!!!!!!!!!--\n");

	pr_dbg("ite9133_set_frontend--\n");
	return  0;
}
void Example_acquireChannel (Demodulator *demod, Word bandwidth, Dword freq) {
    Dword error = Error_NO_ERROR;
    Bool locked;
    Bool found = False;

    //Set Channel
    error = Demodulator_acquireChannel (demod, bandwidth, freq);
    if (error) goto exit;
    
    //Wait demodulator ready and Check if Locked
    //error = Demodulator_isLocked (demod, &locked);
    //if (error) goto exit;

    //printk("Channel is %slocked!\n", locked?"":"not ");

exit:
    if (error) printk("Error = 0x%08x\n", error);
}
示例#4
0
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;
}
示例#5
0
static DWORD DRV_SetFreqBw(
    	void*	handle,      
     	BYTE 	ucSlaveDemod,
      	DWORD   dwFreq,      
      	WORD	ucBw
)
{
	DWORD dwError = Error_NO_ERROR;
    
	PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle;

	Bool bLock = true;

	deb_data("- Enter %s Function -\n ",__FUNCTION__);
	deb_data("       ucSlaveDemod = %d, Freq= %d, BW=%d\n", ucSlaveDemod, dwFreq, ucBw);

    if (pdc->fc[ucSlaveDemod].bEnPID)
    {
		deb_data("		Reset HW PID table\n ");
        //Disable PID filter
		Demodulator_writeRegisterBits ((Demodulator*) &pdc->Demodulator, ucSlaveDemod, Processor_OFDM, p_mp2if_pid_en, mp2if_pid_en_pos, mp2if_pid_en_len, 0);
		
    }
	
    down(&PDC->tunerLock);

    PDC->fc[0].AVerFlags &= ~(0x08);
    PDC->fc[0].AVerFlags |= 0x04;
    PTI.bSettingFreq = true; //before acquireChannel, it is ture;  otherwise, it is false

    if(dwFreq) {
        pdc->fc[ucSlaveDemod].ulDesiredFrequency = dwFreq;
    }
    else {
        dwFreq = pdc->fc[ucSlaveDemod].ulDesiredFrequency;
    }

    if(ucBw) {
        pdc->fc[ucSlaveDemod].ucDesiredBandWidth = ucBw*1000;
	}
    else {
        ucBw = pdc->fc[ucSlaveDemod].ucDesiredBandWidth;
    	}

    deb_data("Real Freq= %d, BW=%d\n", pdc->fc[ucSlaveDemod].ulDesiredFrequency, pdc->fc[ucSlaveDemod].ucDesiredBandWidth);
           

    if(!PTI.bTunerInited){
        deb_data("    Skip SetFreq - Tuner is still off!\n");
        goto exit;
    }
	
    PTI.bTunerOK = false;        

    if (pdc->fc[ucSlaveDemod].ulDesiredFrequency!=0 && pdc->fc[ucSlaveDemod].ucDesiredBandWidth!=0)	
    {
	deb_data("AcquireChannel : Real Freq= %d, BW=%d\n", pdc->fc[ucSlaveDemod].ulDesiredFrequency, pdc->fc[ucSlaveDemod].ucDesiredBandWidth);
	dwError = Demodulator_acquireChannel ((Demodulator*) &pdc->Demodulator, ucSlaveDemod, pdc->fc[ucSlaveDemod].ucDesiredBandWidth, pdc->fc[ucSlaveDemod].ulDesiredFrequency);  
	//PTI.bSettingFreq = false;
    	if (dwError) 
    	{
        	deb_data("Demod_acquireChannel fail! 0x%08x\n", dwError);
        	goto exit;
    	}	
	else //when success acquireChannel, record currentFreq/currentBW.
	{
		pdc->fc[ucSlaveDemod].ulCurrentFrequency = pdc->fc[ucSlaveDemod].ulDesiredFrequency;	
		pdc->fc[ucSlaveDemod].ucCurrentBandWidth = pdc->fc[ucSlaveDemod].ucDesiredBandWidth;  
	}
    }
    else {
       	deb_data("Demod_acquireChannel skipped\n");
    }

    if(pdc->StreamType == StreamType_DVBT_DATAGRAM) {
        PDC->fc[ucSlaveDemod].OvrFlwChk = CHECK_LOCK_LOOPS ;
        PDC->fc[ucSlaveDemod].UnLockCount = 0;
    }

    PTI.bTunerOK = true;

exit:

    PTI.bSettingFreq = false;
    up(&PDC->tunerLock);

    return(dwError);  
}