📄 tmdlfe.c
字号:
//
// NOTES : The dlFeTune function is called because this function starts
// the scanning to the frequency programmed with the tmdlFeTune
//-----------------------------------------------------------------------------
tmdlFeErr_t FeStartScan (
tmdlFeInstance_t FeInstance_U,
tmdlFeSearchConfig_t* pSearchCfg_S,
Bool bAutoscan
)
{
tmdlFeCtx_t* pCtx;
tmdlFeErr_t RetVal_E;
tmdlFeTuningConfig_t TunCfg_S;
tmErrorCode_t errorCode_E;
pCtx = (tmdlFeCtx_t*)FeInstance_U;
// instance control
if ( FeInstance_U != pCtx->Instance_U )
return (tmdlFeNotOpen_E);
// The FeTune function must be called before the startScanFunc function
// because this function start the scanning to the frequency programmed
// with the FeTune function.
//Modif 20040513 no differences betwenn scan and autoscan for the parameters
TunCfg_S.Fsymb_BW_U = pSearchCfg_S->Fsymb_BW_U;
TunCfg_S.Frequency_U = pSearchCfg_S->StartFrequency_U;
TunCfg_S.SpecInv_E = pSearchCfg_S->SpecInv_E;
TunCfg_S.Const_E = pSearchCfg_S->Const_E;
// Saving for scan progress value during the scanning
pCtx->StartScanFreq_U = pSearchCfg_S->StartFrequency_U;
switch (pCtx->FeType_E)
{
case tmdlFeTerrestrial_E:
TunCfg_S.Specific_S.Ter_S.Standard_S = pSearchCfg_S->Specific_S.Ter_S.Standard_S;
// saving for GetStatus
pCtx->DTT_Standard_S = pSearchCfg_S->Specific_S.Ter_S.Standard_S;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.ViterbiRateHP_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.ViterbiRateHP_E;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.ViterbiRateLP_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.ViterbiRateLP_E;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.GuardInterval_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.GuardInterval_E;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.TransmissionMode_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.TransmissionMode_E;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.Hierarchy_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.Hierarchy_E;
TunCfg_S.Specific_S.Ter_S.uStd.DvbT_S.Priority_E = pSearchCfg_S->Specific_S.Ter_S.uStd.DvbT_S.Priority_E;
break;
case tmdlFeSatellite_E:
TunCfg_S.Specific_S.Sat_S.ViterbiRate_E = pSearchCfg_S->Specific_S.Sat_S.ViterbiRate_E;
TunCfg_S.Specific_S.Sat_S.Polar_E = pSearchCfg_S->Specific_S.Sat_S.Polar_E;
TunCfg_S.Specific_S.Sat_S.ToneState = pSearchCfg_S->Specific_S.Sat_S.ToneState;
break;
case tmdlFeCable_E:
break;
default:
return tmdlFeCallFailed_E;
}
// Front-End programmation
if ( FeTune( pCtx->Instance_U, &TunCfg_S ) != tmdlFeNoError_E )
{
DV_DBG_PRINT("DLFE: FeStartScan -> Invalid value in FeTune\n");
return tmdlFeCallFailed_E;
}
// Frequency saving for the FeContinueScan function
pCtx->StopScanFreq_U = pSearchCfg_S->StopFrequency_U;
if (pCtx->FeType_E == tmdlFeSatellite_E)
{
if (bAutoscan)
{
pCtx->uDemodCfg.Sat_S.setCfgFunc(tmUnit0, 18, TMDL_FE_CFG_SAT_SR_MAX);
pCtx->uDemodCfg.Sat_S.setCfgFunc(tmUnit0, 19, TMDL_FE_CFG_SAT_SR_MIN);
}
else
{
pCtx->uDemodCfg.Sat_S.setCfgFunc(tmUnit0, 18, pSearchCfg_S->Fsymb_BW_U);
pCtx->uDemodCfg.Sat_S.setCfgFunc(tmUnit0, 19, pSearchCfg_S->Fsymb_BW_U);
}
}
// Start the scanning
switch (pCtx->FeType_E)
{
case tmdlFeTerrestrial_E:
RetVal_E = pCtx->uDemodCfg.Ter_S.startScanFunc(
pCtx->FeUnit,
pSearchCfg_S->StopFrequency_U
);
break;
case tmdlFeSatellite_E:
RetVal_E = pCtx->uDemodCfg.Sat_S.startScanFunc(
pCtx->FeUnit,
pSearchCfg_S->StopFrequency_U,
( tmhalFEAutoScanMode_t )pSearchCfg_S->Specific_S.Sat_S.AutoScanMode_E
);
break;
case tmdlFeCable_E:
// Start the scanning
RetVal_E = pCtx->uDemodCfg.Cab_S.startScanFunc(
pCtx->FeUnit,
pSearchCfg_S->StopFrequency_U
);
break;
default:
return tmdlFeCallFailed_E;
}
if (RetVal_E != TM_OK)
return (tmdlFeCallFailed_E);
return (tmdlFeNoError_E);
}
//-----------------------------------------------------------------------------
// FUNCTION : FeContinueScan
//
// DESCRIPTION : Starts the scanning
//
// RETURN : tmdlFeErr_t
//
// NOTES :
//-----------------------------------------------------------------------------
tmdlFeErr_t FeContinueScan( tmdlFeInstance_t FeInstance_U )
{
tmdlFeCtx_t* pCtx;
tmdlFeErr_t RetVal_E = TM_OK;
pCtx = (tmdlFeCtx_t*)FeInstance_U;
// instance control
if ( FeInstance_U != pCtx->Instance_U )
return (tmdlFeNotOpen_E);
// continue the scanning with the stop frequency saving in the FeStartScan function
switch (pCtx->FeType_E)
{
case tmdlFeTerrestrial_E:
RetVal_E = pCtx->uDemodCfg.Ter_S.startScanFunc(
pCtx->FeUnit,
pCtx->StopScanFreq_U
);
break;
case tmdlFeSatellite_E:
RetVal_E = pCtx->uDemodCfg.Sat_S.startScanFunc(
pCtx->FeUnit,
pCtx->StopScanFreq_U
);
break;
case tmdlFeCable_E:
// Start the scanning
RetVal_E = pCtx->uDemodCfg.Cab_S.startScanFunc(
pCtx->FeUnit,
pCtx->StopScanFreq_U
);
break;
}
if (RetVal_E != TM_OK)
return (tmdlFeCallFailed_E);
return (tmdlFeNoError_E);
}
//-----------------------------------------------------------------------------
// FUNCTION : FeAlgoReport
//
// DESCRIPTION : Manage the Front-End algorithme
//
// RETURN : tmdlFeErr_t
//
// NOTES :
//-----------------------------------------------------------------------------
tmdlFeErr_t FeAlgoReport( tmdlFeInstance_t FeInstance_U, tmhalFEManagerStatus_t statusManager_E )
{
tmdlFeCtx_t* pCtx;
tmErrorCode_t errorCode_E;
UInt32 events_U = TMDL_FE_EVENT_NO_CARRIER;
pCtx = (tmdlFeCtx_t*)FeInstance_U;
// instance control
if ( FeInstance_U != pCtx->Instance_U )
return (tmdlFeNotOpen_E);
switch (statusManager_E)
{
case tmhalFEManagerStatusCarrierOk:
if ( pCtx->FeCurrState_E == tmdlFeStateTuning_E )
{
pCtx->StatusMask_S = DEMOD_STATUS_FREQ |
DEMOD_FSYMB_BW |
DEMOD_CONST |
DEMOD_STATUS_CARRIER_STS |
DEMOD_STATUS_SCANPROG |
DEMOD_STATUS_SPECIFIC |
DEMOD_STATUS_SI |
DEMOD_STANDARD;
errorCode_E = FeGetStatus ( pCtx->Instance_U );
if ( errorCode_E != tmdlFeNoError_E )
{
DV_DBG_PRINT("DLFE: FeGetStatus error\n");
}
if (pCtx->DemodStatus_S.CarrierStatus_E == tmdlFeCarrierLock_E)
{
pCtx->FeCurrState_E = tmdlFeStateTuned_E;
// report to the upper layer
events_U = TMDL_FE_EVENT_CARRIER_TUNED;
if ((pCtx->CallBack != Null) && (pCtx->EventMask_U & events_U))
{
pCtx->CallBack(events_U, (void *)(&pCtx->DemodStatus_S), pCtx->HpiInstance_U);
}
}
else
{
pCtx->FeCurrState_E = tmdlFeStateUnTuned_E;
DV_DBG_PRINT("DLFE: Abnormal algo termination, tmhalFEManagerStatusCarrierOk but tmdlFeCarrierNoLock_E\n");
// send a message to relloc the FE
tmdlFeTune(pCtx->Instance_U, Null);
}
}
// Get Status call for the callback function
else if ( pCtx->FeCurrState_E == tmdlFeStateScanning_E )
{
pCtx->StatusMask_S = DEMOD_STATUS_FREQ |
DEMOD_FSYMB_BW |
DEMOD_CONST |
DEMOD_STATUS_CARRIER_STS |
DEMOD_STATUS_SCANPROG |
DEMOD_STATUS_SPECIFIC |
DEMOD_STATUS_SI |
DEMOD_STANDARD;
errorCode_E = FeGetStatus ( pCtx->Instance_U );
if ( errorCode_E != tmdlFeNoError_E )
{
DV_DBG_PRINT("DLFE: FeGetStatus error\n");
}
if (pCtx->DemodStatus_S.CarrierStatus_E == tmdlFeCarrierLock_E)
{
// report to the upper layer
events_U = TMDL_FE_EVENT_CARRIER_FOUND;
if ((pCtx->CallBack != Null) && (pCtx->EventMask_U & events_U))
{
pCtx->StatusMask_S = DEMOD_STATUS_FREQ |
DEMOD_FSYMB_BW |
DEMOD_CONST |
DEMOD_STATUS_CARRIER_STS |
DEMOD_STATUS_SCANPROG |
DEMOD_STATUS_SPECIFIC |
DEMOD_STATUS_SI |
DEMOD_STANDARD;
errorCode_E = FeGetStatus ( pCtx->Instance_U );
if ( errorCode_E != tmdlFeNoError_E )
{
DV_DBG_PRINT("DLFE: FeGetStatus error\n");
}
pCtx->CallBack(events_U, (void *)(&pCtx->DemodStatus_S), pCtx->HpiInstance_U);
}
}
else
{
DV_DBG_PRINT("DLFE: Abnormal algo termination of scanning, tmhalFEManagerStatusCarrierOk but tmdlFeCarrierNoLock_E\n");
// send a message to continue the scan
tmdlFeContinueScan(pCtx->Instance_U, Null);
}
}
return (tmdlFeNoError_E);
break;
case tmhalFEManagerStatusNoCarrier:
if ( pCtx->FeCurrState_E == tmdlFeStateScanning_E )
{
events_U = TMDL_FE_EVENT_END_OF_SEARCH;
pCtx->FeCurrState_E = tmdlFeStateUnTuned_E;
}
else
{
pCtx->FeCurrState_E = tmdlFeStateUnTuned_E;
if ( pCtx->NbTuneRetry )
{
pCtx->NbTuneRetry --;
// Some applications expect a NO_CARRIER event
if (!pCtx->NbTuneRetry)
events_U = TMDL_FE_EVENT_NO_CARRIER;
else
events_U = 0;
tmdlFeTune(pCtx->Instance_U, Null);
// For Satellite, a temporisation is required to give
// some time to th e setLnbFunc function.
if ( pCtx->FeType_E == tmdlFeSatellite_E )
tmosalTaskSleep(200); //200ms
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -