?? lnbbeio.c
字號:
SEM_UNLOCK(Lock_InitTermOpenClose);
return(Error);
}
/* ---------- check that at least one init has taken place ---------- */
if(InstanceChainTop == NULL)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
Instance = InstanceChainTop;
while(1)
{
if ( strcmp((char *)Instance->DeviceName, (char *)DeviceName) == 0)
{
/* 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);
memory_deallocate(Instance->MemoryPartition, Instance->LnbIOPort);
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 */
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
else
{
Instance = Instance->InstanceChainNext; /* next block */
}
}
SEM_UNLOCK(Lock_InitTermOpenClose);
#endif
#ifdef STTUNER_MINIDRIVER
memory_deallocate(LNBInstance->MemoryPartition, LNBInstance);
Error = ST_NO_ERROR;
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_Open()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_Open (ST_DeviceName_t *DeviceName, LNB_OpenParams_t *OpenParams, LNB_Capability_t *Capability, LNB_Handle_t *Handle)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
LNB_BackEndIO_InstanceData_t *Instance;
STTUNER_InstanceDbase_t *Inst;
STPIO_OpenParams_t PIO_OpenParams;
/*
static ST_DeviceName_t PIODeviceName[] =
{
"STPIO[0]",
"STPIO[1]",
"STPIO[2]",
"STPIO[3]",
"STPIO[4]",
"STPIO[5]",
"STPIO[6]",
"STPIO[7]"
};
static ST_DeviceName_t PIODeviceName[] =
{
"PIO0",
"PIO1",
"PIO2",
"PIO3",
"PIO4",
"PIO5",
"PIO6",
"PIO7"
};
*/
if(Installed == FALSE)
{
return(STTUNER_ERROR_INITSTATE);
}
Inst = STTUNER_GetDrvInst();
/* now safe to lock semaphore */
SEM_LOCK(Lock_InitTermOpenClose);
/* ---------- check that at least one init has taken place ---------- */
if(InstanceChainTop == NULL)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
/* find handle from name */
Instance = InstanceChainTop;
while(strcmp((char *)Instance->DeviceName, (char *)DeviceName) != 0)
{
/* error, should have found matching DeviceName before end of list */
if(Instance->InstanceChainNext == NULL)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
Instance = Instance->InstanceChainNext; /* next block */
}
if(Instance->TopLevelHandle != STTUNER_MAX_HANDLES)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(ST_ERROR_OPEN_HANDLE);
}
/* this LNB driver is only for use with an STV0299 backend */
Inst = STTUNER_GetDrvInst(); /* pointer to instance database */
/* pointer to **OPENED** backend for this instance */
/* Set LNB capabilties */
Capability->ShortCircuitDetect = FALSE; /* lie (rewrite to get pwr status using stv0299 i/o pin etc.) */
Capability->PowerAvailable = TRUE;
Capability->PolarizationSelect = STTUNER_PLR_ALL;
/* Set latest configuration */
Instance->Config.Status = LNB_STATUS_OFF;
Instance->Config.Polarization = STTUNER_LNB_OFF;
Instance->Config.ToneState = STTUNER_LNB_TONE_OFF;
PIO_OpenParams.ReservedBits = Instance->LnbIOPort->VSEL_PIOPin;
PIO_OpenParams.BitConfigure[0] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[1] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[2] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[3] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[4] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[5] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[6] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[7] = STPIO_BIT_NOT_SPECIFIED;
PIO_OpenParams.BitConfigure[Instance->LnbIOPort->VSEL_PIOBit] = STPIO_BIT_OUTPUT;
PIO_OpenParams.IntHandler = NULL;
/*Error = STPIO_Open(PIODeviceName[Instance->LnbIOPort->VSEL_PIOPort],&PIO_OpenParams,
&(Instance->LNBVSEL_PIOHandle));*/
Error = STPIO_Open(Instance->LnbIOPort->PIODeviceName,&PIO_OpenParams,
&(Instance->LNBVSEL_PIOHandle));
PIO_OpenParams.ReservedBits = Instance->LnbIOPort->VEN_PIOPin;
PIO_OpenParams.BitConfigure[Instance->LnbIOPort->VEN_PIOBit] = STPIO_BIT_OUTPUT;
PIO_OpenParams.IntHandler = NULL;
Error |= STPIO_Open(Instance->LnbIOPort->PIODeviceName,&PIO_OpenParams,
&(Instance->LNBVEN_PIOHandle));
/*Error |= STPIO_Open(PIODeviceName[Instance->LnbIOPort->VEN_PIOPort],&PIO_OpenParams,
&(Instance->LNBVEN_PIOHandle));*/
PIO_OpenParams.ReservedBits = Instance->LnbIOPort->TEN_PIOPin;
PIO_OpenParams.BitConfigure[Instance->LnbIOPort->TEN_PIOBit] = STPIO_BIT_OUTPUT;
PIO_OpenParams.IntHandler = NULL;
Error |= STPIO_Open(Instance->LnbIOPort->PIODeviceName,&PIO_OpenParams,
&(Instance->LNBTEN_PIOHandle));
/*Error |= STPIO_Open(PIODeviceName[Instance->LnbIOPort->TEN_PIOPort],&PIO_OpenParams,
&(Instance->LNBTEN_PIOHandle));*/
/* Make LNB Power OFF during STTUNER_Open()*/
Error = STPIO_Clear(Instance->LNBVEN_PIOHandle, Instance->LnbIOPort->VEN_PIOPin);
/* wait 500uS (0.5mS) then get power status */
UTIL_Delay(500);
Instance->TopLevelHandle = OpenParams->TopLevelHandle; /* mark as valid */
*Handle = (U32)Instance;
SEM_UNLOCK(Lock_InitTermOpenClose);
#endif
#ifdef STTUNER_MINIDRIVER
/* Set latest configuration */
LNBInstance->Config.Status = LNB_STATUS_ON;
LNBInstance->Config.ToneState = STTUNER_LNB_TONE_OFF;
LNBInstance->Config.Polarization = STTUNER_PLR_HORIZONTAL;/* set default pol->Horizontal*/
LNBInstance->Config.ToneSourceControl = STTUNER_22KHz_TONE_BackEndOP0Pin;
LNBInstance->Config.LNBPowerControl = STTUNER_LNB_POWER_LNBPDefault;
LNB_BackEndIO_SetLnb(0);/* LNB tone off */
LNB_BackEndIO_SetPower(LNBInstance->Config.Status);/*LNB power on*/
LNB_BackEndIO_SetPolarization(STTUNER_PLR_HORIZONTAL);
*Handle = (U32)LNBInstance;
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_Close()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_Close(LNB_Handle_t Handle, LNB_CloseParams_t *CloseParams)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
LNB_BackEndIO_InstanceData_t *Instance;
Instance = (LNB_BackEndIO_InstanceData_t *)Handle;
if(Installed == FALSE)
{
return(STTUNER_ERROR_INITSTATE);
}
SEM_LOCK(Lock_InitTermOpenClose);
/* ---------- check that at least one init has taken place ---------- */
if(InstanceChainTop == NULL)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(STTUNER_ERROR_INITSTATE);
}
if(Instance->TopLevelHandle == STTUNER_MAX_HANDLES)
{
SEM_UNLOCK(Lock_InitTermOpenClose);
return(ST_ERROR_OPEN_HANDLE);
}
STPIO_Close(Instance->LNBTEN_PIOHandle);
STPIO_Close(Instance->LNBVEN_PIOHandle);
STPIO_Close(Instance->LNBVSEL_PIOHandle);
Instance->TopLevelHandle = STTUNER_MAX_HANDLES;
SEM_UNLOCK(Lock_InitTermOpenClose);
#endif
#ifdef STTUNER_MINIDRIVER
LNBInstance->TopLevelHandle = STTUNER_MAX_HANDLES;
#endif
return(Error);
}
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_overloadcheck()
Description:
Dummy Function
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_overloadcheck(LNB_BackEndIO_InstanceData_t *Instance, BOOL *IsOverTemp, BOOL *IsCurrentOvrLoad)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_setttxmode()
Description:
Dummy Function
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_setttxmode(LNB_BackEndIO_InstanceData_t *Instance, STTUNER_LnbTTxMode_t Ttxmode)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
return(Error);
}
/* ----------------------------------------------------------------------------
Name: lnb_backendIO_GetConfig()
Description:
Parameters:
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t lnb_backendIO_GetConfig(LNB_Handle_t Handle, LNB_Config_t *Config)
{
ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
LNB_BackEndIO_InstanceData_t *Instance;
Instance = (LNB_BackEndIO_InstanceData_t *)Handle;
Config->Status = Instance->Config.Status;
Config->Polarization = Instance->Config.Polarization;
Config->ToneState = Instance->Config.ToneState;
#endif
#ifdef STTUNER_MINIDRIVER
Config->Status = LNBInstance->Config.Status;
Config->Polarization = LNBInstance->Config.Polarization;
Config->ToneState = LNBInstance->Config.ToneState;
#endif
return(Error);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -