static int viterbi_rt_ber_read(unsigned int* ber) { u32 vframe, esum; u8 vt_ctrl=0; int res = BBM_OK; BBM_READ(NULL, BBM_VT_CONTROL, &vt_ctrl); vt_ctrl |= 0x10; BBM_WRITE(NULL, BBM_VT_CONTROL, vt_ctrl); BBM_LONG_READ(NULL,BBM_VT_RT_BER_PERIOD, &vframe); BBM_LONG_READ(NULL,BBM_VT_RT_ERROR_SUM, &esum); vt_ctrl &= ~0x10; BBM_WRITE(NULL,BBM_VT_CONTROL, vt_ctrl); if(vframe == 0) { *ber = 0; return BBM_NOK; } // *ber = ((float)esum / (float)vframe) * 10000.0f; *ber = (esum * 10000 / vframe); return res; }
void mmi_bbm_write(int argc, char *argv[]) { u16 dest_addr; u8 dest_data; u8 length; int i; if(argc == 3) { dest_addr = htoi(argv[1]); dest_data = htoi(argv[2]); BBM_WRITE(hDevice, dest_addr, dest_data); } else if(argc == 4) { dest_addr = htoi(argv[1]); dest_data = htoi(argv[2]); length = htoi(argv[3]); if(dest_data == 0x1234) { dest_data = 0; for(i=0; i<=length; i++) BBM_WRITE(hDevice, dest_addr+i, dest_data); } else { for(i=0; i<length; i++) BBM_WRITE(hDevice, dest_addr+i, dest_data); } } else { print_log("usage : %s [start addr] [data] [length] ; byte write command\n", (int)argv[0]); } }
//static fci_u16 tunerbb_drv_fc8050_rserror_count(void) static fci_u16 tunerbb_drv_fc8050_rserror_count(fci_u16 *nframe)//for dummy channel. { //fci_u32 rt_esum; fci_u16 rt_nframe, rt_rserror; fci_u8 rs_ctrl=0; #ifdef MON_BURST_MODE uint8 burst[12]; rs_ctrl = 0x21; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); BBM_BULK_READ(0, BBM_RS_RT_BER_PER, &burst[0], 4); //BBM_LONG_READ(0, BBM_RS_RT_BER_PER, burst[0]); rt_nframe = (uint16)(*(uint16*)burst); rt_rserror = (uint16)(*((uint16*)burst+1)); rs_ctrl = 0x1; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); #else BBM_READ(0, BBM_RS_CONTROL, &rs_ctrl); rs_ctrl |= 0x20; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); BBM_WORD_READ(0, BBM_RS_RT_BER_PER, &rt_nframe); //실시간으로 count 되는 frame 수 //BBM_LONG_READ(0, BBM_RS_RT_ERR_SUM, &rt_esum); BBM_WORD_READ(0, BBM_RS_RT_FAIL_CNT, &rt_rserror); rs_ctrl &= ~0x20; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); #endif *nframe=rt_nframe; //실시간으로 count 되는 frame 수 return rt_rserror; }
void fc8050_isr_interruptclear(void) { u8 extIntStatus = 0; BBM_READ(NULL, BBM_COM_INT_STATUS, &extIntStatus); BBM_WRITE(NULL, BBM_COM_INT_STATUS, extIntStatus); BBM_WRITE(NULL, BBM_COM_INT_STATUS, 0x00); }
void mmi_bbm_verify(int argc, char *argv[]) { u8 dest_addr; u8 dest_data, temp_data; int i; int retry; switch(argc) { case 2: dest_data = 0xAA; dest_addr = htoi(argv[1]); print_log("%s [0x%X] [0x%X] [0x%X]\n", argv[0], dest_addr, dest_data, 1); BBM_WRITE(hDevice, dest_addr, dest_data); //Sleep(10); BBM_READ(hDevice, dest_addr, &temp_data); if(dest_data != temp_data) { print_log("Mismatch Data ; addr[0x%X] write [0x%X] : read [0x%X]\n", dest_addr, dest_data, temp_data); } break; case 3: dest_data = 0xff; dest_addr = htoi(argv[1]); retry = htoi(argv[2]); print_log("%s [0x%X] [0x%X]\n", argv[0], dest_addr, retry); for(i=0; i<retry; i++) { BBM_WRITE(hDevice, dest_addr, dest_data); //Sleep(10); BBM_READ(hDevice, dest_addr, &temp_data); if(dest_data != temp_data) { print_log("\n 0x%xth Mismatch Data ; addr[0x%X] write [0x%X] : read [0x%X]\n", i, dest_addr, dest_data, temp_data); } dest_data--; print_log("."); } break; default: print_log("Usage : %s [address] [retry]\n", argv[0]); break; } }
static uint32 tunerbb_drv_fc8050_get_viterbi_ber(void) //msc_ber { uint8 vt_ctrl; uint32 bper, tbe; uint32 ber; BBM_READ(0, BBM_VT_CONTROL, &vt_ctrl); vt_ctrl |= 0x10; BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); BBM_LONG_READ(0, BBM_VT_RT_BER_PERIOD, &bper); BBM_LONG_READ(0, BBM_VT_RT_ERROR_SUM, &tbe); vt_ctrl &= ~0x10; BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); if(bper == 0) { // LGE_INTG_090217 ber = MAX_MSC_BER; } else if(tbe == 0) { ber = 0; } else { //ber = ((tbe / bper) * 100000); //ber = (tbe * 100000) / bper; if(tbe > 42949) { ber = ((tbe * 1000)/bper)*100; } else { ber = (tbe*100000)/bper; } } ber = (ber >= MAX_MSC_BER) ? MAX_MSC_BER : ber; /* ber must bigger than 0 because FactoryTest issue */ if(ber == 0) { ber = 1; } return ber; }
/*==================================================================== FUNCTION fc8150_bb_set_frequency DESCRIPTION DEPENDENCIES RETURN VALUE SIDE EFFECTS ======================================================================*/ int fc8150_bb_set_frequency(int freq_idx) { int ret = 0; u32 f_rf = 0; //ISDBT_MSG_FC8150_BB("[%s] start \n", __func__); f_rf = (freq_idx - 13) * 6000 + 473143; ISDBT_MSG_FC8150_BB("[%s] set FREQ = %d \n", __func__, f_rf); ret = BBM_TUNER_SET_FREQ(NULL, f_rf); if (ret != BBM_OK) { ISDBT_MSG_FC8150_BB("[%s] fail to BBM_TUNER_SET_FREQ (f_rf)%d (ret)%d\n", __func__, f_rf, ret); return -1; } #if 1 // for test ret = BBM_SCAN_STATUS(NULL); if (ret) ISDBT_MSG_FC8150_BB("[%s] LOCK FAIL!\n", __func__); else ISDBT_MSG_FC8150_BB("[%s] LOCK OK! \n", __func__); #endif // 0 BBM_WRITE(0, BBM_BUF_INT, 0x01); //ISDBT_MSG_FC8150_BB("[%s] end \n", __func__); return 0; }
void ptcheck_thread(void *param) { data_dump_param *data = (data_dump_param*)param; int hDevice = data->dev; int num = data->num; u8 buf[MSC_BUF_SIZE]; int check_cnt_size=0; int size; FILE *f; char *f_name[128]; ptcheck_thread_start = 1; print_log("pattern check start \n"); sprintf((void*)f_name,DUMP_PATH"pattern_ts.dat"); f = fopen((void*)f_name, "wb"); #ifdef FEATURE_TS_CHECK create_tspacket_anal(); #endif mtv_ts_start(hDevice); while(1) { size = mtv_data_read(hDevice, buf, MSC_BUF_SIZE); #ifdef FEATURE_TS_CHECK if(!(size%188)) { put_ts_packet(0, &buf[0], size); check_cnt_size+=size; fwrite(&buf[0], 1, size, f); } #ifdef FEATURE_OVERRUN_CHECK { u8 over; BBM_READ(hDevice, 0x8001, &over); if(over) { BBM_WRITE(hDevice, 0x8001, over); print_log("TS OVERRUN : %d\n", over); } } #endif if(check_cnt_size>188*100) { print_pkt_log(); check_cnt_size=0; } #endif if(!ptcheck_thread_start) break; } mtv_ts_stop(hDevice); fclose(f); print_log("\nEnd pattern check\n"); }
static fci_u16 tunerbb_drv_fc8050_rserror_count(void) { fci_u32 rt_esum; fci_u16 rt_nframe, rt_rserror; fci_u8 rs_ctrl=0; BBM_READ(0, BBM_RS_CONTROL, &rs_ctrl); rs_ctrl |= 0x20; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); BBM_WORD_READ(0, BBM_RS_RT_BER_PER, &rt_nframe); BBM_LONG_READ(0, BBM_RS_RT_ERR_SUM, &rt_esum); BBM_WORD_READ(0, BBM_RS_RT_FAIL_CNT, &rt_rserror); rs_ctrl &= ~0x20; BBM_WRITE(0, BBM_RS_CONTROL, rs_ctrl); return rt_rserror; }
void tdmb_fc8050_spi_write_read_test(void) { uint16 i; uint32 wdata = 0; uint32 ldata = 0; uint32 data = 0; uint32 temp = 0; #define TEST_CNT 5 tdmb_fc8050_power_on(); for(i=0;i<TEST_CNT;i++) { BBM_WRITE(NULL, 0x05, i & 0xff); BBM_READ(NULL, 0x05, (fci_u8*)&data); printk("FC8000 byte test (0x%x,0x%x)\n", i & 0xff, data); if((i & 0xff) != data) printk("FC8000 byte test (0x%x,0x%x)\n", i & 0xff, data); } for(i=0;i<TEST_CNT;i++) { BBM_WORD_WRITE(NULL, 0x0210, i & 0xffff); BBM_WORD_READ(NULL, 0x0210, (fci_u16*)&wdata); printk("FC8000 word test (0x%x,0x%x)\n", i & 0xffff, wdata); if((i & 0xffff) != wdata) printk("FC8000 word test (0x%x,0x%x)\n", i & 0xffff, wdata); } for(i=0;i<TEST_CNT;i++) { BBM_LONG_WRITE(NULL, 0x0210, i & 0xffffffff); BBM_LONG_READ(NULL, 0x0210, (fci_u32*)&ldata); printk("FC8000 long test (0x%x,0x%x)\n", i & 0xffffffff, ldata); if((i & 0xffffffff) != ldata) printk("FC8000 long test (0x%x,0x%x)\n", i & 0xffffffff, ldata); } data = 0; for(i=0;i<TEST_CNT;i++) { temp = i&0xff; BBM_TUNER_WRITE(NULL, 0x12, 0x01, (fci_u8*)&temp, 0x01); BBM_TUNER_READ(NULL, 0x12, 0x01, (fci_u8*)&data, 0x01); printk("FC8000 tuner test (0x%x,0x%x)\n", i & 0xff, data); if((i & 0xff) != data) printk("FC8000 tuner test (0x%x,0x%x)\n", i & 0xff, data); } temp = 0x51; BBM_TUNER_WRITE(NULL, 0x12, 0x01, (fci_u8*)&temp, 0x01 ); tdmb_fc8050_power_off(); }
/*==================================================================== FUNCTION fc8150_bb_get_status DESCRIPTION DEPENDENCIES RETURN VALUE SIDE EFFECTS ======================================================================*/ void fc8150_bb_get_status(tIsdbtSigInfo *sig_info) { struct dm_st { u8 start; s8 rssi; u8 wscn; u8 reserved; u16 main_rxd_rsps; u16 main_err_rsps; u32 main_err_bits; u32 dmp_rxd_bits; u32 dmp_err_bits; u16 inter_rxd_rsps; u16 inter_err_rsps; u32 inter_err_bits; u8 lna_code; u8 rfvga; u8 k; u8 csf_gain; u8 pga_gain; u8 extlna; u8 high_current_mode_gain; u8 extlna_gain; } dm; /** read info */ BBM_WRITE(NULL, BBM_REQ_BER, 0x0e); BBM_BULK_READ(NULL, BBM_DM_DATA, (u8*) &dm + 1, sizeof(dm) - 1); /** calc BER */ if (dm.dmp_rxd_bits) sig_info->ber = ((u32)dm.dmp_err_bits * 10000 / (u32)dm.dmp_rxd_bits); else sig_info->ber = 10000; /** calc PER */ if (dm.inter_rxd_rsps) sig_info->per = ((u32)dm.inter_err_rsps * 10000 / (u32)dm.inter_rxd_rsps); else sig_info->per = 10000; /** read CN */ sig_info->cninfo = dm.wscn; }
unsigned char DMBDrv_DeInit(void) { gInitFlag = 0; BBM_VIDEO_DESELECT(NULL, 0, 0, 0); BBM_AUDIO_DESELECT(NULL, 0, 3); BBM_DATA_DESELECT(NULL, 0, 2); BBM_WRITE(NULL, BBM_COM_STATUS_ENABLE, 0x00); msWait(100); BBM_DEINIT(NULL); BBM_FIC_CALLBACK_DEREGISTER(NULL); BBM_MSC_CALLBACK_DEREGISTER(NULL); BBM_HOSTIF_DESELECT(NULL); return TDMB_SUCCESS; }
// Modified by somesoo 20100730 for removing green block effect int8 tunerbb_drv_fc8050_multi_set_channel(int32 freq_num, uint8 subch_cnt, uint8 subch_id[ ], uint8 op_mode[ ]) { int8 res = BBM_OK; int32 freq = 0; uint8 dmb_cnt=0; int i; fc8050_service_type svcType = FC8050_SERVICE_MAX; unsigned short mask; // Added by somesoo 20100730 for removing green block effect fc8050_isr_control(0); for(i=0;i<subch_cnt;i++) { serviceType[i] = op_mode[i]; if(FC8050_ENSQUERY != op_mode[i]) tunerbb_drv_fc8050_stop(); else svcType = FC8050_ENSQUERY; } tunerbb_drv_fc8050_control_fic(0); /* Change freq_num(channel num) to frequency */ freq = tunerbb_drv_convert_chnum_to_freq(freq_num); if(freq == 0) { return FC8050_RESULT_ERROR; } res = BBM_TUNER_SET_FREQ(0, freq); if(res) { return FC8050_RESULT_ERROR; } if(svcType == FC8050_ENSQUERY) { #ifdef FEATURE_FIC_BER BBM_WRITE(0, BBM_VT_CONTROL, 0x01); #endif if(BBM_SCAN_STATUS(0)) { return FC8050_RESULT_ERROR; } } #ifdef FEATURE_FIC_BER else BBM_WRITE(0, BBM_VT_CONTROL, 0x03); #endif BBM_WORD_READ(NULL, BBM_BUF_ENABLE, &mask); mask &= 0x100; for(i=0;i<subch_cnt;i++) { switch(serviceType[i]) { case FC8050_DAB: mask |= (1<<DAB_SVC_ID); BBM_AUDIO_SELECT(0, subch_id[i],DAB_SVC_ID); #ifdef STREAM_TS_UPLOAD fc8050_demux_select_channel(subch_id[i], DAB_SVC_ID); #else g_chinfo[subch_id[i]]=DAB_SVC_ID; #endif break; case FC8050_DMB: case FC8050_VISUAL: mask |= (1 << (DMB_SVC_ID+dmb_cnt)); if(dmb_cnt<2) { BBM_VIDEO_SELECT(0, subch_id[i], DMB_SVC_ID+dmb_cnt, dmb_cnt); #ifdef STREAM_TS_UPLOAD fc8050_demux_select_video(subch_id[i], DMB_SVC_ID+dmb_cnt); #else g_chinfo[subch_id[i]]=dmb_cnt; #endif dmb_cnt++; } else res=BBM_NOK; break; case FC8050_DATA: mask |= (1<<DAT_SVC_ID); BBM_DATA_SELECT(0, subch_id[i], DAT_SVC_ID); #ifdef STREAM_TS_UPLOAD fc8050_demux_select_channel(subch_id[i], DAT_SVC_ID); #else g_chinfo[subch_id[i]]=DAT_SVC_ID; #endif break; case FC8050_ENSQUERY: tunerbb_drv_fc8050_control_fic(1); res = BBM_OK; break; default: res = BBM_NOK; break; } } BBM_WORD_WRITE(NULL, BBM_BUF_ENABLE, mask); tot_subch_cnt = subch_cnt; // Added by somesoo 20100730 for removing green block effect if(svcType != FC8050_ENSQUERY) fc8050_isr_control(1); if(res) return FC8050_RESULT_ERROR; else return FC8050_RESULT_SUCCESS; }
void fc8101_isr(HANDLE hDevice) { u8 extOverStatus = 0; u8 extIntStatus = 0; int mod, div; int i; bbm_ext_read(hDevice, BBM_COM_INT_STATUS, &extIntStatus); bbm_ext_write(hDevice, BBM_COM_INT_STATUS, extIntStatus); bbm_ext_write(hDevice, BBM_COM_INT_STATUS, 0x00); bbm_ext_read(hDevice, BBM_COM_OVERFLOW, &extOverStatus); if(extOverStatus) { BBM_WRITE(0, BBM_SYSRST, 2); bbm_ext_write(hDevice, BBM_COM_RESET, 0x01); //Ext buffer reset bbm_ext_write(hDevice, BBM_COM_RESET, 0x03); PRINTF(0, "FC8101 Buffer Overflow : 0x%x\n", extOverStatus); } else if(extIntStatus & BBM_MF_INT) { u16 size; bbm_ext_word_read(hDevice, BBM_BUF_THR, &size); size += 1; if(size) { mod = size / SPI_READ_BLK_SZ; div = size % SPI_READ_BLK_SZ; for(i=0; i<mod; i++) bbm_ext_data(hDevice, BBM_BUF_RD, &tsBuffer[4+SPI_READ_BLK_SZ*i], SPI_READ_BLK_SZ); if(div) { bbm_ext_data(hDevice, BBM_BUF_RD, &tsBuffer[4+SPI_READ_BLK_SZ*mod], div); } if(pTSCallback) { int j; int sync_cnt = 0,tei_cnt = 0; for(j = 0; j < size ; j += 188) { if(tsBuffer[4 + j] != 0x47) { sync_cnt++; } if((tsBuffer[4 + j + 1]&0x80) != 0) { tei_cnt++; } } (*pTSCallback)(gTSUserData, &tsBuffer[4], (size)); if((sync_cnt>0||tei_cnt>0)) { PRINTF(0, "[0926][ERROR PKT] sync %d, tei %d\n", sync_cnt, tei_cnt); } } } } }
static uint32 tunerbb_drv_fc8050_get_viterbi_ber(void) //msc_ber { uint8 vt_ctrl; uint32 bper, tbe; uint32 ber; #ifdef MON_BURST_MODE uint8 burst[12]; #ifdef FEATURE_FIC_BER if(serviceType[0]==FC8050_ENSQUERY) vt_ctrl = 0x11; else vt_ctrl = 0x13; #else vt_ctrl = 0x13; #endif BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); BBM_BULK_READ(0, BBM_VT_RT_BER_PERIOD, &burst[0], 8); bper = (uint32)(*(uint32*)burst); tbe = (uint32)(*((uint32*)burst+1)); #ifdef FEATURE_FIC_BER if(serviceType[0]==FC8050_ENSQUERY) vt_ctrl = 0x1; else vt_ctrl = 0x3; #else vt_ctrl = 0x3; #endif BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); #else BBM_READ(0, BBM_VT_CONTROL, &vt_ctrl); vt_ctrl |= 0x10; BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); BBM_LONG_READ(0, BBM_VT_RT_BER_PERIOD, &bper); BBM_LONG_READ(0, BBM_VT_RT_ERROR_SUM, &tbe); vt_ctrl &= ~0x10; BBM_WRITE(0, BBM_VT_CONTROL, vt_ctrl); #endif if(bper == 0) { // LGE_INTG_090217 ber = MAX_MSC_BER; } else if(tbe == 0) { ber = 0; } else { //ber = ((tbe / bper) * 100000); //ber = (tbe * 100000) / bper; if(tbe > 42949) { ber = ((tbe * 1000)/bper)*100; } else { ber = (tbe*100000)/bper; } } ber = (ber >= MAX_MSC_BER) ? MAX_MSC_BER : ber; /* ber must bigger than 0 because FactoryTest issue */ if(ber == 0) { ber = 1; } return ber; }
/*==================================================================== FUNCTION fc8150_bb_set_scan_mode DESCRIPTION DEPENDENCIES RETURN VALUE SIDE EFFECTS ======================================================================*/ void fc8150_bb_set_scan_mode(int scanmode) { ISDBT_MSG_FC8150_BB("[%s] start (scanmode)%d\n", __func__, scanmode); if (scanmode) { if (!scan_mode) { BBM_WRITE(0, 0x3040, 0x00); BBM_WRITE(0, 0x3004, 0x02); BBM_WRITE(0, 0x3006, 0x02); BBM_WRITE(0, 0x2020, 0x18); BBM_WRITE(0, 0x2021, 0x14); BBM_WRITE(0, 0x2022, 0xea); BBM_WRITE(0, 0x2082, 0x70); BBM_WRITE(0, 0x2083, 0x70); BBM_WRITE(0, 0x2084, 0x70); BBM_WRITE(0, 0x2085, 0x60); scan_mode = 1; ISDBT_MSG_FC8150_BB("[%s] SCAN MODE ON\n", __func__); } } else { if (scan_mode) { BBM_WRITE(0, 0x3004, 0x04); BBM_WRITE(0, 0x3006, 0x04); BBM_WRITE(0, 0x2020, 0x10); BBM_WRITE(0, 0x2021, 0x0e); BBM_WRITE(0, 0x2022, 0x4a); BBM_WRITE(0, 0x2082, 0x45); BBM_WRITE(0, 0x2083, 0x5f); BBM_WRITE(0, 0x2084, 0x37); BBM_WRITE(0, 0x2085, 0x30); scan_mode = 0; ISDBT_MSG_FC8150_BB("[%s] SCAN MODE OFF\n", __func__); } } //ISDBT_MSG_FC8150_BB("[%s] end \n", __func__); }
/*==================================================================== FUNCTION fc8150_bb_get_tuner_info DESCRIPTION DEPENDENCIES RETURN VALUE SIDE EFFECTS ======================================================================*/ void fc8150_bb_get_tuner_info(tIsdbtTunerInfo* tuner_info) { u8 mode; u8 buf_lock; s32 i32RSSI; u32 ui32BER; u32 ui32PER; s32 CN; static u32 prelvl = 0; u32 ui32Antlvl; u16 AGC; u8 GI; u8 TM; struct dm_st { u8 start; s8 rssi; u8 wscn; u8 reserved; u16 main_rxd_rsps; u16 main_err_rsps; u32 main_err_bits; u32 dmp_rxd_bits; u32 dmp_err_bits; u16 inter_rxd_rsps; u16 inter_err_rsps; u32 inter_err_bits; u8 lna_code; u8 rfvga; u8 k; u8 csf_gain; u8 pga_gain; u8 extlna; u8 high_current_mode_gain; u8 extlna_gain; } dm; BBM_READ(NULL, 0x5053, &buf_lock); ISDBT_MSG_FC8150_BB("[%s] Lock = %d\n", __func__, buf_lock); if (!buf_lock) ui32Antlvl = prelvl = 0; tuner_info->rssi = buf_lock; BBM_WRITE(NULL, BBM_REQ_BER, 0x0e); BBM_BULK_READ(NULL, BBM_DM_DATA, (u8*) &dm + 1, sizeof(dm) - 1); ISDBT_MSG_FC8150_BB("[%s] main_rxd_rsps: %d, dmp_rxd_bits: %d, inter_rxd_rsps: %d\n", __func__, dm.main_rxd_rsps, dm.dmp_rxd_bits, dm.inter_rxd_rsps); if (dm.inter_rxd_rsps) ui32PER = ((u32)dm.inter_err_rsps * 10000 / (u32)dm.inter_rxd_rsps); else ui32PER = 10000; if (dm.dmp_rxd_bits) ui32BER = ((u32)dm.dmp_err_bits * 10000 / (u32)dm.dmp_rxd_bits); else ui32BER = 10000; i32RSSI = dm.rssi; CN = dm.wscn; BBM_READ(NULL, 0x302a, &mode); GI = (mode & 0x70) >> 4; // 1 : 1/32, 2 : 1/16, 3 : 1/8, 4 : 1/4 TM = mode & 0x03; // 1 : mode1, 2 : mode2, 3 : mode3 BBM_WORD_READ(0, 0x100e, &AGC); switch (prelvl) { case 0: if (ui32BER < 650) ui32Antlvl = prelvl = 1; else ui32Antlvl = prelvl; break; case 1: if ((ui32BER > 700) || ((ui32BER > 500) && (CN <= 3))) ui32Antlvl = prelvl = 0; else if ((ui32BER < 300) && (CN > 6)) ui32Antlvl = prelvl = 2; else ui32Antlvl = prelvl; break; case 2: if ((ui32BER > 500) || ((ui32BER > 300) && (CN <= 5))) ui32Antlvl = prelvl = 1; else if ((ui32BER < 100) && (CN >= 9)) ui32Antlvl = prelvl = 3; else ui32Antlvl = prelvl; break; case 3: if ((ui32BER > 200) || ((ui32BER > 100) && (CN <= 9))) ui32Antlvl = prelvl = 2; else if ((ui32BER < 50) && (CN >= 12)) ui32Antlvl = prelvl = 4; else ui32Antlvl = prelvl; break; case 4: if ((ui32BER > 100) || (CN <= 14)) ui32Antlvl = prelvl = 3; else ui32Antlvl = prelvl; break; default : ui32Antlvl = prelvl = 0; break; } ISDBT_MSG_FC8150_BB("[%s] (PER)%d (BER)%d (RSSI)%d (CN)%d (AGC)%d (Ant)%d\n", __func__, ui32PER, ui32BER, i32RSSI, CN, AGC, ui32Antlvl); }
/*======================================================= Function : tunerbb_drv_fc8050_init Description : Initializing the FC8050 Chip after power on Parameter : VOID Return Value : SUCCESS : 1 FAIL : 0 or negative interger (If there is error code) when model who edit history ------------------------------------------------------- 2010/05/17 MOBIT prajuna EBI2 configuration 2010/05/31 MOBIT prajuna Removed test code 2010/06/09 MOBIT prajuna TDMB porting(KB3 Rev. A patch) 2010/07/15 MOBIT prajuna TDMB tuning for QSC 2010/07/16 MOBIT somesoo TDMB tuning for QSC with FCI 최규원 과장 2010/07/17 MOBIT somesoo TDMB porting(VG) 2010/08/19 MOBIT prajuna Code review 2010/09/10 MOBIT prajuna TDMB porting(Aloe) ======================================================== */ int8 tunerbb_drv_fc8050_init(void) { uint8 res; /*test*/ /* uint16 i; uint32 wdata = 0; uint32 ldata = 0; uint32 data = 0; uint32 temp = 0; */ /* Common Code */ #if defined(STREAM_SLAVE_PARALLEL_UPLOAD) /* EBI2 Specific Code */ BBM_HOSTIF_SELECT(NULL, BBM_PPI); #elif defined(STREAM_TS_UPLOAD) /* TSIF Specific Code */ BBM_HOSTIF_SELECT(NULL, BBM_I2C); #elif defined(STREAM_SPI_UPLOAD) /* SPI Specific. Code */ BBM_HOSTIF_SELECT(NULL, BBM_SPI); #else #error code not present #endif BBM_FIC_CALLBACK_REGISTER((fci_u32)NULL, tunerbb_drv_fc8050_fic_cb); BBM_MSC_CALLBACK_REGISTER((fci_u32)NULL, tunerbb_drv_fc8050_msc_cb); res = BBM_INIT(NULL); if(res) return FC8050_RESULT_ERROR; else { #if !defined(STREAM_TS_UPLOAD) memset((void*)&g_chinfo, 0xff, sizeof(g_chinfo)); memset((void*)&msc_buffer, 0x00, sizeof(DATA_BUFFER)); memset((void*)&fic_buffer, 0x00, sizeof(DATA_BUFFER)); #endif } res = BBM_TUNER_SELECT(0, FC8050_TUNER, BAND3_TYPE); // res = BBM_PROBE(0); // printk("tunerbb_drv_fc8050_init probe RES = %d\n", res); #if 0 //fc8050 <-> Host(MSM) 간의 Interface TEST를 위한 code /* test */ for(i=0;i<5000;i++) { // dog_kick(); BBM_WRITE(NULL, 0x05, i & 0xff); BBM_READ(NULL, 0x05, &data); if((i & 0xff) != data) printk("FC8000 byte test (0x%x,0x%x)\n", i & 0xff, data); } for(i=0;i<5000;i++) { BBM_WORD_WRITE(NULL, 0x0210, i & 0xffff); BBM_WORD_READ(NULL, 0x0210, &wdata); if((i & 0xffff) != wdata) printk("FC8000 word test (0x%x,0x%x)\n", i & 0xffff, wdata); } for(i=0;i<5000;i++) { BBM_LONG_WRITE(NULL, 0x0210, i & 0xffffffff); BBM_LONG_READ(NULL, 0x0210, &ldata); if((i & 0xffffffff) != ldata) printk("FC8000 long test (0x%x,0x%x)\n", i & 0xffffffff, ldata); } data = 0; for(i=0;i<5000;i++) { temp = i&0xff; BBM_TUNER_WRITE(NULL, 0x12, 0x01, &temp, 0x01); BBM_TUNER_READ(NULL, 0x12, 0x01, &data, 0x01); if((i & 0xff) != data) printk("FC8000 tuner test (0x%x,0x%x)\n", i & 0xff, data); } temp = 0x51; BBM_TUNER_WRITE(NULL, 0x12, 0x01, &temp, 0x01 ); /* test */ #endif if(res) return FC8050_RESULT_ERROR; else return FC8050_RESULT_SUCCESS; }
unsigned char DMBDrv_init(void) { u8 data; u16 wdata; u32 ldata; int i; u8 temp = 0x1e; #ifdef CONFIG_TDMB_SPI if(BBM_HOSTIF_SELECT(NULL, BBM_SPI)) return TDMB_FAIL; #elif defined(CONFIG_TDMB_EBI) if(BBM_HOSTIF_SELECT(NULL, BBM_PPI)) return TDMB_FAIL; #endif if(BBM_PROBE(NULL) != BBM_OK) // check for factory chip interface test { return TDMB_FAIL; } BBM_FIC_CALLBACK_REGISTER(NULL, TDMBDrv_FIC_CALLBACK); BBM_MSC_CALLBACK_REGISTER(NULL, TDMBDrv_MSC_CALLBACK); BBM_INIT(NULL); BBM_TUNER_SELECT(NULL, FC8050_TUNER, BAND3_TYPE); #if 0 BBM_WRITE(NULL, 0x05, 0xa7); BBM_READ(NULL, 0x05, &data); BBM_READ(NULL, 0x12, &data); BBM_WORD_READ(NULL, 0x12, &wdata); BBM_WORD_WRITE(NULL, 0x310, 0x0b); BBM_WORD_READ(NULL, 0x310, &wdata); BBM_WRITE(NULL, 0x312, 0xc0); BBM_READ(NULL, 0x312, &data); BBM_TUNER_READ(NULL, 0x01, 0x01, &data, 0x01); #endif #if 0 for(i=0;i<1000;i++) { // dog_kick(); BBM_WRITE(NULL, 0x05, i & 0xff); BBM_READ(NULL, 0x05, &data); if((i & 0xff) != data) DPRINTK("FC8000 byte test (0x%x,0x%x)\r\n", i & 0xff, data); } for(i=0;i<1000;i++) { BBM_WORD_WRITE(NULL, 0x0210, i & 0xffff); BBM_WORD_READ(NULL, 0x0210, &wdata); if((i & 0xffff) != wdata) DPRINTK("FC8000 word test (0x%x,0x%x)\r\n", i & 0xffff, wdata); } for(i=0;i<1000;i++) { BBM_LONG_WRITE(NULL, 0x0210, i & 0xffffffff); BBM_LONG_READ(NULL, 0x0210, &ldata); if((i & 0xffffffff) != ldata) DPRINTK("FC8000 long test (0x%x,0x%x)\r\n", i & 0xffffffff, ldata); } for(i=0;i<1000;i++) { temp = i&0xff; BBM_TUNER_WRITE(NULL, 0x12, 0x01, &temp, 0x01); BBM_TUNER_READ(NULL, 0x12, 0x01, &data, 0x01); if((i & 0xff) != data) DPRINTK("FC8000 tuner test (0x%x,0x%x)\r\n", i & 0xff, data); } temp = 0x51; BBM_TUNER_WRITE(NULL, 0x12, 0x01, &temp, 0x01 ); #endif gBer = 3000; gInitFlag = 1; return TDMB_SUCCESS; }
void data_dump_thread(void *param) { data_dump_param *data = (data_dump_param*)param; int hDevice = data->dev; int num = data->num; u8 buf[MSC_BUF_SIZE]; int i; int ret; int check_cnt_size=0; int monitor_size=0; int dump_size=0; u32 berA, perA, berB, perB, berC, perC, cnr, ui32Quality, ui32Antlvl; s32 i32RSSI; u8 slock=0; //while(1) { FILE *f; char *f_name[128]; sprintf((void*)f_name,DUMP_PATH"data_dump_%04d.dat", index++); dump_size=0; f = fopen((void*)f_name, "wb"); #ifdef FEATURE_TS_CHECK create_tspacket_anal(); #endif print_log("Start data dump %s , pkt : %d\n", f_name, data->num); mtv_ts_start(hDevice); for(i=0;i<num;i++) { int k; int size; size = mtv_data_read(hDevice, buf, MSC_BUF_SIZE); #ifdef FEATURE_TS_CHECK if(!(size%188)) { put_ts_packet(0, &buf[0], size); dump_size+=size; monitor_size+=size; check_cnt_size+=size; #ifdef FEATURE_OVERRUN_CHECK { u8 over; BBM_READ(hDevice, 0x8001, &over); if(over) { BBM_WRITE(hDevice, 0x8001, over); print_log("TS OVERRUN : %d\n", over); } } #endif if(check_cnt_size>188*320*40) { print_pkt_log(); check_cnt_size=0; } } #endif if(monitor_size>188*320*40) { monitor_size=0; mtv_signal_quality_info(hDevice, &slock, &cnr, &berA, &perA, &berB, &perB, &berC, &perC, &i32RSSI, &ui32Quality, &ui32Antlvl); print_log("Lock : 0x%x CN : %3d, RSSI : %3d, QT : %d, Ant : %d\n",slock, cnr, i32RSSI, ui32Quality, ui32Antlvl); print_log("BerA : %6d, PerA : %6d, BerB : %6d, PerB : %6d, BerC : %6d, PerC : %6d, \n", berA, perA, berB, perB, berC, perC); } if((dump_size<100*1024*1024)&&(size>0)) fwrite(&buf[0], 1, size, f); } mtv_ts_stop(hDevice); fclose(f); print_log("\nEnd msc dump\n"); index %= 10; } }