예제 #1
0
/**

@see   DVBT_NIM_FP_GET_RF_POWER_LEVEL_DBM

*/
s32 rtl2832_tda18272_GetRfPowerLevelDbm(DVBT_NIM_MODULE *pNim, s64 *pRfPowerLevelDbm)
{
	DVBT_DEMOD_MODULE *pDemod;

	u64 FsmStage;
	s64 IfAgc;

	// Get demod module.
	pDemod = pNim->pDemod;

	// Get FSM stage and IF AGC value.
	if(pDemod->GetRegBitsWithPage(pDemod, DVBT_FSM_STAGE, &FsmStage) != FUNCTION_SUCCESS)
		goto error_status_get_registers;

	if(pDemod->GetIfAgc(pDemod, &IfAgc) != FUNCTION_SUCCESS)
		goto error_status_get_registers;

	//  Determine signal strength according to FSM stage and IF AGC value.
	if(FsmStage < 10)
		*pRfPowerLevelDbm = -120;
	else
	{
		if(IfAgc > -1250)
			*pRfPowerLevelDbm = -71 - (IfAgc / 165);
		else
			*pRfPowerLevelDbm = -60;
	}

	return FUNCTION_SUCCESS;

error_status_get_registers:
	return FUNCTION_ERROR;
}
예제 #2
0
UData_t
demod_get_agc(
	handle_t demod_handle,
	uint16_t *rf_level,
	uint16_t *bb_level
	)
{
	DVBT_DEMOD_MODULE *pDemod;
	int RfAgc;
	int IfAgc;


	// Get demod module.
	pDemod = (DVBT_DEMOD_MODULE *)demod_handle;

	// Get RF and IF AGC value.
	if(pDemod->GetRfAgc(pDemod, &RfAgc) != FUNCTION_SUCCESS)
		goto error_status_get_registers;

	if(pDemod->GetIfAgc(pDemod, &IfAgc) != FUNCTION_SUCCESS)
		goto error_status_get_registers;

	// Convert RF and IF AGC value to proper format.
	*rf_level = (uint16_t)((RfAgc + (1 << (RTL2832_RF_AGC_REG_BIT_NUM - 1))) *
		(1 << (MT2266_DEMOD_ASSUMED_AGC_REG_BIT_NUM - RTL2832_RF_AGC_REG_BIT_NUM)));

	*bb_level = (uint16_t)((IfAgc + (1 << (RTL2832_IF_AGC_REG_BIT_NUM - 1))) *
		(1 << (MT2266_DEMOD_ASSUMED_AGC_REG_BIT_NUM - RTL2832_IF_AGC_REG_BIT_NUM)));


	return MT_OK;


error_status_get_registers:
	return MT_COMM_ERR;
}