📄 d0288.c
字号:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0288_Close(DEMOD_Handle_t Handle, DEMOD_CloseParams_t *CloseParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_Close()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail driver not installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
SEM_LOCK(Lock_InitTermOpenClose);
/* ---------- check that at least one init has taken place ---------- */
if(InstanceChainTop == NULL)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail nothing initalized\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
if(Instance->TopLevelHandle == STTUNER_MAX_HANDLES)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail driver instance not open\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(ST_ERROR_OPEN_HANDLE);
}
Instance->TopLevelHandle = STTUNER_MAX_HANDLES;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s closed\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_GetSignalQuality()
Description:
Obtains a signal quality setting for the current lock.
Parameters:
SignalQuality_p, pointer to area to store the signal quality value.
Ber, pointer to area to store the bit error rate.
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0288_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_GetSignalQuality()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
/* Read noise estimations for C/N and BER */
*SignalQuality_p = FE_288_GetCarrierToNoiseRatio(&Instance->DeviceMap, Instance->IOHandle);
*Ber = FE_288_GetDirectErrors(&Instance->DeviceMap, Instance->IOHandle, COUNTER1_288);
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s SignalQuality=%u Ber=%u\n", identity, *SignalQuality_p, *Ber));
#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);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_GetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_GetModulation()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
/* This implementation of the DEMOD device only supports one type of modulation */
*Modulation = STTUNER_MOD_QPSK;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s Modulation=%u\n", identity, *Modulation));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_SetModulation()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0288_SetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_SetModulation()";
#endif
/* if modulations include STTUNER_MOD_QPSK */
if((Modulation & STTUNER_MOD_QPSK) == STTUNER_MOD_QPSK)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s Modulation: STTUNER_MOD_QPSK accepted ok.\n", identity));
#endif
return(ST_NO_ERROR);
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail, only STTUNER_MOD_QPSK supported.\n", identity));
#endif
return(ST_ERROR_BAD_PARAMETER);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_GetAGC(DEMOD_Handle_t Handle, S16 *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_GetAGC()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
*Agc = FE_288_GetRFLevel(&Instance->DeviceMap, Instance->IOHandle);
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
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);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_GetFECRates()";
#endif
U8 Data;
U8 uData1; /* Used for retrieving the FEC Mode*/
STTUNER_FECRate_t CurFecRate;
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
/*
** uData1 - FEC Mode Register
** 0 - DVB QPSK, 1 - DVB BPSK, 4 = DSS
*/
uData1 = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle,F288_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, F288_PR);
switch (Data)
{
case 0:
CurFecRate = STTUNER_FEC_1_2;
break;
case 1:
CurFecRate = STTUNER_FEC_2_3;
break;
case 2:
CurFecRate = STTUNER_FEC_3_4;
break;
case 3:
CurFecRate = STTUNER_FEC_5_6;
break;
case 4:
CurFecRate = STTUNER_FEC_6_7;
break;
case 5:
CurFecRate = STTUNER_FEC_7_8;
break;
default:
CurFecRate = STTUNER_FEC_NONE;;
break;
}
*FECRates = CurFecRate; /* Copy back for caller */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
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;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_GetIQMode(DEMOD_Handle_t Handle, STTUNER_IQMode_t *IQMode)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_GetIQMode()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
if(STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F288_SYM)==1)
*IQMode = STTUNER_IQ_MODE_INVERTED;
else
*IQMode = STTUNER_IQ_MODE_NORMAL;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s IQMode=%u\n", identity, *IQMode));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_IsLocked()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0288_GetInstFromHandle(Handle);
*IsLocked = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F288_LK) ? TRUE : FALSE;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s IsLocked=%u\n", identity, *IsLocked));
#endif
Error |= Instance->DeviceMap.Error;
Instance->DeviceMap.Error = ST_NO_ERROR;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_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_d0288_SetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_SetFECRates()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
U8 Data = 0, uData1;
D0288_InstanceData_t *Instance;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -