/**

@see   QAM_NIM_FP_SET_PARAMETERS

*/
int
rtl2836b_dvbc_va1t1ed6093_SetParameters(
	QAM_NIM_MODULE *pNim,
	unsigned long RfFreqHz,
	int QamMode,
	unsigned long SymbolRateHz,
	int AlphaMode
	)
{
	QAM_DEMOD_MODULE *pDemod;
	TUNER_MODULE *pTuner;


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


	// Enable demod QAM_I2CT_EN_CTRL.
	if(pDemod->RegAccess.Addr16Bit.SetRegBits(pDemod, QAM_I2CT_EN_CTRL, 0x1) != FUNCTION_SUCCESS)
		goto error_status_set_registers;

	// Set tuner RF frequency in Hz.
	if(pTuner->SetRfFreqHz(pTuner, RfFreqHz) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Disable demod QAM_I2CT_EN_CTRL.
	if(pDemod->RegAccess.Addr16Bit.SetRegBits(pDemod, QAM_I2CT_EN_CTRL, 0x0) != FUNCTION_SUCCESS)
		goto error_status_set_registers;


	// Set demod QAM mode.
	if(pDemod->SetQamMode(pDemod, QamMode) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Set demod symbol rate in Hz.
	if(pDemod->SetSymbolRateHz(pDemod, SymbolRateHz) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Set demod alpha mode.
	if(pDemod->SetAlphaMode(pDemod, AlphaMode) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	// Set demod QAM_AAGC_TARGET and QAM_VTOP according to QAM mode and enhancement mode.
	switch(QamMode)
	{
		default:
		case QAM_QAM_4:
		case QAM_QAM_16:
		case QAM_QAM_32:
		case QAM_QAM_64:

			switch(pNim->EnhancementMode)
			{
				case QAM_DEMOD_EN_NONE:

					if(pDemod->RegAccess.Addr16Bit.SetRegBits(pDemod, QAM_AAGC_TARGET, 0x6b) != FUNCTION_SUCCESS)
						goto error_status_execute_function;

					break;

				default:
				case QAM_DEMOD_EN_AM_HUM:

					if(pDemod->RegAccess.Addr16Bit.SetRegBits(pDemod, QAM_AAGC_TARGET, 0x64) != FUNCTION_SUCCESS)
						goto error_status_execute_function;

					break;
			}

			break;

		case QAM_QAM_128:
		case QAM_QAM_256:
		case QAM_QAM_512:
		case QAM_QAM_1024:

			if(pDemod->RegAccess.Addr16Bit.SetRegBits(pDemod, QAM_AAGC_TARGET, 0x6b) != FUNCTION_SUCCESS)
				goto error_status_execute_function;

			break;
	}


	// Reset demod by software reset.
	if(pDemod->SoftwareReset(pDemod) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	return FUNCTION_SUCCESS;


error_status_set_registers:
error_status_execute_function:
	return FUNCTION_ERROR;
}
Ejemplo n.º 2
0
/**

@see   QAM_NIM_FP_SET_PARAMETERS

*/
s32
rtl2840_max3543_SetParameters(
	QAM_NIM_MODULE *pNim,
	u64 RfFreqHz,
	s32 QamMode,
	u64 SymbolRateHz,
	s32 AlphaMode
	)
{
	QAM_DEMOD_MODULE *pDemod;
	TUNER_MODULE *pTuner;


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


	// Set tuner RF frequency in Hz.
	if(pTuner->SetRfFreqHz(pTuner, RfFreqHz) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Set demod QAM mode.
	if(pDemod->SetQamMode(pDemod, QamMode) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Set demod symbol rate in Hz.
	if(pDemod->SetSymbolRateHz(pDemod, SymbolRateHz) != FUNCTION_SUCCESS)
		goto error_status_execute_function;

	// Set demod alpha mode.
	if(pDemod->SetAlphaMode(pDemod, AlphaMode) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	// Set demod QAM_AAGC_TARGET and QAM_VTOP according to QAM mode and enhancement mode.
	switch(QamMode)
	{
		default:
		case QAM_QAM_4:
		case QAM_QAM_16:
		case QAM_QAM_32:
		case QAM_QAM_64:

			if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, QAM_VTOP, 0x3f) != FUNCTION_SUCCESS)
				goto error_status_execute_function;

			switch(pNim->EnhancementMode)
			{
				case QAM_DEMOD_EN_NONE:

					if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, QAM_AAGC_TARGET, 0x6b) != FUNCTION_SUCCESS)
						goto error_status_execute_function;

					break;

				default:
				case QAM_DEMOD_EN_AM_HUM:

					if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, QAM_AAGC_TARGET, 0x64) != FUNCTION_SUCCESS)
						goto error_status_execute_function;

					break;
			}

			break;

		case QAM_QAM_128:
		case QAM_QAM_256:
		case QAM_QAM_512:
		case QAM_QAM_1024:

			if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, QAM_VTOP, 0x38) != FUNCTION_SUCCESS)
				goto error_status_execute_function;

			if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, QAM_AAGC_TARGET, 0x6b) != FUNCTION_SUCCESS)
				goto error_status_execute_function;

			break;
	}


	// Reset demod by software reset.
	if(pDemod->SoftwareReset(pDemod) != FUNCTION_SUCCESS)
		goto error_status_execute_function;


	return FUNCTION_SUCCESS;


error_status_execute_function:
	return FUNCTION_ERROR;
}