Ejemplo n.º 1
0
YW_ErrorType_T D0367qam_ScanFreq(TUNER_IOREG_DeviceMap_t *DemodDeviceMap,
                                                IOARCH_Handle_t DemodIOHandle)
{
	YW_ErrorType_T              Error = YW_NO_ERROR;
	IOARCH_Handle_t		        IOHandle = DemodIOHandle;
	TUNER_IOREG_DeviceMap_t		*DeviceMap = DemodDeviceMap;
    FE_367qam_InternalParams_t  pParams;
    U32 ZigzagScan = 0;
    S32 SearchRange_Hz_Tmp;


    FirstTimeBER[0] = 1;

    YWLIB_Memset(&pParams, 0, sizeof(FE_367qam_InternalParams_t));
    pParams.State = FE_367qam_NOTUNER;

	pParams.Modulation = D0367qam_GeModulation(DeviceMap, IOHandle);
    pParams.Crystal_Hz = DeviceMap->RegExtClk; //30M 还是27M,由硬件决定
    pParams.SearchRange_Hz = 280000;/*280 kHz*/ //question
    pParams.SymbolRate_Bds = D0367qam_GeSymbolRate(DeviceMap, IOHandle);////
    pParams.Frequency_kHz  = D0367qam_GeFrequencyKhz(DeviceMap, IOHandle);////
    pParams.AdcClock_Hz    = FE_367qam_GetADCFreq(DeviceMap,IOHandle,pParams.Crystal_Hz);
    pParams.MasterClock_Hz = FE_367qam_GetMclkFreq(DeviceMap,IOHandle,pParams.Crystal_Hz);
	printk("demod_d0367qam_ScanFreq  Frequency === %d\n", pParams.Frequency_kHz);
	printk("demod_d0367qam_ScanFreq  Modulation === %d\n", pParams.Modulation);
	printk("SymbolRate_Bds  =========== %d\n", pParams.SymbolRate_Bds);
//    printk("pParams.AdcClock_Hz  ====== %d\n",pParams.AdcClock_Hz);
//    printk("pParams.MasterClock_Hz ===== %d\n",pParams.MasterClock_Hz);

    #if 0
    if (Inst->DriverParam.Cab.TunerDriver.tuner_SetFreq != NULL)
    {
       Error = (Inst->DriverParam.Cab.TunerDriver.tuner_SetFreq)(Index,pParams.Frequency_kHz, NULL);
    }
    #else
	D0367qam_TunerSetFreq(DeviceMap, IOHandle);
    #endif  /* 0 */

	/* Sets the QAM size and all the related parameters */
	D367qam_SetQamSize(TUNER_TUNER_SHARP5469C, DeviceMap,IOHandle,pParams.Frequency_kHz,pParams.SymbolRate_Bds,pParams.Modulation);
	/* Sets the symbol and all the related parameters */
	FE_367qam_SetSymbolRate(DeviceMap,IOHandle,pParams.AdcClock_Hz,pParams.MasterClock_Hz,pParams.SymbolRate_Bds,pParams.Modulation);
	/* Zigzag Algorithm test */
	if(25*pParams.SearchRange_Hz > pParams.SymbolRate_Bds)
	{
		pParams.SearchRange_Hz = -(S32)(pParams.SymbolRate_Bds)/25;
		ZigzagScan = 1;
	}

	/* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */
	pParams.State = D0367qam_Algo(DeviceMap, IOHandle, &pParams);
    SearchRange_Hz_Tmp = pParams.SearchRange_Hz; //lwj add
	if(ZigzagScan&&(pParams.State!=FE_367qam_DATAOK))
	{
		do
		{
            #if 1 //lwj modify
			pParams.SearchRange_Hz = -pParams.SearchRange_Hz;

			if(pParams.SearchRange_Hz>0)
				pParams.DerotOffset_Hz = -pParams.DerotOffset_Hz + pParams.SearchRange_Hz;
			else
				pParams.DerotOffset_Hz = -pParams.DerotOffset_Hz;
            #endif
			/* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */
			pParams.State = D0367qam_Algo(DeviceMap, IOHandle, &pParams);
		}
		while(((pParams.DerotOffset_Hz+pParams.SearchRange_Hz)>=-(S32)SearchRange_Hz_Tmp)&&(pParams.State!=FE_367qam_DATAOK));
	}
	/* check results */
	if( (pParams.State == FE_367qam_DATAOK) && (!Error))
	{
		/* update results */
        printk("TUNER_STATUS_LOCKED #######################\n");
	    //Inst->Status = TUNER_STATUS_LOCKED;
		//pResult->Frequency_kHz = pIntParams->DemodResult.Frequency_kHz;
		//pResult->SymbolRate_Bds = pIntParams->DemodResult.SymbolRate_Bds;
		//pResult->SpectInv = pIntParams->DemodResult.SpectInv;
		//pResult->Modulation = pIntParams->DemodResult.Modulation;
	}
	else
	{
        printk("TUNER_STATUS_UNLOCKED #######################\n");
		//Inst->Status = TUNER_STATUS_UNLOCKED;
	}

	return(Error);

}
Ejemplo n.º 2
0
/***********************************************************************
	函数名称:	demod_d0367qam_ScanFreq

	函数说明:	搜索频率

    修改记录:	日       期      作      者       修定
 				---------         ---------       -----
               	2010.11.11		  lwj			  创建
************************************************************************/
YW_ErrorType_T demod_d0367qam_ScanFreq(U8 Index)
{
	YW_ErrorType_T              Error = YW_NO_ERROR;
	TUNER_ScanTaskParam_T       *Inst;
	IOARCH_Handle_t		        IOHandle;
	TUNER_IOREG_DeviceMap_t		*DeviceMap;
    FE_367qam_InternalParams_t  pParams;
    U32 ZigzagScan = 0;
    S32 SearchRange_Hz_Tmp;

	Inst = TUNER_GetScanInfo(Index);
	IOHandle = Inst->DriverParam.Cab.DemodIOHandle;
	DeviceMap = &Inst->DriverParam.Cab.Demod_DeviceMap;

    FirstTimeBER[Index] = 1;

    YWLIB_Memset(&pParams, 0, sizeof(FE_367qam_InternalParams_t));
    pParams.State = FE_367qam_NOTUNER;
    /*
    --- Modulation type is set to
    */
    switch(Inst->DriverParam.Cab.Param.Modulation)////
    {
        case YWTUNER_MOD_QAM_16 :
            pParams.Modulation = FE_CAB_MOD_QAM16;
        break;

        case YWTUNER_MOD_QAM_32 :
            pParams.Modulation = FE_CAB_MOD_QAM32;
        break;

        case YWTUNER_MOD_QAM_64 :
            pParams.Modulation = FE_CAB_MOD_QAM64;
        break;

        case YWTUNER_MOD_QAM_128 :
            pParams.Modulation = FE_CAB_MOD_QAM128;
        break;

        case YWTUNER_MOD_QAM_256 :
            pParams.Modulation = FE_CAB_MOD_QAM256;
        break;

        default:
            pParams.Modulation = FE_CAB_MOD_QAM64;
            break;
    }
    pParams.Crystal_Hz = DeviceMap->RegExtClk; //30M 还是27M,由硬件决定
    pParams.SearchRange_Hz = 280000;/*280 kHz*/ //question
    pParams.SymbolRate_Bds = Inst->DriverParam.Cab.Param.SymbolRateB;////
    pParams.Frequency_kHz  = Inst->DriverParam.Cab.Param.FreqKHz;////
    pParams.AdcClock_Hz    = FE_367qam_GetADCFreq(DeviceMap,IOHandle,pParams.Crystal_Hz);
    pParams.MasterClock_Hz = FE_367qam_GetMclkFreq(DeviceMap,IOHandle,pParams.Crystal_Hz);
//    printk("demod_d0367qam_ScanFreq  Frequency === %d\n", pParams.Frequency_kHz);
//    printk("SymbolRate_Bds  =========== %d\n", pParams.SymbolRate_Bds);
//    printk("pParams.AdcClock_Hz  ====== %d\n",pParams.AdcClock_Hz);
//    printk("pParams.MasterClock_Hz ===== %d\n",pParams.MasterClock_Hz);

    if (Inst->DriverParam.Cab.TunerDriver.tuner_SetFreq != NULL)
    {
       Error = (Inst->DriverParam.Cab.TunerDriver.tuner_SetFreq)(Index, pParams.Frequency_kHz, NULL);
    }

	/* Sets the QAM size and all the related parameters */
	FE_367qam_SetQamSize(Inst,DeviceMap,IOHandle,pParams.Frequency_kHz,pParams.SymbolRate_Bds,pParams.Modulation);
	/* Sets the symbol and all the related parameters */
	FE_367qam_SetSymbolRate(DeviceMap,IOHandle,pParams.AdcClock_Hz,pParams.MasterClock_Hz,pParams.SymbolRate_Bds,pParams.Modulation);
	/* Zigzag Algorithm test */
	if(25*pParams.SearchRange_Hz > pParams.SymbolRate_Bds)
	{
		pParams.SearchRange_Hz = -(S32)(pParams.SymbolRate_Bds)/25;
		ZigzagScan = 1;
	}

	/* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */
	pParams.State = FE_367qam_Algo(Index, &pParams);
    SearchRange_Hz_Tmp = pParams.SearchRange_Hz; //lwj add
	if(ZigzagScan&&(pParams.State!=FE_367qam_DATAOK))
	{
		do
		{
            #if 1 //lwj modify
			pParams.SearchRange_Hz = -pParams.SearchRange_Hz;

			if(pParams.SearchRange_Hz>0)
				pParams.DerotOffset_Hz = -pParams.DerotOffset_Hz + pParams.SearchRange_Hz;
			else
				pParams.DerotOffset_Hz = -pParams.DerotOffset_Hz;
            #endif
			/* Search algorithm launch, [-1.1*RangeOffset, +1.1*RangeOffset] scan */
			pParams.State = FE_367qam_Algo(Index,&pParams);
		}
		while(((pParams.DerotOffset_Hz+pParams.SearchRange_Hz)>=-(S32)SearchRange_Hz_Tmp)&&(pParams.State!=FE_367qam_DATAOK));
	}
	/* check results */
	if( (pParams.State == FE_367qam_DATAOK) && (!Error))
	{
		/* update results */
        //printk("TUNER_STATUS_LOCKED #######################\n");
	    Inst->Status = TUNER_INNER_STATUS_LOCKED;
		//pResult->Frequency_kHz = pIntParams->DemodResult.Frequency_kHz;
		//pResult->SymbolRate_Bds = pIntParams->DemodResult.SymbolRate_Bds;
		//pResult->SpectInv = pIntParams->DemodResult.SpectInv;
		//pResult->Modulation = pIntParams->DemodResult.Modulation;
	}
	else
	{
		Inst->Status = TUNER_INNER_STATUS_UNLOCKED;
	}


	return(Error);


}