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TSTBISTRES1*/ 0x00,
/*R_TSTBISTRES2*/ 0x00,
/*R_TSTBISTRES3*/ 0x00
};/** end of array**/
#endif
/* Private types/constants ------------------------------------------------ */
#define ANALOG_CARRIER_DETECT_SYMBOL_RATE 5000000
#define ANALOG_CARRIER_DETECT_AGC2_VALUE 25
/* Device capabilities */
#define MAX_AGC 4095 /*fix for DDTS 33979 "AGC calculations for STV0360"*/
#define MAX_SIGNAL_QUALITY 100
#define MAX_BER 200000
#ifdef ST_OS21
#define WAIT_N_MS(X) task_delay( (signed int)(X * (ST_GetClocksPerSecond() / 1000)) ) /*task_delay(X)*/
#else
#define WAIT_N_MS(X) task_delay( (unsigned int)(X * (ST_GetClocksPerSecond() / 1000)) ) /*task_delay(X)*/
#endif
/* private variables ------------------------------------------------------- */
#if defined (ST_OS21) || defined(ST_OSLINUX)
static semaphore_t *Lock_InitTermOpenClose; /* guard calls to the functions */
#else
static semaphore_t Lock_InitTermOpenClose; /* guard calls to the functions */
#endif
static BOOL Installed = FALSE;
/* instance chain, the default boot value is invalid, to catch errors */
static D0360_InstanceData_t *InstanceChainTop = (D0360_InstanceData_t *)0x7fffffff;
/* functions --------------------------------------------------------------- */
int FE_360_PowOf2(int number);
/* API */
ST_ErrorCode_t demod_d0360_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams);
ST_ErrorCode_t demod_d0360_Term(ST_DeviceName_t *DeviceName, DEMOD_TermParams_t *TermParams);
ST_ErrorCode_t demod_d0360_Open (ST_DeviceName_t *DeviceName, DEMOD_OpenParams_t *OpenParams, DEMOD_Capability_t *Capability, DEMOD_Handle_t *Handle);
ST_ErrorCode_t demod_d0360_Close(DEMOD_Handle_t Handle, DEMOD_CloseParams_t *CloseParams);
ST_ErrorCode_t demod_d0360_GetTunerInfo (DEMOD_Handle_t Handle, STTUNER_TunerInfo_t *TunerInfo_p);
ST_ErrorCode_t demod_d0360_GetSignalQuality(DEMOD_Handle_t Handle, U32 *SignalQuality_p, U32 *Ber);
ST_ErrorCode_t demod_d0360_GetModulation (DEMOD_Handle_t Handle, STTUNER_Modulation_t *Modulation);
ST_ErrorCode_t demod_d0360_GetAGC (DEMOD_Handle_t Handle, S16 *Agc);
ST_ErrorCode_t demod_d0360_GetMode (DEMOD_Handle_t Handle, STTUNER_Mode_t *Mode);
ST_ErrorCode_t demod_d0360_GetGuard (DEMOD_Handle_t Handle, STTUNER_Guard_t *Guard);
ST_ErrorCode_t demod_d0360_GetFECRates (DEMOD_Handle_t Handle, STTUNER_FECRate_t *FECRates);
ST_ErrorCode_t demod_d0360_IsLocked (DEMOD_Handle_t Handle, BOOL *IsLocked);
ST_ErrorCode_t demod_d0360_Tracking (DEMOD_Handle_t Handle, BOOL ForceTracking, U32 *NewFrequency, BOOL *SignalFound);
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);
ST_ErrorCode_t demod_d0360_ioctl (DEMOD_Handle_t Handle, U32 Function, void *InParams, void *OutParams,
STTUNER_Da_Status_t *Status);
ST_ErrorCode_t demod_d0360_GetRFLevel(DEMOD_Handle_t Handle, S32 *Rflevel);
ST_ErrorCode_t demod_d0360_GetTPSCellId(DEMOD_Handle_t Handle, U16 *TPSCellId);
/* For STANDBY API mode */
ST_ErrorCode_t demod_d0360_StandByMode(DEMOD_Handle_t Handle, STTUNER_StandByMode_t PowerMode);
/* I/O API */
ST_ErrorCode_t demod_d0360_ioaccess(DEMOD_Handle_t Handle, IOARCH_Handle_t IOHandle,
STTUNER_IOARCH_Operation_t Operation, U16 SubAddr, U8 *Data, U32 TransferSize, U32 Timeout);
ST_ErrorCode_t demod_d0360_TRL_ioctl_set(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle,void *InParams);
ST_ErrorCode_t demod_d0360_TRL_ioctl_get(STTUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle,void *OutParams);
/* local functions --------------------------------------------------------- */
D0360_InstanceData_t *D0360_GetInstFromHandle(DEMOD_Handle_t Handle);
/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STV0360_Install()
Description:
install a terrestrial device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STV0360_Install(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c STTUNER_DRV_DEMOD_STV0360_Install()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == TRUE)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail driver already installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s installing ter:demod:STV0360...", identity));
#endif
/* mark ID in database */
Demod->ID = STTUNER_DEMOD_STV0360;
/* map API */
Demod->demod_Init = demod_d0360_Init;
Demod->demod_Term = demod_d0360_Term;
Demod->demod_Open = demod_d0360_Open;
Demod->demod_Close = demod_d0360_Close;
Demod->demod_IsAnalogCarrier = NULL;
Demod->demod_GetTunerInfo = demod_d0360_GetTunerInfo;
Demod->demod_GetSignalQuality = demod_d0360_GetSignalQuality;
Demod->demod_GetModulation = demod_d0360_GetModulation;
Demod->demod_GetAGC = demod_d0360_GetAGC;
Demod->demod_GetMode = demod_d0360_GetMode;
Demod->demod_GetGuard = demod_d0360_GetGuard;
Demod->demod_GetFECRates = demod_d0360_GetFECRates;
Demod->demod_IsLocked = demod_d0360_IsLocked ;
Demod->demod_SetFECRates = NULL;
Demod->demod_Tracking = demod_d0360_Tracking;
Demod->demod_ScanFrequency = demod_d0360_ScanFrequency;
Demod->demod_ioaccess = demod_d0360_ioaccess;
Demod->demod_ioctl = demod_d0360_ioctl;
Demod->demod_GetRFLevel = demod_d0360_GetRFLevel;
Demod->demod_GetTPSCellId = demod_d0360_GetTPSCellId;
Demod->demod_StandByMode = demod_d0360_StandByMode;
InstanceChainTop = NULL;
#if defined (ST_OS21) || defined(ST_OSLINUX)
Lock_InitTermOpenClose = semaphore_create_fifo(1);
#else
semaphore_init_fifo(&Lock_InitTermOpenClose, 1);
#endif
Installed = TRUE;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("ok\n"));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STV0360_UnInstall()
Description:
install a terrestrial device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STV0360_UnInstall(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c STTUNER_DRV_DEMOD_STV0360_UnInstall()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail driver not installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
if(Demod->ID != STTUNER_DEMOD_STV0360)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail incorrect driver type\n", identity));
#endif
return(STTUNER_ERROR_ID);
}
/* has all memory been freed, by Term() */
if(InstanceChainTop != NULL)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail at least one instance not terminated\n", identity));
#endif
return(ST_ERROR_OPEN_HANDLE);
}
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s uninstalling ter:demod:STV0360...", identity));
#endif
/* mark ID in database */
Demod->ID = STTUNER_NO_DRIVER;
/* unmap API */
Demod->demod_Init = NULL;
Demod->demod_Term = NULL;
Demod->demod_Open = NULL;
Demod->demod_Close = NULL;
Demod->demod_IsAnalogCarrier = NULL;
Demod->demod_GetTunerInfo = NULL;
Demod->demod_GetSignalQuality = NULL;
Demod->demod_GetModulation = NULL;
Demod->demod_GetAGC = NULL;
Demod->demod_GetMode = NULL;
Demod->demod_GetFECRates = NULL;
Demod->demod_GetGuard = NULL;
Demod->demod_IsLocked = NULL;
Demod->demod_SetFECRates = NULL;
Demod->demod_Tracking = NULL;
Demod->demod_ScanFrequency = NULL;
Demod->demod_ioaccess = NULL;
Demod->demod_ioctl = NULL;
Demod->demod_GetRFLevel = NULL;
Demod->demod_GetTPSCellId = NULL;
Demod->demod_StandByMode = NULL ;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("<"));
#endif
#if defined (ST_OS21) || defined (ST_OSLINUX)
semaphore_delete(Lock_InitTermOpenClose);
#else
semaphore_delete(&Lock_InitTermOpenClose);
#endif
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print((">"));
#endif
InstanceChainTop = (D0360_InstanceData_t *)0x7ffffffe;
Installed = FALSE;
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("ok\n"));
#endif
return(Error);
}
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ API /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
Name: demod_d0360_Init()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0360_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
const char *identity = "STTUNER d0360.c demod_d0360_Init()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0360_InstanceData_t *InstanceNew, *Instance;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail driver not installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
/* now safe to lock semaphore */
SEM_LOCK(Lock_InitTermOpenClose);
/* ---------- check params ---------- */
Error = STTUNER_Util_CheckPtrNull(InitParams->MemoryPartition);
if( Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail MemoryPartition not valid\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
Error = STTUNER_Util_CheckPtrNull(DeviceName);
if( Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail DeviceName not valid\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
InstanceNew = memory_allocate_clear(InitParams->MemoryPartition, 1, sizeof( D0360_InstanceData_t ));
if (InstanceNew == NULL)
{
#ifdef STTUNER_DEBUG_MODULE_TERDRV_D0360
STTBX_Print(("%s fail memory allocation InstanceNew\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(ST_ERROR_NO_MEMORY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -