/**

@see   DVBT_NIM_FP_UPDATE_FUNCTION

*/
int
rtl2832_mt2266_UpdateFunction(
	DVBT_NIM_MODULE *pNim
	)
{
	TUNER_MODULE *pTuner;
	DVBT_DEMOD_MODULE *pDemod;
	MT2266_EXTRA_MODULE *pMt2266Extra;
	RTL2832_MT2266_EXTRA_MODULE *pRtl2832Mt2266Extra;

	Handle_t Mt2266Handle;
	UData_t Status;



	// Get tuner module and demod module.
	pTuner = pNim->pTuner;
	pDemod = pNim->pDemod;

	// Get tuner extra module and tuner handle.
	pMt2266Extra = (MT2266_EXTRA_MODULE *)pTuner->pExtra;
	pMt2266Extra->GetHandle(pTuner, &Mt2266Handle);

	// Get NIM extra module.
	pRtl2832Mt2266Extra = (RTL2832_MT2266_EXTRA_MODULE *)pNim->pExtra;


	// Update demod particular registers.
	if(pDemod->UpdateFunction(pDemod) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	// Enable demod DVBT_IIC_REPEAT.
	if(pDemod->SetRegBitsWithPage(pDemod, DVBT_IIC_REPEAT, 0x1) != FUNCTION_SUCCESS)
		goto error_status_set_registers;

	// Update demod and tuner register setting.
	Status = demod_pdcontrol(
		pDemod,
		Mt2266Handle,
		&pRtl2832Mt2266Extra->LnaConfig,
		&pRtl2832Mt2266Extra->UhfSens,
		&pRtl2832Mt2266Extra->AgcCurrentState,
		(uint32_t *)&pRtl2832Mt2266Extra->LnaGainOld
		);

	if(MT_IS_ERROR(Status))
		goto error_status_execute_function;

	// Disable demod DVBT_IIC_REPEAT.
	if(pDemod->SetRegBitsWithPage(pDemod, DVBT_IIC_REPEAT, 0x0) != FUNCTION_SUCCESS)
		goto error_status_set_registers;


	return FUNCTION_SUCCESS;


error_status_execute_function:
error_status_set_registers:
	return FUNCTION_ERROR;
}
/**

@see   DVBT_NIM_FP_UPDATE_FUNCTION

*/
int
rtl2832_mt2266_UpdateFunction(
	DVBT_NIM_MODULE *pNim
	)
{
	TUNER_MODULE *pTuner;
	DVBT_DEMOD_MODULE *pDemod;
	MT2266_EXTRA_MODULE *pTunerExtra;
	RTL2832_MT2266_EXTRA_MODULE *pNimExtra;

	Handle_t Mt2266Handle;
	UData_t Status;
	


	// Get tuner module and demod module.
	pTuner = pNim->pTuner;
	pDemod = pNim->pDemod;

	// Get tuner extra module and tuner handle.
	pTunerExtra = &(pTuner->Extra.Mt2266);
	pTunerExtra->GetHandle(pTuner, &Mt2266Handle);

	// Get NIM extra module.
	pNimExtra = &(pNim->Extra.Rtl2832Mt2266);


	// Update demod particular registers.
	if(pDemod->UpdateFunction(pDemod) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	// Enable demod DVBT_IIC_REPEAT.
	if(pDemod->SetRegBitsWithPage(pDemod, DVBT_IIC_REPEAT, 0x1) != FUNCTION_SUCCESS)
		goto error_status_set_registers;

	// Update demod and tuner register setting.
	Status = demod_pdcontrol(
		pDemod,
		Mt2266Handle,
		&pNimExtra->LnaConfig,
		&pNimExtra->UhfSens,
		&pNimExtra->AgcCurrentState,
		&pNimExtra->LnaGainOld
		);

/*
	handle_t demod_handle,
	handle_t tuner_handle,
	unsigned char* lna_config,
	unsigned char* uhf_sens,
	unsigned char *agc_current_state,
	unsigned long *lna_gain_old
	
	unsigned char LnaConfig;
	unsigned char UhfSens;
	unsigned char AgcCurrentState;
	unsigned long LnaGainOld;	
	
*/

	if(MT_IS_ERROR(Status))
		goto error_status_execute_function;

	// Disable demod DVBT_IIC_REPEAT.
	if(pDemod->SetRegBitsWithPage(pDemod, DVBT_IIC_REPEAT, 0x0) != FUNCTION_SUCCESS)
		goto error_status_set_registers;


	return FUNCTION_SUCCESS;


error_status_execute_function:
error_status_set_registers:
	return FUNCTION_ERROR;
}