1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 12:57:42 +02:00

Improved CPU frequency control.

The maximum frequency for applications was set to 430 MHz before,
while some Dingoos can handle higher frequencies. Now the limit is set to
the theoretical maximum frequency of 500 MHz.

For the menu itself the maximum frequency is set to a safer 408 MHz,
to avoid over-eager users from putting their system in an unusable state
that is difficult to recover from.

Also the frequency settings are now done in 24 MHz increments, to match
the limitations of the current JZ4740 kernel. Note that only new entries
are rounded to 24 MHz multiples, existing entries stay as they are.
This commit is contained in:
Maarten ter Huurne 2011-09-18 18:27:03 +02:00
parent 3995133fa5
commit d354eb85a4
4 changed files with 49 additions and 15 deletions

View File

@ -209,6 +209,27 @@ int main(int /*argc*/, char * /*argv*/[]) {
return 0; return 0;
} }
void GMenu2X::initCPULimits() {
// Note: These values are for the Dingoo.
// The NanoNote does not have cpufreq enabled in its kernel and
// other devices are not actively maintained.
// TODO: Read min and max from sysfs.
cpuFreqMin = 30;
cpuFreqMax = 500;
cpuFreqSafeMax = 420;
cpuFreqMenuDefault = 200;
cpuFreqAppDefault = 384;
cpuFreqMultiple = 24;
// Round min and max values to the specified multiple.
cpuFreqMin = ((cpuFreqMin + cpuFreqMultiple - 1) / cpuFreqMultiple)
* cpuFreqMultiple;
cpuFreqMax = (cpuFreqMax / cpuFreqMultiple) * cpuFreqMultiple;
cpuFreqSafeMax = (cpuFreqSafeMax / cpuFreqMultiple) * cpuFreqMultiple;
cpuFreqMenuDefault = (cpuFreqMenuDefault / cpuFreqMultiple) * cpuFreqMultiple;
cpuFreqAppDefault = (cpuFreqAppDefault / cpuFreqMultiple) * cpuFreqMultiple;
}
void GMenu2X::init() { void GMenu2X::init() {
#ifdef PLATFORM_GP2X #ifdef PLATFORM_GP2X
/* gp2x_mem = open("/dev/mem", O_RDWR); /* gp2x_mem = open("/dev/mem", O_RDWR);
@ -303,6 +324,7 @@ GMenu2X::GMenu2X()
usbnet = samba = inet = web = false; usbnet = samba = inet = web = false;
useSelectionPng = false; useSelectionPng = false;
initCPULimits();
//load config data //load config data
readConfig(); readConfig();
@ -673,8 +695,10 @@ void GMenu2X::readConfig(string conffile) {
confStr["skin"] = "Default"; confStr["skin"] = "Default";
evalIntConf( &confInt["outputLogs"], 0, 0,1 ); evalIntConf( &confInt["outputLogs"], 0, 0,1 );
evalIntConf( &confInt["maxClock"], 430, 30, 500 ); evalIntConf( &confInt["maxClock"],
evalIntConf( &confInt["menuClock"], 200, 30, 430 ); cpuFreqSafeMax, cpuFreqMin, cpuFreqMax );
evalIntConf( &confInt["menuClock"],
cpuFreqMenuDefault, cpuFreqMin, cpuFreqSafeMax );
evalIntConf( &confInt["globalVolume"], 67, 0,100 ); evalIntConf( &confInt["globalVolume"], 67, 0,100 );
evalIntConf( &confInt["backlightTimeout"], 15, 0,120 ); evalIntConf( &confInt["backlightTimeout"], 15, 0,120 );
evalIntConf( &confInt["backlight"], 100, 5,100 ); evalIntConf( &confInt["backlight"], 100, 5,100 );
@ -1221,7 +1245,7 @@ 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();
setClock(200); setClock(cpuFreqAppDefault);
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
@ -1254,8 +1278,8 @@ void GMenu2X::options() {
SettingsDialog sd(this, input, ts, tr["Settings"]); SettingsDialog sd(this, input, ts, tr["Settings"]);
sd.addSetting(new MenuSettingMultiString(this,tr["Language"],tr["Set the language used by GMenu2X"],&lang,&fl_tr.getFiles())); sd.addSetting(new MenuSettingMultiString(this,tr["Language"],tr["Set the language used by GMenu2X"],&lang,&fl_tr.getFiles()));
sd.addSetting(new MenuSettingBool(this,tr["Save last selection"],tr["Save the last selected link and section on exit"],&confInt["saveSelection"])); sd.addSetting(new MenuSettingBool(this,tr["Save last selection"],tr["Save the last selected link and section on exit"],&confInt["saveSelection"]));
sd.addSetting(new MenuSettingInt(this,tr["Clock for GMenu2X"],tr["Set the cpu working frequency when running GMenu2X"],&confInt["menuClock"],200,430)); sd.addSetting(new MenuSettingInt(this,tr["Clock for GMenu2X"],tr["Set the cpu working frequency when running GMenu2X"],&confInt["menuClock"],cpuFreqMin,cpuFreqSafeMax,cpuFreqMultiple));
sd.addSetting(new MenuSettingInt(this,tr["Maximum overclock"],tr["Set the maximum overclock for launching links"],&confInt["maxClock"],200,430)); sd.addSetting(new MenuSettingInt(this,tr["Maximum overclock"],tr["Set the maximum overclock for launching links"],&confInt["maxClock"],cpuFreqMin,cpuFreqMax,cpuFreqMultiple));
sd.addSetting(new MenuSettingInt(this,tr["Global Volume"],tr["Set the default volume for the gp2x soundcard"],&confInt["globalVolume"],0,100)); sd.addSetting(new MenuSettingInt(this,tr["Global Volume"],tr["Set the default volume for the gp2x soundcard"],&confInt["globalVolume"],0,100));
sd.addSetting(new MenuSettingBool(this,tr["Output logs"],tr["Logs the output of the links. Use the Log Viewer to read them."],&confInt["outputLogs"])); sd.addSetting(new MenuSettingBool(this,tr["Output logs"],tr["Logs the output of the links. Use the Log Viewer to read them."],&confInt["outputLogs"]));
//G //G
@ -1666,7 +1690,7 @@ void GMenu2X::editLink() {
sd.addSetting(new MenuSettingMultiString(this,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->getSections())); sd.addSetting(new MenuSettingMultiString(this,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->getSections()));
sd.addSetting(new MenuSettingImage(this,tr["Icon"],tr.translate("Select an icon for the link: $1",linkTitle.c_str(),NULL),&linkIcon,".png,.bmp,.jpg,.jpeg")); sd.addSetting(new MenuSettingImage(this,tr["Icon"],tr.translate("Select an icon for the link: $1",linkTitle.c_str(),NULL),&linkIcon,".png,.bmp,.jpg,.jpeg"));
sd.addSetting(new MenuSettingFile(this,tr["Manual"],tr["Select a graphic/textual manual or a readme"],&linkManual,".man.png,.txt")); sd.addSetting(new MenuSettingFile(this,tr["Manual"],tr["Select a graphic/textual manual or a readme"],&linkManual,".man.png,.txt"));
sd.addSetting(new MenuSettingInt(this,tr["Clock (default: 336)"],tr["Cpu clock frequency to set when launching this link"],&linkClock,200,confInt["maxClock"])); sd.addSetting(new MenuSettingInt(this,tr["Clock (default: 336)"],tr["Cpu clock frequency to set when launching this link"],&linkClock,cpuFreqMin,confInt["maxClock"],cpuFreqMultiple));
// sd.addSetting(new MenuSettingBool(this,tr["Tweak RAM Timings"],tr["This usually speeds up the application at the cost of stability"],&linkUseRamTimings)); // sd.addSetting(new MenuSettingBool(this,tr["Tweak RAM Timings"],tr["This usually speeds up the application at the cost of stability"],&linkUseRamTimings));
sd.addSetting(new MenuSettingInt(this,tr["Volume (default: -1)"],tr["Volume to set for this link"],&linkVolume,-1,100)); sd.addSetting(new MenuSettingInt(this,tr["Volume (default: -1)"],tr["Volume to set for this link"],&linkVolume,-1,100));
sd.addSetting(new MenuSettingInt(this,tr["Backlight (default: -1)"],tr["LCD backlight value to set when launching this link"],&linkBacklight,-1,100)); sd.addSetting(new MenuSettingInt(this,tr["Backlight (default: -1)"],tr["LCD backlight value to set when launching this link"],&linkBacklight,-1,100));
@ -1821,7 +1845,7 @@ void GMenu2X::scanner() {
#ifdef PLATFORM_PANDORA #ifdef PLATFORM_PANDORA
//char *configpath = pnd_conf_query_searchpath(); //char *configpath = pnd_conf_query_searchpath();
#else #else
if (confInt["menuClock"]<430) { if (confInt["menuClock"]<336) {
setClock(336); setClock(336);
scanbg.write(font,tr["Raising cpu clock to 336Mhz"],5,lineY); scanbg.write(font,tr["Raising cpu clock to 336Mhz"],5,lineY);
scanbg.blit(s,0,0); scanbg.blit(s,0,0);
@ -1889,7 +1913,7 @@ void GMenu2X::scanner() {
s->flip(); s->flip();
lineY += 26; lineY += 26;
if (confInt["menuClock"]<430) { if (confInt["menuClock"]<336) {
setClock(confInt["menuClock"]); setClock(confInt["menuClock"]);
scanbg.write(font,tr["Decreasing cpu clock"],5,lineY); scanbg.write(font,tr["Decreasing cpu clock"],5,lineY);
scanbg.blit(s,0,0); scanbg.blit(s,0,0);

View File

@ -106,6 +106,12 @@ private:
unsigned short cpuX; //!< Offset for displaying cpu clock information unsigned short cpuX; //!< Offset for displaying cpu clock information
unsigned short volumeX; //!< Offset for displaying volume level unsigned short volumeX; //!< Offset for displaying volume level
unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar
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
/*! /*!
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.
@ -156,6 +162,7 @@ private:
void tvout_on(bool pal); void tvout_on(bool pal);
void tvout_off(); void tvout_off();
void initCPULimits();
void init(); void init();
void deinit(); void deinit();
void toggleTvOut(); void toggleTvOut();

View File

@ -27,7 +27,7 @@ using std::string;
using std::stringstream; using std::stringstream;
using fastdelegate::MakeDelegate; using fastdelegate::MakeDelegate;
MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max) MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max, int increment)
: MenuSetting(gmenu2x,name,description) : MenuSetting(gmenu2x,name,description)
{ {
IconButton *btn; IconButton *btn;
@ -36,6 +36,7 @@ MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const strin
originalValue = *value; originalValue = *value;
this->min = min; this->min = min;
this->max = max; this->max = max;
this->increment = increment;
setValue(this->value()); setValue(this->value());
//Delegates //Delegates
@ -75,10 +76,10 @@ bool MenuSettingInt::manageInput(bevent_t *event)
inc(); inc();
break; break;
case ALTLEFT: case ALTLEFT:
setValue(value() - 10); setValue(value() - 10 * increment);
break; break;
case ALTRIGHT: case ALTRIGHT:
setValue(value() + 10); setValue(value() + 10 * increment);
break; break;
default: default:
return false; return false;
@ -88,12 +89,12 @@ bool MenuSettingInt::manageInput(bevent_t *event)
void MenuSettingInt::inc() void MenuSettingInt::inc()
{ {
setValue(value() + 1); setValue(value() + increment);
} }
void MenuSettingInt::dec() void MenuSettingInt::dec()
{ {
setValue(value() - 1); setValue(value() - increment);
} }
void MenuSettingInt::setValue(int value) void MenuSettingInt::setValue(int value)

View File

@ -29,6 +29,7 @@ private:
int *_value; int *_value;
std::string strvalue; std::string strvalue;
int min, max; int min, max;
int increment;
void inc(); void inc();
void dec(); void dec();
@ -36,7 +37,8 @@ private:
public: public:
MenuSettingInt( MenuSettingInt(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, const std::string &name,
const std::string &description, int *value, int min, int max); const std::string &description, int *value, int min, int max,
int increment = 1);
virtual ~MenuSettingInt() {} virtual ~MenuSettingInt() {}
virtual bool manageInput(bevent_t *event); virtual bool manageInput(bevent_t *event);