d0299.c

来自「st7710的tuner标准驱动」· C语言 代码 · 共 1,766 行 · 第 1/5 页

C
1,766
字号
#ifdef STTUNER_MINIDRIVER
     Drv0299_GetNoiseEstimator(SignalQuality_p, Ber);
   
#endif    

    return(Error);
}   
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: demod_d0299_GetModulation()

Description:
    This routine returns the modulation scheme in use by this device.
    ** Currently only QPSK is supported.
    
Parameters:
    Modulation, pointer to area to store modulation scheme.
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_GetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_GetModulation()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    D0299_InstanceData_t *Instance;

    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);

    /* This implementation of the DEMOD device only supports one type of modulation */
    *Modulation = STTUNER_MOD_QPSK;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s Modulation=%u\n", identity, *Modulation));
#endif
    return(Error);
}   
#endif

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

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_SetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_SetModulation()";
#endif

    /* if modulations include STTUNER_MOD_QPSK */
    if ( (Modulation & STTUNER_MOD_QPSK) == STTUNER_MOD_QPSK)
    { 
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
        STTBX_Print(("%s Modulation: STTUNER_MOD_QPSK accepted ok.\n", identity));
#endif
        return(ST_NO_ERROR);
    }

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s fail, only STTUNER_MOD_QPSK supported.\n", identity));
#endif
    return(ST_ERROR_BAD_PARAMETER);
}   
#endif
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: demod_d0299_GetAGC()

Description:
    Obtains the current value from the AGC integrator register and computes
    a look-up of power output.
    
Parameters:
    AGC,    pointer to area to store power output value.
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_GetAGC(DEMOD_Handle_t Handle, S16  *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_GetAGC()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    D0299_InstanceData_t *Instance;

    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);

    *Agc = Drv0299_GetPowerEstimator(&Instance->DeviceMap, Instance->IOHandle);

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s Agc=%u\n", identity, *Agc));
#endif
    
    /* GNBvd17801-> Error Handling for any error returned during I2C operation inside the driver */
    Error |= Instance->DeviceMap.Error;
    Instance->DeviceMap.Error = ST_NO_ERROR;
    
    return(Error);
}   
#endif


/* ----------------------------------------------------------------------------
Name: demod_d0299_GetFECRates()

Description:
     Checks the VEN rate register to deduce the forward error correction
    setting that is currently in use.
   
Parameters:
    FECRates,   pointer to area to store FEC rates in use.
  
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_GetFECRates()";
#endif
    U8 Data;
    U8 uData1; /* Used for retrieving the FEC Mode*/
    STTUNER_FECRate_t CurFecRate;
    ST_ErrorCode_t Error = ST_NO_ERROR;
	#ifndef STTUNER_MINIDRIVER
    D0299_InstanceData_t *Instance;

    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);

    /*
    ** uData1 - FEC Mode Register
    ** 0 - DVB QPSK, 1 - DVB BPSK, 4 = DSS
    */
    uData1 = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle,F0299_FECMODE);

    /* Convert venrate value to a STTUNER fecrate */
    /* Following switch statement is added to preempt bug GNBvd14519. Which required
       an error to be reported whenever a wrong FEC rate was specified in either of DVB or DirecTv Mode*/
    Data = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F0299_CPR);
    switch (Data)
    {
    case STV0299_VSTATUS_PR_1_2:
        CurFecRate = STTUNER_FEC_1_2;
        break;

    case STV0299_VSTATUS_PR_2_3:
        CurFecRate = STTUNER_FEC_2_3;
        break;

    case STV0299_VSTATUS_PR_3_4:
        CurFecRate = STTUNER_FEC_3_4;
        break;

    case STV0299_VSTATUS_PR_5_6:
        CurFecRate = STTUNER_FEC_5_6;
        break;
        
    case STV0299_VSTATUS_PR_7_8:
        if(uData1 == 4) /* DSS Mode */
            CurFecRate = STTUNER_FEC_6_7;
        else
            CurFecRate = STTUNER_FEC_7_8;
        break;
    default:
        CurFecRate = STTUNER_FEC_NONE;;
        break;
    }

    *FECRates = CurFecRate;  /* Copy back for caller */
    
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s FECRate=%u\n", identity, CurFecRate));
#endif
    
    /* GNBvd17801-> Error Handling for any error returned during I2C operation inside the driver */
    Error |= Instance->DeviceMap.Error;
    Instance->DeviceMap.Error = ST_NO_ERROR;
	#endif
#ifdef STTUNER_MINIDRIVER
    Error = STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_READ, R0299_VSTATUS, F0299_CPR, F0299_CPR_L, &Data,1, FALSE);
    switch (Data)
    {
    case STV0299_VSTATUS_PR_1_2:
        CurFecRate = STTUNER_FEC_1_2;
        break;

    case STV0299_VSTATUS_PR_2_3:
        CurFecRate = STTUNER_FEC_2_3;
        break;

    case STV0299_VSTATUS_PR_3_4:
        CurFecRate = STTUNER_FEC_3_4;
        break;

    case STV0299_VSTATUS_PR_5_6:
        CurFecRate = STTUNER_FEC_5_6;
        break;
        
    case STV0299_VSTATUS_PR_7_8:
        if(uData1 == 4) /* DSS Mode */
            CurFecRate = STTUNER_FEC_6_7;
        else
            CurFecRate = STTUNER_FEC_7_8;
        break;
    default:
        CurFecRate = STTUNER_FEC_NONE;;
        break;
    }

    *FECRates = CurFecRate;  /* Copy back for caller */
#endif
    
    return(Error);
}

#ifndef STTUNER_MINIDRIVER

/* ----------------------------------------------------------------------------
Name: demod_d0299_GetIQMode()
Function added for GNBvd26107->I2C failure due to direct access to demod device at API level
(Problem:STTUNER_GetTunerInfo was calling STTUNER_SAT_GetTunerInfo, which was reading 
STTUNER_IOCTL_IQMODE directly. This was causing I2C failure due to simultaneous I2C access
to the same device.
Resolution:This functions reads the value for current IQMode from the register which is updated
in the CurrentTunerInfo structure. So now in STTUNER_SAT_GetTunerInfo() (in get.c) no separate
I2C access (due to Ioctl) is required for retrieving the IQ mode )

Description:
     Retrieves the IQMode from the IOCFG register(NORMAL or INVERTED)
   
Parameters:
    IQMode, pointer to area to store the IQMode in use.
  
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_GetIQMode(DEMOD_Handle_t Handle, STTUNER_IQMode_t *IQMode)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_GetIQMode()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    D0299_InstanceData_t *Instance;

    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);

    if(STTUNER_IOREG_GetField(&Instance->DeviceMap,Instance->IOHandle, F0299_IQ)==1)
            *IQMode = STTUNER_IQ_MODE_INVERTED;
    else
            *IQMode = STTUNER_IQ_MODE_NORMAL;
            
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s IQMode=%u\n", identity, *IQMode));
#endif
    return(Error);
}   
#endif


/* ----------------------------------------------------------------------------
Name: demod_d0299_IsLocked()

Description:
     Checks the LK register i.e., are we demodulating a digital carrier.
   
Parameters:
    IsLocked,   pointer to area to store result (bool):
                TRUE -- we are locked.
                FALSE -- no lock.
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_IsLocked()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
	D0299_InstanceData_t *Instance;
    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);
    *IsLocked = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F0299_LK) ? TRUE : FALSE;
    #ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
    STTBX_Print(("%s IsLocked=%u\n", identity, *IsLocked));
    #endif
    /* GNBvd17801-> Error Handling for any error returned during I2C operation inside the driver */
    Error |= Instance->DeviceMap.Error;
    Instance->DeviceMap.Error = ST_NO_ERROR;
#endif
#ifdef STTUNER_MINIDRIVER
	U8 Data;
	Error = STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_READ, R0299_VSTATUS, F0299_LK, F0299_LK_L, &Data,1, FALSE);
	if(Data == 1)
	*IsLocked = TRUE;
	else
	*IsLocked = FALSE;
#endif    
    return(Error);
}   



/* ----------------------------------------------------------------------------
Name: demod_d0299_SetFECRates()

Description:
    Sets the FEC rates to be used during demodulation.
    Parameters:
    
Parameters:
      FECRates, bitmask of FEC rates to be applied.
  
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0299_SetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0299
   const char *identity = "STTUNER d0299.c demod_d0299_SetFECRates()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    U8 Data = 0, uData1;
#ifndef STTUNER_MINIDRIVER
    D0299_InstanceData_t *Instance;
    
    
    /* private driver instance data */
    Instance = D0299_GetInstFromHandle(Handle);

    /*
    ** uData1 - FEC Mode Register
    ** 0 - DVB QPSK, 1 - DVB BPSK, 4 = DSS
    */
    uData1 = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle,F0299_FECMODE);

    /*
    ** For each STTUNER FEC rates (see sttuner.h)
    ** Set specific bit of enable puncture rate register
    ** Bit 0 - 1/2, 1 - 2/3, 2 - 3/4, 3 - 5/6, 4 - 7/8(DVB) or 6/7(DSS)
    */
    i

⌨️ 快捷键说明

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