Exemplo n.º 1
0
/*
Function:	Set RF frequency (Unit: KHz)
Input:
        fvalue -- RF frequency (Unit: KHz)
Output:
        SUCCESS or FAILURE
*/
GX_STATE GX_Set_RFFrequency(unsigned long fvalue)
{
		int UCtmp = FAILURE;
        unsigned char data[5];
        unsigned long freq;

        freq=(fvalue+GX_IF_FREQUENCY)*10/625;              /*freq=(fvalue+GX_IF_FREQUENCY)*/
        data[0] = 0xc0;	                                /*Tunner Address*/
        data[1] =(unsigned char)((freq>>8)&0xff);	
        data[2] =(unsigned char)(freq&0xff);	
        data[3] = 0x86;	/*62.5KHz*/
        data[4] = 0x08;
     
        if (SUCCESS == GX_Set_Tunner_Repeater_Enable(1))	/*open the chip repeater */
		{
			if (SUCCESS == GX_I2cReadWrite( WRITE, data[0],data[1],&data[2], 3 ))
			{
				GX_Delay_N_ms(50);
				UCtmp = GX_Set_Tunner_Repeater_Enable(0);	/*close the chip repeater*/
			}
		}

		if (SUCCESS == UCtmp)
		{
            GX_Delay_N_ms(50);
			UCtmp = GX_HotReset_CHIP();
		}
		return UCtmp;
}
Exemplo n.º 2
0
/*
Funtion:	Set chip wake up
Input:
Sleep_Enable    --    1: Sleep
					  0: Working
Output:
			SUCCESS or FAILURE

*/
GX_STATE GX_Set_Sleep(struct gx1001_state *state, int Sleep_Enable)
{

    if(NEWONE==GX_Get_Version(state))
    {
        int temp1=0,temp2=0;
        int UCtmp1 = FAILURE,UCtmp2 = FAILURE;

        temp1=GX_Read_one_Byte(state, GX_MAN_PARA);	/*0x10 - bit2*/
        temp2=GX_Read_one_Byte(state, 0x14);/*0x14 - - bit4-bit5*/
        if ((temp1!= FAILURE)&&(temp2!= FAILURE))
        {
            temp1 &=0xfb;
            temp2 &=0xcf;

            temp1 |= 0x04&(Sleep_Enable<<2);
            temp2 |= 0x10&(Sleep_Enable<<4);
            temp2 |= 0x20&(Sleep_Enable<<5);

            UCtmp1 = GX_Write_one_Byte(state, GX_MAN_PARA,temp1);
            UCtmp2 = GX_Write_one_Byte(state, 0x14,temp2);

            if ((SUCCESS == UCtmp1)&&(SUCCESS == UCtmp2))
            {
                if (0==Sleep_Enable )
                {
                    UCtmp1 =GX_HotReset_CHIP(state);
                }
            }
        }
        return UCtmp1&&UCtmp2;
    }
    return 1;

}
Exemplo n.º 3
0
GX_STATE GX_Set_RFFrequency(struct gx1001_state *state, unsigned long fvalue)
{
    signed char UCtmp = FAILURE;
    unsigned char data[6];
    unsigned long freq;

    freq=(fvalue+GX_IF_FREQUENCY)*10/625;            /*freq=(fvalue+GX_IF_FREQUENCY)*/
    data[0] = state->config.tuner_addr;	         /*Tunner Address*/
    data[1] =(unsigned char)((freq>>8)&0xff);
    data[2] =(unsigned char)(freq&0xff);
    data[3] = 0X8b;//0xb3;	/*62.5KHz*/ modified by jeffchang

    if (fvalue < 153000)
        data[4] = 0x01;
    else if (fvalue < 430000)
        data[4] = 0x06;
    else
        data[4] = 0x0c;

    data[5] = 0xc3;

    if (SUCCESS == GX_Set_Tunner_Repeater_Enable(state, 1))	/*open the chip repeater */
    {
        GX_Delay_N_10ms(1);
        if (SUCCESS == Tuner_Writeregister(state, &data[1], 5))
        {
            GX_Delay_N_10ms(1);
            UCtmp = GX_Set_Tunner_Repeater_Enable(state, 0);	/*close the chip repeater*/
            UCtmp = SUCCESS;
        }
    }

    if (SUCCESS == UCtmp)
    {
        GX_Delay_N_10ms(5);
        UCtmp = GX_HotReset_CHIP(state);
    }

    return UCtmp;
}
Exemplo n.º 4
0
GX_STATE GX_Set_RFFrequency(unsigned long fvalue)
{
    signed char UCtmp = FAILURE;
    unsigned char data[6];
    unsigned long freq;

    freq=(fvalue+GX_IF_FREQUENCY)*10/625;              /*freq=(fvalue+GX_IF_FREQUENCY)/Fref*/
    data[0] = I2C_TUNER_ADDRESS;	                   /*Tunner Address*/
    data[1] =(unsigned char)((freq>>8)&0xff);
    data[2] =(unsigned char)(freq&0xff);
    data[3] = 0x8b;										/*Fref=62.5KHz*/

    if (fvalue < 153000)
        data[4] = 0x60;
    else if (fvalue < 430000)
        data[4] = 0xa2;
    else
        data[4] = 0xaa;

    data[5] = 0xc6;

    if (SUCCESS == GX_Set_Tunner_Repeater_Enable(1))	/*open the chip repeater */
    {
        GX_Delay_N_10ms(1);
        if (SUCCESS == Tuner_Writeregister(&data[1], 5 ))
        {
            GX_Delay_N_10ms(1);
            UCtmp = GX_Set_Tunner_Repeater_Enable(0);	/*close the chip repeater*/
            UCtmp = SUCCESS;
        }
    }

    if (SUCCESS == UCtmp)
    {
        GX_Delay_N_10ms(5);
        UCtmp = GX_HotReset_CHIP();
    }
    return UCtmp;
}
Exemplo n.º 5
0
/*
Function:	Search signal with setted parameters
Input:
	    Symbol_Rate_1   --  Used first symbol rate value (range: 450 -- 9000)     (Unit: kHz)
	    Symbol_Rate_2	--  Used second symbol rate value. Please set 0 if no use	(Unit: kHz)

	    Spec_Mode	    --	0£ºsearch only positive spectrum
	    			    	1£ºsearch only negative spectrum
	    			    	2£ºfirst positive and then negative spectrum
	    			    	3£ºfirst negative and then positive spectrum

	    Qam_Size	    --  0-2 = reserved;
	    			    	3 = 16QAM;
	    			    	4 = 32QAM;
	    			    	5 = 64QAM;
	    			    	6 = 128QAM;
	    			    	7 = 256QAM.

	    RF_Freq		    --  The RF frequency (KHz)

	    Wait_OK_X_ms    --  The waiting time before give up one search ( Unit: ms )
	    			        (Range: 250ms -- 2000ms, Recommend: 700ms)


Output:
		SUCCESS --  Have signal
		FAILURE	--  No signal
*/
GX_STATE GX_Search_Signal(  struct gx1001_state *state,
                            unsigned long Symbol_Rate_1,
                            unsigned long Symbol_Rate_2,
                            int Spec_Mode,
                            int Qam_Size,
                            unsigned long RF_Freq,
                            int Wait_OK_X_ms)
{
    int After_EQU_OK_Delay	= 60;	//60 ms,
    int spec_invert_enable	= 0;	//spec invert enable flag
    int spec_invert_value	= 0;	//next spec invert value
    int symbol_2_enable		= 0;	//Symbol_Rate_2 enable flag

    int wait_ok_x_ms_temp	= 0;    //for save Wait_OK_X_ms
    int wait_ok_SF_temp=0;              // wait for lock SF
    int GX1001Bflag=0;
    //-----------------------------------------------------------------------------

    GX_CoolReset_CHIP(state);		// must be this !! will result in one i2c error do not care
    if (FAILURE == GX_Init_Chip(state))
    {
        pr_error("GX_Init_Chip FAILURE\n");
        return FAILURE;
    }

    //-----------------------------------------------------------------------------
    wait_ok_x_ms_temp = Wait_OK_X_ms/10;	//as 700 ms = 70 * 10ms_Delay

    if (FAILURE == GX_Select_DVB_QAM_Size(state, Qam_Size))
    {
        pr_error("GX_Select_DVB_QAM_Size FAILURE\n");
        return FAILURE;	//Set QAM size
    }
    if (FAILURE == GX_SetSymbolRate(state, Symbol_Rate_1/1000))
    {
        pr_error("GX_SetSymbolRate FAILURE\n");
        return FAILURE;	//Set Symbol rate value
    }
    if (FAILURE == GX_Set_RFFrequency(state, RF_Freq))
    {
        pr_error("GX_Set_RFFrequency FAILURE\n");
        return FAILURE;		//Set tuner frequency
    }
    if (Symbol_Rate_2 >= 4500)
        symbol_2_enable = 1;	//Symbol_Rate_2 enable

    if (Symbol_Rate_1<2500)
        After_EQU_OK_Delay = 100;   //100ms   (if  <2.5M  = 100ms)

    //-----------------------------------------------------------------------------

    if(NEWONE == GX_Get_Version(state))     //the chip version is GX1001B
    {
        GX1001Bflag=1;
        Spec_Mode=0;
    }

SYMBOL_2_SEARCH:
    switch (Spec_Mode)
    {
    case 3:	// first negative and then positive
    {
        spec_invert_enable = 1;
        spec_invert_value  = 0;	//next spec invert value
    }
    case 1:	//negative
    {
        GX_SetSpecInvert(state, 1);
    }
    break;
    case 2:// first positive and then negative
    {
        spec_invert_enable = 1;
        spec_invert_value  = 1;	//next spec invert value
    }
    default://positive
    {
        GX_SetSpecInvert(state, 0);
    }
    break;
    }
    //-----------------------------------------------------------------------------

SPEC_INVERT_SEARCH:
    if (FAILURE == GX_HotReset_CHIP(state))
    {
        pr_error("GX_HotReset_CHIP FAILURE\n");
        return FAILURE;
    }
    wait_ok_x_ms_temp = Wait_OK_X_ms/10;	//as 700 ms = 70 * 10ms_Delay

    while ((FAILURE == GX_Read_EQU_OK(state)) && (wait_ok_x_ms_temp))
    {
        wait_ok_x_ms_temp --;
        GX_Delay_N_10ms(1);		//Delay 10 ms
    }

    if ( 0 == wait_ok_x_ms_temp)           //Read EQU time over
    {
        if(GX1001Bflag==1&&SFenable==ENABLE)     //the chip version is GX1001B
        {   GX_Set_SF(state, ENABLE);

            GX_Set_FM(state, ENABLE);
            GX_HotReset_CHIP(state);
            wait_ok_SF_temp=80;
            while ((FAILURE == GX_Read_ALL_OK(state)) && (wait_ok_SF_temp))
            {
                wait_ok_SF_temp --;
                GX_Delay_N_10ms(2);		//Delay 20 ms
            }
            if(SUCCESS==GX_Read_ALL_OK(state))    //SUCCESS while open SF&FM
            {
                return SUCCESS;
            }
        }
        else if (symbol_2_enable)
        {
            symbol_2_enable = 0;
            if (Symbol_Rate_2<25000)
                After_EQU_OK_Delay = 100;   //100ms
            else
                After_EQU_OK_Delay = 60;   //60ms
            GX_SetSymbolRate(state, Symbol_Rate_2) ;
            if(GX1001Bflag==1)
            {   GX_Set_SF(state, DISABLE);
                GX_Set_FM(state, DISABLE);
            }
            goto SYMBOL_2_SEARCH;
        }
        else
        {
            return FAILURE;
        }
    }

    GX_Delay_N_10ms(After_EQU_OK_Delay/10);		//Delay After_EQU_OK_Delay ms

    if (SUCCESS == GX_Read_ALL_OK(state))	//All ok
    {
        if(GX1001Bflag==1&&FMenable==ENABLE)     //the chip version is GX1001B
            GX_Set_FM(state, ENABLE);                 //open FM for GX1001B
        return SUCCESS;
    }
    else
    {
        if (spec_invert_enable)
        {
            spec_invert_enable = 0;				//disable spec invert
            if (FAILURE == GX_SetSpecInvert(state, spec_invert_value))
            {
                return FAILURE;	//spec invert
            }
            else
            {
                goto SPEC_INVERT_SEARCH;
            }
        }
        else
        {
            return FAILURE;
        }

    }
}