/** @see DVBT_NIM_FP_SET_PARAMETERS */ int rtl2832_fc2580_SetParameters( DVBT_NIM_MODULE *pNim, unsigned long RfFreqHz, int BandwidthMode ) { TUNER_MODULE *pTuner; DVBT_DEMOD_MODULE *pDemod; FC2580_EXTRA_MODULE *pTunerExtra; int TunerBandwidthMode; // Get tuner module and demod module. pTuner = pNim->pTuner; pDemod = pNim->pDemod; // Get tuner extra module. pTunerExtra = (FC2580_EXTRA_MODULE *)pTuner->pExtra; // Enable demod DVBT_IIC_REPEAT. if(pDemod->SetRegBitsWithPage(pDemod, DVBT_IIC_REPEAT, 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; // Determine TunerBandwidthMode according to bandwidth mode. switch(BandwidthMode) { default: case DVBT_BANDWIDTH_6MHZ: TunerBandwidthMode = FC2580_BANDWIDTH_6000000HZ; break; case DVBT_BANDWIDTH_7MHZ: TunerBandwidthMode = FC2580_BANDWIDTH_7000000HZ; break; case DVBT_BANDWIDTH_8MHZ: TunerBandwidthMode = FC2580_BANDWIDTH_8000000HZ; break; } // Set tuner bandwidth mode with TunerBandwidthMode. if(pTunerExtra->SetBandwidthMode(pTuner, TunerBandwidthMode) != FUNCTION_SUCCESS) 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; // Set demod bandwidth mode. if(pDemod->SetBandwidthMode(pDemod, BandwidthMode) != FUNCTION_SUCCESS) goto error_status_execute_function; // Reset demod particular registers. if(pDemod->ResetFunction(pDemod) != FUNCTION_SUCCESS) goto error_status_execute_function; // Reset demod by software reset. if(pDemod->SoftwareReset(pDemod) != FUNCTION_SUCCESS) goto error_status_execute_function; return FUNCTION_SUCCESS; error_status_execute_function: error_status_set_registers: return FUNCTION_ERROR; }
/** @see DTMB_NIM_FP_INITIALIZE */ int rtl2836_fc2580_Initialize( DTMB_NIM_MODULE *pNim ) { typedef struct { int RegBitName; unsigned long Value; } REG_VALUE_ENTRY; static const REG_VALUE_ENTRY AdditionalInitRegValueTable[RTL2836_FC2580_ADDITIONAL_INIT_REG_TABLE_LEN] = { // RegBitName, Value {DTMB_TARGET_VAL, 0x38 }, }; TUNER_MODULE *pTuner; DTMB_DEMOD_MODULE *pDemod; FC2580_EXTRA_MODULE *pTunerExtra; int i; int RegBitName; unsigned long Value; // Get tuner module and demod module. pTuner = pNim->pTuner; pDemod = pNim->pDemod; // Get tuner extra module. pTunerExtra = &(pTuner->Extra.Fc2580); // Enable demod DTMB_I2CT_EN_CTRL. if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, DTMB_I2CT_EN_CTRL, 0x1) != FUNCTION_SUCCESS) goto error_status_set_registers; // Initialize tuner. if(pTuner->Initialize(pTuner) != FUNCTION_SUCCESS) goto error_status_execute_function; // Set tuner bandwidth mode with 8 MHz. if(pTunerExtra->SetBandwidthMode(pTuner, FC2580_BANDWIDTH_8000000HZ) != FUNCTION_SUCCESS) goto error_status_execute_function; // Disable demod DTMB_I2CT_EN_CTRL. if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, DTMB_I2CT_EN_CTRL, 0x0) != FUNCTION_SUCCESS) goto error_status_set_registers; // Initialize demod. if(pDemod->Initialize(pDemod) != FUNCTION_SUCCESS) goto error_status_execute_function; // Set demod IF frequency with 0 Hz. if(pDemod->SetIfFreqHz(pDemod, IF_FREQ_0HZ) != FUNCTION_SUCCESS) goto error_status_execute_function; // Set demod spectrum mode with SPECTRUM_NORMAL. if(pDemod->SetSpectrumMode(pDemod, SPECTRUM_NORMAL) != FUNCTION_SUCCESS) goto error_status_execute_function; // Set demod registers. for(i = 0; i < RTL2836_FC2580_ADDITIONAL_INIT_REG_TABLE_LEN; i++) { // Get register bit name and its value. RegBitName = AdditionalInitRegValueTable[i].RegBitName; Value = AdditionalInitRegValueTable[i].Value; // Set demod registers if(pDemod->RegAccess.Addr8Bit.SetRegBitsWithPage(pDemod, RegBitName, Value) != FUNCTION_SUCCESS) goto error_status_set_registers; } return FUNCTION_SUCCESS; error_status_execute_function: error_status_set_registers: return FUNCTION_ERROR; }