📄 d0288.c
字号:
#endif
return(STTUNER_ERROR_INITSTATE);
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s installing sat:demod:STX0288...", identity));
#endif
/* mark ID in database */
Demod->ID = STTUNER_DEMOD_STX0288;
/* map API */
Demod->demod_Init = demod_d0288_Init;
Demod->demod_Term = demod_d0288_Term;
Demod->demod_Open = demod_d0288_Open;
Demod->demod_Close = demod_d0288_Close;
Demod->demod_GetSignalQuality = demod_d0288_GetSignalQuality;
Demod->demod_GetModulation = demod_d0288_GetModulation;
Demod->demod_SetModulation = demod_d0288_SetModulation;
Demod->demod_GetAGC = demod_d0288_GetAGC;
Demod->demod_GetFECRates = demod_d0288_GetFECRates;
Demod->demod_GetIQMode = demod_d0288_GetIQMode; /*added for GNBvd26107->I2C failure due to direct access to demod device at API level*/
Demod->demod_IsLocked = demod_d0288_IsLocked ;
Demod->demod_SetFECRates = demod_d0288_SetFECRates;
Demod->demod_Tracking = demod_d0288_Tracking;
Demod->demod_ScanFrequency = demod_d0288_ScanFrequency;
Demod->demod_DiSEqC = demod_d0288_DiSEqC;
Demod->demod_GetConfigDiSEqC = demod_d0288_DiSEqCGetConfig;
Demod->demod_SetDiSEqCBurstOFF = demod_d0288_DiSEqCBurstOFF;
Demod->demod_ioaccess = demod_d0288_ioaccess;
Demod->demod_ioctl = demod_d0288_ioctl;
Demod->demod_GetSymbolrate = demod_0288_GetSymbolrate;
#ifdef STTUNER_DRV_SAT_SCR
Demod->demod_tonedetection = demod_d0288_tonedetection;
#endif
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_SATDRV_D0288
STTBX_Print(("ok\n"));
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STX0288_UnInstall()
Description:
install a satellite device driver into the demod database.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STX0288_UnInstall(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c STTUNER_DRV_DEMOD_STX0288_UnInstall()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail driver not installed\n", identity));
#endif
return(STTUNER_ERROR_INITSTATE);
}
if(Demod->ID != STTUNER_DEMOD_STX0288)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
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_SATDRV_D0288
STTBX_Print(("%s fail at least one instance not terminated\n", identity));
#endif
return(ST_ERROR_OPEN_HANDLE);
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s uninstalling sat:demod:STV0288...", identity));
#endif
Demod->ID = STTUNER_NO_DRIVER;
Demod->demod_Init = NULL;
Demod->demod_Term = NULL;
Demod->demod_Open = NULL;
Demod->demod_Close = NULL;
Demod->demod_IsAnalogCarrier = NULL;
Demod->demod_GetSignalQuality = NULL;
Demod->demod_GetModulation = NULL;
Demod->demod_SetModulation = NULL;
Demod->demod_GetAGC = NULL;
Demod->demod_GetFECRates = NULL;
Demod->demod_GetIQMode = NULL; /*added for GNBvd26107->I2C failure due to direct access to demod device at API level*/
Demod->demod_IsLocked = NULL;
Demod->demod_SetFECRates = NULL;
Demod->demod_Tracking = NULL;
Demod->demod_ScanFrequency = NULL;
Demod->demod_DiSEqC = NULL;
Demod->demod_GetConfigDiSEqC = NULL;
Demod->demod_SetDiSEqCBurstOFF= NULL;
Demod->demod_ioaccess = NULL;
Demod->demod_ioctl = NULL;
Demod->demod_GetSymbolrate = NULL;
#ifdef STTUNER_DRV_SAT_SCR
Demod->demod_tonedetection = NULL;
#endif
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("<"));
#endif
#if defined(ST_OS21) || defined(ST_OSLINUX)
semaphore_delete(Lock_InitTermOpenClose);
#else
semaphore_delete(&Lock_InitTermOpenClose);
#endif
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print((">"));
#endif
InstanceChainTop = (D0288_InstanceData_t *)0x7ffffffe;
Installed = FALSE;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("ok\n"));
#endif
return(Error);
}
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ API /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
Name: demod_d0288_Init()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0288_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_Init()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *InstanceNew, *Instance;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
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_SATDRV_D0288
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_SATDRV_D0288
STTBX_Print(("%s fail DeviceName not valid\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
InstanceNew = memory_allocate_clear(InitParams->MemoryPartition, 1, sizeof( D0288_InstanceData_t ));
if (InstanceNew == NULL)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail memory allocation InstanceNew\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(ST_ERROR_NO_MEMORY);
}
/* slot into chain */
if (InstanceChainTop == NULL)
{
InstanceNew->InstanceChainPrev = NULL; /* no previous instance */
InstanceChainTop = InstanceNew;
}
else /* tag onto last data block in chain */
{
Instance = InstanceChainTop;
while(Instance->InstanceChainNext != NULL)
{
Instance = Instance->InstanceChainNext; /* next block */
}
Instance->InstanceChainNext = (void *)InstanceNew;
InstanceNew->InstanceChainPrev = (void *)Instance;
}
InstanceNew->DeviceName = DeviceName;
InstanceNew->TopLevelHandle = STTUNER_MAX_HANDLES;
InstanceNew->IOHandle = InitParams->IOHandle;
InstanceNew->MemoryPartition = InitParams->MemoryPartition;
InstanceNew->DeviceMap.Timeout = IOREG_DEFAULT_TIMEOUT;
InstanceNew->DeviceMap.Registers = STX288_NBREGS;
InstanceNew->DeviceMap.Fields = STX288_NBFIELDS;
InstanceNew->DeviceMap.Mode = IOREG_MODE_SUBADR_8; /* NEW as of 3.4.0: i/o addressing mode to use */
InstanceNew->DeviceMap.MemoryPartition = InitParams->MemoryPartition;
InstanceNew->InstanceChainNext = NULL; /* always last in the chain */
InstanceNew->ExternalClock = InitParams->ExternalClock;
#ifdef STTUNER_DRV_SAT_5188
InstanceNew->ExternalClock = 30000000;
#else
InstanceNew->ExternalClock = 4000000;
#endif
InstanceNew->TSOutputMode = InitParams->TSOutputMode;
InstanceNew->SerialDataMode = InitParams->SerialDataMode;
InstanceNew->BlockSyncMode = InitParams->BlockSyncMode;/* add block sync bit control for bug GNBvd27452*/
InstanceNew->FECMode = InitParams->FECMode;
InstanceNew->ClockPolarity = InitParams->ClockPolarity;
InstanceNew->DataClockAtParityBytes = InitParams->DataClockAtParityBytes;
InstanceNew->DataFIFOMode = InitParams->DataFIFOMode;
InstanceNew->OutputFIFOConfig = InitParams->OutputFIFOConfig;
InstanceNew->DiSEqC_RxFreq = 22000;
/*********************Added for Diseqc***************************/
InstanceNew->DiSEqCConfig.Command=STTUNER_DiSEqC_COMMAND;
InstanceNew->DiSEqCConfig.ToneState=STTUNER_DiSEqC_TONE_CONTINUOUS_OFF;
/**************************************************/
/* reserve memory for register mapping */
Error = STTUNER_IOREG_Open(&InstanceNew->DeviceMap);
if (Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail setup new register database\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s allocated & initalized block named '%s' at 0x%08x (%d bytes)\n", identity, InstanceNew->DeviceName, (U32)InstanceNew, sizeof( D0288_InstanceData_t ) ));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ----------------------------------------------------------------------------
Name: demod_d0288_Term()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0288_Term(ST_DeviceName_t *DeviceName, DEMOD_TermParams_t *TermParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
const char *identity = "STTUNER d0288.c demod_d0288_Term()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
D0288_InstanceData_t *Instance, *InstancePrev, *InstanceNext;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
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(TermParams);
if( Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail TermParams not valid\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ---------- check that at least one init has taken place ---------- */
if(InstanceChainTop == NULL)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail nothing initalized\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
Instance = InstanceChainTop;
while(1)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("(%s)", Instance->DeviceName));
#endif
if ( strcmp( (char *)Instance->DeviceName, (char *)DeviceName) == 0)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("]\n"));
#endif
Error = STTUNER_IOREG_Close(&Instance->DeviceMap);
if (Error != ST_NO_ERROR)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0288
STTBX_Print(("%s fail close register database\n", identity));
#endif
}
/* found so now xlink prev and next(if applicable) and deallocate memory */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -