📄 d0399e.c
字号:
}
#endif
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: demod_d0399_SetModulation()
Description:
This routine sets the modulation scheme for use when scanning.
Parameters:
Modulation.
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_SetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_SetModulation()";
#endif
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
switch(Modulation)
{
case STTUNER_MOD_BPSK:
Instance->FE_399_Modulation = FE_MOD_BPSK;
break;
case STTUNER_MOD_QPSK:
Instance->FE_399_Modulation = FE_MOD_QPSK;
break;
case STTUNER_MOD_8PSK:
Instance->FE_399_Modulation = FE_MOD_8PSK;
break;
default:
return(ST_ERROR_BAD_PARAMETER);
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s Modulation=%u\n", identity, Modulation));
#endif
return(ST_NO_ERROR);
}
#endif
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: demod_d0399_GetAGC()
Description:
Obtains the current RF signal power.
Parameters:
AGC, pointer to area to store power output value.
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_GetAGC(DEMOD_Handle_t Handle, S16 *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_GetAGC()";
#endif
FE_399_Error_t Error;
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
*Agc = FE_399_GetRFLevel(&Instance->DeviceMap,Instance->IOHandle); /* Power of the RF signal (dBm) */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s Agc=%u\n", identity, *Agc));
#endif
return(Error);
}
#endif
/* ----------------------------------------------------------------------------
Name: demod_d0399_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_d0399_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_GetFECRates()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
STTUNER_FECRate_t CurFecRate = 0;
U8 Data;
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
#ifndef STTUNER_MINIDRIVER
Data = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F399_PR);
#endif
#ifdef STTUNER_MINIDRIVER
Error = STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_READ, R399_VSTATUS, F399_PR, F399_PR_L, &Data,1, FALSE);
#endif
/* Convert 399 value to a STTUNER fecrate */
switch (Data)
{
case STV0399_VSTATUS_PR_1_2:
CurFecRate = STTUNER_FEC_1_2;
break;
case STV0399_VSTATUS_PR_2_3:
CurFecRate = STTUNER_FEC_2_3;
break;
case STV0399_VSTATUS_PR_3_4:
CurFecRate = STTUNER_FEC_3_4;
break;
case STV0399_VSTATUS_PR_5_6:
CurFecRate = STTUNER_FEC_5_6;
break;
case STV0399_VSTATUS_PR_6_7:
CurFecRate = STTUNER_FEC_6_7;
break;
case STV0399_VSTATUS_PR_7_8:
CurFecRate = STTUNER_FEC_7_8;
break;
case STV0399_VSTATUS_PR_RE1:
CurFecRate = STTUNER_FEC_NONE;
break;
case STV0399_VSTATUS_PR_RE2:
CurFecRate = STTUNER_FEC_NONE;
break;
}
*FECRates = CurFecRate; /* Copy back for caller */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s FECRate=%u\n", identity, CurFecRate));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0399_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 FECM register(NORMAL or INVERTED)
Parameters In:
IQMode, pointer to area to store the IQMode in use.
Parameters Out:
IQMode
Return Value:
Error
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_GetIQMode(DEMOD_Handle_t Handle, STTUNER_IQMode_t *IQMode)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_GetIQMode()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
#ifndef STTUNER_MINIDRIVER
if(STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle, F399_SYM)==1)
*IQMode = STTUNER_IQ_MODE_INVERTED;
else
*IQMode = STTUNER_IQ_MODE_NORMAL;
#endif
#ifdef STTUNER_MINIDRIVER
U8 Data;
Error = STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_READ, R399_FECM, F399_SYM, F399_SYM_L, &Data,1, FALSE);
if(Data ==1)
*IQMode = STTUNER_IQ_MODE_INVERTED;
else
*IQMode = STTUNER_IQ_MODE_NORMAL;
#endif
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s IQMode=%u\n", identity, *IQMode));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0399_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_d0399_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_IsLocked()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
#ifdef STTUNER_MINIDRIVER
FE_399_SignalInfo_t Info;
#endif
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
#ifndef STTUNER_MINIDRIVER
*IsLocked = STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle,F399_LK);
#endif
#ifdef STTUNER_MINIDRIVER
Error = FE_399_GetSignalInfo(&Info);
*IsLocked = Info.Locked; /* Transponder locked */
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0399_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_d0399_SetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_SetFECRates()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
U8 Data = 0;
D0399_InstanceData_t *Instance;
Instance = D0399_GetInstFromHandle(Handle);
/* Convert STTUNER FEC rates (see sttuner.h) to a VENRATE value to be applied to the STV0399 */
if (FECRates & STTUNER_FEC_1_2) Data |= STV0399_PR_MASK_1_2;
if (FECRates & STTUNER_FEC_2_3) Data |= STV0399_PR_MASK_2_3;
if (FECRates & STTUNER_FEC_3_4) Data |= STV0399_PR_MASK_3_4;
if (FECRates & STTUNER_FEC_5_6) Data |= STV0399_PR_MASK_5_6;
if (FECRates & STTUNER_FEC_6_7) Data |= STV0399_PR_MASK_6_7;
if (FECRates & STTUNER_FEC_7_8) Data |= STV0399_PR_MASK_7_8;
#ifndef STTUNER_MINIDRIVER
Error = STTUNER_IOREG_SetRegister( &Instance->DeviceMap, Instance->IOHandle, R399_PR, Data);
#endif
#ifdef STTUNER_MINIDRIVER
STTUNER_IODIRECT_ReadWrite(STTUNER_IO_SA_WRITE, R399_PR, 0, 0, &Data, 1, FALSE);
#endif
if ( Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s fail ChipSetField()\n", identity));
#endif
}
else
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s Field F0399_RATE = 0x%02x\n", identity, Data));
#endif
}
return(Error);
}
#ifndef STTUNER_MINIDRIVER
/* ----------------------------------------------------------------------------
Name: demod_d0399_Tracking()
Description:
This routine checks the carrier against a certain threshold value and will
perform derotator centering, if necessary -- using the ForceTracking
option ensures that derotator centering is always performed when
this routine is called.
This routine should be periodically called once a lock has been
established in order to maintain the lock.
Parameters:
ForceTracking, boolean to control whether to always perform
derotator centering, regardless of the carrier.
NewFrequency, pointer to area where to store the new frequency
value -- it may be changed when trying to optimize
the derotator.
SignalFound, indicates that whether or not we're still locked
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_Tracking(DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency, BOOL *SignalFound)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
const char *identity = "STTUNER d0399.c demod_d0399_Tracking()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0399_InstanceData_t *Instance;
FE_399_SignalInfo_t pInfo;
STTUNER_InstanceDbase_t *Inst;
Inst = STTUNER_GetDrvInst();
Instance = D0399_GetInstFromHandle(Handle);
Error = demod_d0399_IsLocked(Handle, SignalFound);
if((Error == ST_NO_ERROR) && (*SignalFound == TRUE))
{
FE_399_GetSignalInfo(&Instance->DeviceMap, Instance->IOHandle, &pInfo);
*NewFrequency = pInfo.Frequency;
Inst[Instance->TopLevelHandle].CurrentTunerInfo.ScanInfo.SymbolRate = pInfo.SymbolRate;
Inst[Instance->TopLevelHandle].CurrentTunerInfo.BitErrorRate = pInfo.BER;
Inst[Instance->TopLevelHandle].CurrentTunerInfo.SignalQuality = pInfo.C_N;
Inst[Instance->TopLevelHandle].CurrentTunerInfo.ScanInfo.AGC = pInfo.Power;
demod_d0399_GetFECRates(Handle,&Inst[Instance->TopLevelHandle].CurrentTunerInfo.ScanInfo.FECRates);
Inst[Instance->TopLevelHandle].CurrentTunerInfo.ScanInfo.IQMode=STTUNER_IOREG_GetField(&Instance->DeviceMap, Instance->IOHandle,F399_SYM);
}
#ifdef STTUNER_DRV_SAT_SCR
if ((Inst[Instance->TopLevelHandle].Capability.SCREnable)&& (Inst[Instance->TopLevelHandle].CurrentTunerInfo.ScanInfo.LNB_SignalRouting == STTUNER_VIA_SCRENABLED_LNB))
{
*NewFrequency = Inst[Instance->TopLevelHandle].ScanList.ScanList->ScrParams.SCRVCOFrequency - pInfo.Frequency;
}
else
{
*NewFrequency = pInfo.Frequency;
}
#else
*NewFrequency = pInfo.Frequency;
#endif
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
STTBX_Print(("%s SignalFound=%u NewFrequency=%u\n", identity, *SignalFound, *NewFrequency));
#endif
return(Error);
}
#endif
/* ----------------------------------------------------------------------------
Name: demod_d0399_ScanFrequency()
Description:
This routine will attempt to scan and find a QPSK signal based on the
passed in parameters.
Parameters:
InitialFrequency, IF value to commence scan (in kHz).
SymbolRate, required symbol bit rate (in Hz).
MaxLNBOff
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -