/*====================================================================
FUNCTION       mtv319_reconfig_n_ber
DESCRIPTION 
DEPENDENCIES
RETURN VALUE
SIDE EFFECTS
======================================================================*/
void mtv319_get_ber(tdmb_bb_sig_type *psigs)
{
  int rssi;

  //TDMB_MSG_RTV_BB("[%s]\n", __func__);

  rssi = (rtvTDMB_GetRSSI() / (int)RTV_TDMB_RSSI_DIVIDER);

  // 04/20 block
  //if(g_sync_status == RTV_TDMB_CHANNEL_LOCK_OK)// 채ë„� lock ?¼ë•Œë§?ê°’ì�„ ?½ì�Œ
      psigs->PCBER = rtvTDMB_GetCER();//(int)RTV_TDMB_CER_DIVIDER;
  //else
  //    psigs->PCBER = 20000;

  psigs->RSBER = rtvTDMB_GetPER();
  psigs->SNR = (rtvTDMB_GetCNR()/100);
  psigs->RSSI = mtv319_Ant_Level(psigs->PCBER);//rtvTDMB_GetCNR() / (int)RTV_TDMB_CNR_DIVIDER;
  psigs->RxPowerLevel = rssi;
  

  //TDMB_MSG_BB("[%s] pcber[%d], rssi[%d] snr[%d] rsber[%d]\n", __func__, psigs->PCBER, psigs->RSSI, psigs->SNR, psigs->RSBER);

#if (defined(FEATURE_TDMB_KERNEL_MSG_ON) && !defined(FEATURE_TS_PKT_MSG))
  TDMB_MSG_RTV_BB("[%s] Packet read Cnt[%d]\n", __func__, g_packet_read_cnt);

  g_packet_read_cnt = 0;
#endif /* FEATURE_TS_PKT_MSG */
}
/*--------------------------------------------------------------------------
int8 tunerbb_drv_mtv319_get_ber(struct broadcast_tdmb_sig_info *dmb_bb_info)
    (1)   Getting the RF/BB Information 
    (2)   Return Value
           Sucess : 1
           Fail : 0 or negative interger (If there is error code)
    (3)   Argument
            struct broadcast_tdmb_sig_info *dmb_bb_info (IN/OUT)
           struct broadcast_tdmb_sig_info
           {
                 uint32 dab_ok;
                 uint32 msc_ber;
                 uint32 sync_lock;
                 uint32 afc_ok;
                 uint32 cir;
                 uint32 fic_ber;
                 uint32 tp_lock;
                 uint32 sch_ber;
                 uint32 tp_err_cnt;
                 uint32 va_ber;
                 byte   srv_state_flag;
                 uint32 antenna_level;
           };

           These paramters are dependent on Information supplied by Device.
---------------------------------------------------------------------------- */
int8	tunerbb_drv_mtv319_get_ber(struct broadcast_tdmb_sig_info *dmb_bb_info)
{
	uint32 lock_mask, msc_cer, fic_cer, per, va_ber;

	msc_cer = rtvTDMB_GetCER();
	dmb_bb_info->msc_ber = msc_cer;
	dmb_bb_info->antenna_level = rtvTDMB_GetAntennaLevel(msc_cer);

	lock_mask = rtvTDMB_GetLockStatus();
	if (lock_mask & RTV_TDMB_OFDM_LOCK_MASK)
	{
		dmb_bb_info->sync_lock = 1;
		dmb_bb_info->dab_ok = 1;
		dmb_bb_info->cir = 1;
		dmb_bb_info->sch_ber = 1;
	}
	else
	{
		dmb_bb_info->sync_lock = 0;
		dmb_bb_info->dab_ok = 0;
		dmb_bb_info->cir = 0;
		dmb_bb_info->sch_ber = 0;
	}

	if (lock_mask & RTV_TDMB_AGC_LOCK_MASK)
		dmb_bb_info->afc_ok = 1;
	else
		dmb_bb_info->afc_ok = 0;

	if ((opened_subch_info[0].svc_type == MTV319_DMB)
	|| (opened_subch_info[0].svc_type == MTV319_VISUAL))
	{
		if (lock_mask & RTV_TDMB_FEC_LOCK_MASK)
			dmb_bb_info->tp_lock = 1;
		else
			dmb_bb_info->tp_lock = 0;

		va_ber = rtvTDMB_GetBER();
		dmb_bb_info->va_ber = va_ber;

		per = rtvTDMB_GetPER();
		dmb_bb_info->tp_err_cnt = per;
	}
	else
	{
		dmb_bb_info->tp_lock = 0;
		dmb_bb_info->tp_err_cnt = 0;
		dmb_bb_info->va_ber = 0;
	}

	fic_cer = rtvTDMB_GetFicCER();
	dmb_bb_info->fic_ber = fic_cer;

	return MTV319_RESULT_SUCCESS;
}
static void mtv318_get_dm(struct tdmb_dm *info)
{
	if (mtv318_pwr_on == true && mtv318_on_air == true) {
		info->rssi = (rtvTDMB_GetRSSI() / RTV_TDMB_RSSI_DIVIDER);
		info->per = rtvTDMB_GetPER();
		info->ber = rtvTDMB_GetCER();
		info->antenna = rtvTDMB_GetAntennaLevel(info->ber);
	} else {
		info->rssi = 100;
		info->ber = 2000;
		info->per = 0;
		info->antenna = 0;
	}
}