Console::Console() : _enabled(false), _currentInput(""), _inputHistoryPos(0), _cursorPos(0), _cursorDispTime(0.0f), _bCursorDisp(true) { RegisterFont("Resources/Fonts/Inconsolata.otf", 24, "Console"); RegisterFont("Resources/Fonts/Inconsolata.otf", 18, "ConsoleSmall"); }
/** * \brief Loads fonts from the file specified in fontPath. * * \param fontPath The absolute path to the font file * \param registeredFor The user of the font. */ void MythFontManager::LoadFontFile(const QString &fontPath, const QString ®isteredFor) { if (fontPath.isEmpty() || fontPath == "/" || registeredFor.isEmpty()) return; QMutexLocker locker(&m_lock); if (IsFontFileLoaded(fontPath)) { LOG(VB_GUI | VB_FILE, LOG_INFO, LOC + QString("Font file '%1' already loaded") .arg(fontPath)); if (!RegisterFont(fontPath, registeredFor)) { LOG(VB_GUI | VB_FILE, LOG_INFO, LOC + QString("Unable to load font(s) in file '%1'") .arg(fontPath)); } } else { LOG(VB_GUI | VB_FILE, LOG_INFO, LOC + QString("Loading font file: '%1'").arg(fontPath)); int result = QFontDatabase::addApplicationFont(fontPath); if (result > -1) { LOG(VB_GUI | VB_FILE, LOG_DEBUG, LOC + QString("In file '%1', found font(s) '%2'") .arg(fontPath) .arg(QFontDatabase::applicationFontFamilies(result) .join(", "))); if (!RegisterFont(fontPath, registeredFor, result)) { LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Unable to register font(s) in file '%1'") .arg(fontPath)); } } else { LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Unable to load font(s) in file '%1'") .arg(fontPath)); } } }
void m1_init_machine(void) { #ifdef ENABLE_FONT_RESOURCE RegisterFont(&ISO_88591_24Font); #endif #ifdef CONFIG_AML_I2C sys_test_i2c_init(aml_i2c_info, ARRAY_SIZE(aml_i2c_info)); #endif run_command("lcd clear",0); power_on_backlight(); }
int switch_boot_mode(void) { // unsigned long hold_time = 50000, polling_time = 10000, tmp; unsigned long upgrade_step; int ret=0; act8942_init(&act8942_pdata); //act8942_dump(); upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16); printf("upgrade_step = %d\n", upgrade_step); saradc_enable(); #ifdef ENABLE_FONT_RESOURCE RegisterFont(DEFAULT_FONT); #endif ret=isVolAKeyPress(); if(ret==1) aml_autoscript(); powerkey_hold(0); #ifdef CONFIG_AML_TINY_USBTOOL usb_boot(1); #endif if(upgrade_step == 2) { switch(reboot_mode) { case AMLOGIC_NORMAL_BOOT: { ret=keypress_to_upgrade(); if(ret==0) return 0; printf("AMLOGIC_NORMAL_BOOT...\n"); power_up(); logo_display(); return 1; } case AMLOGIC_FACTORY_RESET_REBOOT: { printf("AMLOGIC_FACTORY_RESET_REBOOT...\n"); power_up(); logo_display(); run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0); run_command ("bootm", 0); break; } case AMLOGIC_UPDATE_REBOOT: { printf("AMLOGIC_UPDATE_REBOOT...\n"); power_up(); logo_display(); run_command ("set upgrade_step 0", 0); run_command ("save", 0); upgrade_step = 0; break; } default: { printf("AMLOGIC_CHARGING_REBOOT...\n"); if(is_ac_connected) { power_up(); #ifdef CONFIG_BATTERY_CHARGING //battery_charging(); #endif logo_display(); } else { powerkey_hold(0); #ifdef CONFIG_BATTERY_CHARGING if(get_powerkey_hold_count()) { logo_display(); if(get_battery_percentage() < 10) { power_low_display(); sdelay(2); power_down(); printf("Low Power!!!\nPower Down!\n"); hang(); } #else if(powerkey_hold(1000)) { #endif logo_display(); power_up(); printf("Power Up!\n"); } else { power_down(); printf("Power Down!\n"); hang(); } } break; } } } else { power_up(); printf("Upgrade step %d...\n", upgrade_step); } if(upgrade_step == 0) { #ifdef CONFIG_AML_TINY_USBTOOL usb_boot(1); #endif display_messge("upgrade step 1! Don't Power Off!"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } else { printf("### ERROR: u-boot write failed!!!\n"); return -1; } } else if(upgrade_step == 1) { display_messge("upgrade step 2! Don't Power Off!"); run_command ("defenv", 0); run_command ("set upgrade_step 2", 0); run_command ("save", 0); into_recovery(); } //added by Elvis for added fool idle /*get_key(); get_key(); while(hold_time > 0) { udelay(polling_time); tmp = get_key(); printf("get_key(): %d\n", tmp); if(!tmp) break; hold_time -= polling_time; } if(hold_time > 0) { printf("Normal Start...\n"); return 1; } else { display_messge("upgrading... please wait"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } run_command ("set upgrade_step 2", 0); run_command ("save", 0); into_recovery(); } */ ret=keypress_to_upgrade(); return ret; //return 0; }
void InitFont(void) { RegisterFont(&ISO_88591_24Font); }
void CG_DrawConnectScreen(qboolean interactive, qboolean forcerefresh) { static qboolean inside = qfalse; char buffer[1024]; if (!DC) { return; } if (inside) { return; } inside = qtrue; if (!bg_loadscreeninited) { trap_Cvar_Set("ui_connecting", "0"); RegisterFont("ariblk", 27, &cgs.media.bg_loadscreenfont1); RegisterFont("courbd", 30, &cgs.media.bg_loadscreenfont2); bg_axispin = DC->registerShaderNoMip("gfx/loading/pin_axis"); bg_alliedpin = DC->registerShaderNoMip("gfx/loading/pin_allied"); bg_neutralpin = DC->registerShaderNoMip("gfx/loading/pin_neutral"); bg_pin = DC->registerShaderNoMip("gfx/loading/pin_shot"); bg_filter_bo = DC->registerShaderNoMip("ui/assets/filter_bots"); bg_filter_ff = DC->registerShaderNoMip("ui/assets/filter_ff"); bg_filter_hw = DC->registerShaderNoMip("ui/assets/filter_weap"); bg_filter_lv = DC->registerShaderNoMip("ui/assets/filter_lives"); bg_filter_al = DC->registerShaderNoMip("ui/assets/filter_antilag"); bg_filter_bt = DC->registerShaderNoMip("ui/assets/filter_balance"); bg_mappic = 0; BG_PanelButtonsSetup(loadpanelButtons); C_PanelButtonsSetup(loadpanelButtons, cgs.wideXoffset); bg_loadscreeninited = qtrue; } BG_PanelButtonsRender(loadpanelButtons); if (interactive) { DC->drawHandlePic(DC->cursorx, DC->cursory, 32, 32, DC->Assets.cursor); } DC->getConfigString(CS_SERVERINFO, buffer, sizeof(buffer)); if (*buffer) { const char *str; float x = 540.0f + cgs.wideXoffset; float y = 322; int i; qboolean enabled = qfalse; CG_Text_Paint_Centred_Ext(x, y, 0.22f, 0.22f, clr3, ("^1" LEGACY_MOD " ^0" ETLEGACY_VERSION), 0, 0, 0, &cgs.media.bg_loadscreenfont1); y = 340; str = Info_ValueForKey(buffer, "sv_hostname"); CG_Text_Paint_Centred_Ext(x, y, 0.2f, 0.2f, colorWhite, str && *str ? str : "ETHost", 0, 26, 0, &cgs.media.bg_loadscreenfont2); y += 14; for (i = 0; i < MAX_MOTDLINES; i++) { str = CG_ConfigString(CS_CUSTMOTD + i); if (!str || !*str) { break; } CG_Text_Paint_Centred_Ext(x, y, 0.2f, 0.2f, colorWhite, str, 0, 26, 0, &cgs.media.bg_loadscreenfont2); y += 10; } y = 417; str = Info_ValueForKey(buffer, "g_friendlyfire"); if (str && *str && atoi(str)) { x = 461 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_ff); } if (atoi(Info_ValueForKey(buffer, "g_gametype")) != GT_WOLF_LMS) { str = Info_ValueForKey(buffer, "g_maxlives"); if (str && *str && atoi(str)) { enabled = qtrue; } if (!enabled) { str = Info_ValueForKey(buffer, "g_alliedmaxlives"); if (str && *str && atoi(str)) { enabled = qtrue; } } if (!enabled) { str = Info_ValueForKey(buffer, "g_axismaxlives"); if (str && *str && atoi(str)) { enabled = qtrue; } } } if (enabled) { x = 489 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_lv); } str = Info_ValueForKey(buffer, "omnibot_playing"); if (str && *str && atoi(str)) { x = 518 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_bo); } str = Info_ValueForKey(buffer, "g_heavyWeaponRestriction"); if (str && *str && atoi(str) != 100) { x = 546 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_hw); } str = Info_ValueForKey(buffer, "g_antilag"); if (str && *str && atoi(str)) { x = 575 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_al); } str = Info_ValueForKey(buffer, "g_balancedteams"); if (str && *str && atoi(str)) { x = 604 + cgs.wideXoffset; CG_DrawPic(x, y, 16, 16, bg_filter_bt); } } if (*cgs.rawmapname) { float x = 16 + cgs.wideXoffset + 1; if (!bg_mappic) { bg_mappic = DC->registerShaderNoMip(va("levelshots/%s", cgs.rawmapname)); if (!bg_mappic) { bg_mappic = DC->registerShaderNoMip("levelshots/unknownmap"); } } trap_R_SetColor(colorBlack); CG_DrawPic(x, 2 + 1, 192, 144, bg_mappic); trap_R_SetColor(NULL); x = 16 + cgs.wideXoffset; CG_DrawPic(x, 2, 192, 144, bg_mappic); x = 16 + cgs.wideXoffset + 80; CG_DrawPic(x, 2 + 6, 20, 20, bg_pin); } if (forcerefresh) { DC->updateScreen(); } inside = qfalse; }
bool World::Initialize(unsigned int windowWidth, unsigned int windowHeight, String windowName, bool antiAliasing, bool fullScreen, bool resizable) { if (_initialized) { return false; } _running = true; // Windows DLL locations #if defined(WIN32) && defined(ANGEL_RELEASE) String bitsPath = "bits"; char currentDir[MAX_PATH]; _getcwd(currentDir, MAX_PATH); String currDir(currentDir); StringList libs; #if !ANGEL_DISABLE_DEVIL libs.push_back("DevIL.dll"); libs.push_back("ILU.dll"); libs.push_back("ILUT.dll"); #endif #if ANGEL_DISABLE_FMOD libs.push_back("OpenAL32.dll"); #else libs.push_back("fmodex.dll"); #endif for (int i=0; i < libs.size(); i++) { String libstring = currDir + "\\" + bitsPath + "\\" + libs[i]; HMODULE work = LoadLibrary(libstring.c_str()); if (work == 0) { DWORD err = GetLastError(); _com_error error(err); LPCSTR errorText = error.ErrorMessage(); sysLog.Printf("ERROR: Couldn't load DLL (%s); %s", libs[i].c_str(), errorText); } } // does bits directory exist? DWORD dwAttrib = GetFileAttributes(bitsPath.c_str()); if (dwAttrib != INVALID_FILE_ATTRIBUTES && dwAttrib & FILE_ATTRIBUTE_DIRECTORY) { _chdir(bitsPath.c_str()); } #endif // General windowing initialization #if !ANGEL_MOBILE glfwInit(); #endif #if defined(__APPLE__) // Set up paths correctly in the .app bundle #if !ANGEL_MOBILE CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { sysLog.Log("ERROR: Problem setting up working directory! Probably nothing will work!"); } CFRelease(resourcesURL); chdir(path); chdir(".."); #if defined(ANGEL_DEBUG) // set paths to the local resources rather than the copied ones String fileName = __FILE__; String dirPath = fileName.substr(0, fileName.size() - String("Angel/Infrastructure/World.cpp").size()); CFURLRef exeURL = CFBundleCopyExecutableURL(mainBundle); char exePath[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(exeURL, TRUE, (UInt8 *)exePath, PATH_MAX)) { sysLog.Log("ERROR: Problem setting up working directory! Probably nothing will work!"); } CFRelease(exeURL); chdir(dirPath.c_str()); StringList pathElements = SplitString(exePath, "/"); String exeName = pathElements[pathElements.size()-1]; chdir(exeName.c_str()); #endif #else CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { std::cout << "Problem setting up working directory! Probably nothing will work!" << std::endl; } CFRelease(resourcesURL); chdir(path); chdir("Angel"); // the iPhone doesn't like having a "Resources" directory in the root of the .app bundle #endif #endif //Start scripting LuaScriptingModule::Prep(); //Reset values based on preferences antiAliasing = thePrefs.OverrideInt("WindowSettings", "antiAliasing", antiAliasing); fullScreen = thePrefs.OverrideInt("WindowSettings", "fullScreen", fullScreen); resizable = thePrefs.OverrideInt("WindowSettings", "resizable", resizable); windowHeight = thePrefs.OverrideInt("WindowSettings", "height", windowHeight); windowWidth = thePrefs.OverrideInt("WindowSettings", "width", windowWidth); windowName = thePrefs.OverrideString("WindowSettings", "name", windowName); //Windowing system setup #if !ANGEL_MOBILE if (antiAliasing) { glfwWindowHint(GLFW_SAMPLES, 4); //4x looks pretty good _antiAliased = true; } else { _antiAliased = false; } GLFWmonitor* openOn = NULL; // windowed if (fullScreen) { openOn = glfwGetPrimaryMonitor(); } if (resizable) { glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); } else { glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); } _mainWindow = glfwCreateWindow(windowWidth, windowHeight, windowName.c_str(), openOn, NULL); glfwMakeContextCurrent(_mainWindow); int fbw, fbh; glfwGetFramebufferSize(_mainWindow, &fbw, &fbh); if (fbw == windowWidth * 2) { SetHighResolutionScreen(true); } #if defined(WIN32) glfwSwapInterval(0); // because double-buffering and Windows don't get along apparently #else glfwSwapInterval(1); #endif glfwSetWindowSizeCallback(_mainWindow, Camera::ResizeCallback); glfwSetKeyCallback(_mainWindow, keyboardInput); glfwSetCharCallback(_mainWindow, charInput); glfwSetCursorPosCallback(_mainWindow, MouseMotion); glfwSetMouseButtonCallback(_mainWindow, MouseButton); glfwSetScrollCallback(_mainWindow, MouseWheel); glfwSetWindowCloseCallback(_mainWindow, windowClosed); _prevTime = glfwGetTime(); Camera::ResizeCallback(_mainWindow, fbw, fbh); #else struct timeval tv; gettimeofday(&tv, NULL); _currTime = _startTime = tv.tv_sec + (double) tv.tv_usec / 1000000.0; #endif //OpenGL state setup #if !ANGEL_MOBILE glClearDepth(1.0f); glPolygonMode(GL_FRONT, GL_FILL); #else glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0f, -1.0f); #endif glShadeModel(GL_FLAT); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glCullFace(GL_BACK); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearStencil(0); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); //Get textures going InitializeTextureLoading(); //Subscribe to camera changes theSwitchboard.SubscribeTo(this, "CameraChange"); //initialize singletons #if !ANGEL_MOBILE theInput; theControllerManager.Setup(); #endif theSound; theSpatialGraph; #if !ANGEL_MOBILE RegisterConsole(new TestConsole()); #else // register fonts, since we don't have the console doing it for us on the phone RegisterFont("Resources/Fonts/Inconsolata.otf", 24, "Console"); RegisterFont("Resources/Fonts/Inconsolata.otf", 18, "ConsoleSmall"); #endif LuaScriptingModule::Initialize(); return _initialized = true; }
bool World::Initialize(unsigned int windowWidth, unsigned int windowHeight, String windowName, bool antiAliasing, bool fullScreen, bool resizable) { if (_initialized) { return false; } _running = true; // General windowing initialization #if !ANGEL_MOBILE glfwInit(); #endif #if defined(__APPLE__) // Set up paths correctly in the .app bundle #if !ANGEL_MOBILE CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { //sysLog.Log("Problem setting up working directory!"); } CFRelease(resourcesURL); chdir(path); chdir(".."); #if DEBUG // set paths to the local resources rather than the copied ones String fileName = __FILE__; String dirPath = fileName.substr(0, fileName.size() - String("Angel/Infrastructure/World.cpp").size()); CFURLRef exeURL = CFBundleCopyExecutableURL(mainBundle); char exePath[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(exeURL, TRUE, (UInt8 *)exePath, PATH_MAX)) { //sysLog.Log("Problem setting up working directory!"); } CFRelease(exeURL); chdir(dirPath.c_str()); StringList pathElements = SplitString(exePath, "/"); String exeName = pathElements[pathElements.size()-1]; chdir(exeName.c_str()); #endif #else CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { std::cout << "Problem setting up working directory!" << std::endl; } CFRelease(resourcesURL); chdir(path); chdir("Angel"); // the iPhone doesn't like having a "Resources" directory in the root of the .app bundle #endif #endif //Start scripting LuaScriptingModule::Prep(); //Reset values based on preferences antiAliasing = thePrefs.OverrideInt("WindowSettings", "antiAliasing", antiAliasing); fullScreen = thePrefs.OverrideInt("WindowSettings", "antiAliasing", fullScreen); resizable = thePrefs.OverrideInt("WindowSettings", "antiAliasing", resizable); windowHeight = thePrefs.OverrideInt("WindowSettings", "height", windowHeight); windowWidth = thePrefs.OverrideInt("WindowSettings", "width", windowWidth); windowName = thePrefs.OverrideString("WindowSettings", "name", windowName); //Windowing system setup #if !ANGEL_MOBILE if (antiAliasing) { glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); //4x looks pretty good } int windowMode = GLFW_WINDOW; if (fullScreen) { windowMode = GLFW_FULLSCREEN; } if (resizable) { glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_FALSE); } else { glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); } glfwOpenWindow(windowWidth, windowHeight, 8, 8, 8, 8, 8, 1, windowMode); glfwSetWindowTitle(windowName.c_str()); glfwSetWindowPos(50, 50); glfwSwapInterval(1); //better visual quality, set to zero for max drawing performance glfwSetWindowSizeCallback(Camera::ResizeCallback); glfwSetKeyCallback(keyboardInput); glfwSetCharCallback(charInput); glfwDisable(GLFW_KEY_REPEAT); glfwSetMousePosCallback(MouseMotion); glfwSetMouseButtonCallback(MouseButton); glfwSetMouseWheelCallback(MouseWheel); glfwSetWindowCloseCallback(windowClosed); _prevTime = glfwGetTime(); #else struct timeval tv; gettimeofday(&tv, NULL); _currTime = _startTime = tv.tv_sec + (double) tv.tv_usec / 1000000.0; #endif //OpenGL state setup #if !ANGEL_MOBILE glClearDepth(1.0f); glPolygonMode(GL_FRONT, GL_FILL); #endif glShadeModel(GL_FLAT); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glCullFace(GL_BACK); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearStencil(0); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); theCamera.ResizeCallback(windowWidth, windowHeight); //Get textures going InitializeTextureLoading(); //Subscribe to camera changes theSwitchboard.SubscribeTo(this, "CameraChange"); //initialize singletons #if !ANGEL_MOBILE theInput; theControllerManager.Setup(); #endif theSound; theSpatialGraph; #if !ANGEL_MOBILE RegisterConsole(new TestConsole()); #else // register fonts, since we don't have the console doing it for us on the phone RegisterFont("Resources/Fonts/Inconsolata.otf", 24, "Console"); RegisterFont("Resources/Fonts/Inconsolata.otf", 18, "ConsoleSmall"); #endif LuaScriptingModule::Initialize(); return _initialized = true; }
int switch_boot_mode(void) { unsigned long hold_time = 3000, polling_time = 10000, tmp; unsigned long upgrade_step; upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16); printf("upgrade_step = %d !!!!!!!!!!!!!!!!!!\n", upgrade_step); #ifdef CONFIG_SARADC saradc_enable(); #endif #ifdef ENABLE_FONT_RESOURCE RegisterFont(DEFAULT_FONT); #endif //aml_autoscript(); //logo_display(); //return 1; if(upgrade_step == 3) { switch(reboot_mode) { case AMLOGIC_NORMAL_BOOT: { printf("AMLOGIC_NORMAL_BOOT...\n"); printf("reboot_mode is %d...\n", reboot_mode); power_hold(); logo_display(); return 1; } case AMLOGIC_FACTORY_RESET_REBOOT: { printf("AMLOGIC_FACTORY_RESET_REBOOT...\n"); power_hold(); logo_display(); run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0); run_command ("bootm", 0);; break; } case AMLOGIC_UPDATE_REBOOT: { printf("AMLOGIC_UPDATE_REBOOT...\n"); power_hold(); logo_display(); run_command ("set upgrade_step 0", 0); run_command ("save", 0); upgrade_step = 0; break; } default: { printf("Default.... \n"); power_hold(); logo_display(); break; } } } else { power_hold(); printf("Upgrade step %d...\n", upgrade_step); } if(upgrade_step == 0) { display_messge("upgrade step 1! Don't Power Off!"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } else { printf("### ERROR: u-boot write failed!!!\n"); //return -1; } } else if((upgrade_step >0) && (upgrade_step < 3)) { if(upgrade_step == 1) { display_messge("upgrade step 2! Don't Power Off!"); if(upgrade_env()) { run_command ("set upgrade_step 2", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } else { run_command ("defenv", 0); run_command ("save", 0); } } display_messge("upgrade step 3! Don't Power Off!"); run_command ("set upgrade_step 3", 0); run_command ("save", 0); //upgrade_partition(); into_recovery(); } powerkey_hold(0); if(!powerkey_hold(hold_time)) { //aml_autoscript(); if(upgrade_step == 0) { logo_display(); run_command ("set upgrade_step 3", 0); run_command ("save", 0); } printf("Normal Start...\n"); return 1; } else { display_messge("upgrading... please wait"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } if(upgrade_env()) { run_command ("set upgrade_step 2", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } run_command ("set upgrade_step 3", 0); run_command ("save", 0); #ifndef CONFIG_UBI_SUPPORT //upgrade_partition(); #endif into_recovery(); } }
int switch_boot_mode(void) { unsigned long hold_time = 50000, polling_time = 10000, tmp; unsigned long upgrade_step; clrbits_le32(P_PREG_PAD_GPIO2_EN_N, (1<<25)); // VCC5V_EN GPIOD_9 setbits_le32(P_PREG_PAD_GPIO2_O, (1<<25)); get_osd_size(); #ifdef CONFIG_PMU_ACT8942 act8942_init(&act8942_pdata); //act8942_dump(); #endif upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16); printf("upgrade_step = %d\n", upgrade_step); saradc_enable(); #ifdef ENABLE_FONT_RESOURCE RegisterFont(DEFAULT_FONT); #endif aml_autoscript(); powerkey_hold(0); u32 reboot_mode_current = reboot_mode;//cvt reboot_mode_clear();//cvt #ifdef CONFIG_AML_TINY_USBTOOL //cvt extern int usb_boot(int clk_cfg, int time_out); if((reboot_mode_current == MESON_USB_BURNER_REBOOT) || get_burner_key()) { usb_boot(1, 200000); } #endif if(upgrade_step == 2) { switch(reboot_mode_current) { case AMLOGIC_NORMAL_BOOT: { printf("AMLOGIC_NORMAL_BOOT...\n"); power_up(); logo_display(); return 1; } case AMLOGIC_FACTORY_RESET_REBOOT: { printf("AMLOGIC_FACTORY_RESET_REBOOT...\n"); power_up(); logo_display(); run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0); run_command ("bootm", 0); break; } case AMLOGIC_UPDATE_REBOOT: { printf("AMLOGIC_UPDATE_REBOOT...\n"); power_up(); logo_display(); run_command ("set upgrade_step 0", 0); run_command ("save", 0); upgrade_step = 0; break; } default: { printf("AMLOGIC_CHARGING_REBOOT...\n"); if(is_ac_connected) { power_up(); #ifdef CONFIG_BATTERY_CHARGING battery_charging(); #endif logo_display(); } else { powerkey_hold(0); #ifdef CONFIG_BATTERY_CHARGING if(get_powerkey_hold_count()) { logo_display(); if(get_battery_percentage() < 10) { power_low_display(); sdelay(2); power_down(); printf("Low Power!!!\nPower Down!\n"); hang(); } logo_display(); power_up(); printf("Power Up!\n"); } #else if(powerkey_hold(1000)) { logo_display(); power_up(); printf("Power Up!\n"); } #endif else { power_down(); printf("Power Down!\n"); hang(); } } break; } } } else { power_up(); printf("Upgrade step %d...\n", upgrade_step); } if(upgrade_step == 0) { display_messge("upgrade step 1! Don't Power Off!"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } else { printf("### ERROR: u-boot write failed!!!\n"); return -1; } } else if(upgrade_step == 1) { display_messge("upgrade step 2! Don't Power Off!"); run_command ("set upgrade_step 2", 0); run_command ("save", 0); into_recovery(); } //added by Elvis for added fool idle get_key(); get_key(); while(hold_time > 0) { udelay(polling_time); tmp = get_key(); printf("get_key(): %d\n", tmp); if(!tmp) break; hold_time -= polling_time; } if(hold_time > 0) { printf("Normal Start...\n"); char *recovery_command; recovery_command = getenv("recovery_command"); if (strcmp(recovery_command, "--usb_burning") == 0){ run_command ("set recovery_command", 0); } run_command ("save", 0); return 1; } else { display_messge("upgrading... please wait"); if(upgrade_bootloader()) { run_command ("set upgrade_step 1", 0); run_command ("save", 0); run_command ("reset", 0); hang(); } run_command ("set upgrade_step 2", 0); run_command ("save", 0); into_recovery(); } return 0; }