static enum hrtimer_restart _DISP_CmdModeTimer_handler(struct hrtimer *timer) { EXT_DISP_LOG("fake timer, wake up\n"); dpmgr_signal_event(pgc->dpmgr_handle, DISP_PATH_EVENT_IF_VSYNC); #if 0 if((get_current_time_us() - pgc->last_vsync_tick) > 16666) { dpmgr_signal_event(pgc->dpmgr_handle, DISP_PATH_EVENT_IF_VSYNC); pgc->last_vsync_tick = get_current_time_us(); } #endif return HRTIMER_RESTART; }
void dprec_logger_done(unsigned int type_logsrc, unsigned int val1, unsigned int val2) { unsigned long flags = 0; dprec_to_mmp(type_logsrc, MMProfileFlagEnd, val1, val2); DPREC_LOGGER_ENUM source = type_logsrc &0xffffff; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger* l = &logger[source]; unsigned long long time = get_current_time_us(); if(l->ts_start == 0) { goto done; } l->period_frame = time- l->ts_trigger; if(l->period_frame > l->period_max_frame) l->period_max_frame = l->period_frame; if(l->period_frame < l->period_min_frame) l->period_min_frame = l->period_frame; l->period_total += l->period_frame; l->count ++; if(source == DPREC_LOGGER_RDMA0_TRANSFER) { //DISPMSG("done, count=%llu,period=%llu.%02lums,max=%llu.%02lums\n", l->count, SPLIT_NS(l->period_frame), SPLIT_NS(l->period_max_frame)); } done: spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); }
void DBG_OnHDMIDone(void) { long int time; if (!dbg_opt.en_fps_log && !dbg_opt.en_touch_latency_log) return; // deal with touch latency log time = get_current_time_us(); hdmi_fps.current_hdmi_time_us = (time - hdmi_fps.trigger_hdmi_time_us); if (!dbg_opt.en_fps_log) return; // deal with fps log hdmi_fps.total_hdmi_time_us += hdmi_fps.current_hdmi_time_us; ++ hdmi_fps.trigger_hdmi_count; if (hdmi_fps.trigger_hdmi_count >= dbg_opt.log_fps_wnd_size) { long int f = hdmi_fps.trigger_hdmi_count * 100 * 1000 * 1000 / (time - hdmi_fps.hdmi_start_time_us); long int update = hdmi_fps.total_hdmi_time_us * 100 / (1000 * hdmi_fps.trigger_hdmi_count); DISP_LOG_PRINT(ANDROID_LOG_INFO, "DBG", "[HDMI] FPS: %ld.%02ld, Avg. update time: %ld.%02ld ms\n", f / 100, f % 100, update / 100, update % 100); reset_hdmi_fps_logger(); } }
static void _WaitForEngineNotBusy(void) { int timeOut; #if ENABLE_DSI_INTERRUPT long int time; static const long WAIT_TIMEOUT = 2 * HZ; // 2 sec #endif if (DSI_REG->DSI_MODE_CTRL.MODE) return ; timeOut = 20; #if ENABLE_DSI_INTERRUPT time = get_current_time_us(); if (in_interrupt()) { // perform busy waiting if in interrupt context while(_IsEngineBusy()) { msleep(1); if (--timeOut < 0) { DISP_LOG_PRINT(ANDROID_LOG_ERROR, "DSI", " Wait for DSI engine not busy timeout!!!(Wait %d us)\n", get_current_time_us() - time); DSI_DumpRegisters(); DSI_Reset(); break; } } } else { while (_IsEngineBusy()) { long ret = wait_event_interruptible_timeout(_dsi_wait_queue, !_IsEngineBusy(), WAIT_TIMEOUT); if (0 == ret) { DISP_LOG_PRINT(ANDROID_LOG_WARN, "DSI", " Wait for DSI engine not busy timeout!!!\n"); } } } #else while(_IsEngineBusy()) { msleep(1); if (--timeOut < 0) { DISP_LOG_PRINT(ANDROID_LOG_ERROR, "DSI", " Wait for DSI engine not busy timeout!!!\n"); DSI_DumpRegisters(); DSI_Reset(); break; } } #endif }
void DBG_OnTriggerHDMI(void) { if (!dbg_opt.en_fps_log && !dbg_opt.en_touch_latency_log) return; hdmi_fps.trigger_hdmi_time_us = get_current_time_us(); if (hdmi_fps.trigger_hdmi_count == 0) { hdmi_fps.hdmi_start_time_us = hdmi_fps.trigger_hdmi_time_us; } }
void DBG_OnTriggerLcd(void) { if (!dbg_opt.en_fps_log && !dbg_opt.en_touch_latency_log) return; fps.trigger_lcd_time_us = get_current_time_us(); if (fps.trigger_lcd_count == 0) { fps.start_time_us = fps.trigger_lcd_time_us; } }
void dprec_logger_reset_all(void) { int i = 0; for(i = 0;i<sizeof(logger)/sizeof(logger[0]);i++) { dprec_logger_reset(i); } ts_dprec_reset = get_current_time_us(); }
void DBG_OnLcdDone(void) { long int time; if (!dbg_opt.en_fps_log && !dbg_opt.en_touch_latency_log) return; // deal with touch latency log time = get_current_time_us(); fps.current_lcd_time_us = (time - fps.trigger_lcd_time_us); #if 0 // FIXME if (dbg_opt.en_touch_latency_log && tpd_start_profiling) { DISP_LOG_PRINT(ANDROID_LOG_INFO, "DBG", "Touch Latency: %ld ms\n", (time - tpd_last_down_time) / 1000); DISP_LOG_PRINT(ANDROID_LOG_INFO, "DBG", "LCD update time %ld ms (TE delay %ld ms + LCD %ld ms)\n", fps.current_lcd_time_us / 1000, fps.current_te_delay_time_us / 1000, (fps.current_lcd_time_us - fps.current_te_delay_time_us) / 1000); tpd_start_profiling = 0; } #endif if (!dbg_opt.en_fps_log) return; // deal with fps log fps.total_lcd_time_us += fps.current_lcd_time_us; ++ fps.trigger_lcd_count; if (fps.trigger_lcd_count >= dbg_opt.log_fps_wnd_size) { long int f = fps.trigger_lcd_count * 100 * 1000 * 1000 / (time - fps.start_time_us); long int update = fps.total_lcd_time_us * 100 / (1000 * fps.trigger_lcd_count); long int te = fps.total_te_delay_time_us * 100 / (1000 * fps.trigger_lcd_count); long int lcd = (fps.total_lcd_time_us - fps.total_te_delay_time_us) * 100 / (1000 * fps.trigger_lcd_count); DISP_LOG_PRINT(ANDROID_LOG_INFO, "DBG", "MTKFB FPS: %ld.%02ld, Avg. update time: %ld.%02ld ms " "(TE delay %ld.%02ld ms, LCD %ld.%02ld ms)\n", f / 100, f % 100, update / 100, update % 100, te / 100, te % 100, lcd / 100, lcd % 100); reset_fps_logger(); } }
void DBG_OnTeDelayDone(void) { long int time; if (!dbg_opt.en_fps_log && !dbg_opt.en_touch_latency_log) return; time = get_current_time_us(); fps.current_te_delay_time_us = (time - fps.trigger_lcd_time_us); fps.total_te_delay_time_us += fps.current_te_delay_time_us; }
void dprec_done(dprec_logger_event *event, unsigned int val1, unsigned int val2) { if(event) { if(event->level & DPREC_LOGGER_LEVEL_MMP) { MMProfileLogEx(event->mmp, MMProfileFlagEnd, val1, val2); } if(event->level & DPREC_LOGGER_LEVEL_LOGGER) { unsigned long flags = 0; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger *l = &(event->logger); unsigned long long time = get_current_time_us(); if(l->ts_start != 0) { l->period_frame = time- l->ts_trigger; if(l->period_frame > l->period_max_frame) l->period_max_frame = l->period_frame; if(l->period_frame < l->period_min_frame) l->period_min_frame = l->period_frame; l->ts_trigger = 0; l->period_total += l->period_frame; l->count ++; } spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); } if(event->level & DPREC_LOGGER_LEVEL_MOBILE_LOG) { //xlog_printk(ANDROID_LOG_DEBUG,"DPREC"LOG_TAG, "DISP/"LOG_TAG,"done,0x%08x,0x%08x\n",event->name, val1, val2); } if(event->level & DPREC_LOGGER_LEVEL_UART_LOG) { printk("DISP/%s done,0x%08x,0x%08x\n",event->name, val1, val2); } #ifdef CONFIG_TRACING if(event->level & DPREC_LOGGER_LEVEL_SYSTRACE && _control.systrace) { mmp_kernel_trace_end(); //trace_printk("E|%s\n", event->name); } #endif } }
void dprec_start(dprec_logger_event *event, unsigned int val1, unsigned int val2) { if(event) { if(event->level & DPREC_LOGGER_LEVEL_MMP) { MMProfileLogEx(event->mmp, MMProfileFlagStart, val1, val2); } if(event->level & DPREC_LOGGER_LEVEL_LOGGER) { unsigned long flags = 0; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger *l = &(event->logger); unsigned long long time = get_current_time_us(); if(l->count == 0) { l->ts_start = time; l->period_min_frame = 0xffffffffffffffff; } l->ts_trigger = time; spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); } if(event->level & DPREC_LOGGER_LEVEL_MOBILE_LOG) { //xlog_printk(ANDROID_LOG_DEBUG, "DPREC/"LOG_TAG, "DISP/%s start,0x%08x,0x%08x\n",event->name, val1, val2); } if(event->level & DPREC_LOGGER_LEVEL_UART_LOG) { printk("DISP/%s start,0x%08x,0x%08x\n",event->name, val1, val2); } #ifdef CONFIG_TRACING if(event->level & DPREC_LOGGER_LEVEL_SYSTRACE && _control.systrace) { char name[256]; scnprintf(name, sizeof(name)/sizeof(name[0]), "K_%s_0x%x_0x%x", event->name, val1, val2); mmp_kernel_trace_begin(name); //trace_printk("B|%d|%s\n", current->pid, event->name); } #endif } }
int ext_disp_wait_for_vsync(void *config) { disp_session_vsync_config *c = (disp_session_vsync_config *)config; int ret = 0; ret = dpmgr_wait_event(pgc->dpmgr_handle, DISP_PATH_EVENT_IF_VSYNC); ///dprec_logger_trigger(DPREC_LOGGER_VSYNC); if(ret == -2) { EXT_DISP_LOG("vsync for ext display path not enabled yet\n"); return -1; } //EXT_DISP_LOG("vsync signaled\n"); c->vsync_ts = get_current_time_us(); c->vsync_cnt ++; return ret; }
void dprec_logger_trigger(unsigned int type_logsrc, unsigned int val1, unsigned int val2) { unsigned long flags = 0; dprec_to_mmp(type_logsrc, MMProfileFlagPulse, val1, val2); DPREC_LOGGER_ENUM source = type_logsrc &0xffffff; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger* l = &logger[source]; unsigned long long time = get_current_time_us(); if(l->count == 0) { l->ts_start = time; l->ts_trigger = time; l->period_min_frame = 0xffffffffffffffff; } else { l->period_frame = time- l->ts_trigger; if(l->period_frame > l->period_max_frame) l->period_max_frame = l->period_frame; if(l->period_frame < l->period_min_frame) l->period_min_frame = l->period_frame; l->ts_trigger = time; if(l->count == 0) { l->ts_start = l->ts_trigger; } } l->count ++; if(source == DPREC_LOGGER_DSI_EXT_TE) { //DISPMSG("count=%d, time=%llu, period=%llu, max=%llu,min=%llu,start=%llu,trigger=%llu\n", l->count, time, l->period_frame, l->period_max_frame, l->period_min_frame, l->ts_start, l->ts_trigger); //DISPMSG("count=%d,period=%lld.%02lums,max=%lld.%02lums\n", l->count, SPLIT_NS(l->period_frame), SPLIT_NS(l->period_max_frame)); } spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); }
void dprec_logger_start(unsigned int type_logsrc, unsigned int val1, unsigned int val2) { unsigned long flags = 0; dprec_to_mmp(type_logsrc, MMProfileFlagStart, val1, val2); DPREC_LOGGER_ENUM source = type_logsrc &0xffffff; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger* l = &logger[source]; unsigned long long time = get_current_time_us(); if(l->count == 0) { l->ts_start = time; l->period_min_frame = 0xffffffffffffffff; } l->ts_trigger = time; if(source == DPREC_LOGGER_RDMA0_TRANSFER) { //DISPMSG("start, count=%llu,trigger=%llu.%02lums\n", l->count, SPLIT_NS(l->ts_trigger)); } spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); }
unsigned long long dprec_logger_get_current_hold_period(unsigned int type_logsrc) { unsigned long long period = 0; unsigned long flags = 0; unsigned long long time = get_current_time_us(); DPREC_LOGGER_ENUM source = type_logsrc &0xffffff; spin_lock_irqsave(&gdprec_logger_spinlock, flags); dprec_logger* l = &logger[source]; if(l->ts_trigger) { period = (time - l->ts_trigger); } else { period = 0; } spin_unlock_irqrestore(&gdprec_logger_spinlock, flags); return period; }
int fec_encode_manager_t::append(char *s,int len/*,int &is_first_packet*/) { if(counter==0) { itimerspec its; memset(&its.it_interval,0,sizeof(its.it_interval)); first_packet_time=get_current_time_us(); my_time_t tmp_time=fec_timeout+first_packet_time; its.it_value.tv_sec=tmp_time/1000000llu; its.it_value.tv_nsec=(tmp_time%1000000llu)*1000llu; timerfd_settime(timer_fd,TFD_TIMER_ABSTIME,&its,0); } if(fec_mode==0)//for type 0 use blob { assert(blob_encode.input(s,len)==0); } else if(fec_mode==1)//for tpe 1 use input_buf and counter { mylog(log_trace,"counter=%d\n",counter); assert(len<=65535&&len>=0); //assert(len<=fec_mtu);//relax this limitation char * p=input_buf[counter]+sizeof(u32_t)+4*sizeof(char);//copy directly to final position,avoid unnecessary copy. //remember to change this,if protocol is modified write_u16(p,(u16_t)((u32_t)len)); //TODO omit this u16 for data packet while sending p+=sizeof(u16_t); memcpy(p,s,len); input_len[counter]=len+sizeof(u16_t); } else { assert(0==1); } counter++; return 0; }
void hdmi_update_impl(void) { HDMI_LOG("hdmi_update_impl\n"); int t = 0; //int ret = 0; //MdpkBitbltConfig pmdp; //int lcm_physical_rotation = 0; int pixelSize = p->hdmi_width * p->hdmi_height; int dataSize = pixelSize * hdmi_bpp; RET_VOID_IF_NOLOG(p->output_mode == HDMI_OUTPUT_MODE_DPI_BYPASS); if(pixelSize == 0) { HDMI_LOG("ignored[resolution is null]\n"); return; } //HDMI_FUNC(); if(down_interruptible(&hdmi_update_mutex)) { HDMI_LOG("[HDMI] can't get semaphore in\n"); return; } if (IS_HDMI_NOT_ON()) { goto done; } if(IS_HDMI_IN_VIDEO_MODE()) { goto done; } DBG_OnTriggerHDMI(); //LCD_WaitForNotBusy(); if(temp_va != 0 && hdmi_va != 0) { DdpkBitbltConfig pddp; int dstOffset; memset((void*)&pddp, 0, sizeof(DdpkBitbltConfig)); pddp.srcX = pddp.srcY = 0; pddp.srcW = p->lcm_width; pddp.srcH = p->lcm_height; pddp.srcWStride = p->lcm_width; pddp.srcHStride = p->lcm_height; pddp.srcAddr[0] = temp_va; pddp.srcFormat = eRGB888_K; pddp.srcBufferSize[0] = p->lcm_width*p->lcm_height*3; pddp.srcPlaneNum = 1; pddp.dstX = 0; pddp.dstY = 0; pddp.dstFormat = eARGB8888_K; pddp.pitch = p->hdmi_width; pddp.dstWStride = p->hdmi_width; pddp.dstHStride = p->hdmi_height; pddp.dstPlaneNum = 1; pddp.orientation = 0; switch(pddp.orientation) { case 90: case 270: #if 1 { pddp.dstW = ALIGN_TO(p->lcm_height * p->hdmi_height / p->lcm_width * 95 / 100, 4); pddp.dstH = ALIGN_TO(p->hdmi_height * 95 /100, 4); break; } #endif // fall through now case 0: case 180: { pddp.dstW = ALIGN_TO(p->hdmi_width * 95 / 100, 4); pddp.dstH = ALIGN_TO(p->hdmi_height * 95 /100, 4); break; } default: HDMI_LOG("Unknown orientation %d\n", pddp.orientation); return; } dstOffset = (p->hdmi_height - pddp.dstH ) / 2 * p->hdmi_width * hdmi_bpp + (p->hdmi_width - pddp.dstW) / 2 * hdmi_bpp; pddp.dstAddr[0] = hdmi_va;// + hdmi_buffer_write_id * p->hdmi_width * p->hdmi_height * hdmi_bpp + dstOffset; pddp.dstBufferSize[0] = p->hdmi_width*p->hdmi_height*hdmi_bpp; t = get_current_time_us(); DDPK_Bitblt_Config(DDPK_CH_HDMI_0, &pddp); DDPK_Bitblt(DDPK_CH_HDMI_0); } //HDMI_LOG("dstw=%d, dsth=%d, ori=%d\n", p.dstW, p.dstH, p.orientation); DBG_OnHDMIDone(); HDMI_LOG("cost %d us\n", get_current_time_us() - t); //hdmi_buffer_read_id = hdmi_buffer_write_id; //hdmi_buffer_write_id = (hdmi_buffer_write_id+1) % hdmi_params->intermediat_buffer_num; done: up(&hdmi_update_mutex); return; }
// learn_workloads(SharedVariable* v): // This function is called at the start part of the program before actual scheduling // - Parameters // sv: The variable which is shared for every function over all threads void learn_workloads(SharedVariable* sv) { // TODO: Fill the body // This function is executed before the scheduling simulation. // You need to calculate the execution time of each thread here. long long beginTime; long long endTime; // Thread functions for workloads: // thread_button, thread_twocolor, thread_temp, thread_track, // thread_shock, thread_rgbcolor, thread_aled, thread_buzzer beginTime = get_current_time_us(); thread_button(&sv); endTime = get_current_time_us(); sv->exec_times[0] = endTime - beginTime; beginTime = get_current_time_us(); thread_twocolor(&sv); endTime = get_current_time_us(); sv->exec_times[1] = endTime - beginTime; beginTime = get_current_time_us(); thread_temp(&sv); endTime = get_current_time_us(); sv->exec_times[2] = endTime - beginTime; beginTime = get_current_time_us(); thread_track(&sv); endTime = get_current_time_us(); sv->exec_times[3] = endTime - beginTime; beginTime = get_current_time_us(); thread_shock(&sv); endTime = get_current_time_us(); sv->exec_times[4] = endTime - beginTime; beginTime = get_current_time_us(); thread_rgbcolor(&sv); endTime = get_current_time_us(); sv->exec_times[5] = endTime - beginTime; beginTime = get_current_time_us(); thread_aled(&sv); endTime = get_current_time_us(); sv->exec_times[6] = endTime - beginTime; beginTime = get_current_time_us(); thread_buzzer(&sv); endTime = get_current_time_us(); sv->exec_times[7] = endTime - beginTime; //initiate idle time sv->totalIdleTime = 0; int i,j; //long long temp; for(i = 0; i < 8; ++i) { /**if(i%2 == 0) { sv->freq[i] = 0; } else { sv->freq[i] = 1; }**/ sv->deadlines[i] = LLONG_MAX; sv->prev_alive[i] = 0; } //basic way of setting a few tasks to high frequency long long max = sv->exec_times[7]; sv->freq[7] = 1; for(i = 6; i >= 0; --i) { if(sv->exec_times[i] > max) { max = sv->exec_times[i]; sv->freq[i] = 1; } else { sv->freq[i] = 0; } printDBG("exec %d = %lld\n", i, sv->exec_times[i]); printDBG("freq = %d\n", sv->freq[i]); } /** for(i = 0; i < 8; ++i) { for(j = i + 1; j < 8; ++j) { if(sv->exec_time[i] > sv->exec_time[j]) { temp = sv->exec_time[i]; sv->exec_time[i] = sv->exec_time[j]; sv->exec_time[j] = temp; } } }**/ // Tip 1. You can call each workload function here like: // thread_button(); // Tip 2. You can get the current time here like: // long long curTime = get_current_time_us(); }
int dprec_logger_get_result_string_all(char *stringbuf, int strlen) { int n = 0; int i = 0; n += scnprintf(stringbuf+n, strlen - n, "|**** Display Driver Statistic Information Dump ****\n"); n += scnprintf(stringbuf+n, strlen - n, "|Timestamp Begin=%llu.%03lds, End=%llu.%03lds\n", SPLIT_MS(ts_dprec_reset), SPLIT_MS(get_current_time_us())); n += scnprintf(stringbuf+n, strlen - n, "|------------------------+---------+------------+------------+------------+------------|\n"); n += scnprintf(stringbuf+n, strlen - n, "|Event | count | fps |average(ms) | max(ms) | min(ms) |\n"); n += scnprintf(stringbuf+n, strlen - n, "|------------------------+---------+------------+------------+------------+------------|\n"); for(i = 0;i<sizeof(logger)/sizeof(logger[0]);i++) { n += dprec_logger_get_result_string(i, stringbuf + n, strlen-n); } n += scnprintf(stringbuf+n, strlen - n, "|------------------------+---------+------------+------------+------------+------------|\n"); n += scnprintf(stringbuf+n, strlen - n, "dprec error log buffer\n"); return n; }