📄 d0mini360.c
字号:
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_GetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_GetModulation()";
#endif
U8 Data;
STTUNER_Modulation_t CurModulation;
ST_ErrorCode_t Error = ST_NO_ERROR;
D0360_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0360_GetInstFromHandle(Handle);
/* Get the modulation type */
Data =ChipDemodGetField( TPS_CONST);
/* Data = ChipGetFieldImage( TPS_CONST);*/
switch (Data)
{
case 0:
CurModulation = STTUNER_MOD_QPSK;
break;
case 1:
CurModulation = STTUNER_MOD_16QAM;
break;
case 2:
CurModulation = STTUNER_MOD_64QAM;
break;
default:
CurModulation = STTUNER_MOD_ALL;
break;
}
*Modulation = CurModulation;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s Modulation=%u\n", identity, *Modulation));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_GetMode()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_GetMode(DEMOD_Handle_t Handle, STTUNER_Mode_t *Mode)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_GetMode()";
#endif
U8 Data;
STTUNER_Mode_t CurMode;
ST_ErrorCode_t Error = ST_NO_ERROR;
D0360_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0360_GetInstFromHandle(Handle);
/* Get the mode type */
Data=ChipDemodGetField(TPS_MODE /*R_TPS_RCVD1*/);
/* Data = ChipGetFieldImage(FE2CHIP(Instance->FE_360_Handle), TPS_MODE);*/
switch (Data)
{
case 0:
CurMode = STTUNER_MODE_2K;
break;
case 1:
CurMode = STTUNER_MODE_8K;
break;
default:
CurMode = 0xff; /* error */
break;
}
*Mode = CurMode;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s Mode=%u\n", identity, *Mode));
#endif
/*Resolve Bug GNBvd17801 - For proper I2C error handling inside the driver*/
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_GetAGC()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_GetAGC(DEMOD_Handle_t Handle, S16 *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_GetAGC()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
S16 Data1=0;
S16 Data2=0;
/* D0360_InstanceData_t *Instance;*/
/** fix done here for the bug GNBvd20972 **
** where body of the function demod_d0360_GetAGC written **
** and the function now returns the core gain **/
/* private driver instance data */
/* Instance = D0360_GetInstFromHandle(Handle);*/
/* Get the mode type */
Data1 = ChipDemodGetField(AGC_GAIN_LO);
/*Data1=ChipGetOneRegister(FE2CHIP(Instance->FE_360_Handle), R_AGC_GAIN1);*/
Data2 = ChipDemodGetField(AGC_GAIN_HI);
/* Data2=ChipGetOneRegister(FE2CHIP(Instance->FE_360_Handle), R_AGC_GAIN2);*/
Data2 <<=8;
Data2 &= 0x0F00;
Data2 |= Data1 ;
*Agc=Data2 ;
/*Resolve Bug GNBvd17801 - For proper I2C error handling inside the driver*/
/*Error |= STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error;
STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error = CHIPERR_NO_ERROR; */
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_GetFECRates()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_GetFECRates()";
#endif
U8 Data;
STTUNER_FECRate_t CurFecRate;
ST_ErrorCode_t Error = ST_NO_ERROR;
/* D0360_InstanceData_t *Instance;*/
/* private driver instance data */
/* Instance = D0360_GetInstFromHandle(Handle);*/
CurFecRate = 0;
Data =ChipDemodGetField( TPS_HPCODE);
/* ChipGetFieldImage(FE2CHIP(Instance->FE_360_Handle), TPS_HPCODE);*/
/* Convert venrate value to a STTUNER fecrate */
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_7_8;
break;
default:
CurFecRate = 0; /* error */
break;
}
*FECRates = CurFecRate; /* Copy back for caller */
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s FECRate=%u\n", identity, CurFecRate));
#endif
/*Resolve Bug GNBvd17801 - For proper I2C error handling inside the driver*/
/* Error |= STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error;
STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error = CHIPERR_NO_ERROR;*/
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_GetGuard()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_GetGuard(DEMOD_Handle_t Handle, STTUNER_Guard_t *Guard)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_GetGuard()";
#endif
U8 Data;
STTUNER_Guard_t CurGuard;
ST_ErrorCode_t Error = ST_NO_ERROR;
D0360_InstanceData_t *Instance;
/* private driver instance data */
Instance = D0360_GetInstFromHandle(Handle);
CurGuard = 0;
Data = ChipDemodGetField( TPS_GUARD);
/* Convert venrate value to a STTUNER fecrate */
switch (Data)
{
case 0:
CurGuard = STTUNER_GUARD_1_32;
break;
case 1:
CurGuard = STTUNER_GUARD_1_16;
break;
case 2:
CurGuard = STTUNER_GUARD_1_8;
break;
case 3:
CurGuard = STTUNER_GUARD_1_4;
break;
default:
CurGuard = 0xff; /* error */
break;
}
*Guard = CurGuard; /* Copy back for caller */
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s Guard=%u\n", identity, CurGuard));
#endif
/*Resolve Bug GNBvd17801 - For proper I2C error handling inside the driver*/
/* Error |= STCHIP_HANDLE(FE2CHIP(Instance->FE_360_Handle))->Chip.Error;
STCHIP_HANDLE(FE2CHIP(Instance->FE_360_Handle))->Chip.Error = CHIPERR_NO_ERROR;*/
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_IsLocked()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_IsLocked()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
/* D0360_InstanceData_t *Instance;*/
/* private driver instance data */
/* Instance = D0360_GetInstFromHandle(Handle);*/
*IsLocked = ChipDemodGetField( LK) ? TRUE : FALSE;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s IsLocked=%u\n", identity, *IsLocked));
#endif
/*Resolve Bug GNBvd17801 - For proper I2C error handling inside the driver*/
/* Error |= STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error;
STCHIP_HANDLE(FE2CHIP(DEMODInstance->FE_360_Handle))->Chip.Error = CHIPERR_NO_ERROR;*/
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_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_d0360_Tracking(DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency, BOOL *SignalFound)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_Tracking()";
#endif
FE_360_Error_t Error = ST_NO_ERROR;
/*D0360_InstanceData_t *Instance;*/
FE_360_InternalParams_t *pInternalParams;
/* Instance = D0360_GetInstFromHandle(Handle);*/
pInternalParams = (FE_360_InternalParams_t *)DEMODInstance->FE_360_Handle;
FE_360_Tracking(pInternalParams);
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s SignalFound=%u NewFrequency=%u\n", identity, *SignalFound, *NewFrequency));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0360_ScanFrequency()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_ScanFrequency (DEMOD_Handle_t Handle,
U32 InitialFrequency,
U32 SymbolRate,
U32 MaxOffset,
U32 TunerStep,
U8 DerotatorStep,
BOOL *ScanSuccess,
U32 *NewFrequency,
U32 Mode,
U32 Guard,
U32 Force,
U32 Hierarchy,
U32 Spectrum,
U32 FreqOff,
U32 ChannelBW,
S32 EchoPos)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_ScanFrequency()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
FE_360_Error_t error = FE_NO_ERROR;
STTUNER_tuner_instance_t *TunerInstance;
STTUNER_InstanceDbase_t *Inst;
/* D0360_InstanceData_t *Instance;*/
FE_360_InternalParams_t *pInternalParams;
FE_360_SearchParams_t Search;
FE_360_SearchResult_t Result;
/* private driver instance data */
/* Instance = D0360_GetInstFromHandle(Handle);*/
/* top level public instance data */
Inst = STTUNER_GetDrvInst();
/* get the tuner instance for this driver from the top level handle */
TunerInstance = &Inst[DEMODInstance->TopLevelHandle].Terr.Tuner;
pInternalParams = (FE_360_InternalParams_t *)DEMODInstance->FE_360_Handle;
/*pInternalParams->hChip = FE2CHIP(Instance->FE_360_Handle); */
pInternalParams->Quartz = (FE_360_Quarz_t)ChipDemodGetField( ENA_27);
/*pInternalParams->Tuner = TunerInstance->Driver->ID; */
/******* For Minituner tuner type added here for Driver layer***************/
pInternalParams->Tuner= STTUNER_TUNER_DTT7592;
Search.Frequency = (U32)(InitialFrequency);
Search.Mode = (STTUNER_Mode_t)Mode;
Search.Guard = (STTUNER_Guard_t)Guard;
Search.Force = (STTUNER_Force_t)Force;
Search.Inv = (STTUNER_Spectrum_t)Spectrum;
Search.Offset = (STTUNER_FreqOff_t)FreqOff;
Search.ChannelBW = ChannelBW;
Search.EchoPos = EchoPos;
/** error checking is done here for the fix of the bug GNBvd20315 **/
error=FE_360_LookFor(pInternalParams, &Search, &Result, TunerInstance);
if(error != FE_NO_ERROR)
{
Error= ST_ERROR_BAD_PARAMETER;
return Error;
}
if (Result.SignalStatus == LOCK_OK)
{
Echo_Init ( &(pInternalParams->Echo));
/* Pass new frequency to caller */
*NewFrequency = Result.Frequency/*InitialFrequency*/;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s NewFrequency=%u\n", identity, *NewFrequency));
#endif
}
*ScanSuccess = (Result.SignalStatus == LOCK_OK);
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s ScanSuccess=%u\n", identity, *ScanSuccess));
#endif
return(Error);
}
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\UTILITY Functions/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
D0360_InstanceData_t *D0360_GetInstFromHandle(DEMOD_Handle_t Handle)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360_HANDLES
const char *identity = "STTUNER d0360.c D0360_GetInstFromHandle()";
#endif
D0360_InstanceData_t *Instance;
Instance = (D0360_InstanceData_t *)Handle;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360_HANDLES
STTBX_Print(("%s block at 0x%08x\n", identity, Instance));
#endif
return(Instance);
}
/* End of d0360.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -