GED_ERROR ged_monitor_3D_fence_add(int fence_fd) { int err; GED_MONITOR_3D_FENCE* psMonitor; psMonitor = (GED_MONITOR_3D_FENCE*)ged_alloc(sizeof(GED_MONITOR_3D_FENCE)); if (!psMonitor) { return GED_ERROR_OOM; } sync_fence_waiter_init(&psMonitor->sSyncWaiter, ged_sync_cb); INIT_WORK(&psMonitor->sWork, ged_monitor_3D_fence_work_cb); psMonitor->psSyncFence = sync_fence_fdget(fence_fd); if (NULL == psMonitor->psSyncFence) { ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); return GED_ERROR_INVALID_PARAMS; } err = sync_fence_wait_async(psMonitor->psSyncFence, &psMonitor->sSyncWaiter); if ((1 == err) || (0 > err)) { sync_fence_put(psMonitor->psSyncFence); ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); } else if (0 == err) { int iCount = atomic_add_return(1, &g_i32Count); if (iCount > 1) { if (0 == ged_monitor_3D_fence_disable) { //unsigned int uiFreqLevelID; //if (mtk_get_bottom_gpu_freq(&uiFreqLevelID)) { //if (uiFreqLevelID != 4) { #ifdef CONFIG_GPU_TRACEPOINTS if (ged_monitor_3D_fence_systrace) { unsigned long long t = cpu_clock(smp_processor_id()); trace_gpu_sched_switch("Smart Boost", t, 1, 0, 1); } #endif mtk_set_bottom_gpu_freq(4); } } } } } if (ged_monitor_3D_fence_debug > 0) { GED_LOGI("[+]3D fences count = %d\n", atomic_read(&g_i32Count)); } return GED_OK; }
GED_ERROR ged_monitor_3D_fence_add(int fence_fd) { int err; GED_MONITOR_3D_FENCE* psMonitor = (GED_MONITOR_3D_FENCE*)ged_alloc(sizeof(GED_MONITOR_3D_FENCE)); #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "[+]ged_monitor_3D_fence_add"); #endif if (!psMonitor) { return GED_ERROR_OOM; } sync_fence_waiter_init(&psMonitor->sSyncWaiter, ged_sync_cb); INIT_WORK(&psMonitor->sWork, ged_monitor_3D_fence_work_cb); psMonitor->psSyncFence = sync_fence_fdget(fence_fd); if (NULL == psMonitor->psSyncFence) { ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); return GED_ERROR_INVALID_PARAMS; } #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "[+]sync_fence_wait_async"); #endif err = sync_fence_wait_async(psMonitor->psSyncFence, &psMonitor->sSyncWaiter); #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "[-]sync_fence_wait_async, err = %d", err); #endif if ((1 == err) || (0 > err)) { sync_fence_put(psMonitor->psSyncFence); ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); } else if (0 == err) { int iCount = atomic_add_return (1, &g_i32Count); if (iCount > 1) { //mtk_set_bottom_gpu_freq(iCount + 1); mtk_set_bottom_gpu_freq(4); } } #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "[-]ged_monitor_3D_fence_add, count = %d", atomic_read(&g_i32Count)); #endif return GED_OK; }
static void ged_monitor_3D_fence_work_cb(struct work_struct *psWork) { GED_MONITOR_3D_FENCE *psMonitor; if (atomic_sub_return(1, &g_i32Count) < 1) { if (0 == ged_monitor_3D_fence_disable) { //unsigned int uiFreqLevelID; //if (mtk_get_bottom_gpu_freq(&uiFreqLevelID)) { //if (uiFreqLevelID > 0) { mtk_set_bottom_gpu_freq(0); #ifdef CONFIG_GPU_TRACEPOINTS if (ged_monitor_3D_fence_systrace) { unsigned long long t = cpu_clock(smp_processor_id()); trace_gpu_sched_switch("Smart Boost", t, 0, 0, 1); } #endif } } } } if (ged_monitor_3D_fence_debug > 0) { GED_LOGI("[-]3D fences count = %d\n", atomic_read(&g_i32Count)); } psMonitor = GED_CONTAINER_OF(psWork, GED_MONITOR_3D_FENCE, sWork); sync_fence_put(psMonitor->psSyncFence); ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); }
static void ged_monitor_3D_fence_work_cb(struct work_struct *psWork) { GED_MONITOR_3D_FENCE *psMonitor; #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "ged_monitor_3D_fence_work_cb"); #endif if (atomic_sub_return(1, &g_i32Count) < 1) { #ifdef GED_DEBUG_MONITOR_3D_FENCE ged_log_buf_print(ghLogBuf_GED, "mtk_set_bottom_gpu_freq(0)"); #endif mtk_set_bottom_gpu_freq(0); } psMonitor = GED_CONTAINER_OF(psWork, GED_MONITOR_3D_FENCE, sWork); sync_fence_put(psMonitor->psSyncFence); ged_free(psMonitor, sizeof(GED_MONITOR_3D_FENCE)); }
/* * Initialize mged, configure the path, set up the tcl interpreter. */ void mged_setup(Tcl_Interp **interpreter) { int try_auto_path = 0; int init_tcl = 1; int init_itcl = 1; struct bu_vls str = BU_VLS_INIT_ZERO; const char *name = bu_argv0_full_path(); /* locate our run-time binary (must be called before Tcl_CreateInterp()) */ if (name) { Tcl_FindExecutable(name); } else { Tcl_FindExecutable("mged"); } if (!interpreter ) { bu_log("mged_setup Error - interpreter is NULL!\n"); return; } if (*interpreter != NULL) Tcl_DeleteInterp(*interpreter); /* Create the interpreter */ *interpreter = Tcl_CreateInterp(); /* a two-pass init loop. the first pass just tries default init * routines while the second calls tclcad_auto_path() to help it * find other, potentially uninstalled, resources. */ while (1) { /* not called first time through, give Tcl_Init() a chance */ if (try_auto_path) { /* Locate the BRL-CAD-specific Tcl scripts, set the auto_path */ tclcad_auto_path(*interpreter); } /* Initialize Tcl */ Tcl_ResetResult(*interpreter); if (init_tcl && Tcl_Init(*interpreter) == TCL_ERROR) { if (!try_auto_path) { try_auto_path = 1; continue; } bu_log("Tcl_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); break; } init_tcl = 0; /* Initialize [incr Tcl] */ Tcl_ResetResult(*interpreter); /* NOTE: Calling "package require Itcl" here is apparently * insufficient without other changes elsewhere. The * Combination Editor in mged fails with an iwidgets class * already loaded error if we don't perform Itcl_Init() here. */ if (init_itcl && Itcl_Init(*interpreter) == TCL_ERROR) { if (!try_auto_path) { Tcl_Namespace *nsp; try_auto_path = 1; /* Itcl_Init() leaves initialization in a bad state * and can cause retry failures. cleanup manually. */ Tcl_DeleteCommand(*interpreter, "::itcl::class"); nsp = Tcl_FindNamespace(*interpreter, "::itcl", NULL, 0); if (nsp) Tcl_DeleteNamespace(nsp); continue; } bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); break; } init_itcl = 0; /* don't actually want to loop forever */ break; } /* end iteration over Init() routines that need auto_path */ Tcl_ResetResult(*interpreter); /* if we haven't loaded by now, load auto_path so we find our tclscripts */ if (!try_auto_path) { /* Locate the BRL-CAD-specific Tcl scripts */ tclcad_auto_path(*interpreter); } /*XXX FIXME: Should not be importing Itcl into the global namespace */ /* Import [incr Tcl] commands into the global namespace. */ if (Tcl_Import(*interpreter, Tcl_GetGlobalNamespace(*interpreter), "::itcl::*", /* allowOverwrite */ 1) != TCL_OK) { bu_log("Tcl_Import ERROR: %s\n", Tcl_GetStringResult(*interpreter)); Tcl_ResetResult(*interpreter); } /* Initialize libbu */ if (Bu_Init(*interpreter) == TCL_ERROR) { bu_log("Bu_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); Tcl_ResetResult(*interpreter); } /* Initialize libbn */ if (Bn_Init(*interpreter) == TCL_ERROR) { bu_log("Bn_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); Tcl_ResetResult(*interpreter); } /* Initialize librt */ if (Rt_Init(*interpreter) == TCL_ERROR) { bu_log("Rt_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); Tcl_ResetResult(*interpreter); } /* Initialize libged */ if (Go_Init(*interpreter) == TCL_ERROR) { bu_log("Ged_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter)); Tcl_ResetResult(*interpreter); } BU_ALLOC(view_state->vs_gvp, struct ged_view); ged_view_init(view_state->vs_gvp); view_state->vs_gvp->gv_callback = mged_view_callback; view_state->vs_gvp->gv_clientData = (void *)view_state; MAT_DELTAS_GET_NEG(view_state->vs_orig_pos, view_state->vs_gvp->gv_center); if (gedp) { /* release any allocated memory */ ged_free(gedp); } else { BU_ALLOC(gedp, struct ged); } GED_INIT(gedp, NULL); /* register commands */ cmd_setup(); history_setup(); mged_global_variable_setup(*interpreter); mged_variable_setup(*interpreter); /* Tcl needs to write nulls onto subscripted variable names */ bu_vls_printf(&str, "%s(state)", MGED_DISPLAY_VAR); Tcl_SetVar(*interpreter, bu_vls_addr(&str), state_str[STATE], TCL_GLOBAL_ONLY); /* Set defaults for view status variables */ bu_vls_trunc(&str, 0); bu_vls_printf(&str, "set mged_display(.topid_0.ur,ang) {ang=(0.00 0.00 0.00)};\ set mged_display(.topid_0.ur,aet) {az=35.00 el=25.00 tw=0.00};\ set mged_display(.topid_0.ur,size) sz=1000.000;\ set mged_display(.topid_0.ur,center) {cent=(0.000 0.000 0.000)};\ set mged_display(units) mm"); Tcl_Eval(*interpreter, bu_vls_addr(&str)); Tcl_ResetResult(*interpreter); bu_vls_free(&str); }