1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 02:11:54 +02:00

Add --disable-cpufreq switch to disable clock management

This commit is contained in:
Paul Cercueil 2012-12-08 01:03:33 -03:00
parent 473949bb4f
commit c9fc163bea
4 changed files with 54 additions and 3 deletions

View File

@ -34,6 +34,10 @@ AC_ARG_ENABLE(platform,
[ --enable-platform=X specify the targeted platform], [ --enable-platform=X specify the targeted platform],
[GMENU2X_PLATFORM="$enableval"], [GMENU2X_PLATFORM="default"]) [GMENU2X_PLATFORM="$enableval"], [GMENU2X_PLATFORM="default"])
AC_ARG_ENABLE(cpufreq,
[ --disable-cpufreq disable support for CPU frequency scaling],,
[CPUFREQ=yes])
case "$GMENU2X_PLATFORM" in case "$GMENU2X_PLATFORM" in
a320) a320)
AC_DEFINE(PLATFORM_A320) AC_DEFINE(PLATFORM_A320)
@ -75,5 +79,9 @@ AC_SUBST(PLATFORM)
AC_SUBST(SCREEN_RES) AC_SUBST(SCREEN_RES)
AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}") AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}")
if test "x$CPUFREQ" = xyes ; then
AC_DEFINE(ENABLE_CPUFREQ)
fi
AC_OUTPUT(Makefile src/Makefile data/Makefile) AC_OUTPUT(Makefile src/Makefile data/Makefile)

View File

@ -220,6 +220,7 @@ int main(int /*argc*/, char * /*argv*/[]) {
return 0; return 0;
} }
#ifdef ENABLE_CPUFREQ
void GMenu2X::initCPULimits() { void GMenu2X::initCPULimits() {
// Note: These values are for the Dingoo. // Note: These values are for the Dingoo.
// The NanoNote does not have cpufreq enabled in its kernel and // The NanoNote does not have cpufreq enabled in its kernel and
@ -240,13 +241,16 @@ void GMenu2X::initCPULimits() {
cpuFreqMenuDefault = (cpuFreqMenuDefault / cpuFreqMultiple) * cpuFreqMultiple; cpuFreqMenuDefault = (cpuFreqMenuDefault / cpuFreqMultiple) * cpuFreqMultiple;
cpuFreqAppDefault = (cpuFreqAppDefault / cpuFreqMultiple) * cpuFreqMultiple; cpuFreqAppDefault = (cpuFreqAppDefault / cpuFreqMultiple) * cpuFreqMultiple;
} }
#endif
GMenu2X::GMenu2X() GMenu2X::GMenu2X()
{ {
usbnet = samba = inet = web = false; usbnet = samba = inet = web = false;
useSelectionPng = false; useSelectionPng = false;
#ifdef ENABLE_CPUFREQ
initCPULimits(); initCPULimits();
#endif
//load config data //load config data
readConfig(); readConfig();
@ -303,7 +307,9 @@ GMenu2X::GMenu2X()
PowerSaver::getInstance()->setScreenTimeout( confInt["backlightTimeout"] ); PowerSaver::getInstance()->setScreenTimeout( confInt["backlightTimeout"] );
setInputSpeed(); setInputSpeed();
#ifdef ENABLE_CPUFREQ
setClock(confInt["menuClock"]); setClock(confInt["menuClock"]);
#endif
//recover last session //recover last session
readTmp(); readTmp();
if (lastSelectorElement>-1 && menu->selLinkApp()!=NULL && (!menu->selLinkApp()->getSelectorDir().empty() || !lastSelectorDir.empty())) if (lastSelectorElement>-1 && menu->selLinkApp()!=NULL && (!menu->selLinkApp()->getSelectorDir().empty() || !lastSelectorDir.empty()))
@ -356,12 +362,16 @@ void GMenu2X::initBG() {
bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle); bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle);
delete sd; delete sd;
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
cpuX = font->getTextWidth(df)+32; cpuX = font->getTextWidth(df)+32;
#ifdef ENABLE_CPUFREQ
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY); if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
cpuX += 19; cpuX += 19;
manualX = cpuX+font->getTextWidth("300MHz")+5; manualX = cpuX+font->getTextWidth("300MHz")+5;
delete cpu; delete cpu;
#else
manualX = cpuX;
#endif
int serviceX = resX-38; int serviceX = resX-38;
if (usbnet) { if (usbnet) {
@ -515,10 +525,12 @@ void GMenu2X::readConfig(string conffile) {
confStr["skin"] = "Default"; confStr["skin"] = "Default";
evalIntConf( &confInt["outputLogs"], 0, 0,1 ); evalIntConf( &confInt["outputLogs"], 0, 0,1 );
#ifdef ENABLE_CPUFREQ
evalIntConf( &confInt["maxClock"], evalIntConf( &confInt["maxClock"],
cpuFreqSafeMax, cpuFreqMin, cpuFreqMax ); cpuFreqSafeMax, cpuFreqMin, cpuFreqMax );
evalIntConf( &confInt["menuClock"], evalIntConf( &confInt["menuClock"],
cpuFreqMenuDefault, cpuFreqMin, cpuFreqSafeMax ); cpuFreqMenuDefault, cpuFreqMin, cpuFreqSafeMax );
#endif
evalIntConf( &confInt["backlightTimeout"], 15, 0,120 ); evalIntConf( &confInt["backlightTimeout"], 15, 0,120 );
evalIntConf( &confInt["videoBpp"], 32, 16, 32 ); evalIntConf( &confInt["videoBpp"], 32, 16, 32 );
@ -702,7 +714,9 @@ void GMenu2X::main() {
if (menu->selLink()!=NULL) { if (menu->selLink()!=NULL) {
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom ); s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom );
if (menu->selLinkApp()!=NULL) { if (menu->selLinkApp()!=NULL) {
#ifdef ENABLE_CPUFREQ
s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle ); s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle );
#endif
//Manual indicator //Manual indicator
if (!menu->selLinkApp()->getManual().empty()) if (!menu->selLinkApp()->getManual().empty())
sc.skinRes("imgs/manual.png")->blit(s,manualX,bottomBarIconY); sc.skinRes("imgs/manual.png")->blit(s,manualX,bottomBarIconY);
@ -839,7 +853,9 @@ void GMenu2X::explorer() {
string command = cmdclean(fd.getPath()+"/"+fd.getFile()); string command = cmdclean(fd.getPath()+"/"+fd.getFile());
chdir(fd.getPath().c_str()); chdir(fd.getPath().c_str());
quit(); quit();
#ifdef ENABLE_CPUFREQ
setClock(cpuFreqAppDefault); setClock(cpuFreqAppDefault);
#endif
execlp("/bin/sh","/bin/sh","-c",command.c_str(),NULL); execlp("/bin/sh","/bin/sh","-c",command.c_str(),NULL);
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
@ -850,7 +866,9 @@ void GMenu2X::explorer() {
} }
void GMenu2X::options() { void GMenu2X::options() {
#ifdef ENABLE_CPUFREQ
int curMenuClock = confInt["menuClock"]; int curMenuClock = confInt["menuClock"];
#endif
bool showRootFolder = fileExists(CARD_ROOT); bool showRootFolder = fileExists(CARD_ROOT);
FileLister fl_tr(getHome() + "/translations"); FileLister fl_tr(getHome() + "/translations");
@ -868,15 +886,19 @@ void GMenu2X::options() {
SettingsDialog sd(this, input, ts, tr["Settings"]); SettingsDialog sd(this, input, ts, tr["Settings"]);
sd.addSetting(new MenuSettingMultiString(this, ts, tr["Language"], tr["Set the language used by GMenu2X"], &lang, &fl_tr.getFiles())); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Language"], tr["Set the language used by GMenu2X"], &lang, &fl_tr.getFiles()));
sd.addSetting(new MenuSettingBool(this, ts, tr["Save last selection"], tr["Save the last selected link and section on exit"], &confInt["saveSelection"])); sd.addSetting(new MenuSettingBool(this, ts, tr["Save last selection"], tr["Save the last selected link and section on exit"], &confInt["saveSelection"]));
#ifdef ENABLE_CPUFREQ
sd.addSetting(new MenuSettingInt(this, ts, tr["Clock for GMenu2X"], tr["Set the cpu working frequency when running GMenu2X"], &confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Clock for GMenu2X"], tr["Set the cpu working frequency when running GMenu2X"], &confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple));
sd.addSetting(new MenuSettingInt(this, ts, tr["Maximum overclock"], tr["Set the maximum overclock for launching links"], &confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Maximum overclock"], tr["Set the maximum overclock for launching links"], &confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple));
#endif
sd.addSetting(new MenuSettingBool(this, ts, tr["Output logs"], tr["Logs the output of the links. Use the Log Viewer to read them."], &confInt["outputLogs"])); sd.addSetting(new MenuSettingBool(this, ts, tr["Output logs"], tr["Logs the output of the links. Use the Log Viewer to read them."], &confInt["outputLogs"]));
sd.addSetting(new MenuSettingInt(this, ts, tr["Screen Timeout"], tr["Set screen's backlight timeout in seconds"], &confInt["backlightTimeout"], 0, 120)); sd.addSetting(new MenuSettingInt(this, ts, tr["Screen Timeout"], tr["Set screen's backlight timeout in seconds"], &confInt["backlightTimeout"], 0, 120));
// sd.addSetting(new MenuSettingMultiString(this, ts, tr["Tv-Out encoding"], tr["Encoding of the tv-out signal"], &confStr["tvoutEncoding"], &encodings)); // sd.addSetting(new MenuSettingMultiString(this, ts, tr["Tv-Out encoding"], tr["Encoding of the tv-out signal"], &confStr["tvoutEncoding"], &encodings));
sd.addSetting(new MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder)); sd.addSetting(new MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
#ifdef ENABLE_CPUFREQ
if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]); if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]);
#endif
if (confInt["backlightTimeout"] == 0) { if (confInt["backlightTimeout"] == 0) {
if (PowerSaver::isRunning()) if (PowerSaver::isRunning())
@ -1210,7 +1232,9 @@ void GMenu2X::editLink() {
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
} }
#endif #endif
#ifdef ENABLE_CPUFREQ
sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple));
#endif
sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir));
sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser));
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
@ -1350,7 +1374,9 @@ void GMenu2X::scanner() {
#ifdef PLATFORM_PANDORA #ifdef PLATFORM_PANDORA
//char *configpath = pnd_conf_query_searchpath(); //char *configpath = pnd_conf_query_searchpath();
#else #else
#ifdef ENABLE_CPUFREQ
setSafeMaxClock(); setSafeMaxClock();
#endif
scanbg.write(font,tr["Scanning filesystem..."],5,lineY); scanbg.write(font,tr["Scanning filesystem..."],5,lineY);
scanbg.blit(s,0,0); scanbg.blit(s,0,0);
@ -1393,7 +1419,9 @@ void GMenu2X::scanner() {
s->flip(); s->flip();
lineY += 26; lineY += 26;
#ifdef ENABLE_CPUFREQ
setMenuClock(); setMenuClock();
#endif
sync(); sync();
#endif #endif
@ -1477,12 +1505,14 @@ void GMenu2X::setInputSpeed() {
SDL_EnableKeyRepeat(1,150); SDL_EnableKeyRepeat(1,150);
} }
#ifdef ENABLE_CPUFREQ
void GMenu2X::setClock(unsigned mhz) { void GMenu2X::setClock(unsigned mhz) {
mhz = constrain(mhz, cpuFreqMin, confInt["maxClock"]); mhz = constrain(mhz, cpuFreqMin, confInt["maxClock"]);
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE) #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE)
jz_cpuspeed(mhz); jz_cpuspeed(mhz);
#endif #endif
} }
#endif
string GMenu2X::getDiskFree(const char *path) { string GMenu2X::getDiskFree(const char *path) {
stringstream ss; stringstream ss;

View File

@ -73,12 +73,16 @@ private:
std::string getDiskFree(const char *path); std::string getDiskFree(const char *path);
unsigned short cpuX; //!< Offset for displaying cpu clock information unsigned short cpuX; //!< Offset for displaying cpu clock information
unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar
#ifdef ENABLE_CPUFREQ
unsigned cpuFreqMin; //!< Minimum CPU frequency unsigned cpuFreqMin; //!< Minimum CPU frequency
unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency
unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency
unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x
unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps
unsigned cpuFreqMultiple; //!< All valid CPU frequencies are a multiple of this unsigned cpuFreqMultiple; //!< All valid CPU frequencies are a multiple of this
void initCPULimits();
#endif
/*! /*!
Reads the current battery state and returns a number representing it's level of charge Reads the current battery state and returns a number representing it's level of charge
@return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power. @return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power.
@ -114,7 +118,6 @@ private:
void initServices(); void initServices();
void initFont(); void initFont();
void initMenu(); void initMenu();
void initCPULimits();
void showManual(); void showManual();
@ -158,10 +161,12 @@ public:
void contextMenu(); void contextMenu();
void changeWallpaper(); void changeWallpaper();
#ifdef ENABLE_CPUFREQ
void setClock(unsigned mhz); void setClock(unsigned mhz);
unsigned getDefaultAppClock() { return cpuFreqAppDefault; }
void setMenuClock() { setClock(cpuFreqMenuDefault); } void setMenuClock() { setClock(cpuFreqMenuDefault); }
void setSafeMaxClock() { setClock(cpuFreqSafeMax); } void setSafeMaxClock() { setClock(cpuFreqSafeMax); }
unsigned getDefaultAppClock() { return cpuFreqAppDefault; }
#endif
void setInputSpeed(); void setInputSpeed();

View File

@ -68,7 +68,9 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
manual = ""; manual = "";
file = linkfile; file = linkfile;
dontleave = false; dontleave = false;
#ifdef ENABLE_CPUFREQ
setClock(gmenu2x->getDefaultAppClock()); setClock(gmenu2x->getDefaultAppClock());
#endif
selectordir = ""; selectordir = "";
selectorfilter = ""; selectorfilter = "";
icon = iconPath = ""; icon = iconPath = "";
@ -417,8 +419,10 @@ void LinkApp::showManual() {
// Png manuals // Png manuals
string ext8 = manual.substr(manual.size()-8,8); string ext8 = manual.substr(manual.size()-8,8);
if (ext8==".man.png" || ext8==".man.bmp" || ext8==".man.jpg" || manual.substr(manual.size()-9,9)==".man.jpeg") { if (ext8==".man.png" || ext8==".man.bmp" || ext8==".man.jpg" || manual.substr(manual.size()-9,9)==".man.jpeg") {
#ifdef ENABLE_CPUFREQ
//Raise the clock to speed-up the loading of the manual //Raise the clock to speed-up the loading of the manual
gmenu2x->setSafeMaxClock(); gmenu2x->setSafeMaxClock();
#endif
Surface *pngman = Surface::loadImage(manual); Surface *pngman = Surface::loadImage(manual);
if (!pngman) { if (!pngman) {
@ -440,8 +444,10 @@ void LinkApp::showManual() {
string spagecount; string spagecount;
ss >> spagecount; ss >> spagecount;
#ifdef ENABLE_CPUFREQ
//Lower the clock //Lower the clock
gmenu2x->setMenuClock(); gmenu2x->setMenuClock();
#endif
while (!close) { while (!close) {
if (repaint) { if (repaint) {
@ -631,9 +637,11 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
if (selectedFile == "") { if (selectedFile == "") {
gmenu2x->writeTmp(); gmenu2x->writeTmp();
} }
#ifdef ENABLE_CPUFREQ
if (clock() != gmenu2x->confInt["menuClock"]) { if (clock() != gmenu2x->confInt["menuClock"]) {
gmenu2x->setClock(clock()); gmenu2x->setClock(clock());
} }
#endif
gmenu2x->quit(); gmenu2x->quit();
/* Make the terminal we're connected to (via stdin/stdout) our /* Make the terminal we're connected to (via stdin/stdout) our