Ejemplo n.º 1
0
int set_tuner_fj2207(struct aml_demod_sta *demod_sta, 
		     struct aml_demod_i2c *adap)
{
    tmErrorCode_t err = TM_OK;
    tmNT220xStandardMode_t StandardMode;
    tmbslFrontEndState_t PLLLock;
    UInt32 ch_if;
    UInt32 ch_pow;
    
    int only_set_freq;
    only_set_freq = (demod_sta->ch_freq)&0x1;

    unsigned long ch_freq;
    int ch_bw;
    
    ch_freq = demod_sta->ch_freq; // kHz
    ch_bw   = demod_sta->ch_bw / 1000; // MHz

    printk("Set Tuner FJ2207 to %ld kHz, demod mode is %d\n", ch_freq, demod_sta->dvb_mode);
    ch_freq *= 1000; // Hz

    StandardMode = demod_sta->dvb_mode==0 ?	(ch_bw<8 ? tmNT220x_QAM_6MHz : tmNT220x_QAM_8MHz) :
    	             demod_sta->dvb_mode==1 ? (ch_bw-6 + tmNT220x_DVBT_6MHz) :
    	             demod_sta->dvb_mode==2 ? tmNT220x_DVBT_8MHz:tmNT220x_DVBT_8MHz;//tmNT220x_ISDBT_6MHz

    if (only_set_freq == 1)
    {
    	
    }
    else
    {
        printk("Mode: %s\n", NT220x_mode_name[StandardMode]);
        err = tmbslNT220xSetStandardMode(0, StandardMode);
        if(err != TM_OK)
            return err;
    }

        err = tmbslNT220xSetRf(0, ch_freq);
        if(err != TM_OK)
        return err;

        err = tmbslNT220xGetLockStatus(0, &PLLLock);
        if(err != TM_OK)
           return err;
  
        err = tmbslNT220xGetIF(0, &ch_if);
        if(err != TM_OK)
           return err;
        demod_sta->ch_if = ch_if / 1000;
        printk("IF: %d kHz\n", demod_sta->ch_if);

        err = tmbslNT220xGetPowerLevel(0, &ch_pow);
        if(err != TM_OK)
           return err;
        printk("Signal Power: %d dBuV\n", (int)ch_pow);

    return err;
}
Ejemplo n.º 2
0
INT32 tun_nt220x_control(UINT32 tuner_id, UINT32 freq, UINT32 sym, UINT8 AGC_Time_Const, UINT8 _i2c_cmd)	
{	

	INT32   result;
	tmErrorCode_t err = TM_OK;
	static INT8 tun_status=0;
	tmNT220xStandardMode_t stdModeMaster;

	UInt32 uRFMaster = freq*1000;
	UInt32 uIFMaster = 0;

	if (0==tun_status)
	{
	   /* Variable declarations */
	   tmbslFrontEndDependency_t sSrvTunerFunc;
	/* Low layer struct set-up to link with user written functions */
	   sSrvTunerFunc.sIo.Write             = UserWrittenI2CWrite;
	   sSrvTunerFunc.sIo.Read              = UserWrittenI2CRead;
	   sSrvTunerFunc.sTime.Get             = Null;
	   sSrvTunerFunc.sTime.Wait            = UserWrittenWait;
	   sSrvTunerFunc.sDebug.Print          = UserWrittenPrint;
	   sSrvTunerFunc.sMutex.Init           = UserWrittenMutexInit;
	   sSrvTunerFunc.sMutex.DeInit         = UserWrittenMutexDeInit;
	   sSrvTunerFunc.sMutex.Acquire        = UserWrittenMutexAcquire;
	   sSrvTunerFunc.sMutex.Release        = UserWrittenMutexRelease;
	   sSrvTunerFunc.dwAdditionalDataSize  = 0;
	   sSrvTunerFunc.pAdditionalData       = Null;
	   
	   /* NT220X Master Driver low layer setup */
	   err = tmbslNT220xInit(0, &sSrvTunerFunc);
	   if(err != TM_OK)
	   {
	   		NT220X_PRINTF("tmNT220x init failed\n");
	       return err;
	   }
	   /* NT220X Master Hardware initialization */
	   do
	   {
	   err = tmbslNT220xReset(0);
	   if(err != TM_OK)
	   		{
	   			NT220X_PRINTF("tmNT220x reset again\n");
				osal_task_sleep(100);
	   		}
	   }while(err != TM_OK);
	   
	   if(err != TM_OK)
	   {
	   		NT220X_PRINTF("tmNT220x reset failed\n");
	       return err;
	   }
	   
	   /* NT220X Master Hardware power state */
	   
	   err = tmbslNT220xSetPowerState(0, tmNT220x_PowerNormalMode);

	   if(err != TM_OK)
	    {
	    
		NT220X_PRINTF("tmNT220x_error 1\n");
	       return err;
	    }

	#if (1)		
	   /* NT220X Master standard mode */
	#ifdef NT220x_IF5M_BW8M
	   stdModeMaster = tmNT220x_QAM_8MHz;
	#else
	  stdModeMaster = tmNT220x_QAM_6MHz;		
	#endif
	   err = tmbslNT220xSetStandardMode(0, stdModeMaster);

	   if(err != TM_OK)
	   {
	   	NT220X_PRINTF("tmNT220x_error 2\n");
	       return err;
	   }
	#endif
		tun_status = 1;
	}
#if (0)
/*
   if(sym<= 4500)
   {
		stdModeMaster = tmNT220x_QAM_6MHz;	
		NT220X_PRINTF("tmNT220x_QAM_6MHz\n");
			
   }
   else
   {	
   		stdModeMaster = tmNT220x_QAM_8MHz;
		NT220X_PRINTF("tmNT220x_QAM_8MHz\n");
   }
*/   
   stdModeMaster = tmNT220x_QAM_6MHz;	
	NT220X_PRINTF("tmNT220x_QAM_6MHz\n");
	
   /* NT220X Master standard mode */
   err = tmbslNT220xSetStandardMode(0, stdModeMaster);
   NT220X_PRINTF("tmNT220x_QAM,stdModeMaster=%d\n",stdModeMaster);	

   if(err != TM_OK)
   {
   		NT220X_PRINTF("set tmNT220x_QAM failed\n");
       return err;
	}
#endif
	
   /* NT220X Master RF frequency */
   err = tmbslNT220xSetRf(0, uRFMaster);// tUnit-> 0: master 1:slaver,uRF(hz)

   if(err != TM_OK)
   {
   		NT220X_PRINTF("tmbslNT220xSetRf failed! uRFMaster=%d\n",uRFMaster);
       return err;
   }

	osal_task_sleep(100); // we don't know wait how long, just give a norminal value.   
   /* Get NT220X Master IF */
/*
   err = tmbslNT220xGetIF(0, &uIFMaster);
   if(err != TM_OK)
       return err;
*/
	if (err !=TM_OK) 
	{
		result= ERR_FAILED;
	}
	else
	{
		result = SUCCESS;
	}
	return result;

}