static void AS_DUMP_SAT(S_NODE *sat) { AS_PRINTF("***************************************\n"); AS_PRINTF("* sat id = %d\n", sat->sat_id); AS_PRINTF("* sat lnb_type = %d\n", sat->lnb_type); AS_PRINTF("* sat lnb_low = %d\n", sat->lnb_low); AS_PRINTF("* sat lnb_high = %d\n", sat->lnb_high); AS_PRINTF("* sat polar = %d\n", sat->pol); AS_PRINTF("***************************************\n"); }
static void AS_DUMP_TP(T_NODE *tp) { AS_PRINTF("***************************************\n"); AS_PRINTF("* tp id = %d\n", tp->tp_id); AS_PRINTF("* tp freq = %d\n", tp->frq); AS_PRINTF("* tp sym = %d\n", tp->sym); AS_PRINTF("* tp pol = %d\n", tp->pol); AS_PRINTF("* tp FEC inner = %d\n", tp->FEC_inner); AS_PRINTF("***************************************\n"); }
/* description : auto scan main routine for command parsing and switching.*/ static void as_main(struct libpub_cmd *cmd) { INT32 i, j; INT32 ret; INT32 method; INT32 tp_nr; INT32 as_method; UINT16 sat_id; UINT8 dmx_mode_need_resume = 0; UINT32 dmx_dma_mode; as_update_event_t event_handler; struct dmx_device *dmx = NULL; T_NODE *tp = &as_info->cur_tp;; S_NODE *sat = &as_info->cur_sat; struct ft_antenna *antenna = &as_info->antenna; AS_PRINTF("start time stamp = %d\n", osal_get_tick()); as_method = as_info->param.as_method; event_handler = as_info->param.as_handler; if(event_handler!=NULL) { event_handler(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANSTART); } //Select DMX dmx = dev_get_by_id(HLD_DEV_TYPE_DMX, 0); if(dmx == NULL) { AS_PRINTF("%s(): select dmx failed!\n"); return; } as_info->dmx = dmx; //fix BUG20874: init psi info to avoid dmx changed by video playing psi_info_init(as_info->dmx, as_info->nim, (void *)__MM_PSI_START_ADDR, 180*1024); //Check and Switch Buffer Mode of Dmx (From Divided Buffer To Union Buffer) dmx_io_control(as_info->dmx, DMX_CHK_BUF_MODE, (UINT32)&dmx_dma_mode); if(dmx_dma_mode == DMX_DIVIDED_BUFF_MODE) { dmx_io_control(as_info->dmx, DMX_SWITCH_TO_UNI_BUF, 0); dmx_mode_need_resume = 1; } for(i = 0; i<as_info->sat_nr; i++) { //For Each Satellite, Create its TP View, Set Antenna sat_id = as_info->sat_id[i]; db_search_create_tp_view(sat_id); if(event_handler != NULL) { event_handler(ASM_TYPE_SATELLITE, sat_id); } //Set Antenna Information according to Satellite Information MEMSET(sat, 0, sizeof(S_NODE)); get_sat_by_id(sat_id, sat); AS_DUMP_SAT(sat); MEMSET(antenna, 0, sizeof(struct ft_antenna)); sat2antenna(sat, antenna); as_info->dual_LNB = (antenna->lnb_high>0) && (antenna->lnb_low>0) && (antenna->lnb_high != antenna->lnb_low); as_info->voltage_ctrl = (antenna->pol==LNB_POL_H)||(antenna->pol==LNB_POL_V); //>>> Unicable begin if(antenna->lnb_type == LNB_CTRL_UNICABLE) { as_info->nim_para.unicable = 1; as_info->nim_para.Fub = antenna->unicable_freq; } else as_info->nim_para.unicable = 0; //<<< Unicable end //select right nim and dmx as_select_nim(sat); if(as_info->nim ==NULL) { AS_PRINTF("%s(): select nim failed!\n"); continue; } //for 29E 2-Tuner the dmx path may not same as default!! tsi_dmx_src_select(TSI_DMX_0, TSI_TS_A); //blind scan if((AS_METHOD_FFT==as_method)||(AS_METHOD_MULTI_FFT==as_method)) { method = AS_METHOD_FFT; } else { as_info->tp_nr = 0; MEMSET(as_info->tp_nit, 0,AS_MODULE_MAX_T_NUM*sizeof(UINT8)); //single tp scan if((AS_METHOD_TP==as_method)||(AS_METHOD_TP_PID==as_method) ||(AS_METHOD_NIT_TP==as_method)||(AS_METHOD_NVOD==as_method)) { as_info->tp_nr = 1; as_info->tp_id[0] = as_info->param.as_from; if ((AS_METHOD_NIT_TP==as_method)&&(event_handler!=NULL)) { event_handler(ASM_TYPE_INC_TRANSPONDER, 0); } } //multi tp scan else if((AS_METHOD_SAT_TP==as_method)||(AS_METHOD_NIT==as_method) ||(AS_METHOD_MULTI_TP==as_method)||(AS_METHOD_MULTI_NIT==as_method) ||(AS_METHOD_NVOD_MULTI_TP==as_method)) { tp_nr = get_tp_num_sat(sat_id); for(j=0; j<tp_nr; j++) { get_tp_at(sat_id, j, tp); if(as_info->param.as_frontend_type==FRONTEND_TYPE_S) { if(dvbs_tp_sanity_check(as_info->voltage_ctrl,tp, sat)==FALSE) { continue; } } else if(as_info->param.as_frontend_type == FRONTEND_TYPE_C) { if(dvbc_tp_sanity_check(FALSE, tp, NULL) == FALSE) { continue; } } AS_DUMP_TP(tp); #ifdef NVOD_FEATURE if((AS_METHOD_NVOD_MULTI_TP == as_method) && (tp->nvod_flg == 1)) #endif { as_info->tp_id[as_info->tp_nr++] = tp->tp_id; } if (AS_MODULE_MAX_T_NUM == as_info->tp_nr) { AS_PRINTF("%s: tp exceed AS_MODULE_MAX_T_NUM!\n", __FUNCTION__); } } } if((AS_METHOD_NIT==as_method)||(AS_METHOD_NIT_TP==as_method) ||(AS_METHOD_MULTI_NIT==as_method)) { MEMSET(as_info->tp_nit, 1, as_info->tp_nr); } method = AS_METHOD_TP; } ret = as_scan(sat_id, sat, method, 0); update_data( ); if (ret || as_info->stop_scan_signal) { break; } } //Show Scan Over by Upper Layer if(event_handler != NULL) { event_handler(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANOVER); } dmx_io_control(as_info->dmx, CLEAR_STOP_GET_SECTION, 0); //Switch Buffer Mode of Dmx (From Union Buffer to Divided Buffer) if(dmx_mode_need_resume) { dmx_io_control(as_info->dmx, DMX_SWITCH_TO_DVI_BUF, 0); } sie_open(as_info->dmx, MAX_FILTER_NUMBER, NULL, 0); osal_task_dispatch_off(); nim_io_control(as_info->nim, NIM_DRIVER_STOP_ATUOSCAN, 0); as_info = NULL; AS_PRINTF("end time stamp = %d\n", osal_get_tick()); osal_task_dispatch_on(); }
static INT32 as_enum_scan(UINT16 sat_id, UINT16 type, psi_tuning_t tuning_fn) { BOOL db_ret = TRUE; INT32 ret = 0; UINT32 search_scheme; UINT8 lock_stat; struct as_tuning_param *atp = &as_info->atp; as_update_event_t update_event = as_info->param.as_handler; AS_PRINTF("start at %d\n", osal_get_tick()); if(update_event != NULL) { update_event(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANSTART+1); } //Set First TP Info if(tuning_fn != NULL) { tuning_fn(atp); } //TP Scan Loop while((atp->finish == FALSE) && (ret == 0)) { //Set Search Scheme, that is whether Search NIT or not search_scheme = as_info->param.as_prog_attr; if (atp->nit_enable) { search_scheme |= P_SEARCH_NIT; } AS_PRINTF("id=%d, t_nr=%d\n",atp->tp_id, as_info->tp_nr); lock_stat = 0; //Show New TP for DVB-S by Upper Layer if ((tuning_fn == as_dvbs_preset_tuning) && (update_event)) { update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); } //Try to Lock Signal do { nim_get_lock(as_info->nim, &lock_stat); if((lock_stat) || (as_info->stop_scan_signal)) { break; } osal_task_sleep(1); } while((INT32)osal_get_tick() < (INT32)atp->timeout); // fix a bug of 3501B tp scan, it need more time. (3501 SSI to SPI 8bit mode, for some coderate). if(atp->ft_type == FRONTEND_TYPE_S) { osal_task_sleep(1200); } AS_PRINTF("lock stat = %d\n", lock_stat); if (!as_info->stop_scan_signal) { //If Lock Signal, then Search Prog in this TP if (lock_stat) { //Scan from Start Frq to End Frq for DVB-C and DVB-T if (type == ATP_TYPE_STEP) { //For DVB-C, Set TP Info according to as_info if(as_info->param.as_frontend_type == FRONTEND_TYPE_C) { db_ret = dvbc_alloc_transponder(as_info, atp, &as_info->xp, sat_id); } else if(as_info->param.as_frontend_type == FRONTEND_TYPE_T) { } if (db_ret != TRUE) { ret = 1; break; } //Show New TP for DVB-C and DVB-T by Upper Layer if(update_event) { update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); } } //Prog Search in this TP psi_module_init(as_info->dmx, as_info->nim, (void *)__MM_PSI_START_ADDR, 180*1024); if (SI_STOFULL == psi_search_start(sat_id, atp->tp_id, search_scheme, as_info->param.as_p_add_cfg, psi_callback, tuning_fn, atp)) { ret= 1; } } //Not Lock Signal, then Switch to next TP else { tuning_fn(atp); } } if (as_info->stop_scan_signal || ret) { break; } //Show Scan Progress by Upper Layer if ((!as_info->tp_nit[0]) && (type == ATP_TYPE_DBASE) && (update_event)) { update_event(ASM_TYPE_PROGRESS, atp->pos*99/(as_info->tp_nr+2)); } } AS_PRINTF("end at %d\n", osal_get_tick()); return ret; }
//dvbs blind scan nim api callback function. static INT32 dvbs_as_callback(UINT8 signal, UINT8 polar, UINT32 freq, UINT32 sym, UINT8 fec) { static INT16 crnum; T_NODE *tp; UINT16 sat_id; as_update_event_t handle = as_info->param.as_handler; UINT8 progress = 0; /* sky.bi 20101227 */ FIXED_PRINTF("dvbs_as_callback ******search_callback*********sky.bi\n"); if (NULL == as_info) { AS_PRINTF("%s: wrong status!\n", __FUNCTION__); return 2; } if(as_info->stop_scan_signal) { return 2; } else if((signal == AS_SGN_UNLOCKED) || (signal == AS_SGN_LOCKED)) { /* Patches for lib_nim Out-Band Xponder Mis-Report */ if ((crnum < 0) && ((freq < as_info->param.as_from) || (freq > as_info->param.as_to))) { return 0; } else if ((as_info->param.as_method == AS_METHOD_FFT) || (as_info->param.as_method == AS_METHOD_MULTI_FFT)) { //Calculate and Show Scan Progress progress = (UINT8)dvbs_calculate_progress(as_info, freq, polar, crnum); if(handle != NULL) { handle(ASM_TYPE_PROGRESS, progress); /* sky.bi 20101227 */ FIXED_PRINTF("dvbs_as_callback ******search_callback ASM_TYPE_PROGRESS*********sky.bi\n"); } } } switch(signal) { case AS_SGN_LOCKED: //Check whether New Freq Point, Sym Rate, and Polarity is same to the Old TP or not if (dvbs_tp_duplicate_check(freq, sym, polar) == FALSE) { break; } //Construct one New TP according to Locked Freq and Sym tp = &as_info->xp; MEMSET(tp, 0, sizeof(T_NODE)); dvbs_convert_freq(as_info, tp, freq); tp->sym = sym; tp->sat_id = sat_id = as_info->cur_sat.sat_id; tp->ft_type = FRONTEND_TYPE_S; AS_DUMP_TP(tp); if(db_search_lookup_node(TYPE_SEARCH_TP_NODE, tp)!=SUCCESS) { INT32 ret; ret = add_node(TYPE_SEARCH_TP_NODE, tp->sat_id, tp); if ((DBERR_FLASH_FULL==ret) || (DBERR_MAX_LIMIT)==ret) { return 1; } } //Process by Upper Layer if(handle != NULL) { handle(ASM_TYPE_ADD_TRANSPONDER, tp->tp_id); } /* start searching si information of all programs in this frequency point */ psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 180*1024); if (SI_STOFULL == psi_search_start(sat_id,tp->tp_id, as_info->param.as_prog_attr, as_info->param.as_p_add_cfg, psi_callback,NULL, NULL)) { return 1; } break; case AS_SGN_STOP: AS_PRINTF(">>>>>>>>>>>>>>STOP!!!<<<<<<<<<<<<<<<<<<\n"); as_info->stop_scan_signal=1; break; case AS_SGN_CRNUM: crnum = freq; break; case AS_SGN_INIT: crnum = -1; //Initialize one TP dvbs_tp_duplicate_check(0, 0, 0); break; //>>> Unicable begin case AS_SET_UNICABLE: tp = &as_info->xp; MEMSET(tp, 0, sizeof(T_NODE)); dvbs_convert_freq(as_info, tp, freq); as_info->xponder.s_info.frq = tp->frq; as_info->xponder.s_info.pol = as_info->polar; frontend_set_unicable(as_info->nim,&as_info->antenna, &as_info->xponder); break; //<<< Unicable end default: break; } return (as_info->stop_scan_signal)? 2: 0; }
/* description : auto scan main routine for command parsing and switching.*/ static void as_main(struct mid27_cmd *cmd) { INT32 i; INT32 j; INT32 ret; INT32 method; INT32 tp_nr; INT32 as_method; UINT16 sat_id; T_NODE *tp; S_NODE *sat; UINT8 dmx_mode_need_resume = 0; UINT32 dmx_dma_mode; as_update_event_t event_handler; extern BOOL cc_stop_channel(BOOL, BOOL); #ifdef BASE_TP_HALF_SCAN_SUPPORT if(cmd->cmd_type == MID27_CMD_AS_HL_START) { as_bastp_halfscan(cmd); return; } #endif AS_PRINTF("start time stamp = %d\n", osal_get_tick()); cc_stop_channel(0, 0); /*get default nim, for dual nim projects, will get correct nim later below*/ as_info->nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, 0); as_info->dmx = (struct dmx_device *)dev_get_by_id(HLD_DEV_TYPE_DMX, 0); //fix BUG20874: init psi info to avoid dmx changed by video playing #ifdef BASE_TP_HALF_SCAN_SUPPORT psi_info_init(as_info->dmx, as_info->nim, (void *)__MM_PSI_START_ADDR, 280*1024); #else psi_info_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 180*1024); #endif dmx_io_control(as_info->dmx, DMX_CHK_BUF_MODE, (UINT32)&dmx_dma_mode); if(dmx_dma_mode == DMX_DIVIDED_BUFF_MODE) { dmx_io_control(as_info->dmx, DMX_SWITCH_TO_UNI_BUF, 0); dmx_mode_need_resume = 1; } tp = &as_info->cur_tp; sat = &as_info->cur_sat; as_method = as_info->param.as_method; event_handler = as_info->param.as_handler; event_handler(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANSTART); for(i = 0; i<as_info->sat_nr; i++) { sat_id = as_info->sat_id[i]; db_search_create_tp_view(sat_id); #if (SYS_PROJECT_FE == PROJECT_FE_DVBS||SYS_PROJECT_FE == PROJECT_FE_DVBS2) event_handler(ASM_TYPE_SATELLITE, sat_id); get_sat_by_id(sat_id, sat); /*get correct nim*/ as_select_nim(sat); #endif AS_DUMP_SAT(sat); if ((AS_METHOD_FFT == as_method)||(AS_METHOD_MULTI_FFT == as_method)) { method = AS_METHOD_FFT; } else { as_info->tp_nr = 0; MEMSET(as_info->tp_nit, 0,AS_MODULE_MAX_T_NUM*sizeof(UINT8)); if ((AS_METHOD_TP == as_method)||(AS_METHOD_TP_PID == as_method) ||(AS_METHOD_NIT_TP== as_method)||(AS_METHOD_NVOD == as_method)) { as_info->tp_nr = 1; as_info->tp_id[0] = as_info->param.as_from; if (AS_METHOD_NIT_TP == as_method) event_handler(ASM_TYPE_INC_TRANSPONDER, 0); } else if ((AS_METHOD_SAT_TP == as_method)||(AS_METHOD_NIT == as_method) ||(AS_METHOD_MULTI_TP == as_method)||(AS_METHOD_MULTI_NIT == as_method) ||(AS_METHOD_NVOD_MULTI_TP==as_method)) { tp_nr = get_tp_num_sat(sat_id); for(j=0; j<tp_nr; j++) { get_tp_at(sat_id, j, tp); if (FALSE == tp_sanity_check(as_info,tp, sat)) continue; AS_DUMP_TP(tp); #ifdef NVOD_FEATURE if(tp->nvod_flg==1) #endif as_info->tp_id[as_info->tp_nr++] = tp->tp_id; if (AS_MODULE_MAX_T_NUM == as_info->tp_nr) AS_PRINTF("%s: tp exceed AS_MODULE_MAX_T_NUM!\n", __FUNCTION__); } } if ((AS_METHOD_NIT == as_method)||(AS_METHOD_NIT_TP == as_method) ||(AS_METHOD_MULTI_NIT == as_method)) { MEMSET(as_info->tp_nit, 1, as_info->tp_nr); } method = AS_METHOD_TP; } ret = as_scan(sat_id, sat, method, as_method != AS_METHOD_NVOD); update_data( ); if (ret||as_info->stop_scan_signal) break; } #ifdef KAON_SAVE_USE event_handler(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANOVER|(prog_num << 16)); #else event_handler(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANOVER); #endif dmx_io_control(as_info->dmx, CLEAR_STOP_GET_SECTION, 0); if(dmx_mode_need_resume) dmx_io_control(as_info->dmx, DMX_SWITCH_TO_DVI_BUF, 0); sie_open(as_info->dmx, MAX_FILTER_NUMBER, NULL, 0); osal_task_dispatch_off(); if ((as_info->param.as_method == AS_METHOD_NVOD) ||(as_info->param.as_method==AS_METHOD_NVOD_MULTI_TP)) { nim_io_control(as_info->nim, NIM_DRIVER_STOP_ATUOSCAN, 0); as_info = NULL; AS_PRINTF("end time stamp = %d\n", osal_get_tick()); mid27_declare_cmd_finish(MID27_FLG_AS_NVOD); } else { nim_io_control(as_info->nim, NIM_DRIVER_STOP_ATUOSCAN, 0); as_info = NULL; AS_PRINTF("end time stamp = %d\n", osal_get_tick()); } osal_task_dispatch_on(); }
static INT32 as_enum_scan(UINT16 sat_id, UINT16 type) { INT32 db_ret; INT32 ret=0; UINT32 search_scheme; UINT8 lock_stat; struct as_tuning_param *atp = &as_info->atp; UINT8 i,j; psi_tuning_t tuning_fn = NULL; as_update_event_t update_event = as_info->param.as_handler; AS_PRINTF("start at %d\n", osal_get_tick()); update_event(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANSTART+1); MEMSET(atp, 0, sizeof(as_info->atp)); if (type == ATP_TYPE_DBASE) { if (as_info->tp_nr<=0) { AS_PRINTF("no preset transponder on this satellite!\n"); return ret; } tuning_fn = as_preset_tuning; } else if (type == ATP_TYPE_STEP) { #if (SYS_PROJECT_FE == PROJECT_FE_DVBC) if (dvbc_init_search_param(atp, as_info->param.as_from,as_info->param.as_to) == FALSE) return ret; #endif tuning_fn = as_blind_tuning; } #ifndef DVBC_AUTOSCAN_MULTI_SYMBOL_QAM tuning_fn(atp); #else if(type == ATP_TYPE_DBASE) tuning_fn(atp); autoscan_symbol[0]=as_info->param.as_sym; autoscan_symbol[1]=as_info->param.as_sym2; autoscan_symbol[2]=as_info->param.as_sym3; #endif while((atp->finish==FALSE)&&(ret==0)) { search_scheme = as_info->param.as_prog_attr; if (atp->nit_enable) search_scheme |= P_SEARCH_NIT; AS_PRINTF("id=%d, t_nr=%d\n",atp->tp_id, as_info->tp_nr); lock_stat = 0; if (tuning_fn == as_preset_tuning) update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); #ifdef DVBC_AUTOSCAN_MULTI_SYMBOL_QAM if(type == ATP_TYPE_STEP) { for(i = 0; i < SCAN_SYMBOL_NUM; i++) { for(j=0;j<SCAN_QAM_NUM;j++) { as_info->param.as_sym = autoscan_symbol[i]; as_info->param.as_constellation=autoscan_qam[j]; if(as_info->param.as_sym==0&&((i != SCAN_SYMBOL_NUM-1)||(j!=SCAN_QAM_NUM-1))) continue; as_blind_tuning_multisym_multiqam(atp,i,j); lock_stat = 0; do { nim_get_lock(as_info->nim, &lock_stat); if((lock_stat)||(as_info->stop_scan_signal)) { break; } osal_task_sleep(1); }while((INT32)osal_get_tick()<(INT32)atp->timeout); AS_PRINTF("lock stat = %d\n", lock_stat); if (!as_info->stop_scan_signal) { if (lock_stat) { db_ret = dvbc_alloc_transponder(as_info, atp, &as_info->xp, sat_id); if (db_ret != TRUE) { ret = 1; break; } update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); #ifdef BASE_TP_HALF_SCAN_SUPPORT psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 280*1024); #else psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 180*1024); #endif if (SI_STOFULL == psi_search_start(sat_id, atp->tp_id, search_scheme, as_info->param.as_p_add_cfg, psi_callback, tuning_fn, atp)) {ret= 1;} break; } } } if(lock_stat) break; } if((i < SCAN_SYMBOL_NUM-1||j<SCAN_QAM_NUM-1)) { if(atp->pos < atp->limit) as_blind_tuning_multisym_multiqam(atp,SCAN_SYMBOL_NUM-1,SCAN_QAM_NUM-1); else if(atp->pos >= atp->limit) atp->finish=TRUE; } } else #endif { do { nim_get_lock(as_info->nim, &lock_stat); if((lock_stat)||(as_info->stop_scan_signal)) break; osal_task_sleep(1); } while((INT32)osal_get_tick()<(INT32)atp->timeout); AS_PRINTF("lock stat = %d\n", lock_stat); if (!as_info->stop_scan_signal) { if (lock_stat) { #if (SYS_PROJECT_FE == PROJECT_FE_DVBC) if (type == ATP_TYPE_STEP) { db_ret = dvbc_alloc_transponder(as_info,atp, &as_info->xp, sat_id); if (db_ret != TRUE) { ret = 1; break; } update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); } #endif #ifdef BASE_TP_HALF_SCAN_SUPPORT psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 280*1024); #else psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 180*1024); #endif if (SI_STOFULL == psi_search_start(sat_id,atp->tp_id, search_scheme, as_info->param.as_p_add_cfg,psi_callback, tuning_fn, atp)) { ret= 1; } } else tuning_fn(atp); } } if (as_info->stop_scan_signal||ret) break; if ((!as_info->tp_nit[0])&&(type == ATP_TYPE_DBASE)) update_event(ASM_TYPE_PROGRESS,atp->pos*99/(as_info->tp_nr+2)); } AS_PRINTF("end at %d\n", osal_get_tick()); return ret; }
/*description : autoscan nim api callback function.*/ static INT32 dvbs_as_callback(UINT8 signal, UINT8 polar, UINT32 freq, UINT32 sym, UINT8 fec) { static INT16 crnum; T_NODE *tp; UINT16 sat_id; as_update_event_t handle = as_info->param.as_handler; if (NULL == as_info) { AS_PRINTF("%s: wrong status!\n", __FUNCTION__); return 2; } tp = &as_info->xp; if (as_info->stop_scan_signal) { return 2; } else if ((signal==AS_SGN_UNLOCKED)||(signal==AS_SGN_LOCKED)) { /* patches for lib_nim out-band xponder mis-report*/ if ((crnum<0)&&((freq<as_info->param.as_from)||(freq>as_info->param.as_to))) return 0; else if ((as_info->param.as_method == AS_METHOD_BLIND) ||(as_info->param.as_method == AS_METHOD_MULTI_FFT)) { handle(ASM_TYPE_PROGRESS,(UINT8)dvbs_calculate_progress(as_info, freq, polar, crnum)); } } switch(signal) { case AS_SGN_LOCKED: if (dvbs_tp_duplicate_check(freq, sym, polar) == FALSE) break; MEMSET(tp, 0, sizeof(T_NODE)); dvbs_convert_freq(as_info, tp, freq); tp->sym = sym; tp->sat_id = sat_id = as_info->cur_sat.sat_id; AS_DUMP_SAT(&as_info->cur_sat); AS_DUMP_TP(tp); if(db_search_lookup_node(TYPE_SEARCH_TP_NODE, tp)!=SUCCESS) { INT32 ret; ret = add_node(TYPE_SEARCH_TP_NODE, tp->sat_id, tp); if ((DBERR_FLASH_FULL==ret) || (DBERR_MAX_LIMIT)==ret) return 1; } handle(ASM_TYPE_ADD_TRANSPONDER, tp->tp_id); #ifdef BASE_TP_HALF_SCAN_SUPPORT psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 280*1024); #else psi_module_init(as_info->dmx, as_info->nim,(void *)__MM_PSI_START_ADDR, 180*1024); #endif if (SI_STOFULL == psi_search_start(sat_id,tp->tp_id, as_info->param.as_prog_attr, as_info->param.as_p_add_cfg, psi_callback,NULL, NULL)) { return 1; } break; case AS_SGN_STOP: AS_PRINTF(">>>>>>>>>>>>>>STOP!!!<<<<<<<<<<<<<<<<<<\n"); as_info->stop_scan_signal=1; break; case AS_SGN_CRNUM: crnum = freq; break; case AS_SGN_INIT: crnum = -1; dvbs_tp_duplicate_check(0, 0, 0); break; //>>> Unicable begin case AS_SET_UNICABLE: dvbs_convert_freq(as_info, tp, freq); as_info->xponder.frq = tp->frq; as_info->xponder.pol = as_info->antenna.pol; //libc_printf("pol: %d\n",as_info->antenna.pol); set_unicable(&as_info->antenna, &as_info->xponder); wait_nim_ready(); // wait_nim_ready(); break; //<<< Unicable end default: break; } return (as_info->stop_scan_signal)? 2: 0; }
static INT32 as_enum_scan(UINT16 sat_id, UINT16 type, psi_tuning_t tuning_fn) { BOOL db_ret = TRUE; INT32 ret = 0; INT32 func_ret = 0; UINT32 search_scheme; UINT8 lock_stat; struct as_tuning_param *atp = &as_info->atp; as_update_event_t update_event = as_info->param.as_handler; AS_PRINTF("start at %d\n", osal_get_tick()); if(update_event != NULL) { update_event(ASM_TYPE_PROGRESS, AS_PROGRESS_SCANSTART+1); } //Set First TP Info if(tuning_fn != NULL) { tuning_fn(atp); } //TP Scan Loop while((atp->finish == FALSE) && (ret == 0)) { //Set Search Scheme, that is whether Search NIT or not search_scheme = as_info->param.as_prog_attr; if (atp->nit_enable) { if (atp->si_enable) { search_scheme |= P_SEARCH_NIT; } else { search_scheme = P_SEARCH_NIT; } } AS_PRINTF("id=%d, t_nr=%d\n",atp->tp_id, as_info->tp_nr); lock_stat = 0; //Show New TP for DVB-S by Upper Layer if ((tuning_fn == as_dvbs_preset_tuning) && (update_event)) { update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id); } //Try to Lock Signal do { nim_get_lock(as_info->nim, &lock_stat); if((lock_stat) || (as_info->stop_scan_signal)) { break; } osal_task_sleep(1); } while((INT32)osal_get_tick() < (INT32)atp->timeout); AS_PRINTF("lock stat = %d\n", lock_stat); if (!as_info->stop_scan_signal) { //If Lock Signal, then Search Prog in this TP if (lock_stat) { //Scan from Start Frq to End Frq for DVB-C and DVB-T if (type == ATP_TYPE_STEP) { //For DVB-C, Set TP Info according to as_info if(as_info->param.as_frontend_type == FRONTEND_TYPE_C) { db_ret = dvbc_alloc_transponder(as_info, atp, &as_info->xp, sat_id); } if (db_ret != TRUE) { ret = 1; break; } //Show New TP for DVB-C and DVB-T by Upper Layer if(update_event) { update_event(ASM_TYPE_ADD_TRANSPONDER, atp->tp_id);//notify ap show tp } } //Prog Search in this TP #if (defined(SUPPORT_MTILINGUAL_SERVICE_NAME)) psi_module_init(as_info->dmx, as_info->nim, (void *)__MM_PSI_START_ADDR, 400*1024); #else psi_module_init(as_info->dmx, as_info->nim, (void *)__MM_PSI_START_ADDR, 180*1024); #endif func_ret = psi_search_start(sat_id, atp->tp_id, search_scheme, as_info->param.as_p_add_cfg, psi_callback, tuning_fn, atp); if (SI_STOFULL == func_ret) { ret= 1; } } //Not Lock Signal, then Switch to next TP else { #ifdef NIT_AUTO_SEARCH_SUPPORT if(tuning_fn== as_dvbc_blind_tuning && b_found_nit_tp) {// because doing auto scan,so atp->pos must > AS_MIN_CAB_FREQUENCY and we need to change to nit search. if(atp->pos > AS_MIN_CAB_FREQUENCY) atp->pos = 0; tuning_fn = as_dvbs_preset_tuning; } #endif tuning_fn(atp); } } if (as_info->stop_scan_signal || ret) { break; } //Show Scan Progress by Upper Layer if ((!as_info->tp_nit[0]) && (type == ATP_TYPE_DBASE) && (update_event)) { update_event(ASM_TYPE_PROGRESS, atp->pos*99/(as_info->tp_nr+2)); } } #ifdef NIT_AUTO_SEARCH_SUPPORT b_found_nit_tp = FALSE; // nit search done #endif AS_PRINTF("end at %d\n", osal_get_tick()); return ret; }