mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-28 16:15:10 +02:00
Add --disable-cpufreq switch to disable clock management
This commit is contained in:
parent
473949bb4f
commit
c9fc163bea
@ -34,6 +34,10 @@ AC_ARG_ENABLE(platform,
|
||||
[ --enable-platform=X specify the targeted platform],
|
||||
[GMENU2X_PLATFORM="$enableval"], [GMENU2X_PLATFORM="default"])
|
||||
|
||||
AC_ARG_ENABLE(cpufreq,
|
||||
[ --disable-cpufreq disable support for CPU frequency scaling],,
|
||||
[CPUFREQ=yes])
|
||||
|
||||
case "$GMENU2X_PLATFORM" in
|
||||
a320)
|
||||
AC_DEFINE(PLATFORM_A320)
|
||||
@ -75,5 +79,9 @@ AC_SUBST(PLATFORM)
|
||||
AC_SUBST(SCREEN_RES)
|
||||
AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}")
|
||||
|
||||
if test "x$CPUFREQ" = xyes ; then
|
||||
AC_DEFINE(ENABLE_CPUFREQ)
|
||||
fi
|
||||
|
||||
|
||||
AC_OUTPUT(Makefile src/Makefile data/Makefile)
|
||||
|
@ -220,6 +220,7 @@ int main(int /*argc*/, char * /*argv*/[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
void GMenu2X::initCPULimits() {
|
||||
// Note: These values are for the Dingoo.
|
||||
// The NanoNote does not have cpufreq enabled in its kernel and
|
||||
@ -240,13 +241,16 @@ void GMenu2X::initCPULimits() {
|
||||
cpuFreqMenuDefault = (cpuFreqMenuDefault / cpuFreqMultiple) * cpuFreqMultiple;
|
||||
cpuFreqAppDefault = (cpuFreqAppDefault / cpuFreqMultiple) * cpuFreqMultiple;
|
||||
}
|
||||
#endif
|
||||
|
||||
GMenu2X::GMenu2X()
|
||||
{
|
||||
usbnet = samba = inet = web = false;
|
||||
useSelectionPng = false;
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
initCPULimits();
|
||||
#endif
|
||||
//load config data
|
||||
readConfig();
|
||||
|
||||
@ -303,7 +307,9 @@ GMenu2X::GMenu2X()
|
||||
PowerSaver::getInstance()->setScreenTimeout( confInt["backlightTimeout"] );
|
||||
|
||||
setInputSpeed();
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setClock(confInt["menuClock"]);
|
||||
#endif
|
||||
//recover last session
|
||||
readTmp();
|
||||
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);
|
||||
delete sd;
|
||||
|
||||
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
|
||||
cpuX = font->getTextWidth(df)+32;
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
|
||||
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
|
||||
cpuX += 19;
|
||||
manualX = cpuX+font->getTextWidth("300MHz")+5;
|
||||
delete cpu;
|
||||
#else
|
||||
manualX = cpuX;
|
||||
#endif
|
||||
|
||||
int serviceX = resX-38;
|
||||
if (usbnet) {
|
||||
@ -515,10 +525,12 @@ void GMenu2X::readConfig(string conffile) {
|
||||
confStr["skin"] = "Default";
|
||||
|
||||
evalIntConf( &confInt["outputLogs"], 0, 0,1 );
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
evalIntConf( &confInt["maxClock"],
|
||||
cpuFreqSafeMax, cpuFreqMin, cpuFreqMax );
|
||||
evalIntConf( &confInt["menuClock"],
|
||||
cpuFreqMenuDefault, cpuFreqMin, cpuFreqSafeMax );
|
||||
#endif
|
||||
evalIntConf( &confInt["backlightTimeout"], 15, 0,120 );
|
||||
evalIntConf( &confInt["videoBpp"], 32, 16, 32 );
|
||||
|
||||
@ -702,7 +714,9 @@ void GMenu2X::main() {
|
||||
if (menu->selLink()!=NULL) {
|
||||
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom );
|
||||
if (menu->selLinkApp()!=NULL) {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
#endif
|
||||
//Manual indicator
|
||||
if (!menu->selLinkApp()->getManual().empty())
|
||||
sc.skinRes("imgs/manual.png")->blit(s,manualX,bottomBarIconY);
|
||||
@ -839,7 +853,9 @@ void GMenu2X::explorer() {
|
||||
string command = cmdclean(fd.getPath()+"/"+fd.getFile());
|
||||
chdir(fd.getPath().c_str());
|
||||
quit();
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setClock(cpuFreqAppDefault);
|
||||
#endif
|
||||
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
|
||||
@ -850,7 +866,9 @@ void GMenu2X::explorer() {
|
||||
}
|
||||
|
||||
void GMenu2X::options() {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
int curMenuClock = confInt["menuClock"];
|
||||
#endif
|
||||
bool showRootFolder = fileExists(CARD_ROOT);
|
||||
|
||||
FileLister fl_tr(getHome() + "/translations");
|
||||
@ -868,15 +886,19 @@ void GMenu2X::options() {
|
||||
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 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["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 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 MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder));
|
||||
|
||||
if (sd.exec() && sd.edited()) {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]);
|
||||
#endif
|
||||
|
||||
if (confInt["backlightTimeout"] == 0) {
|
||||
if (PowerSaver::isRunning())
|
||||
@ -1210,7 +1232,9 @@ void GMenu2X::editLink() {
|
||||
#ifdef HAVE_LIBOPK
|
||||
}
|
||||
#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));
|
||||
#endif
|
||||
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));
|
||||
#ifdef HAVE_LIBOPK
|
||||
@ -1350,7 +1374,9 @@ void GMenu2X::scanner() {
|
||||
#ifdef PLATFORM_PANDORA
|
||||
//char *configpath = pnd_conf_query_searchpath();
|
||||
#else
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setSafeMaxClock();
|
||||
#endif
|
||||
|
||||
scanbg.write(font,tr["Scanning filesystem..."],5,lineY);
|
||||
scanbg.blit(s,0,0);
|
||||
@ -1393,7 +1419,9 @@ void GMenu2X::scanner() {
|
||||
s->flip();
|
||||
lineY += 26;
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setMenuClock();
|
||||
#endif
|
||||
sync();
|
||||
#endif
|
||||
|
||||
@ -1477,12 +1505,14 @@ void GMenu2X::setInputSpeed() {
|
||||
SDL_EnableKeyRepeat(1,150);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
void GMenu2X::setClock(unsigned mhz) {
|
||||
mhz = constrain(mhz, cpuFreqMin, confInt["maxClock"]);
|
||||
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE)
|
||||
jz_cpuspeed(mhz);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
string GMenu2X::getDiskFree(const char *path) {
|
||||
stringstream ss;
|
||||
|
@ -73,12 +73,16 @@ private:
|
||||
std::string getDiskFree(const char *path);
|
||||
unsigned short cpuX; //!< Offset for displaying cpu clock information
|
||||
unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
unsigned cpuFreqMin; //!< Minimum CPU frequency
|
||||
unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency
|
||||
unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency
|
||||
unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x
|
||||
unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps
|
||||
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
|
||||
@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 initFont();
|
||||
void initMenu();
|
||||
void initCPULimits();
|
||||
|
||||
void showManual();
|
||||
|
||||
@ -158,10 +161,12 @@ public:
|
||||
void contextMenu();
|
||||
void changeWallpaper();
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
void setClock(unsigned mhz);
|
||||
unsigned getDefaultAppClock() { return cpuFreqAppDefault; }
|
||||
void setMenuClock() { setClock(cpuFreqMenuDefault); }
|
||||
void setSafeMaxClock() { setClock(cpuFreqSafeMax); }
|
||||
unsigned getDefaultAppClock() { return cpuFreqAppDefault; }
|
||||
#endif
|
||||
|
||||
void setInputSpeed();
|
||||
|
||||
|
@ -68,7 +68,9 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
||||
manual = "";
|
||||
file = linkfile;
|
||||
dontleave = false;
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
setClock(gmenu2x->getDefaultAppClock());
|
||||
#endif
|
||||
selectordir = "";
|
||||
selectorfilter = "";
|
||||
icon = iconPath = "";
|
||||
@ -417,8 +419,10 @@ void LinkApp::showManual() {
|
||||
// Png manuals
|
||||
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") {
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
//Raise the clock to speed-up the loading of the manual
|
||||
gmenu2x->setSafeMaxClock();
|
||||
#endif
|
||||
|
||||
Surface *pngman = Surface::loadImage(manual);
|
||||
if (!pngman) {
|
||||
@ -440,8 +444,10 @@ void LinkApp::showManual() {
|
||||
string spagecount;
|
||||
ss >> spagecount;
|
||||
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
//Lower the clock
|
||||
gmenu2x->setMenuClock();
|
||||
#endif
|
||||
|
||||
while (!close) {
|
||||
if (repaint) {
|
||||
@ -631,9 +637,11 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
|
||||
if (selectedFile == "") {
|
||||
gmenu2x->writeTmp();
|
||||
}
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
if (clock() != gmenu2x->confInt["menuClock"]) {
|
||||
gmenu2x->setClock(clock());
|
||||
}
|
||||
#endif
|
||||
gmenu2x->quit();
|
||||
|
||||
/* Make the terminal we're connected to (via stdin/stdout) our
|
||||
|
Loading…
Reference in New Issue
Block a user