📄 tunsdrv.c
字号:
STTUNER_DRV_TUNER_MAX2116_UnInstall()
STTUNER_DRV_TUNER_DSF8910_UnInstall()
STTUNER_DRV_TUNER_STB6000_UnInstall()
Description:
uninstall a satellite device driver.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
#ifdef STTUNER_BASIC
#ifdef STTUNER_DRV_SAT_TUN_VG1011
ST_ErrorCode_t STTUNER_DRV_TUNER_VG1011_UnInstall (STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_VG1011) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_S68G21
ST_ErrorCode_t STTUNER_DRV_TUNER_S68G21_UnInstall (STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_S68G21) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_TUA6100
ST_ErrorCode_t STTUNER_DRV_TUNER_TUA6100_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_TUA6100) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_EVALMAX
ST_ErrorCode_t STTUNER_DRV_TUNER_EVALMAX_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_EVALMAX) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_VG0011
ST_ErrorCode_t STTUNER_DRV_TUNER_VG0011_UnInstall (STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_VG0011) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_HZ1184
ST_ErrorCode_t STTUNER_DRV_TUNER_HZ1184_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_HZ1184) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_MAX2116
ST_ErrorCode_t STTUNER_DRV_TUNER_MAX2116_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_MAX2116) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_DSF8910
ST_ErrorCode_t STTUNER_DRV_TUNER_DSF8910_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_DSF8910) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_STB6000
ST_ErrorCode_t STTUNER_DRV_TUNER_STB6000_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_STB6000) );
}
#endif
#ifdef STTUNER_DRV_SAT_TUN_IX2476
ST_ErrorCode_t STTUNER_DRV_TUNER_IX2476_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_IX2476) );
}
#endif
#endif
#ifdef STTUNER_DRV_SAT_TUN_STB6100
ST_ErrorCode_t STTUNER_DRV_TUNER_STB6100_UnInstall(STTUNER_tuner_dbase_t *Tuner)
{
return( STTUNER_DRV_TUNER_TUNSDRV_UnInstall(Tuner, STTUNER_TUNER_STB6100) );
}
#endif
/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ API /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
Name: tuner_tunsdrv_Init()
Description: called for every perdriver.
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t tuner_tunsdrv_Init(ST_DeviceName_t *DeviceName, TUNER_InitParams_t *InitParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
const char *identity = "STTUNER tunsdrv.c tuner_tunsdrv_Init()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
TUNSDRV_InstanceData_t *InstanceNew, *Instance;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s fail no driver 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_TUNSDRV
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_TUNSDRV
STTBX_Print(("%s fail DeviceName not valid\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
InstanceNew = memory_allocate_clear(InitParams->MemoryPartition, 1, sizeof( TUNSDRV_InstanceData_t ));
if (InstanceNew == NULL)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
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->InstanceChainNext = NULL; /* always last in the chain */
InstanceNew->TunerType = InitParams->TunerType;
InstanceNew->DeviceMap.MemoryPartition = InitParams->MemoryPartition;;
switch(InstanceNew->TunerType)
{
#ifdef STTUNER_BASIC
#ifdef STTUNER_DRV_SAT_TUN_VG1011
case STTUNER_TUNER_VG1011:
InstanceNew->PLLType = TUNER_PLL_5655;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_TUA6100
case STTUNER_TUNER_TUA6100:
InstanceNew->PLLType = TUNER_PLL_TUA6100;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_EVALMAX
case STTUNER_TUNER_EVALMAX:
InstanceNew->PLLType = TUNER_PLL_5655;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_S68G21
case STTUNER_TUNER_S68G21:
InstanceNew->PLLType = TUNER_PLL_5522;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_VG0011
case STTUNER_TUNER_VG0011:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_HZ1184
case STTUNER_TUNER_HZ1184:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_DSF8910
case STTUNER_TUNER_DSF8910:
InstanceNew->PLLType = TUNER_PLL_5655;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_MAX2116
case STTUNER_TUNER_MAX2116:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_STB6000
case STTUNER_TUNER_STB6000:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
#ifdef STTUNER_DRV_SAT_TUN_IX2476
case STTUNER_TUNER_IX2476:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
#endif
#ifdef STTUNER_DRV_SAT_TUN_STB6100
case STTUNER_TUNER_STB6100:
InstanceNew->PLLType = TUNER_PLL_ABSENT;
break;
#endif
default:
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s incorrect tuner index", identity));
#endif
return(ST_ERROR_UNKNOWN_DEVICE);
break;
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s allocated & initalized block named '%s' at 0x%08x (%d bytes) for tuner ID=%d\n", identity, InstanceNew->DeviceName, InstanceNew, sizeof( TUNSDRV_InstanceData_t ), InstanceNew->TunerType ));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ----------------------------------------------------------------------------
Name: tuner_tunsdrv_Term()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t tuner_tunsdrv_Term(ST_DeviceName_t *DeviceName, TUNER_TermParams_t *TermParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
const char *identity = "STTUNER tunsdrv.c tuner_tunsdrv_Term()";
#endif
ST_ErrorCode_t Error = ST_NO_ERROR;
TUNSDRV_InstanceData_t *Instance, *InstancePrev, *InstanceNext;
if(Installed == FALSE)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
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_TUNSDRV
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_TUNSDRV
STTBX_Print(("%s fail nothing initalized\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
/* reap next matching DeviceName */
Instance = InstanceChainTop;
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("Looking (%s)", Instance->DeviceName));
#endif
while(1)
{
if ( strcmp((char *)Instance->DeviceName, (char *)DeviceName) == 0)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("]\n"));
#endif
/* found so now xlink prev and next(if applicable) and deallocate memory */
InstancePrev = Instance->InstanceChainPrev;
InstanceNext = Instance->InstanceChainNext;
/* if instance to delete is first in chain */
if (Instance->InstanceChainPrev == NULL)
{
InstanceChainTop = InstanceNext; /* which would be NULL if last block to be term'd */
if(InstanceNext != NULL)
{
InstanceNext->InstanceChainPrev = NULL; /* now top of chain, no previous instance */
}
}
else
{ /* safe to set value for prev instaance (because there IS one) */
InstancePrev->InstanceChainNext = InstanceNext;
}
/* if there is a next block in the chain */
if (InstanceNext != NULL)
{
InstanceNext->InstanceChainPrev = InstancePrev;
}
memory_deallocate(Instance->MemoryPartition, Instance->TunerRegVal );
memory_deallocate(Instance->MemoryPartition, Instance);
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s freed block at %0x%08x\n", identity, (U32)Instance ));
#endif
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s terminated ok\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
else if(Instance->InstanceChainNext == NULL)
{ /* error we should have found a matching name before the end of the list */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("\n%s fail no free handle before end of list\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
else
{
Instance = Instance->InstanceChainNext; /* next block */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("(%s)", Instance->DeviceName));
#endif
}
}
#ifdef STTUNER_DEBUG_MODULE_SATDRV_TUNSDRV
STTBX_Print(("%s FAIL! this point should NEVER be reached\n", identity));
#endif
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -