d0370vsb.c
来自「st7710的tuner标准驱动」· C语言 代码 · 共 1,614 行 · 第 1/4 页
C
1,614 行
{
CurSignalQuality = MAX_SIGNAL_QUALITY;
}
TunerInfo_p->FrequencyFound = CurFrequency;
TunerInfo_p->SignalQuality = CurSignalQuality;
TunerInfo_p->BitErrorRate = CurBitErrorRate;
TunerInfo_p->ScanInfo.Modulation = CurModulation;
TunerInfo_p->ScanInfo.FECRates = CurFECRates;
TunerInfo_p->ScanInfo.Spectrum = CurSpectrum;
/*Inst[Instance->TopLevelHandle].TunerInfoError = TunerError;)*/
Error = Instance->DeviceMap.Error;
STTUNER_task_unlock();
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_GetSignalQuality()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_GetSignalQuality()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0370VSB_InstanceData_t *Instance;
/* private driver instance data */
Instance = d0370VSB_GetInstFromHandle(Handle);
/* Read noise estimations for C/N and BER */
*SignalQuality_p = FE_370_VSB_GetCarrierToNoiseRatio(&(Instance->DeviceMap), Instance->IOHandle);
*Ber=FE_370_VSB_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_d0370VSB_GetModulation()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_GetModulation(DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_GetModulation()";
#endif
STTUNER_Modulation_t CurModulation;
ST_ErrorCode_t Error = ST_NO_ERROR;
CurModulation = STTUNER_MOD_8VSB;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_GetAGC()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_GetAGC(DEMOD_Handle_t Handle, S16 *Agc)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_GetAGC()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_GetFECRates()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_GetFECRates(DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_GetFECRates()";
#endif
STTUNER_FECRate_t CurFecRate;
ST_ErrorCode_t Error = ST_NO_ERROR;
CurFecRate = STTUNER_FEC_2_3;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_IsLocked()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_IsLocked(DEMOD_Handle_t Handle, BOOL *IsLocked)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_IsLocked()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0370VSB_InstanceData_t *Instance;
U32 LockedStatus =0;
/* private driver instance data */
Instance = d0370VSB_GetInstFromHandle(Handle);
LockedStatus = STTUNER_IOREG_GetRegister(&(Instance->DeviceMap), Instance->IOHandle, R0370_DEMSTATUS);
if(LockedStatus == 0x5A)
{
*IsLocked =1;
}
else
{
*IsLocked =0;
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
STTBX_Print(("%s IsLocked=%u\n", identity, *IsLocked));
#endif
Error = Instance->DeviceMap.Error;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_ScanFrequency()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_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_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_ScanFrequency()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
FE_370_VSB_Error_t error = FE_VSB_NO_ERROR;
STTUNER_tuner_instance_t *TunerInstance;
STTUNER_InstanceDbase_t *Inst;
D0370VSB_InstanceData_t *Instance;
/* FE_360_InternalParams_t *pInternalParams;*/
FE_370_VSB_SearchParams_t Search;
FE_370_VSB_SearchResult_t Result;
/* private driver instance data */
Instance = d0370VSB_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;
/** error checking is done here for the fix of the bug GNBvd20315 **/
error=FE_370_VSB_Search(&(Instance->DeviceMap),Instance->IOHandle, &Search, &Result,Instance->TopLevelHandle);
if(error == FE_VSB_BAD_PARAMETER)
{
Error= ST_ERROR_BAD_PARAMETER;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
STTBX_Print(("%s fail, scan not done: bad parameter(s) to FE_370_VSB_Search() == FE_BAD_PARAMETER\n", identity ));
#endif
return Error;
}
else if (error == FE_VSB_SEARCH_FAILED)
{
Error= ST_NO_ERROR;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
STTBX_Print(("%s FE_370_VSB_Search() == FE_VSB_SEARCH_FAILED\n", identity ));
#endif
return Error;
}
*ScanSuccess = Result.Locked;
if (*ScanSuccess == TRUE)
{
*NewFrequency = Result.Frequency;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
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_d0370VSB_ioctl()
Description:
access device specific low-level functions
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0370VSB_ioctl(DEMOD_Handle_t Handle, U32 Function, void *InParams, void *OutParams, STTUNER_Da_Status_t *Status)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_ioctl()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0370VSB_InstanceData_t *Instance;
/* private driver instance data */
Instance = d0370VSB_GetInstFromHandle(Handle);
if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
STTBX_Print(("%s invalid handle\n", identity));
#endif
return(ST_ERROR_INVALID_HANDLE);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
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_D0370VSB
STTBX_Print(("%s function %d not found\n", identity, Function));
#endif
return(ST_ERROR_FEATURE_NOT_SUPPORTED);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
STTBX_Print(("%s called ok\n", identity, Function)); /* signal that function came back */
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0370VSB_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_d0370VSB_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_D0370VSB
const char *identity = "STTUNER d0370VSB.c demod_d0370VSB_ioaccess()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
IOARCH_Handle_t ThisIOHandle;
D0370VSB_InstanceData_t *Instance;
Instance = d0370VSB_GetInstFromHandle(Handle);
if(STTUNER_Util_CheckPtrNull(Instance) != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB
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_D0370VSB
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_D0370VSB
STTBX_Print(("%s write repeater\n", identity));
#endif
STTUNER_task_lock(); /* prevent any other activity on this bus (no task must preempt us) */
/* 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, F0370_STOP_ENABLE_1, 1);
Error = STTUNER_IOREG_SetField(&(Instance->DeviceMap), Instance->IOHandle, F0370_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);
STTUNER_task_unlock();
}
return(Error);
}
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\UTILITY Functions/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
D0370VSB_InstanceData_t *d0370VSB_GetInstFromHandle(DEMOD_Handle_t Handle)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB_HANDLES
const char *identity = "STTUNER d0370VSB.c d0370VSB_GetInstFromHandle()";
#endif
D0370VSB_InstanceData_t *Instance;
Instance = (D0370VSB_InstanceData_t *)Handle;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0370VSB_HANDLES
STTBX_Print(("%s block at 0x%08x\n", identity, Instance));
#endif
return(Instance);
}
/* End of d0370VSB.c */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?