/**

@brief   RTL2832 MAX3543 NIM module builder

Use BuildRtl2832Max3543Module() to build RTL2832 MAX3543 NIM module, set all module function pointers with the
corresponding functions, and initialize module private variables.


@param [in]   ppNim                        Pointer to RTL2832 MAX3543 NIM module pointer
@param [in]   pDvbtNimModuleMemory         Pointer to an allocated DVB-T NIM module memory
@param [in]   I2cReadingByteNumMax         Maximum I2C reading byte number for basic I2C reading function
@param [in]   I2cWritingByteNumMax         Maximum I2C writing byte number for basic I2C writing function
@param [in]   I2cRead                      Basic I2C reading function pointer
@param [in]   I2cWrite                     Basic I2C writing function pointer
@param [in]   WaitMs                       Basic waiting function pointer
@param [in]   DemodDeviceAddr              RTL2832 I2C device address
@param [in]   DemodCrystalFreqHz           RTL2832 crystal frequency in Hz
@param [in]   DemodTsInterfaceMode         RTL2832 TS interface mode for setting
@param [in]   DemodAppMode                 RTL2832 application mode for setting
@param [in]   DemodUpdateFuncRefPeriodMs   RTL2832 update function reference period in millisecond for setting
@param [in]   DemodIsFunc1Enabled          RTL2832 Function 1 enabling status for setting
@param [in]   TunerDeviceAddr              MAX3543 I2C device address
@param [in]   TunerCrystalFreqHz           MAX3543 crystal frequency in Hz


@note
	-# One should call BuildRtl2832Max3543Module() to build RTL2832 MAX3543 NIM module before using it.

*/
void
BuildRtl2832Max3543Module(
	DVBT_NIM_MODULE **ppNim,							// DVB-T NIM dependence
	DVBT_NIM_MODULE *pDvbtNimModuleMemory,

	unsigned long I2cReadingByteNumMax,					// Base interface dependence
	unsigned long I2cWritingByteNumMax,
	BASE_FP_I2C_READ I2cRead,
	BASE_FP_I2C_WRITE I2cWrite,
	BASE_FP_WAIT_MS WaitMs,

	unsigned char DemodDeviceAddr,						// Demod dependence
	unsigned long DemodCrystalFreqHz,
	int DemodTsInterfaceMode,
	int DemodAppMode,
	unsigned long DemodUpdateFuncRefPeriodMs,
	int DemodIsFunc1Enabled,

	unsigned char TunerDeviceAddr,						// Tuner dependence
	unsigned long TunerCrystalFreqHz
	)
{
	DVBT_NIM_MODULE *pNim;



	// Set NIM module pointer with NIM module memory.
	*ppNim = pDvbtNimModuleMemory;
	
	// Get NIM module.
	pNim = *ppNim;

	// Set I2C bridge module pointer with I2C bridge module memory.
	pNim->pI2cBridge = &pNim->I2cBridgeModuleMemory;


	// Set NIM type.
	pNim->NimType = DVBT_NIM_RTL2832_MAX3543;


	// Build base interface module.
	BuildBaseInterface(
		&pNim->pBaseInterface,
		&pNim->BaseInterfaceModuleMemory,
		I2cReadingByteNumMax,
		I2cWritingByteNumMax,
		I2cRead,
		I2cWrite,
		WaitMs
		);

	// Build RTL2832 demod module.
	BuildRtl2832Module(
		&pNim->pDemod,
		&pNim->DvbtDemodModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		DemodDeviceAddr,
		DemodCrystalFreqHz,
		DemodTsInterfaceMode,
		DemodAppMode,
		DemodUpdateFuncRefPeriodMs,
		DemodIsFunc1Enabled
		);

	// Build MAX3543 tuner module.
	BuildMax3543Module(
		&pNim->pTuner,
		&pNim->TunerModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		TunerDeviceAddr,
		TunerCrystalFreqHz,
		RTL2832_MAX3543_STANDARD_MODE_DEFAULT,
		RTL2832_MAX3543_IF_FREQ_HZ_DEFAULT,
		RTL2832_MAX3543_SAW_INPUT_TYPE_DEFAULT
		);


	// Set NIM module function pointers with default functions.
	pNim->GetNimType        = dvbt_nim_default_GetNimType;
	pNim->GetParameters     = dvbt_nim_default_GetParameters;
	pNim->IsSignalPresent   = dvbt_nim_default_IsSignalPresent;
	pNim->IsSignalLocked    = dvbt_nim_default_IsSignalLocked;
	pNim->GetSignalStrength = dvbt_nim_default_GetSignalStrength;
	pNim->GetSignalQuality  = dvbt_nim_default_GetSignalQuality;
	pNim->GetBer            = dvbt_nim_default_GetBer;
	pNim->GetSnrDb          = dvbt_nim_default_GetSnrDb;
	pNim->GetTrOffsetPpm    = dvbt_nim_default_GetTrOffsetPpm;
	pNim->GetCrOffsetHz     = dvbt_nim_default_GetCrOffsetHz;
	pNim->GetTpsInfo        = dvbt_nim_default_GetTpsInfo;
	pNim->UpdateFunction    = dvbt_nim_default_UpdateFunction;

	// Set NIM module function pointers with particular functions.
	pNim->Initialize     = rtl2832_max3543_Initialize;
	pNim->SetParameters  = rtl2832_max3543_SetParameters;


	return;
}
Exemple #2
0
/**

@brief   RTL2840 MAX3543 NIM module builder

Use BuildRtl2840Max3543Module() to build RTL2840 MAX3543 NIM module, set all module function pointers with the
corresponding functions, and initialize module private variables.


@param [in]   ppNim                       Pointer to RTL2840 MAX3543 NIM module pointer
@param [in]   pQamNimModuleMemory         Pointer to an allocated QAM NIM module memory
@param [in]   I2cReadingByteNumMax        Maximum I2C reading byte number for basic I2C reading function
@param [in]   I2cWritingByteNumMax        Maximum I2C writing byte number for basic I2C writing function
@param [in]   I2cRead                     Basic I2C reading function pointer
@param [in]   I2cWrite                    Basic I2C writing function pointer
@param [in]   WaitMs                      Basic waiting function pointer
@param [in]   DemodDeviceAddr             RTL2840 I2C device address
@param [in]   DemodCrystalFreqHz          RTL2840 crystal frequency in Hz
@param [in]   DemodTsInterfaceMode        RTL2840 TS interface mode for setting
@param [in]   DemodEnhancementMode        RTL2840 enhancement mode for setting
@param [in]   TunerDeviceAddr             MAX3543 I2C device address
@param [in]   TunerCrystalFreqHz          MAX3543 crystal frequency in Hz


@note
	-# One should call BuildRtl2840Max3543Module() to build RTL2840 MAX3543 NIM module before using it.

*/
void
BuildRtl2840Max3543Module(
	QAM_NIM_MODULE **ppNim,							// QAM NIM dependence
	QAM_NIM_MODULE *pQamNimModuleMemory,

	u64 I2cReadingByteNumMax,				// Base interface dependence
	u64 I2cWritingByteNumMax,
	BASE_FP_I2C_READ I2cRead,
	BASE_FP_I2C_WRITE I2cWrite,
	BASE_FP_WAIT_MS WaitMs,

	u8 DemodDeviceAddr,					// Demod dependence
	u64 DemodCrystalFreqHz,
	s32 DemodTsInterfaceMode,
	s32 DemodEnhancementMode,

	u8 TunerDeviceAddr,					// Tuner dependence
	u64 TunerCrystalFreqHz
	)
{
	QAM_NIM_MODULE *pNim;



	// Set NIM module pointer with NIM module memory.
	*ppNim = pQamNimModuleMemory;
	
	// Get NIM module.
	pNim = *ppNim;

	// Set I2C bridge module pointer with I2C bridge module memory.
	pNim->pI2cBridge = &pNim->I2cBridgeModuleMemory;

	// Set enhancement mode in NIM module.
	pNim->EnhancementMode = DemodEnhancementMode;


	// Build base interface module.
	BuildBaseInterface(
		&pNim->pBaseInterface,
		&pNim->BaseInterfaceModuleMemory,
		I2cReadingByteNumMax,
		I2cWritingByteNumMax,
		I2cRead,
		I2cWrite,
		WaitMs
		);

	// Build RTL2840 QAM demod module.
	BuildRtl2840Module(
		&pNim->pDemod,
		&pNim->QamDemodModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		DemodDeviceAddr,
		DemodCrystalFreqHz,
		DemodTsInterfaceMode,
		DemodEnhancementMode
		);

	// Build MAX3543 tuner module.
	BuildMax3543Module(
		&pNim->pTuner,
		&pNim->TunerModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		TunerDeviceAddr,
		TunerCrystalFreqHz,
		RTL2840_MAX3543_STANDARD_MODE_DEFAULT,
		RTL2840_MAX3543_IF_FREQ_HZ_DEFAULT,
		RTL2840_MAX3543_SAW_INPUT_TYPE_DEFAULT
		);


	// Set NIM module manipulating function pointers.
	pNim->Initialize        = rtl2840_max3543_Initialize;
	pNim->SetParameters     = rtl2840_max3543_SetParameters;

	// Set NIM module manipulating function pointers with default.
	pNim->GetNimType        = qam_nim_default_GetNimType;
	pNim->GetParameters     = qam_nim_default_GetParameters;
	pNim->IsSignalPresent   = qam_nim_default_IsSignalPresent;
	pNim->IsSignalLocked    = qam_nim_default_IsSignalLocked;
	pNim->GetSignalStrength = qam_nim_default_GetSignalStrength;
	pNim->GetSignalQuality  = qam_nim_default_GetSignalQuality;
	pNim->GetErrorRate      = qam_nim_default_GetErrorRate;
	pNim->GetSnrDb          = qam_nim_default_GetSnrDb;
	pNim->GetTrOffsetPpm    = qam_nim_default_GetTrOffsetPpm;
	pNim->GetCrOffsetHz     = qam_nim_default_GetCrOffsetHz;
	pNim->UpdateFunction    = qam_nim_default_UpdateFunction;


	// Set NIM type.
	pNim->NimType = QAM_NIM_RTL2840_MAX3543;


	return;
}