📄 d0372.c
字号:
/* ----------------------------------------------------------------------------
Name: demod_d0372_GetSignalQuality()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_GetSignalQuality()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0372_InstanceData_t *Instance;
/* private driver instance data */
Instance = d0372_GetInstFromHandle(Handle);
/* Read noise estimations for C/N and BER */
*SignalQuality_p = FE_372_GetCarrierToNoiseRatio(&(Instance->DeviceMap), Instance->IOHandle);
*Ber=FE_372_GetBitErrorRate(&(Instance->DeviceMap), Instance->IOHandle);
*SignalQuality_p = (*SignalQuality_p * 10)/36; /*signal qaulity in % calculated considering 36dB as 100% signal-quality,. x*100/36 *10 as value should be devided by 10 */
/*If it reaches maximum value then force it to max value*/
if ( *SignalQuality_p > MAX_SIGNAL_QUALITY)
{
*SignalQuality_p = MAX_SIGNAL_QUALITY;
}
Error = Instance->DeviceMap.Error;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_GetModulation()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_GetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_GetModulation()";
#endif
STTUNER_Modulation_t CurModulation;
ST_ErrorCode_t Error = ST_NO_ERROR;
CurModulation = STTUNER_MOD_8VSB;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_GetAGC()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_GetAGC(DEMOD_Handle_t Handle, S16 *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_GetAGC()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_GetFECRates()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_GetFECRates()";
#endif
STTUNER_FECRate_t CurFecRate;
ST_ErrorCode_t Error = ST_NO_ERROR;
CurFecRate = STTUNER_FEC_2_3;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_IsLocked()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_IsLocked()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0372_InstanceData_t *Instance;
U32 LockedStatus =0;
/* private driver instance data */
Instance = d0372_GetInstFromHandle(Handle);
LockedStatus = STTUNER_IOREG_GetRegister(&(Instance->DeviceMap), Instance->IOHandle, R0372_DEMSTATUS);
if(LockedStatus == 0x5A)
{
*IsLocked =1;
}
else
{
*IsLocked =0;
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s IsLocked=%u\n", identity, *IsLocked));
#endif
Error = Instance->DeviceMap.Error;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_ScanFrequency()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_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 IQMode,
U32 FreqOff,
U32 ChannelBW,
S32 EchoPos)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_ScanFrequency()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
FE_372_Error_t error = FE_372_NO_ERROR;
STTUNER_tuner_instance_t *TunerInstance;
STTUNER_InstanceDbase_t *Inst;
D0372_InstanceData_t *Instance;
/* FE_360_InternalParams_t *pInternalParams;*/
FE_372_SearchParams_t Search;
FE_372_SearchResult_t Result;
/* private driver instance data */
Instance = d0372_GetInstFromHandle(Handle);
/* top level public instance data */
Inst = STTUNER_GetDrvInst();
/* get the tuner instance for this driver from the top level handle */
TunerInstance = &Inst[Instance->TopLevelHandle].Terr.Tuner;
Search.Frequency = InitialFrequency;
Search.SymbolRate = SymbolRate;
Search.SearchRange = 0;
Search.IQMode = IQMode;
Search.FistWatchdog = ST_GetClocksPerSecond() *5 ; /*get number of ticks per 10 seconds*/
Search.DefaultWatchdog = ST_GetClocksPerSecond() ;/*get number of ticks per seconds*/
Search.LOWPowerTh = 90;
Search.UPPowerTh = 130;
error=FE_372_Search(&(Instance->DeviceMap),Instance->IOHandle, &Search, &Result,Instance->TopLevelHandle);
if(error == FE_372_BAD_PARAMETER)
{
Error= ST_ERROR_BAD_PARAMETER;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s fail, scan not done: bad parameter(s) to FE_372_Search() == FE_BAD_PARAMETER\n", identity ));
#endif
return Error;
}
else if (error == FE_372_SEARCH_FAILED)
{
Error= ST_NO_ERROR;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s FE_372_Search() == FE_372_SEARCH_FAILED\n", identity ));
#endif
return Error;
}
*ScanSuccess = Result.Locked;
if (*ScanSuccess == TRUE)
{
*NewFrequency = Result.Frequency;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s NewFrequency=%u\t", identity, *NewFrequency));
STTBX_Print(("%s ScanSuccess=%u\n", identity, *ScanSuccess));
#endif
/* return(ST_NO_ERROR);*/
}
return(ST_NO_ERROR);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_ioctl()
Description:
access device specific low-level functions
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_ioctl(DEMOD_Handle_t Handle, U32 Function, void *InParams, void *OutParams, STTUNER_Da_Status_t *Status)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_ioctl()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0372_InstanceData_t *Instance;
/* private driver instance data */
Instance = d0372_GetInstFromHandle(Handle);
if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s invalid handle\n", identity));
#endif
return(ST_ERROR_INVALID_HANDLE);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s demod driver instance handle=%d\n", identity, Handle));
STTBX_Print(("%s function=%d\n", identity, Function));
STTBX_Print(("%s I/O handle=%d\n", identity, Instance->IOHandle));
#endif
/* ---------- select what to do ---------- */
switch(Function){
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,
((TERIOCTL_SETREG_InParams_t *)InParams)->RegIndex,
((TERIOCTL_SETREG_InParams_t *)InParams)->Value );
break;
default:
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s function %d not found\n", identity, Function));
#endif
return(ST_ERROR_FEATURE_NOT_SUPPORTED);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s called ok\n", identity, Function)); /* signal that function came back */
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0372_ioaccess()
Description:
called from ioarch.c when some driver does I/O but with the repeater/passthru
set to point to this function.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0372_ioaccess(DEMOD_Handle_t Handle, IOARCH_Handle_t IOHandle, STTUNER_IOARCH_Operation_t Operation, U16 SubAddr, U8 *Data, U32 TransferSize, U32 Timeout)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
const char *identity = "STTUNER d0372.c demod_d0372_ioaccess()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
IOARCH_Handle_t ThisIOHandle;
D0372_InstanceData_t *Instance;
Instance = d0372_GetInstFromHandle(Handle);
if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s invalid handle\n", identity));
#endif
return(ST_ERROR_INVALID_HANDLE);
}
/* this (demod) drivers I/O 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_TERDRV_D0372
STTBX_Print(("%s write passthru\n", identity));
#endif
Error = STTUNER_IOARCH_ReadWrite(ThisIOHandle, Operation, SubAddr, Data, TransferSize, Timeout);
}
else /* repeater */
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372
STTBX_Print(("%s write repeater\n", identity));
#endif
#ifndef ST_OSLINUX
task_lock(); /* prevent any other activity on this bus (no task must preempt us) */
#endif
/* enable repeater then send the data using I/O handle supplied through ioarch.c */
#ifdef PROCESSOR_C1 /***For C1 core this delay needed otherwise STTUNER_task_lock(); not working fine ****/
task_delay(5);
#endif
Error = STTUNER_IOREG_SetField(&(Instance->DeviceMap), Instance->IOHandle, F0372_STOP_ENABLE_1, 1);
Error = STTUNER_IOREG_SetField(&(Instance->DeviceMap), Instance->IOHandle, F0372_I2CT_ON_1, 1);
/* send callers data using their address. (nb: subaddress == 0)
Function 'STTUNER_IOARCH_ReadWriteNoRep' is called as calling the normal 'STTUNER_IOARCH_ReadWrite'
function would cause it to call the redirection function which is THIS function, and around we
would go forever. */
Error = STTUNER_IOARCH_ReadWriteNoRep(IOHandle, Operation, SubAddr, Data, TransferSize, Timeout);
#ifndef ST_OSLINUX
task_unlock();
#endif
}
return(Error);
}
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\UTILITY Functions/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
D0372_InstanceData_t *d0372_GetInstFromHandle(DEMOD_Handle_t Handle)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372_HANDLES
const char *identity = "STTUNER d0372.c d0372_GetInstFromHandle()";
#endif
D0372_InstanceData_t *Instance;
Instance = (D0372_InstanceData_t *)Handle;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0372_HANDLES
STTBX_Print(("%s block at 0x%08x\n", identity, Instance));
#endif
return(Instance);
}
/* End of d0372.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -