⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lnb21.c

📁 st7710的tuner标准驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
                return(ST_ERROR_BAD_PARAMETER);
        }
        LNB21Instance->Config.ToneState = Config->ToneState;
    }


    /* Select polarization */
    if (LNB21Instance->Config.Polarization != Config->Polarization)
    {
        switch (Config->Polarization)
        {
            case STTUNER_PLR_VERTICAL:      /* OP_2 controls -- 18V (high) */
                LNB21_SetPolarization(VERTICAL);
                break;

            case STTUNER_PLR_HORIZONTAL:    /* OP_2 controls -- 13V (low) */
                LNB21_SetPolarization(HORIZONTAL);
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail polarity not V or H\n", identity));
#endif
                return(ST_ERROR_BAD_PARAMETER);
        }
       LNB21Instance->Config.Polarization = Config->Polarization;
    }
    
    /* Select CurrentSelection*/
    if (LNB21Instance->Config.CurrentThresholdSelection != Config->CurrentThresholdSelection)
    {
        switch (Config->CurrentThresholdSelection)
        {
            /* The below two cases are for future use*/
            /*case STTUNER_LNB_CURRENT_THRESHOLD_HIGH:*/ /*ISEL=0*/
                /*LNB21_SetCurrentThreshold(0);*/
                /*break;*/

            /*case STTUNER_LNB_CURRENT_THRESHOLD_LOW:*/ /*ISEL=1*/
                /*LNB21_SetCurrentThreshold(1);*/
                /*break;*/

            default:/* Currently above both cases will not be entered, for future use*/
                LNB21_SetCurrentThreshold(1);/* always set ISEL=1 for default setting of LNB21*/
            	break;
         }
         /* Below statement is for future use */
       /*Instance->Config.CurrentThresholdSelection = Config->CurrentThresholdSelection;*/
    }
    
    /* Select CableLossCompensation*/
    if (LNB21Instance->Config.CableLossCompensation != Config->CableLossCompensation)
    {
        /* Below statement is for future use */
        /*LNB21_SetLossCompensation(Config->CableLossCompensation);*/
        /*LNB21Instance->Config.CableLossCompensation = Config->CableLossCompensation;*/
        
        /* Set cable loss compensation off as default*/
        LNB21_SetLossCompensation(FALSE);
    }
    
    
    /* Select ShortCircuitProtection*/
    if (LNB21Instance->Config.ShortCircuitProtectionMode != Config->ShortCircuitProtectionMode)
    {
        switch (Config->ShortCircuitProtectionMode)
        {
        	/* The below two cases are for future use*/
            /*case STTUNER_LNB_PROTECTION_DYNAMIC:*/ /*PCL=0*/
                /*LNB21_SetProtectionMode(Config->ShortCircuitProtectionMode);*/
                /*break;*/

            /*case STTUNER_LNB_PROTECTION_STATIC:*/ /*PCL=1*/
                /*LNB21_SetProtectionMode(Config->ShortCircuitProtectionMode);*/
                /*break;*/

            default:
                LNB21_SetProtectionMode(1); /* set lnb protection mode static as default*/
            	break;
         }
        
        /* Below statement is for future use */
        /*LNB21Instance->Config.ShortCircuitProtectionMode = Config->ShortCircuitProtectionMode;*/
    }


    /* Select power status */
        switch (Config->Status)
        {
            case LNB_STATUS_ON:
            case LNB_STATUS_OFF:
                LNB21_SetPower(Config->Status);
                break;

            default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
                STTBX_Print(("%s fail status not ON or OFF\n", identity));
#endif
                return(ST_ERROR_BAD_PARAMETER);
        }
       LNB21Instance->Config.Status = Config->Status;
    
    /* now write in LNBP21 to update the status*/
    Error = LNB21_UpdateLNB();

#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s ok\n", identity));
#endif
    return(Error);
}   
#endif

#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: lnb_lnb21_ioctl()

Description:
    access device specific low-level functions
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_ioctl(LNB_Handle_t Handle, U32 Function, void *InParams, void *OutParams, STTUNER_Da_Status_t *Status)
   
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_ioctl()";
#endif
    ST_ErrorCode_t Error;
    LNB21_InstanceData_t     *Instance;

    Instance = (LNB21_InstanceData_t *)Handle;

    if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s invalid handle\n", identity));
#endif
        return(ST_ERROR_INVALID_HANDLE);
    }

    switch(Function){

        case STTUNER_IOCTL_RAWIO: /* read/write device register (actual write) */
            Error =  STTUNER_IOARCH_ReadWrite( Instance->IOHandle, 
                                                 ((SATIOCTL_IOARCH_Params_t *)InParams)->Operation,
                                                 ((SATIOCTL_IOARCH_Params_t *)InParams)->SubAddr,
                                                 ((SATIOCTL_IOARCH_Params_t *)InParams)->Data,
                                                 ((SATIOCTL_IOARCH_Params_t *)InParams)->TransferSize,
                                                 ((SATIOCTL_IOARCH_Params_t *)InParams)->Timeout );
            break;

        case STTUNER_IOCTL_REG_IN: /* read device register */
            *(int *)OutParams = STTUNER_IOREG_GetRegister(&Instance->DeviceMap, Instance->IOHandle, *(int *)InParams);
            break;

        case STTUNER_IOCTL_REG_OUT: /* write device register */
            Error =  STTUNER_IOREG_SetRegister(  &Instance->DeviceMap,Instance->IOHandle,
                  (U32)((SATIOCTL_SETREG_InParams_t *)InParams)->RegIndex,
                  (U32)((SATIOCTL_SETREG_InParams_t *)InParams)->Value );
            break;
		case STTUNER_IOCTL_SETLNB: /* set lnb parameters through ioctl */
			Error = ST_ERROR_FEATURE_NOT_SUPPORTED  ;
			break;

		case STTUNER_IOCTL_GETLNB: /* get lnb parameters through ioctl */
			Error = ST_ERROR_FEATURE_NOT_SUPPORTED;
			break;

        default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
            STTBX_Print(("%s function %d not found\n", identity, Function));
#endif
            return(ST_ERROR_FEATURE_NOT_SUPPORTED);
    }


#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s function %d called\n", identity, Function));
#endif
	
	Error |= Instance->DeviceMap.Error;
    
    Instance->DeviceMap.Error = ST_NO_ERROR;

    return(Error);

}



/* ----------------------------------------------------------------------------
Name: lnb_lnb21_ioaccess()

Description:
    we get called with the instance of
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_lnb21_ioaccess(LNB_Handle_t Handle, IOARCH_Handle_t IOHandle, STTUNER_IOARCH_Operation_t Operation, U16 SubAddr, U8 *Data, U32 TransferSize, U32 Timeout)
   
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
   const char *identity = "STTUNER lnb21.c lnb_lnb21_ioaccess()";
#endif
    ST_ErrorCode_t        Error = ST_NO_ERROR;
    IOARCH_Handle_t       ThisIOHandle;
    LNB21_InstanceData_t *Instance;

    Instance = (LNB21_InstanceData_t *)Handle;

    /* check handle */
    if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s invalid handle\n", identity));
#endif
        return(ST_ERROR_INVALID_HANDLE);
    }

    ThisIOHandle = Instance->IOHandle;

    /* if STTUNER_IOARCH_MAX_HANDLES then passthrough function required using our device handle (address) */ 
    if (IOHandle == STTUNER_IOARCH_MAX_HANDLES)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s write passthru\n", identity));
#endif
        Error = STTUNER_IOARCH_ReadWrite(ThisIOHandle, Operation, SubAddr, Data, TransferSize, Timeout);
    }
    else    /* repeater */
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
        STTBX_Print(("%s write repeater\n", identity));
#endif
        
        Error = STTUNER_IOARCH_ReadWriteNoRep(IOHandle, Operation, 0, Data, TransferSize, Timeout);
    }


#ifdef STTUNER_DEBUG_MODULE_SATDRV_LNB21
    STTBX_Print(("%s called\n", identity));
#endif
    return(Error);
}

#endif

/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\UTILITY Functions/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */

#ifndef STTUNER_MINIDRIVER
ST_ErrorCode_t LNB21_UpdateLNB(LNB21_InstanceData_t     *Instance)
{
	
	ST_ErrorCode_t        Error = ST_NO_ERROR;
    /* update LNB hardware */
    STTUNER_IOREG_SetContigousRegisters(&Instance->DeviceMap, Instance->IOHandle,RLNB21_REGS, (&(Instance->RegVal))  ,1);
	Error |= Instance->DeviceMap.Error;
    
    Instance->DeviceMap.Error = ST_NO_ERROR;
	return(Error);

}
#endif
#ifdef STTUNER_MINIDRIVER
ST_ErrorCode_t LNB21_UpdateLNB( )
{
	ST_ErrorCode_t        Error = ST_NO_ERROR;
    
    	STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_LNB_WRITE, RLNB21_REGS, 0x00, 0x00, LNB21_Default_Reg, 1, FALSE);

	return(Error);

}

#endif


/*----------------------------------------------------
 FUNCTION      LNB21_SetLnb
 ACTION        set the Lnb
 PARAMS IN     Lnb -> true for LnbHigh, false for LnbLow
 PARAMS OUT    NONE
 RETURN        NONE
------------------------------------------------------*/
#ifndef STTUNER_MINIDRIVER
void LNB21_SetLnb(LNB21_InstanceData_t     *Instance, int Lnb)
{
	
	/* Low band -> no 22KHz tone */
	if (Lnb == STTUNER_LNB_TONE_OFF) 
	{
		STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_OP2_CONF, 0, &(Instance->RegVal)  );
	
	}
	/* High band -> 22KHz tone */
	if (Lnb == STTUNER_LNB_TONE_22KHZ) 
	{
	STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_OP2_CONF, 1, &(Instance->RegVal)  );
	}
}
#endif
#ifdef STTUNER_MINIDRIVER
void LNB21_SetLnb(int Lnb)
{
	/* Low band -> no 22KHz tone */
	if (Lnb == STTUNER_LNB_TONE_OFF) 
	{
		LNB21_Default_Reg[0x00] &= 0xDF;
	}
	else if(Lnb == STTUNER_LNB_TONE_22KHZ) 
	{
		LNB21_Default_Reg[0x00] |= 0x20;
	}
	
}
#endif


/*----------------------------------------------------
 FUNCTION      LNB21_SetPolarization
 ACTION        set the polarization
 PARAMS IN     Polarization -> Polarization
 PARAMS OUT    NONE
 RETURN        NONE
------------------------------------------------------*/
#ifndef STTUNER_MINIDRIVER
void LNB21_SetPolarization(LNB21_InstanceData_t     *Instance,LNB_Polarization_t Polarization)
{
    if(Polarization == VERTICAL)/* Set 13V for Vertical Pol*/
    {
         STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_EN, 1,&(Instance->RegVal) );
        STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_VSEL, 0,&(Instance->RegVal)  );
       
		    
    }
    if(Polarization == HORIZONTAL)/* Set 18v for Horizontal Pol*/
    {
        
        STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_EN, 1,&(Instance->RegVal) );
        STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_VSEL, 1,&(Instance->RegVal)  );
    
    }
    if(Polarization == NOPOLARIZATION)/* Turn off LNB*/
    {
       
        STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_EN, 0, &(Instance->RegVal)  );
      
    }
}
#endif
#ifdef STTUNER_MINIDRIVER
void LNB21_SetPolarization(LNB_Polarization_t Polarization)
{
   
        /* Low band -> no 22KHz tone */
	if (Polarization == VERTICAL) 
	{
		LNB21_Default_Reg[0x00] &= 0xF7;
	}
	else if(Polarization == HORIZONTAL) 
	{
		LNB21_Default_Reg[0x00] |= 0x08;
	}
}
#endif
/*----------------------------------------------------
 FUNCTION      LNB21_SetCurrentThreshold
 ACTION        set the Current for LNB
 PARAMS IN     CurrentSelection 
 PARAMS OUT    NONE
 RETURN        NONE
------------------------------------------------------*/
#ifndef STTUNER_MINIDRIVER
void LNB21_SetCurrentThreshold(LNB21_InstanceData_t     *Instance,LNB_CurrentThresholdSelection_t CurrentThresholdSelection)
{
	if(CurrentThresholdSelection == CURRENT_THRESHOLD_HIGH)/* Set ISEL=0 to set high(500-650mA)*/
        {
        	STTUNER_IOREG_SetFieldVal(&Instance->DeviceMap, FLNB21_ISEL, 0, &(Instance->RegVal)  );
        
        }
        if(CurrentThresholdSelection == CURRENT_THRESHOLD_LOW)/* Set ISEL=1 to set low(400-550mA)*/
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -