📄 demod_dcf.c
字号:
NIMs[0].exit_acquring = False;
/* initialize current state */
NIMs[0].cur_state = DCF_NIM_ACQUIRING;
NIMs[1].cur_state = DCF_NIM_ACQUIRING;
/*debug_out(TL_ALWAYS, "DEMOD CONNECT after, current status=%d\n", NIMs[0].cur_state);*/
/* the NIM type must be always DEMOD_NIM_CABLE */
if((pTuning == NULL) || (pTuning->type != DEMOD_NIM_CABLE))
{
return(DEMOD_BAD_PARAMETER);
}
#if 0 /* test code: test fade after reset IRD */
/* ONLY FOR TEST */
pTuning->tune.nim_cable_tune.frequency = 682000000;
pTuning->tune.nim_cable_tune.symbol_rate = 6900000;
pTuning->tune.nim_cable_tune.modulation = MOD_QAM64;
pTuning->tune.nim_cable_tune.spectrum = SPECTRUM_NORMAL;
pTuning->tune.nim_cable_tune.auto_spectrum = 1;
pTuning->tune.nim_cable_tune.annex = ANNEX_A;
#endif
/* parameters check */
if( pTuning->tune.nim_cable_tune.frequency < 49000000 ||
pTuning->tune.nim_cable_tune.frequency > 870000000 ||
pTuning->tune.nim_cable_tune.symbol_rate < 150000 ||
pTuning->tune.nim_cable_tune.symbol_rate > 28900000)
{
return(DEMOD_BAD_PARAMETER);
}
/* save the tuning parameters to local memory */
gLocalTuning[u32Unit].type = pTuning->type;
gLocalTuning[u32Unit].tune.nim_cable_tune.frequency = pTuning->tune.nim_cable_tune.frequency;
gLocalTuning[u32Unit].tune.nim_cable_tune.symbol_rate = pTuning->tune.nim_cable_tune.symbol_rate;
gLocalTuning[u32Unit].tune.nim_cable_tune.modulation = pTuning->tune.nim_cable_tune.modulation;
gLocalTuning[u32Unit].tune.nim_cable_tune.spectrum = pTuning->tune.nim_cable_tune.spectrum;
gLocalTuning[u32Unit].tune.nim_cable_tune.auto_spectrum = pTuning->tune.nim_cable_tune.auto_spectrum;
gLocalTuning[u32Unit].tune.nim_cable_tune.annex = pTuning->tune.nim_cable_tune.annex;
/*debug_out(TL_ALWAYS, "Modulation is %2X\n", gLocalTuning[u32Unit].tune.nim_cable_tune.modulation);*/
/* at first, translate the handle into the NO. of NIM */
/* change the sate of the demodulator */
/*debug_out(TL_ALWAYS, "DEMOD CONNECT FUNC: End.\n");*/
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_disconnect */
/* */
/* PARAMETERS: u32Unit - the unit number for which the disconnect */
/* operation is requested. */
/* */
/* DESCRIPTION: This function disconnects from a stream. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_UNINITIALIZED - this module has not been initialized. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_disconnect(u_int32 u32Unit)
{
DEMOD_CALLBACK_DATA CallbackData;
debug_out(TL_INFO, "CABLE TASK: received NIM_MSG_DISCONNECT message\n");
/* do something to disconnect the current signal.
after disconnection, update the state. */
NIMs[u32Unit].cur_state = DCF_NIM_UNCONNECTED;
NIMs[u32Unit].pre_state = DCF_NIM_UNCONNECTED;
/* call the callback function to indicate DISCONNECTED. */
if (gpfnCallbacks[u32Unit])
{
CallbackData.type = DEMOD_DISCONNECT_STATUS;
CallbackData.parm.type = DEMOD_DISCONNECTED;
gpfnCallbacks[u32Unit](gu32LocalModule, u32Unit, DEMOD_DISCONNECT_STATUS, &CallbackData);
}
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_get_tuning */
/* */
/* PARAMETERS: u32Unit - the unit number for which the get tuning */
/* operation is requested. */
/* pTuning - pointer to the TUNING_SPEC structure to be filled */
/* out with parameters for the current connection. */
/* */
/* DESCRIPTION: This function returns the tuning parameters for the */
/* specified unit. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* DEMOD_UNINITIALIZED - this module has not been initialized. */
/* DEMOD_BAD_PARAMETER - there is a bad parameter. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_ERROR - there has been an error. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/* Since there is no actual underlying tuner, this function just returns */
/* the last tuning parameters set. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_get_tuning (u_int32 u32Unit, TUNING_SPEC *pTuning)
{
if(!gu32Initialized)
{
return (DEMOD_UNINITIALIZED);
}
if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
{
return (DEMOD_BAD_UNIT);
}
if(NULL == pTuning)
{
return(DEMOD_BAD_PARAMETER);
}
/* return the current signal type */
pTuning->type = NIMs[u32Unit].demod_type;
/* return the current signal parameters: frequency, symbol rate, ... */
pTuning->tune.nim_cable_tune.frequency = NIMs[u32Unit].freq_ideal;
pTuning->tune.nim_cable_tune.symbol_rate = NIMs[u32Unit].symbol_rate_ideal;
pTuning->tune.nim_cable_tune.modulation = NIMs[u32Unit].mod_type;
pTuning->tune.nim_cable_tune.auto_spectrum = NIMs[u32Unit].auto_spec_inv;
pTuning->tune.nim_cable_tune.spectrum = NIMs[u32Unit].spec_inv;
pTuning->tune.nim_cable_tune.annex = NIMs[u32Unit].annex;
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_set_callback */
/* */
/* PARAMETERS: u32Unit - the unit number for which the callback is to be */
/* set. */
/* pfnCallback - the function address to be used for the */
/* callback for this unit. */
/* */
/* DESCRIPTION: This function sets the callback pointer for the specified */
/* unit. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* DEMOD_UNINITIALIZED - this module has not been initialized. */
/* DEMOD_BAD_PARAMETER - there is a bad parameter. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_ERROR - there has been an error. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_set_callback (u_int32 u32Unit, MODULE_STATUS_FUNCTION *pfnCallback)
{
if(!gu32Initialized)
{
return(DEMOD_UNINITIALIZED);
}
if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
{
return(DEMOD_BAD_UNIT);
}
if(NULL == pfnCallback)
{
return(DEMOD_BAD_PARAMETER);
}
/* save the callback function pointer */
gpfnCallbacks[u32Unit] = pfnCallback;
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_clear_callback */
/* */
/* PARAMETERS: u32Unit - the unit number for which the callback is to be */
/* cleared. */
/* */
/* DESCRIPTION: This function clears the callback pointer for the specified */
/* unit. */
/* */
/* RETURNS: DEMOD_UNINITIALIZED - this module has not been initialized. */
/* DEMOD_BAD_PARAMETER - there is a bad parameter. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_ERROR - there has been an error. */
/* DEMOD_SUCCESS - the function completed successfully. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_clear_callback (u_int32 u32Unit)
{
if(!gu32Initialized)
{
return(DEMOD_UNINITIALIZED);
}
if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
{
return(DEMOD_BAD_UNIT);
}
/* clear the callback function pointer */
gpfnCallbacks[u32Unit] = 0;
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_get_signal_stats */
/* */
/* PARAMETERS: u32Unit - the unit number for which the get signal stats */
/* operation is requested. */
/* pSignalStats - pointer to the SIGNAL_STATS structure to be */
/* filled out with parameters for the specified unit. */
/* */
/* DESCRIPTION: This function returns the signal statistics for the */
/* specified unit. */
/* */
/* RETURNS: DEMOD_SUCCESS - If all went well. */
/* DEMOD_UNINITIALIZED - this module has not been initialized. */
/* DEMOD_BAD_PARAMETER - there is a bad parameter. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_ERROR - there has been an error. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_get_signal_stats (u_int32 u32Unit, SIGNAL_STATS *pSignalStats)
{
int nCNE;
if(!gu32Initialized)
{
return(DEMOD_UNINITIALIZED);
}
if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
{
return(DEMOD_BAD_UNIT);
}
if(NULL == pSignalStats)
{
return(DEMOD_BAD_PARAMETER);
}
/* Fill stats (points to pSignalStats) with the status information */
pSignalStats->type = DEMOD_NIM_CABLE;
nCNE = (int)(NIMs[u32Unit].cne) * 5; /* pNim->cne * 100 / 40 */
nCNE = nCNE >> 1;
pSignalStats->stats.c_signal.signal_quality = nCNE;
/* We could not get the AGC(s) values of Thomson cable front-end. */
/* so now the signal strength is equal to the signal quality. */
pSignalStats->stats.c_signal.signal_strength = NIMs[u32Unit].signal_strength;
pSignalStats->stats.c_signal.rs_uncorrected = NIMs[u32Unit].ber.dividen;
pSignalStats->stats.c_signal.rs_total = NIMs[u32Unit].ber.divisor;
return(DEMOD_SUCCESS);
}
/*****************************************************************************/
/* FUNCTION: cnxt_dcf_get_lock_status */
/* */
/* PARAMETERS: u32Unit - the unit number for which the get lock status */
/* operation is requested. */
/* pLocked - pointer to the boolean to be filled out indicated */
/* in locked/not locked for the specified unit. */
/* */
/* DESCRIPTION: This function returns the lock status for the specified */
/* unit. */
/* */
/* RETURNS: DEMOD_UNINITIALIZED - this module has not been initialized. */
/* DEMOD_BAD_UNIT - the unit number is not valid. */
/* DEMOD_BAD_PARAMETER - there is a bad parameter. */
/* DEMOD_SUCCESS - the function completed successfully. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_get_lock_status (u_int32 u32Unit, bool *pLocked)
{
if(!gu32Initialized)
{
return(DEMOD_UNINITIALIZED);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -