/** @see DVBT_NIM_FP_GET_CR_OFFSET_HZ */ s32 dvbt_nim_default_GetCrOffsetHz( DVBT_NIM_MODULE *pNim, s64 *pCrOffsetHz ) { DVBT_DEMOD_MODULE *pDemod; // Get demod module. pDemod = pNim->pDemod; // Get CR offset in Hz from demod. if(pDemod->GetCrOffsetHz(pDemod, pCrOffsetHz) != FUNCTION_SUCCESS) goto error_status_execute_function; return FUNCTION_SUCCESS; error_status_execute_function: return FUNCTION_ERROR; }
static int fe_demod_info_ioctrl(struct dvb_frontend *fe, void *parg) { struct rtl2832u_ioctl_info_struct* info_ctrl = (struct rtl2832u_ioctl_info_struct*)parg; int ret =-1; struct rtl2832_state* p_state = fe->demodulator_priv; DVBT_NIM_MODULE *pNim; DVBT_DEMOD_MODULE *pDemod; u16 strength=0; u32 quality=0; int answer=0; unsigned long BerNum=0,BerDen=1; long SnrDbNum=0, SnrDbDen=1; long tr_ppm=0,cr_hz=0; unsigned long data_length=info_ctrl->data_length; int info_cmd = info_ctrl->cmd_num; deb_info("+%s : ioctl -demod info cmd = %d ,data length= %d (must > %d )\n", __FUNCTION__,info_cmd,(int)data_length,INFO_DEMOD_DATA_LEN); if (p_state->demod_type != RTL2832) { deb_info("ERROR::demod type not rtl2832u...\n"); return -1; } if (data_length < INFO_DEMOD_DATA_LEN) { deb_info("ERROR::data length is too short...,must be greater than %d \n",INFO_DEMOD_DATA_LEN); return -1; } pNim = p_state->pNim; if (pNim == NULL) { deb_info("ERROR::nim is null...\n"); return -1; } pDemod=pNim->pDemod; if ((info_cmd != FE_GET_SIGN_STRENGTH) && (info_cmd != FE_GET_SIGN_QUALITY)) { if( mutex_lock_interruptible(&p_state->i2c_repeater_mutex) ) { return -10; } } info_ctrl->data[INFO_DATA_VALUE]=0x00000000; info_ctrl->data[INFO_DATA_DEN]=1; switch(info_cmd) { case FE_GET_SIGN_STRENGTH: if (rtl2832_read_signal_strength(fe,&strength) != 0) { ret=-10; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=(unsigned long)strength; info_ctrl->data[INFO_DATA_DEN]=1; // deb_info("rtl2832u ioctl (FE_GET_SIGN_STRENGTH)- strength = %x (%x). \n",strength,info_ctrl->data[INFO_DATA_VALUE] ); } break; case FE_GET_SIGN_QUALITY: if (rtl2832_read_signal_quality(fe,&quality) != 0) { ret=-10; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=(unsigned long)quality; info_ctrl->data[INFO_DATA_DEN]=1; // deb_info("rtl2832u ioctl (FE_GET_SIGN_QUALITY)- quality = %x (%x). \n",quality,info_ctrl->data[INFO_DATA_VALUE] ); } break; case FE_GET_SIGN_LOCK: answer=NO; if (pDemod->IsSignalLocked(pDemod, &answer) != FUNCTION_SUCCESS) { ret=-10; } else { if (answer == YES) { info_ctrl->data[INFO_DATA_VALUE]=1; } else info_ctrl->data[INFO_DATA_VALUE]=0; info_ctrl->data[INFO_DATA_DEN]=1; ret=10; } break; case FE_GET_DEMOD_BER: if(pDemod->GetBer(pDemod, &BerNum, &BerDen) != FUNCTION_SUCCESS) { ret=-10; info_ctrl->data[INFO_DATA_VALUE]=19616; info_ctrl->data[INFO_DATA_DEN]=1; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=BerNum; info_ctrl->data[INFO_DATA_DEN]=BerDen; } break; case FE_GET_DEMOD_SNR_DB: if(pDemod->GetSnrDb(pDemod, &SnrDbNum, &SnrDbDen) != FUNCTION_SUCCESS) { ret=-10; info_ctrl->data[INFO_DATA_VALUE]=0; info_ctrl->data[INFO_DATA_DEN]=1; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=SnrDbNum; info_ctrl->data[INFO_DATA_DEN]=SnrDbDen; } break; case FE_GET_DEMOD_TR_PPM: if(pDemod->GetTrOffsetPpm(pDemod, &tr_ppm) != FUNCTION_SUCCESS) { ret=-10; info_ctrl->data[INFO_DATA_VALUE]=0; info_ctrl->data[INFO_DATA_DEN]=1; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=tr_ppm; info_ctrl->data[INFO_DATA_DEN]=1; } break; case FE_GET_DEMOD_CR_HZ: if(pDemod->GetCrOffsetHz(pDemod, &cr_hz) != FUNCTION_SUCCESS) { ret=-10; info_ctrl->data[INFO_DATA_VALUE]=0; info_ctrl->data[INFO_DATA_DEN]=1; } else { ret=10; info_ctrl->data[INFO_DATA_VALUE]=cr_hz; info_ctrl->data[INFO_DATA_DEN]=1; } break; default: deb_info("ERROR::rtl2832u ioctl - std info cmd ret= unknow info commond. \n" ); ret=-1; break; } if ((info_cmd != FE_GET_SIGN_STRENGTH) && (info_cmd != FE_GET_SIGN_QUALITY)) { mutex_unlock(&p_state->i2c_repeater_mutex); } // deb_info("-%s :ioctl - std info cmd ret= %x,data=%x,den=%x\n", __FUNCTION__,ret,(int)info_ctrl->data[INFO_DATA_VALUE],info_ctrl->data[INFO_DATA_DEN]); return ret; }