コード例 #1
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;
}