static void scan_process_msg_idle(void *p_handle, os_msg_t *p_msg) { scan_priv_t *p_scan_priv = (scan_priv_t *)p_handle; scan_data_t *p_scan_data = p_scan_priv->p_priv_data; MT_ASSERT(p_msg != NULL); switch(p_msg->content) { case SCAN_CMD_START_SCAN: scan_start(p_scan_priv, p_msg); log_perf(LOG_AP_SCAN, PERF_BEGIN,0,0); p_scan_data->state = SCAN_GET_TP; log_perf(LOG_AP_SCAN, PERF_GET_TP_BEGIN,0,0);//start scan log_perf(LOG_AP_SCAN, PERF_GET_ONETP_BEGIN,0,0); //The implement policy may override message process of scan process if(p_scan_priv->p_policy != NULL) { scan_policy_t *p_policy = p_scan_priv->p_policy; #if 0 //for specified bouquet id if(p_policy->require_extend_table(p_policy,DVB_TABLE_ID_BAT) && p_policy->get_bouquet_id_list != NULL) { p_scan_data->p_rt_data->bouquet_num = p_policy->get_bouquet_id_list(p_policy, p_scan_data->p_rt_data->bouquet_id); } #else #endif p_policy->msg_proc(p_policy->p_priv_data, p_msg); } break; default: break; } }
static void scan_on_nc_locked(scan_priv_t *p_scan_priv, os_msg_t *p_msg) { scan_data_t *p_scan_data = p_scan_priv->p_priv_data; dvb_request_t param = {0}; //The current tp is always the scan result nc_channel_info_t *p_tp_info = &p_scan_data->p_rt_data->result.tp_info; log_perf(LOG_AP_SCAN, PERF_LOCK_EVT, p_tp_info->channel_info.frequency, 0); memcpy(p_tp_info, (void *)p_msg->para1, sizeof(nc_channel_info_t)); SCAN_DBG("scan get 22k %d, pol %d, freq %d, sym %d\n",p_tp_info->onoff22k, p_tp_info->polarization, p_tp_info->channel_info.frequency, p_tp_info->channel_info.param.dvbs.symbol_rate); //Reset flag information for current tp //MT_ASSERT(0 == p_scan_data->p_rt_data->pending_job); memset(&p_scan_data->p_rt_data->job_dbg_info, 0, sizeof(job_dbg_info_t)); //Request PAT param.req_mode = DATA_SINGLE; param.table_id = DVB_TABLE_ID_PAT; param.para1 = DVB_TABLE_ID_PAT; p_scan_data->p_dvb_svc->do_cmd(p_scan_data->p_dvb_svc, DVB_REQUEST, (u32)¶m, sizeof(dvb_request_t)); log_perf(LOG_AP_SCAN, PERF_PAT_REQUEST, 0, 0); p_scan_data->p_rt_data->job_dbg_info.pat_num = 1; p_scan_data->p_rt_data->pending_job = 1; }
int main(int argc, char *argv[]) { int size, length, i; int *data; int *target; double bt, at; if (argc > 1) { size = atoi(argv[1]); length = size / sizeof(int); size = sizeof(int) * length; } else exit(1); log_perf("before init, size=%d", size); data = malloc(size); for(i=0; i<length; i++) data[i] = i; log_perf("after init"); target = malloc(size); bt = log_perf("after target malloc"); memcpy(target, data, size); at = log_perf("after memcpy"); for(i=0; i<length; i++) assert(target[i] == i); printf("TIME: %f\n", (at-bt)); return 0; }
static void scan_on_pat_found(scan_priv_t *p_scan_priv, os_msg_t *p_msg) { scan_data_t *p_scan_data = p_scan_priv->p_priv_data; scan_policy_t *p_policy = p_scan_priv->p_policy; dvb_request_t param = {0}; // Request SDT param.req_mode = DATA_SINGLE; param.table_id = DVB_TABLE_ID_SDT_ACTUAL; param.para1 = DVB_TABLE_ID_SDT_ACTUAL; p_scan_data->p_dvb_svc->do_cmd(p_scan_data->p_dvb_svc, DVB_REQUEST, (u32)¶m, sizeof(dvb_request_t)); log_perf(LOG_AP_SCAN, PERF_SDT_REQUEST, 0, 0); if(p_policy->require_extend_table(p_policy,DVB_TABLE_ID_BAT)) { // Request BAT log_perf(LOG_AP_SCAN, PERF_BAT_REQUEST, 0, 0); scan_request_bat(p_scan_priv); } if(p_policy->require_extend_table(p_policy,DVB_TABLE_ID_NIT_ACTUAL)) { // Request NIT OS_PRINTF("---------------------------------->>request nit in scan\n"); param.req_mode = DATA_SINGLE; param.table_id = DVB_TABLE_ID_NIT_ACTUAL; param.para1 = DVB_TABLE_ID_NIT_ACTUAL; param.para2 = 0xFFFF; p_scan_data->p_dvb_svc->do_cmd(p_scan_data->p_dvb_svc, DVB_REQUEST, (u32)¶m, sizeof(dvb_request_t)); p_scan_data->p_rt_data->job_dbg_info.nit_num++; p_scan_data->p_rt_data->pending_job++; log_perf(LOG_AP_SCAN, PERF_NIT_REQUEST, 0, 0); } if(p_policy->require_extend_table(p_policy,DVB_TABLE_ID_CAT)) { // Request CAT OS_PRINTF("---------------------------------->>request cat in scan\n"); param.req_mode = DATA_SINGLE; param.table_id = DVB_TABLE_ID_CAT; p_scan_data->p_dvb_svc->do_cmd(p_scan_data->p_dvb_svc, DVB_REQUEST, (u32)¶m, sizeof(dvb_request_t)); log_perf(LOG_AP_SCAN, PERF_CAT_REQUEST, 0, 0); p_scan_data->p_rt_data->job_dbg_info.cat_num++; p_scan_data->p_rt_data->pending_job++; } //Currently only pat has been requested //MT_ASSERT(1 == p_scan_data->p_rt_data->pending_job); p_scan_data->p_rt_data->job_dbg_info.pat_num --; p_scan_data->p_rt_data->pending_job--; p_scan_data->p_rt_data->job_dbg_info.sdt_num++; p_scan_data->p_rt_data->pending_job++; }
static RET_CODE on_locked_evt(bl_scan_priv_t *p_priv, nim_channel_info_t *p_ch) { nc_channel_info_t p_nc_channel_info = {0}; RET_CODE ret = SUCCESS; bs_cfg_t *p_cur_cfg = p_priv->bs_cfg_info + p_priv->cur_bs_times; BS_DBG("\n $$$$ on_locked_evt 1\n"); if(cancel_flag) { OS_PRINTF("%s,%s,cancel!\n",__FILE__,__FUNCTION__); return ERR_FAILURE; } BS_DBG("\n $$$$ on_locked_evt 2\n"); if(p_priv->channel_count >= MAX_TP_NUM_PER_SAT) { OS_PRINTF("$$$$ %s,%s,channel_map is full!\n",__FILE__,__FUNCTION__); return ERR_FAILURE; } if((p_ch->frequency + p_ch->param.dvbs.symbol_rate / 2 < p_cur_cfg->start_fre_khz) || (p_ch->frequency - p_ch->param.dvbs.symbol_rate / 2 > p_cur_cfg->end_fre_khz)) { OS_PRINTF("$$$$ %s,%s,illegal freq!\n",__FILE__,__FUNCTION__); return ERR_FAILURE; } memcpy(&p_priv->channel_map[ p_priv->channel_count], p_ch, sizeof(nim_channel_info_t)); memcpy(&p_priv->cur_channel_locked, p_ch, sizeof(nim_channel_info_t)); p_priv->tp_index_locked[p_priv->channel_count_locked] = p_priv->channel_count; memcpy(&p_nc_channel_info.channel_info, p_ch, sizeof(nim_channel_info_t)); p_nc_channel_info.polarization = p_cur_cfg->polarization; p_nc_channel_info.onoff22k = p_cur_cfg->onoff22k; if(p_priv->hook.check_tp(&p_nc_channel_info) != SUCCESS) { OS_PRINTF("$$$$ %s,%s,tp is illegal!\n",__FILE__,__FUNCTION__); return ERR_FAILURE; } log_perf(LOG_AP_SCAN, PERF_GET_TP_END, p_ch->frequency, 0); log_perf(LOG_AP_SCAN, PERF_LOCK_EVT, (u32)(nc_channel_info_t *)(&p_nc_channel_info), 0); ret = on_locked(p_priv, &p_nc_channel_info); if(ret == SUCCESS) { p_priv->channel_count++; p_priv->channel_count_locked++; } return ret; }
static RET_CODE blind_scan_tp_done(void *p_data, void *p_tp_info) { bl_scan_priv_t *p_priv = (bl_scan_priv_t *)p_data; scan_tp_info_t *p_tp = (scan_tp_info_t *)p_tp_info; scan_tp_info_i_t tp_info = {{0}}; u8 ret = 0; //Notify progress notify_progress(progress_calc(p_data)); tp_info.pg_num = p_tp->pg_num; tp_info.p_pg_list = p_tp->p_pg_list; BS_UNLOCK(); /*BS_DBG("%s,line %d:tp [%d,%d]\n",__FUNCTION__,__LINE__, p_tp->tp_info.channel_info.frequency,p_tp->tp_info.channel_info.param.dvbs.symbol_rate);*/ //return p_priv->hook.process_pg_list(&tp_info); #ifdef BS_DEBUG_ON g_tpdone_ticks = mtos_ticks_get(); /*BS_DBG("***************tp done ticks %d,used ticks[%d]\n", g_tpdone_ticks, g_tpdone_ticks - g_lock_ticks);*/ g_used_ticks += (g_tpdone_ticks - g_lock_ticks); #endif ret = p_priv->hook.process_pg_list(&tp_info); log_perf(LOG_AP_SCAN,PERF_DO_LOCK, 0, 0); return ret; }
static RET_CODE on_unlocked_evt(bl_scan_priv_t *p_priv, nim_channel_info_t *p_ch) { BS_DBG("\n $$$$ on_unlocked_evt 1\n"); if(cancel_flag) { if(pause_flag) BS_UNLOCK_PAUSE(); return SUCCESS; } BS_DBG("\n $$$$ on_unlocked_evt 2\n"); memcpy(& p_priv->cur_channel_unlocked, p_ch, sizeof(nim_channel_info_t)); //add perf log log_perf(LOG_AP_SCAN, PERF_GET_TP_END, p_ch->frequency,0); log_perf(LOG_AP_SCAN, PERF_UNLOCK_EVT, p_ch->frequency, 0); log_perf(LOG_AP_SCAN, PERF_GET_ONETP_END,0,0); log_perf(LOG_AP_SCAN, PERF_GET_ONETP_BEGIN,0,0); log_perf(LOG_AP_SCAN, PERF_GET_TP_BEGIN,0,0); log_perf(LOG_AP_SCAN, PERF_SAVE_DB_START,UNLOCK_TP_DB,0); log_perf(LOG_AP_SCAN, PERF_SAVE_DB_DONE,UNLOCK_TP_DB,0); //Notify progress notify_progress(progress_calc(p_priv)); return SUCCESS; }
static void scan_on_timedout(scan_priv_t *p_scan_priv, os_msg_t *p_msg) { scan_data_t *p_scan_data = p_scan_priv->p_priv_data; SCAN_DBG("time out table 0x%x, module %d\n", p_msg->para1, p_msg->para2); switch(p_msg->para1) { case DVB_TABLE_ID_PMT: p_scan_data->p_rt_data->job_dbg_info.pmt_num --; //log_perf(LOG_AP_SCAN, PERF_PMT_FOUND, ((dvb_section_t *)(&(p_msg->para2)))->sid, 0); break; case DVB_TABLE_ID_PAT: scan_on_pat_time_out(p_scan_priv, p_msg); log_perf(LOG_AP_SCAN, PERF_PAT_FOUND, 1, 0); p_scan_data->p_rt_data->job_dbg_info.pat_num --; break; case DVB_TABLE_ID_NIT_ACTUAL: log_perf(LOG_AP_SCAN, PERF_NIT_FOUND, 1, 0); p_scan_data->p_rt_data->job_dbg_info.nit_num --; break; case DVB_TABLE_ID_SDT_ACTUAL: log_perf(LOG_AP_SCAN, PERF_SDT_FOUND, 1, 0); p_scan_data->p_rt_data->job_dbg_info.sdt_num --; break; case DVB_TABLE_ID_BAT: log_perf(LOG_AP_SCAN, PERF_BAT_FOUND, 1, 0); #if 0 //for specified bouquet id p_scan_data->p_rt_data->job_dbg_info.bat_num --; #else scan_free_bat(p_scan_priv); #endif break; case MPEG_TS_PACKET: p_scan_data->p_rt_data->job_dbg_info.video_packet_num --; break; case DVB_TABLE_ID_CAT: log_perf(LOG_AP_SCAN, PERF_CAT_FOUND, 1, 0); p_scan_data->p_rt_data->job_dbg_info.cat_num --; break; } p_scan_data->p_rt_data->pending_job--; }
static RET_CODE on_locked(bl_scan_priv_t *p_priv, nc_channel_info_t *p_ch) { tp_rcv_para_t *p_tp_para = &p_priv->cur_tp_info.tp_info; scan_sat_info_t *p_sat = p_priv->perset_sat_list + p_priv->cur_sat_idx; RET_CODE ret = ERR_FAILURE; bs_cfg_t *p_cur_cfg = p_priv->bs_cfg_info + p_priv->cur_bs_times; if(C_BAND == p_cur_cfg->freqBand && DOUBLE_LOCAL_OSCILLATOR == p_cur_cfg->localOscillator) { p_ch->polarization = p_ch->channel_info.frequency > (1550 * KHZ) ? 1 : 0; BS_DBG("$$$$ %s,line %d,pol=%d\n",__FUNCTION__,__LINE__,p_ch->polarization); } else { p_ch->polarization = p_cur_cfg->polarization; BS_DBG("$$$$ %s,line %d,pol=%d\n",__FUNCTION__,__LINE__,p_ch->polarization); } memset(&p_priv->cur_tp_info, 0, sizeof(scan_tp_info_i_t)); p_tp_para->freq = bs_calc_down_frq(p_ch, p_sat); p_tp_para->sym = p_ch->channel_info.param.dvbs.symbol_rate; p_tp_para->polarity = p_ch->polarization; p_tp_para->is_on22k = p_ch->onoff22k; p_tp_para->nim_type = p_ch->channel_info.param.dvbs.nim_type; p_priv->cur_tp_info.sat_id = p_sat->sat_id; p_priv->cur_tp_info.can_locked = 1; p_priv->cur_tp_info.tp_origin = TP_FROM_SCAN; memcpy(&p_priv->cur_tp_info.perf, &p_ch->channel_info.param.dvbs.perf, sizeof(nim_channel_perf_t)); BS_DBG("agc[%ld], snr[%ld],ber[%d]\n", p_priv->cur_tp_info.perf.agc, p_priv->cur_tp_info.perf.snr, (u8)p_priv->cur_tp_info.perf.ber); //add perf log log_perf(LOG_AP_SCAN, PERF_SAVE_DB_START,LOCK_TP_DB,0); ret = p_priv->hook.process_tp(&p_priv->cur_tp_info); log_perf(LOG_AP_SCAN, PERF_SAVE_DB_DONE,LOCK_TP_DB,0); //Notify progress notify_progress(progress_calc(p_priv)); return ret; }
static void scan_on_pmt_info_found(scan_priv_t *p_scan_priv, os_msg_t *p_msg) { scan_data_t *p_scan_data = p_scan_priv->p_priv_data; u32 param = ((p_msg->para1 << 16) | p_msg->para2); dvb_request_t req_param = {0}; //Request PMT information req_param.req_mode = DATA_SINGLE; req_param.table_id = DVB_TABLE_ID_PMT; req_param.para1 = DVB_TABLE_ID_PMT; req_param.para2 = param; p_scan_data->p_dvb_svc->do_cmd(p_scan_data->p_dvb_svc, DVB_REQUEST, (u32)&req_param, sizeof(dvb_request_t)); p_scan_data->p_rt_data->job_dbg_info.pmt_num++; p_scan_data->p_rt_data->pending_job++; log_perf(LOG_AP_SCAN, PERF_PMT_REQUEST, p_msg->para2, 0); }
void sc_dump_and_reset(void) { uint64_t now = get_time_usec(); uint64_t dur_current = now - g_stat_collect.item_start_time; uint64_t dur_total = now - g_stat_collect.total_start_time; if (dur_current <= 0) dur_current = 1; if (dur_total <= 0) dur_total = 1; for (int i = 0; i < STAT_ITEM_MAX; i++) { struct stat_item_t *item = &g_stat_collect.stats[i]; uint64_t total_count = item->total_count; uint64_t count = item->count; log_perf("%s," // item name "%" PRIu64 "," // total count "%.3f," // total average "%.3f," // total throughput "%" PRIu64 "," // current count "%.3f," // current average "%.3f," // current throughput "%" PRIu64 "," // current max "%" PRIu64, // current min stat_item_names[i], item->total_count, total_count == 0 ? 0 : ((double)item->total_value_sum / total_count), item->total_count / (double)dur_total * 1000000, item->count, count == 0 ? 0 : ((double)item->value_sum / count), item->count / (double)dur_current * 1000000, item->max_value, ((uint64_t)-1 == item->min_value) ? 0 : item->min_value); } reset_current(now); }
static void blind_scan_next_time_process(bl_scan_priv_t *p_priv) { bs_cfg_t *p_cur_cfg = p_priv->bs_cfg_info + p_priv->cur_bs_times; class_handle_t nc_handle = class_get_handle_by_id(NC_CLASS_ID); scan_sat_info_t *p_sat = p_priv->perset_sat_list + p_priv->cur_sat_idx; p_priv->tuner_id = p_sat->tuner_id; nc_get_ts_by_tuner(nc_handle, p_priv->tuner_id, &p_priv->ts_in); if(p_cur_cfg->unicable_param.use_uc) { //always 13V and disable 22K nc_set_22k(nc_handle, p_priv->tuner_id, 0); nc_set_polarization(nc_handle, p_priv->tuner_id, NIM_PORLAR_VERTICAL); } else { nc_set_22k(nc_handle, p_priv->tuner_id, p_cur_cfg->onoff22k); nc_set_polarization(nc_handle, p_priv->tuner_id, p_cur_cfg->polarization); BS_DBG("blind cfg[%d],onoff[%d],polarization[%d]\n", p_priv->cur_bs_times, p_cur_cfg->onoff22k, p_cur_cfg->polarization); } nc_set_diseqc(nc_handle, p_priv->tuner_id, &p_sat->diseqc_info); p_priv->lst_fre_khz = p_cur_cfg->start_fre_khz; p_priv->scan_info.start_freq = p_cur_cfg->start_fre_khz; p_priv->scan_info.end_freq = p_cur_cfg->end_fre_khz; memcpy(&(p_priv->scan_info.uc_param), &(p_cur_cfg->unicable_param), sizeof(nim_unicable_param_t)); memset(&p_priv->cur_channel_unlocked, 0, sizeof(nim_channel_info_t)); memset(&p_priv->cur_channel_locked, 0, sizeof(nim_channel_info_t)); BS_DBG("next blind cfg[%d],start[%d],end[%d]\n", p_priv->cur_bs_times, p_priv->scan_info.start_freq, p_priv->scan_info.end_freq); nim_blind_scan_start(p_priv->p_dev[p_priv->tuner_id], &p_priv->scan_info);//start nim scan log_perf(LOG_AP_SCAN,PERF_DO_LOCK, 0, 0); }
/*! process the message mothed, it will be called by playback task. \param[in] p_handle playback handle \param[in] p_msg new message */ static void pb_single_step(handle_t handle, os_msg_t *p_msg) { pb_handle_t *p_handle = (pb_handle_t *)handle; priv_data_t *p_data = &p_handle->data; play_param_t *p_play_param = NULL; if(p_msg != NULL) { switch(p_msg->content) { case NC_EVT_UNLOCKED: case NC_EVT_LOCKED: OS_PRINTF("!!!!!PB:PB_EVT_LOCK_RSL %d\n", NC_EVT_LOCKED == p_msg->content); if(p_data->status != PB_STOP) { if (check_same_tp(p_handle, &p_data->play_param)) { OS_PRINTF("PB play ticks %d\n", mtos_ticks_get()); do_play(p_handle, &p_data->play_param); p_data->status = PB_PLAYING; p_handle->data.pat_monitor_start = mtos_ticks_get(); p_handle->data.pat_monitor_interval = 100; p_handle->p_policy->on_play(p_handle->p_policy->p_data, &p_data->play_param); p_data->sm = PB_SM_WAIT_VIDEO; } send_evt_to_ui(PB_EVT_LOCK_RSL, NC_EVT_LOCKED == p_msg->content, 0); } break; case PB_CMD_PLAY: OS_PRINTF("do lock ticks %d\n", mtos_ticks_get()); p_play_param = (play_param_t *)p_msg->para1; memcpy(&p_data->play_param, p_play_param, sizeof(play_param_t)); p_data->status = PB_PLAYING; do_play_chan_open(p_handle, &p_data->play_param); log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_START, 0, 0); lock_tuner_1(p_handle, &p_data->play_param); p_data->sm = PB_SM_WAIT_LOCK; break; case PB_CMD_STOP: log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_STOP, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); do_stop(p_handle, p_msg->para1); //pat_free(p_handle); OS_PRINTF("PB stop ticks %d\n", mtos_ticks_get()); p_data->status = PB_STOP; //p_data->status.cur_pg_id = INVALID_PG_ID; p_data->sm = PB_SM_IDLE; break; case PB_CMD_STOP_SYNC: log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_STOP_SYNC, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); do_stop(p_handle, p_msg->para1); OS_PRINTF("PB stop by sync ticks %d\n", mtos_ticks_get()); p_data->status = PB_STOP; p_data->sm = PB_SM_WAIT_STOP; send_evt_to_ui(PB_EVT_STOPPED, 0, 0); break; case PB_CMD_SWITCH_AUDIO_CHANNEL: switch_audio_channel(p_handle, p_msg->para1, p_msg->para2); break; case PB_CMD_SET_MUTE: //avc_set_mute((BOOL)p_msg->para1, (BOOL)p_msg->para2); send_evt_to_ui(PB_EVT_SET_MUTE, 0, 0); break; case PB_CMD_SET_VOL: //avc_setvolume((u8)p_msg->para1); send_evt_to_ui(PB_EVT_SET_VOL, 0, 0); break; case PB_CMD_RESET_TVMODE: p_data->play_param.pg_info.tv_mode = (u16)p_msg->para1; break; case PB_CMD_RESET_VIDEO_ASPECT_MODE: p_data->play_param.pg_info.aspect_ratio = p_msg->para1; break; case DVB_TABLE_TIMED_OUT: if(p_msg->para1 == DVB_TABLE_ID_PAT) { p_data->pat_request_flag = 0; } if(p_msg->para1 == DVB_TABLE_ID_NIT_ACTUAL) { p_data->nit_request_flag = 0; } break; case DVB_PAT_FOUND: p_data->pat_request_flag = 0; break; case DVB_PAT_PMT_INFO: if(p_data->play_param.pg_info.s_id == p_msg->para2) { pmt_request(p_handle, (u16)p_msg->para1, (u16)p_msg->para2); } break; case DVB_PMT_FOUND: if((p_data->status == PB_PLAYING) && (p_data->play_param.pg_info.s_id == (u32)(((pmt_t *)(p_msg->para1))->prog_num))) { do_dynamic_pid(p_handle, (pmt_t *)p_msg->para1); pmt_update_1(p_handle->data.p_sub_ttx_data, (pmt_t *)p_msg->para1); } else { subt_txt_info_reset_1(p_handle->data.p_sub_ttx_data); } break; case DVB_SDT_FOUND: if(p_data->status == PB_PLAYING) { do_revise_eid(p_handle, (sdt_t *)p_msg->para1); } if(p_data->play_param.lock_mode == SYS_DVBC) { pb_on_sdt_found(p_handle, (sdt_t *)p_msg->para1); } break; case DVB_NIT_FOUND: p_data->nit_request_flag = 0; pb_on_nit_found(p_handle, (nit_t *)p_msg->para1); break; //falcon debug case PB_CMD_START_TTX: vbi_ttx_start_vsb(p_msg->para1, p_msg->para2); break; case PB_CMD_STOP_TTX: vbi_ttx_stop_vsb(); break; case PB_CMD_SET_TTX_LANG: set_ttx_lang_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_POST_TTX_KEY: post_ttx_key_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_SHOW_TTX: show_ttx_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_HIDE_TTX: if(!hide_ttx_1(p_handle->data.p_sub_ttx_data)) { send_evt_to_ui(PB_EVT_HIDE_TTX, 0, 0); } break; case VBI_TTX_HIDED: case VBI_TTX_STOPPED: OS_PRINTF(">>>>>>VBI_TTX_HIDED!!!\n"); send_evt_to_ui(PB_EVT_HIDE_TTX, 0, 0); break; case PB_CMD_START_VBI_INSERTER: start_vbi_inserter_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_VBI_INSERTER: stop_vbi_inserter_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_START_SUBT: start_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_SUBT: stop_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_SUBT_SYNC: stop_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case SUBT_EVT_STOPPED: //OS_PRINTF("\n\n\n=====OK======\n\n\n"); send_evt_to_ui(PB_EVT_SUBT_STOPED, 0, 0); break; case PB_CMD_SET_SUBT_SERVICE: set_subt_service_1(p_handle->data.p_sub_ttx_data, p_msg->para1, p_msg->para2); break; case PB_CMD_SHOW_SUBT: show_subtitle_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_HIDE_SUBT: if(FALSE == hide_subtitle_1(p_handle->data.p_sub_ttx_data)) { send_evt_to_ui(PB_EVT_HIDE_SUBT, 0, 0); } //send_evt_to_ui(PB_EVT_HIDE_SUBT, 0, 0); break; default: break; } } else { switch(p_data->sm) { case PB_SM_IDLE: break; case PB_SM_WAIT_LOCK: break; case PB_SM_WAIT_VIDEO: if(wait_video_frame_1(p_handle)) { log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_DO_PLAY, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); OS_PRINTF("video out ticks %d\n", mtos_ticks_get()); p_data->signal_monitor_start = mtos_ticks_get(); p_data->sm = PB_SM_MONITOR_SIGNAL; sdt_request(p_handle); p_data->pat_request_flag = 0; } break; case PB_SM_MONITOR_SIGNAL: if((mtos_ticks_get() - p_data->signal_monitor_start) > 50) // 50ticks { p_data->signal_monitor_start = mtos_ticks_get(); monitor(p_handle); } if(((mtos_ticks_get() - p_data->pat_monitor_start) > p_data->pat_monitor_interval) && (!p_data->pat_request_flag)) // && (p_data->play_param.lock_mode == SYS_DVBS)) { pat_request(p_handle); p_data->pat_request_flag = 1; p_data->pat_monitor_start = mtos_ticks_get(); p_data->pat_monitor_interval = PAT_MONITOR_INTERVAL; } if(((mtos_ticks_get() - p_data->nit_monitor_start) > NIT_MONITOR_INTERVAL) && (!p_data->nit_request_flag) && (p_data->play_param.lock_mode == SYS_DVBC)) { nit_request(p_handle); p_data->nit_request_flag = 1; p_data->nit_monitor_start = mtos_ticks_get(); } break; case PB_SM_WAIT_STOP: p_data->sm = PB_SM_IDLE; break; default: break; } } }
int runTest(clFFT_Dim3 n, int batchSize, clFFT_Direction dir, clFFT_Dimension dim, clFFT_DataFormat dataFormat, int numIter, clFFT_TestType testType) { cl_int err = CL_SUCCESS; int iter; double t; uint64_t t0, t1; int mx = log2(n.x); int my = log2(n.y); int mz = log2(n.z); int length = n.x * n.y * n.z * batchSize; double gflops = 5e-9 * ((double)mx + (double)my + (double)mz) * (double)n.x * (double)n.y * (double)n.z * (double)batchSize * (double)numIter; clFFT_SplitComplex data_i_split = (clFFT_SplitComplex) { NULL, NULL }; clFFT_SplitComplex data_cl_split = (clFFT_SplitComplex) { NULL, NULL }; clFFT_Complex *data_i = NULL; clFFT_Complex *data_cl = NULL; clFFT_SplitComplexDouble data_iref = (clFFT_SplitComplexDouble) { NULL, NULL }; clFFT_SplitComplexDouble data_oref = (clFFT_SplitComplexDouble) { NULL, NULL }; clFFT_Plan plan = NULL; cl_mem data_in = NULL; cl_mem data_out = NULL; cl_mem data_in_real = NULL; cl_mem data_in_imag = NULL; cl_mem data_out_real = NULL; cl_mem data_out_imag = NULL; if(dataFormat == clFFT_SplitComplexFormat) { data_i_split.real = (float *) malloc(sizeof(float) * length); data_i_split.imag = (float *) malloc(sizeof(float) * length); data_cl_split.real = (float *) malloc(sizeof(float) * length); data_cl_split.imag = (float *) malloc(sizeof(float) * length); if(!data_i_split.real || !data_i_split.imag || !data_cl_split.real || !data_cl_split.imag) { err = -1; log_error("Out-of-Resources\n"); goto cleanup; } } else { data_i = (clFFT_Complex *) malloc(sizeof(clFFT_Complex)*length); data_cl = (clFFT_Complex *) malloc(sizeof(clFFT_Complex)*length); if(!data_i || !data_cl) { err = -2; log_error("Out-of-Resouces\n"); goto cleanup; } } data_iref.real = (double *) malloc(sizeof(double) * length); data_iref.imag = (double *) malloc(sizeof(double) * length); data_oref.real = (double *) malloc(sizeof(double) * length); data_oref.imag = (double *) malloc(sizeof(double) * length); if(!data_iref.real || !data_iref.imag || !data_oref.real || !data_oref.imag) { err = -3; log_error("Out-of-Resources\n"); goto cleanup; } int i; if(dataFormat == clFFT_SplitComplexFormat) { for(i = 0; i < length; i++) { data_i_split.real[i] = 2.0f * (float) rand() / (float) RAND_MAX - 1.0f; data_i_split.imag[i] = 2.0f * (float) rand() / (float) RAND_MAX - 1.0f; data_cl_split.real[i] = 0.0f; data_cl_split.imag[i] = 0.0f; data_iref.real[i] = data_i_split.real[i]; data_iref.imag[i] = data_i_split.imag[i]; data_oref.real[i] = data_iref.real[i]; data_oref.imag[i] = data_iref.imag[i]; } } else { for(i = 0; i < length; i++) { data_i[i].real = 2.0f * (float) rand() / (float) RAND_MAX - 1.0f; data_i[i].imag = 2.0f * (float) rand() / (float) RAND_MAX - 1.0f; data_cl[i].real = 0.0f; data_cl[i].imag = 0.0f; data_iref.real[i] = data_i[i].real; data_iref.imag[i] = data_i[i].imag; data_oref.real[i] = data_iref.real[i]; data_oref.imag[i] = data_iref.imag[i]; } } plan = clFFT_CreatePlan( context, n, dim, dataFormat, &err ); if(!plan || err) { log_error("clFFT_CreatePlan failed\n"); goto cleanup; } //clFFT_DumpPlan(plan, stdout); if(dataFormat == clFFT_SplitComplexFormat) { data_in_real = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float), data_i_split.real, &err); if(!data_in_real || err) { log_error("clCreateBuffer failed\n"); goto cleanup; } data_in_imag = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float), data_i_split.imag, &err); if(!data_in_imag || err) { log_error("clCreateBuffer failed\n"); goto cleanup; } if(testType == clFFT_OUT_OF_PLACE) { data_out_real = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float), data_cl_split.real, &err); if(!data_out_real || err) { log_error("clCreateBuffer failed\n"); goto cleanup; } data_out_imag = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float), data_cl_split.imag, &err); if(!data_out_imag || err) { log_error("clCreateBuffer failed\n"); goto cleanup; } } else { data_out_real = data_in_real; data_out_imag = data_in_imag; } } else { data_in = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float)*2, data_i, &err); if(!data_in) { log_error("clCreateBuffer failed\n"); goto cleanup; } if(testType == clFFT_OUT_OF_PLACE) { data_out = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, length*sizeof(float)*2, data_cl, &err); if(!data_out) { log_error("clCreateBuffer failed\n"); goto cleanup; } } else data_out = data_in; } err = CL_SUCCESS; t0 = mach_absolute_time(); if(dataFormat == clFFT_SplitComplexFormat) { for(iter = 0; iter < numIter; iter++) err |= clFFT_ExecutePlannar(queue, plan, batchSize, dir, data_in_real, data_in_imag, data_out_real, data_out_imag, 0, NULL, NULL); } else { for(iter = 0; iter < numIter; iter++) err |= clFFT_ExecuteInterleaved(queue, plan, batchSize, dir, data_in, data_out, 0, NULL, NULL); } err |= clFinish(queue); if(err) { log_error("clFFT_Execute\n"); goto cleanup; } t1 = mach_absolute_time(); t = subtractTimes(t1, t0); char temp[100]; sprintf(temp, "GFlops achieved for n = (%d, %d, %d), batchsize = %d", n.x, n.y, n.z, batchSize); log_perf(gflops / (float) t, 1, "GFlops/s", "%s", temp); if(dataFormat == clFFT_SplitComplexFormat) { err |= clEnqueueReadBuffer(queue, data_out_real, CL_TRUE, 0, length*sizeof(float), data_cl_split.real, 0, NULL, NULL); err |= clEnqueueReadBuffer(queue, data_out_imag, CL_TRUE, 0, length*sizeof(float), data_cl_split.imag, 0, NULL, NULL); } else { err |= clEnqueueReadBuffer(queue, data_out, CL_TRUE, 0, length*sizeof(float)*2, data_cl, 0, NULL, NULL); } if(err) { log_error("clEnqueueReadBuffer failed\n"); goto cleanup; } computeReferenceD(&data_oref, n, batchSize, dim, dir); double diff_avg, diff_max, diff_min; if(dataFormat == clFFT_SplitComplexFormat) { diff_avg = computeL2Error(&data_cl_split, &data_oref, n.x*n.y*n.z, batchSize, &diff_max, &diff_min); if(diff_avg > eps_avg) log_error("Test failed (n=(%d, %d, %d), batchsize=%d): %s Test: rel. L2-error = %f eps (max=%f eps, min=%f eps)\n", n.x, n.y, n.z, batchSize, (testType == clFFT_OUT_OF_PLACE) ? "out-of-place" : "in-place", diff_avg, diff_max, diff_min); else log_info("Test passed (n=(%d, %d, %d), batchsize=%d): %s Test: rel. L2-error = %f eps (max=%f eps, min=%f eps)\n", n.x, n.y, n.z, batchSize, (testType == clFFT_OUT_OF_PLACE) ? "out-of-place" : "in-place", diff_avg, diff_max, diff_min); } else { clFFT_SplitComplex result_split; result_split.real = (float *) malloc(length*sizeof(float)); result_split.imag = (float *) malloc(length*sizeof(float)); convertInterleavedToSplit(&result_split, data_cl, length); diff_avg = computeL2Error(&result_split, &data_oref, n.x*n.y*n.z, batchSize, &diff_max, &diff_min); if(diff_avg > eps_avg) log_error("Test failed (n=(%d, %d, %d), batchsize=%d): %s Test: rel. L2-error = %f eps (max=%f eps, min=%f eps)\n", n.x, n.y, n.z, batchSize, (testType == clFFT_OUT_OF_PLACE) ? "out-of-place" : "in-place", diff_avg, diff_max, diff_min); else log_info("Test passed (n=(%d, %d, %d), batchsize=%d): %s Test: rel. L2-error = %f eps (max=%f eps, min=%f eps)\n", n.x, n.y, n.z, batchSize, (testType == clFFT_OUT_OF_PLACE) ? "out-of-place" : "in-place", diff_avg, diff_max, diff_min); free(result_split.real); free(result_split.imag); } cleanup: clFFT_DestroyPlan(plan); if(dataFormat == clFFT_SplitComplexFormat) { if(data_i_split.real) free(data_i_split.real); if(data_i_split.imag) free(data_i_split.imag); if(data_cl_split.real) free(data_cl_split.real); if(data_cl_split.imag) free(data_cl_split.imag); if(data_in_real) clReleaseMemObject(data_in_real); if(data_in_imag) clReleaseMemObject(data_in_imag); if(data_out_real && testType == clFFT_OUT_OF_PLACE) clReleaseMemObject(data_out_real); if(data_out_imag && clFFT_OUT_OF_PLACE) clReleaseMemObject(data_out_imag); } else { if(data_i) free(data_i); if(data_cl) free(data_cl); if(data_in) clReleaseMemObject(data_in); if(data_out && testType == clFFT_OUT_OF_PLACE) clReleaseMemObject(data_out); } if(data_iref.real) free(data_iref.real); if(data_iref.imag) free(data_iref.imag); if(data_oref.real) free(data_oref.real); if(data_oref.imag) free(data_oref.imag); return err; }
static void scan_on_nc_unlocked(scan_priv_t *p_scan_priv, os_msg_t *p_msg) { log_perf(LOG_AP_SCAN, PERF_UNLOCK_EVT, ((nc_channel_info_t *)(p_msg->para1))->channel_info.frequency, 0); }
static void scan_state_machine(void *p_handle) { scan_priv_t *p_scan_priv = (scan_priv_t *)p_handle; scan_policy_t *p_scan_policy = p_scan_priv->p_policy; scan_data_t *p_scan_data = p_scan_priv->p_priv_data; find_tp_ret_t ret = FIND_SUC; class_handle_t nc_handle = class_get_handle_by_id(NC_CLASS_ID); event_t evt = {0}; // State machine switch(p_scan_data->state) { case SCAN_IDLE: break; case SCAN_GET_TP: // Get current tp information //log_perf(LOG_AP_SCAN, PERF_GET_TP_BEGIN,0,0); //log_perf(LOG_AP_SCAN, PERF_GET_ONETP_BEGIN,0,0); ret = p_scan_policy->get_tp_info(p_scan_policy->p_priv_data, &p_scan_data->p_rt_data->find_tp); if(FIND_SUC == ret) //found new tp { log_perf(LOG_AP_SCAN, PERF_GET_TP_END, p_scan_data->p_rt_data->find_tp.channel_info.frequency,0); p_scan_data->state = SCAN_LOCK_TP; } else if(FIND_DONE == ret) { log_perf(LOG_AP_SCAN, PERF_END,0,0); p_scan_data->state = SCAN_FINISHED; } else if(FIND_BUSY == ret) { //waiting.... } else { //what's happend? UFO? MT_ASSERT(0); } break; case SCAN_LOCK_TP: //Set current tp information log_perf(LOG_AP_SCAN,PERF_DO_LOCK, 0, 0); nc_set_tp(nc_handle, p_scan_data->p_nc_svc, &p_scan_data->p_rt_data->find_tp); p_scan_data->p_rt_data->job_dbg_info.spend_ticks = mtos_ticks_get(); //reset parameter init_para(p_scan_data); memcpy(&p_scan_data->p_rt_data->result.tp_info, &p_scan_data->p_rt_data->find_tp, sizeof(nc_channel_info_t)); //Wait new the lock status of recently set tp p_scan_data->state = SCAN_WAIT_TP_LOCK; break; case SCAN_WAIT_TP_LOCK: break; case SCAN_FINISHED: OS_PRINTF("scan state: SCAN_FINISHED\n"); log_perf(LOG_AP_SCAN, 100, 0, 0); scan_stop(p_scan_priv); evt.id = SCAN_EVT_FINISHED; evt.data1 = 0; ap_frm_send_evt_to_ui(APP_SCAN, &evt); p_scan_data->state = SCAN_IDLE; nvod_mosaic_buf_reset(class_get_handle_by_id(NVOD_MOSAIC_CLASS_ID)); break; case SCAN_SCANING: if(p_scan_data->p_rt_data->pending_job == 0) { RET_CODE ret = SUCCESS; /* MT_ASSERT(p_scan_data->p_rt_data->job_dbg_info.pat_num == 0); MT_ASSERT(p_scan_data->p_rt_data->job_dbg_info.sdt_num == 0); MT_ASSERT(p_scan_data->p_rt_data->job_dbg_info.pmt_num == 0); MT_ASSERT(p_scan_data->p_rt_data->job_dbg_info.video_packet_num == 0); MT_ASSERT(p_scan_data->p_rt_data->job_dbg_info.nit_num == 0); */ log_perf(LOG_AP_SCAN,PERF_SAVE_DB_START,PROG_DB,0); p_scan_data->p_rt_data->result.pg_num = p_scan_data->p_rt_data->cur_pg_offset; ret = p_scan_policy->on_tp_done(p_scan_policy->p_priv_data, &p_scan_data->p_rt_data->result); log_perf(LOG_AP_SCAN,PERF_SAVE_DB_DONE,PROG_DB,0); if(ret == SUCCESS) { log_perf(LOG_AP_SCAN, PERF_GET_ONETP_END,0,0); p_scan_data->state = SCAN_GET_TP; log_perf(LOG_AP_SCAN, PERF_GET_TP_BEGIN,0,0); log_perf(LOG_AP_SCAN, PERF_GET_ONETP_BEGIN,0,0); } else { //Database is full or some error, break scan p_scan_data->state = SCAN_IDLE; } } #if 0 //for specified bouquet id #else else if(p_scan_data->p_rt_data->bat_multi_mode) { if(mtos_ticks_get() - p_scan_data->p_rt_data->start_bat_tickets > 100*2) { scan_free_bat(p_scan_priv); } } #endif /* //for debug else { if(mtos_ticks_get() - p_scan_data->p_rt_data->job_dbg_info.spend_ticks > 100*2) { job_dbg_info_t *p_dbg = &p_scan_data->p_rt_data->job_dbg_info; SCAN_DBG("pending job %d, nit %d, pat %d, pmt %d, sdt %d, v %d\n", p_scan_data->p_rt_data->pending_job, p_dbg->nit_num, p_dbg->pat_num, p_dbg->pmt_num, p_dbg->sdt_num, p_dbg->video_packet_num); } } */ break; default: break; } }
static void scan_process_msg_runing(void *p_handle, os_msg_t *p_msg) { scan_priv_t *p_scan_priv = (scan_priv_t *)p_handle; scan_data_t *p_scan_data = p_scan_priv->p_priv_data; BOOL is_proc_policy = TRUE; RET_CODE ret = 0; MT_ASSERT(p_msg != NULL); //SCAN_DBG("scan get msg 0x%x\n", p_msg->content); switch(p_msg->content) { case NC_EVT_LOCKED: SCAN_DBG(("SCAN: NC_EVT_LOCKED\n")); if((p_scan_priv->p_policy != NULL) && (p_scan_priv->p_policy->repeat_tp_check != NULL) && (!p_scan_priv->p_policy->repeat_tp_check (p_scan_priv->p_policy->p_priv_data, (nc_channel_info_t *)p_msg->para1))) { p_scan_data->state = SCAN_GET_TP; is_proc_policy = FALSE; } else { scan_on_nc_locked(p_scan_priv, p_msg); p_scan_data->state = SCAN_SCANING; } break; case NC_EVT_UNLOCKED: SCAN_DBG(("SCAN: NC_EVT_UNLOCKED\n")); scan_on_nc_unlocked(p_scan_priv, p_msg); p_scan_data->state = SCAN_GET_TP; break; case DVB_PAT_FOUND: SCAN_DBG(("SCAN: DVB_PAT_FOUND\n")); scan_on_pat_found(p_scan_priv, p_msg); break; case DVB_NIT_FOUND: SCAN_DBG(("SCAN: DVB_NIT_FOUND\n")); log_perf(LOG_AP_SCAN, PERF_NIT_FOUND, 0, 0); scan_on_nit_found(p_scan_priv, p_msg); break; case DVB_BAT_FOUND: SCAN_DBG(("SCAN: DVB_BAT_FOUND\n")); log_perf(LOG_AP_SCAN, PERF_BAT_FOUND, 0, 0); scan_on_bat_found(p_scan_priv, p_msg); break; case DVB_PAT_PMT_INFO: SCAN_DBG(("SCAN: DVB_PAT_PMT_INFO\n")); log_perf(LOG_AP_SCAN, PERF_PAT_FOUND, 0, 0); scan_on_pmt_info_found(p_scan_priv, p_msg); break; case DVB_PMT_FOUND: log_perf(LOG_AP_SCAN, PERF_PMT_FOUND, ((pmt_t *)(p_msg->para1))->prog_num, 0); SCAN_DBG(("SCAN: DVB_PMT_FOUND\n")); scan_on_pmt_found(p_scan_priv, p_msg); break; case DVB_SCRAMBLE_FLAG_FOUND: SCAN_DBG(("SCAN: DVB_SCRAMBLE_FLAG_FOUND\n")); scan_on_scrambled(p_scan_priv, p_msg); break; case DVB_SDT_FOUND: SCAN_DBG(("SCAN: DVB_SDT_FOUND\n")); log_perf(LOG_AP_SCAN, PERF_SDT_FOUND, 0, 0); scan_on_sdt_found(p_scan_priv, p_msg); break; case DVB_TABLE_TIMED_OUT: SCAN_DBG("SCAN: DVB_TABLE_TIMED_OUT%x\n",p_msg->para1); scan_on_timedout(p_scan_priv, p_msg); break; case SCAN_CMD_CANCEL_SCAN: p_scan_data->state = SCAN_FINISHED; #if 0 //for specified bouquet id #else if(p_scan_priv->p_priv_data->p_rt_data->bat_multi_mode == TRUE) scan_free_bat(p_scan_priv); #endif break; case DVB_CAT_FOUND: log_perf(LOG_AP_SCAN, PERF_CAT_FOUND, 0, 0); p_scan_data->p_rt_data->job_dbg_info.cat_num--; p_scan_data->p_rt_data->pending_job--; break; default: break; } //The implement policy may override message process of scan process if(is_proc_policy && (p_scan_priv->p_policy != NULL)) { scan_policy_t *p_policy = p_scan_priv->p_policy; if(NC_EVT_LOCKED == p_msg->content) { log_perf(LOG_AP_SCAN, PERF_SAVE_DB_START,LOCK_TP_DB,0); ret = p_policy->msg_proc(p_policy->p_priv_data, p_msg); log_perf(LOG_AP_SCAN, PERF_SAVE_DB_DONE,LOCK_TP_DB,0); } else if(NC_EVT_UNLOCKED == p_msg->content) { log_perf(LOG_AP_SCAN, PERF_SAVE_DB_START,UNLOCK_TP_DB,0); ret = p_policy->msg_proc(p_policy->p_priv_data, p_msg); log_perf(LOG_AP_SCAN, PERF_SAVE_DB_DONE,UNLOCK_TP_DB,0); log_perf(LOG_AP_SCAN, PERF_GET_ONETP_END,0,0); log_perf(LOG_AP_SCAN, PERF_GET_TP_BEGIN,0,0); log_perf(LOG_AP_SCAN, PERF_GET_ONETP_BEGIN,0,0); } else { ret = p_policy->msg_proc(p_policy->p_priv_data, p_msg); } if(ERR_NO_MEM == ret) { scan_cancel(p_handle); } } }
static void epg_single_step(void *p_handle, os_msg_t *p_msg) { epg_priv_t *p_priv_data = (epg_priv_t *)p_handle; epg_policy_t *p_epg_impl = p_priv_data->p_epg_impl; epg_impl_data_t *p_impl_data = (epg_impl_data_t *)(p_epg_impl->p_data); proc_para_t *p_proc_data = (proc_para_t *)p_priv_data->p_proc_data; void *p_epg_db_handle = p_priv_data->p_epg_db_handle; epg_event_para_t evt_para = {0}; u32 cur_tick = 0; event_t evt = {0}; eit_t *p_eit = NULL; eit_t *p_eit_impl = NULL; eit_t eit_temp ={0}; dvb_section_t *p_sec = NULL; u32 section_buf_len = 0; dvb_request_t *p_eit_req = NULL; epg_db_status_t ret = EPG_DB_NORM; BOOL pf_new_ver = FALSE; BOOL lang_switch = FALSE; class_handle_t nc_handle = class_get_handle_by_id(NC_CLASS_ID); if(p_msg != NULL) { switch(p_msg->content) { case DVB_ONE_SEC_FOUND: p_eit = (eit_t *)p_msg->para1; p_sec = (dvb_section_t *)p_msg->para1; section_buf_len = p_msg->para2; eit_section_processing(p_sec->p_buffer, &eit_temp); p_eit_impl = (eit_t *)&eit_temp; if (p_epg_impl->epg_impl_send_rc_epg != NULL) { if (p_eit_impl->table_id != 0x4e && p_eit_impl->table_id != 0x4f) { //send p_sec buffer p_epg_impl->epg_impl_send_rc_epg(p_sec->p_buffer,section_buf_len); } } log_perf(LOG_AP_EPG, PERF_20_EVTS_BEGIN, p_eit_impl->svc_id, (u32)(sht_evt_desc_t *)(p_eit_impl->sht_evt_info)); /*****filter epg lang code*********/ lang_switch = epg_data_try_lang_code_priority( p_epg_db_handle,p_eit_impl); if(lang_switch == TRUE) { epg_data_delete(p_epg_db_handle, EPG_DEL_ALL_NODE, NULL); evt.id = EPG_EVT_EVT_DELETED; evt.data1 = 0; evt.data2 = 0; ap_frm_send_evt_to_ui(APP_EPG, &evt); epg_process_on_tab_free4(p_proc_data, p_epg_impl); epg_process_on_tab_req4(p_proc_data, p_epg_impl); break; } epg_data_filter_evt_lang_code(p_epg_db_handle,p_eit_impl); /**********filter epg lang code end**/ ret = epg_data_add(p_epg_db_handle, p_eit_impl, &pf_new_ver); log_perf(LOG_AP_EPG, PERF_20_EVTS_END, p_eit_impl->svc_id, (u32)(sht_evt_desc_t *)(p_eit_impl->sht_evt_info)); //epg_data_get_db_report(p_epg_db_handle); break; case EPG_CMD_START_SCAN: p_impl_data->ts_in = p_msg->para1; p_epg_impl->epg_impl_start(p_epg_impl->p_data, p_msg->para2); epg_process_tab_status_reset4(p_proc_data); epg_process_on_tab_req4(p_proc_data, p_epg_impl); break; case EPG_CMD_START_SCAN_PF: req_single_eit(p_proc_data->p_svc, p_msg->para1, p_msg->para2, p_impl_data->ts_in); break; case EPG_CMD_EIT_TS_UPDATE: nc_get_ts_by_tuner(nc_handle, p_msg->para1&0xff, &p_impl_data->ts_in); p_proc_data->p_svc->do_cmd(p_proc_data->p_svc, DVB_TABLE_TS_UPDATE, DVB_TABLE_ID_EIT_ACTUAL, p_impl_data->ts_in); break; case EPG_CMD_STOP_SCAN: epg_process_on_tab_free4(p_proc_data, p_epg_impl); break; case DVB_FREED: p_eit_req = (dvb_request_t *)p_msg->para1; if(p_eit_req->table_id == DVB_TABLE_ID_EIT_SCH_ACTUAL_51) { epg_data_mem_release(p_epg_db_handle); send_msg_to_ui(EPG_EVT_STOP); } break; case EPG_CMD_SAMPLE: EPG_PRINT("!!!!!!!!!!!!!rcv msg from UI"); break; default: break; } } if(pf_new_ver == TRUE) { EPG_PRINT("!!!!EPG_EVT_NEW_PF_VER_FOUND:%d %d\n", p_eit->svc_id, p_eit->sht_evt_info[0].parental_rating.rating); evt_para.orig_network_id = p_eit->org_nw_id; evt_para.ts_id = p_eit->stream_id; evt_para.svc_id = p_eit->svc_id; evt_para.parental_rating = p_eit->sht_evt_info[0].parental_rating.rating; evt.id = EPG_EVT_NEW_PF_VER_FOUND; evt.data1 = (u32)(&evt_para); ap_frm_send_evt_to_ui(APP_EPG, &evt); } if(p_impl_data->pf_switch_enable == TRUE) { //check pf section status before state machine if(p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].table_is_requested == TRUE) { cur_tick = mtos_ticks_get(); if((cur_tick - p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].tick_requsted) > p_impl_data->pf_requested_interval) { free_eit_section4(p_proc_data->p_svc, p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].table_id, p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].p_buf_addr); p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].table_is_requested = FALSE; p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].tick_freed = mtos_ticks_get(); } } else { cur_tick = mtos_ticks_get(); if((cur_tick - p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].tick_freed) > p_impl_data->pf_freed_interval) { //EPG_PRINT("!!!!!Before delete overdue!!\n"); epg_data_delete(p_epg_db_handle, EPG_DEL_OVERDEU_EVT, NULL); ///EPG_PRINT("!!!!!After delete overdue!!\n"); evt.id = EPG_EVT_EVT_DELETED; evt.data1 = 0; evt.data2 = 0; ap_frm_send_evt_to_ui(APP_EPG, &evt); //EPG_PRINT("!!!!!!!!!PF section OPEN!!!!!!!\n"); request_eit_section4(p_proc_data->p_svc, p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].table_id, p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].p_buf_addr, p_impl_data->ts_in); p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].table_is_requested = TRUE; p_proc_data->default_tab_map[EIT_ACTUAL_INDEX].tick_requsted = mtos_ticks_get(); } } } //state machine switch(ret) { case EPG_DB_OVERFLOW: // EPG_PRINT("!!!!!MEM_OVERFLOW!Before delete by dynamic policy!\n"); // epg_data_get_db_report(p_epg_db_handle); epg_data_delete(p_epg_db_handle, EPG_DEL_EXP_DY_POLICY, NULL); evt.id = EPG_EVT_EVT_DELETED; evt.data1 = 0; evt.data2 = 0; ap_frm_send_evt_to_ui(APP_EPG, &evt); // EPG_PRINT("!!!!!After delete by dynamic policy!\n"); // epg_data_get_db_report(p_epg_db_handle); break; case EPG_DB_NEW_SEC_FOUND: if(++p_proc_data->captured_eit_num >= p_impl_data->new_section_num) { p_proc_data->captured_eit_num = 0; evt.id = EPG_EVT_NEW_SEC_FOUND; evt.data1 = p_eit->svc_id; evt.data2 = p_eit->stream_id; ap_frm_send_evt_to_ui(APP_EPG, &evt); } break; default: break; } }
static RET_CODE rec_pin_on_fill_sample(handle_t _this, media_sample_t *p_sample, u32 fill_len, s64 position) { rec_pin_private_t *p_priv = get_priv(_this); u8 *p_data = NULL; u64 up = 0; u64 data_size = 0; u64 get_size = 0; u64 unit_size = p_priv->cfg.fill_unit_size; u64 unit_left = 0; u64 offset = 0; u64 overflow_len = 0; u32 top = 0; CHECK_FAIL_RET_CODE(_this != NULL); if(p_priv->b_hold) { return ERR_FAILURE; } dmx_rec_get_data(p_priv->p_dmx_dev, p_priv->cfg.rec_in, &data_size); if(data_size == 0) { //mtos_task_sleep(10); //wait stream in return SUCCESS; } up = data_size - p_priv->obtain_data_len; get_size = up - up % unit_size; if(get_size >= p_priv->cfg.fill_expect_size) { if(get_size > p_priv->cfg.total_buf_len) { overflow_len = get_size - p_priv->cfg.total_buf_len; OS_PRINTF("\n\n\nrec data overflow %lld packet !!\n\n\n", overflow_len / 188); //find to the don't overwrite buffer p_priv->obtain_data_len += overflow_len; get_size -= overflow_len; get_size = get_size - get_size % unit_size; if(get_size < p_priv->cfg.fill_expect_size) { return ERR_FAILURE; } } offset = p_priv->obtain_data_len % p_priv->cfg.total_buf_len; p_data = p_priv->cfg.p_rec_buffer + (u32)offset; #if 1 unit_left = (u64)p_priv->cfg.total_buf_len - offset; if ((unit_left < unit_size) && (p_priv->cfg.total_buf_len % p_priv->cfg.fill_unit_size)) { memcpy((void *)((u32)p_data + (u32)unit_left), p_priv->cfg.p_rec_buffer, (u32)(unit_size - unit_left)); p_priv->obtain_data_len += unit_size; p_sample->payload = unit_size; p_sample->p_data = p_data; return SUCCESS; } #endif if(get_size + offset > p_priv->cfg.total_buf_len) { top = get_size + offset - p_priv->cfg.total_buf_len; get_size -= top; get_size = get_size - get_size % unit_size; } p_sample->p_data = p_data; p_sample->payload = get_size; p_priv->obtain_data_len += get_size; //OS_PRINTF("rec_fill_sample: offset [%d]*188, get_size[%d]*188\n", // offset/188, get_size / 188); log_perf(LOG_DMX_FILTER_REC_PIN, TAG_GET_PALYLOAD, (u32)(p_sample->payload / 188), 0); return SUCCESS; } else { mtos_task_sleep(10); //wait stream in return ERR_FAILURE; } }
int main(int argc, char *argv[]) { int size, length, i; int *data; int *target; int fds[2]; int shm_size = SHM_SIZE; char *areas[2]; double bs, as, br, ar; if (argc > 1) { size = atoi(argv[1]); length = size / sizeof(int); size = sizeof(int) * length; } else exit(1); if (argc > 2) { shm_size = atoi(argv[2]); } if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) { perror("socketpair"); exit(1); } areas[0] = mmap(0, shm_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); if (areas[0] == MAP_FAILED) { perror("mmap: "); abort(); } areas[1] = mmap(0, shm_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); if (areas[1] == MAP_FAILED) { perror("mmap: "); abort(); } log_perf("before init, size=%d", size); data = malloc(size); for(i=0; i<length; i++) data[i] = i; log_perf("after init"); int idx; int count = 0; if (!fork()) { /* child */ free(data); target = malloc(size); idx = 0; count = 0; syncup(fds[1]); br = log_perf("start read"); syncup(fds[1]); while (count < size) { int read_size = (size - count) > shm_size ? shm_size : (size - count); memcpy(((void *)target)+count, areas[idx], read_size); count += read_size; idx = (idx + 1) % 2; syncup(fds[1]); } ar = log_perf("done read"); internal_send(fds[1], &br, sizeof(double)); internal_send(fds[1], &ar, sizeof(double)); for(i=0; i<length; i++) assert(target[i] == i); } else { /* parent */ idx = 0; count = 0; syncup(fds[0]); bs = log_perf("start write"); while (count < size) { int write_size = (size - count) > shm_size ? shm_size : (size - count); memcpy(areas[idx], ((void *)data)+count, write_size); count += write_size; idx = (idx + 1) % 2; syncup(fds[0]); } syncup(fds[0]); as = log_perf("done write"); internal_recv(fds[0], &br, sizeof(double)); internal_recv(fds[0], &ar, sizeof(double)); printf("TIME: %f\n", max(as,ar) - min(bs,br) ); /* wait for child to die */ wait(NULL); } return 0; }
static find_tp_ret_t find_tp(bl_scan_priv_t *p_priv, nc_channel_info_t *p_channel) { u16 count = 0; u16 index = p_priv->cur_channel_idx; bs_cfg_t *p_cur_cfg = NULL; while(TRUE) { if(index < p_priv->channel_count) { p_cur_cfg = p_priv->bs_cfg_info + p_priv->cur_bs_times; memcpy(&p_channel->channel_info, p_priv->channel_map + index, sizeof(nim_channel_info_t)); p_channel->onoff22k = p_cur_cfg->onoff22k; if(C_BAND == p_cur_cfg->freqBand && DOUBLE_LOCAL_OSCILLATOR == p_cur_cfg->localOscillator) { p_channel->polarization = p_channel->channel_info.frequency > (1550 * KHZ) ? 1 : 0; } else { p_channel->polarization = p_cur_cfg->polarization; } //copy unicable information. if(p_cur_cfg->unicable_param.use_uc) { memcpy(&p_channel->channel_info.param.dvbs.uc_param, &p_cur_cfg->unicable_param, sizeof(nim_unicable_param_t)); } else { memset(&p_channel->channel_info.param.dvbs.uc_param, 0x0, sizeof(nim_unicable_param_t)); } return FIND_SUC; } log_perf(LOG_AP_SCAN, PERF_PRE_SCAN, 0, 0); //pre scan current satellite if(pre_scan(p_priv, &count)) { if(count > 0) { p_priv->channel_count += count; if(p_priv->channel_count > MAX_TP_NUM_PER_SAT) { return FIND_DONE; } } else { log_perf(LOG_AP_SCAN, PERF_SCAN_EVT, 0, 0); return FIND_BUSY; } } else { log_perf(LOG_AP_SCAN, PERF_SCAN_EVT, 0, 0); return FIND_DONE; } log_perf(LOG_AP_SCAN, PERF_SCAN_EVT, 0, 0); } }