00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef POWERSAVE_CONFIG_H
00026 #define POWERSAVE_CONFIG_H
00027
00028 #include <map>
00029 #include <string>
00030 #include "powerlib.h"
00031 #include "event.h"
00032 #include "device.h"
00033
00034 #ifdef CREATE_DEBUG_OUTPUT
00035 #include <sstream>
00036 #include <iostream>
00037 #endif
00038
00039 #define MAX_SCHEMES 50
00040 #define MAX_THERMAL_ZONES 10
00041 #define ACPI_THERMAL_MAX_ACTIVE 10
00042
00043 enum CPUFREQ_MODE { _DYNAMIC, _PERFORMANCE, _POWERSAVE };
00044
00049 enum CPUFREQ_CONTROL_MODE { CPUFREQ_USERSPACE = 1, CPUFREQ_KERNEL };
00050
00051 enum THERMAL_MANAGEMENT_DELIGATION { OFF, KERNEL, KERNEL_PASSIVE };
00052
00053 class Event;
00054 class GeneralConfig;
00055
00056 using namespace std;
00057
00059 class PS_Config {
00060 public:
00062 PS_Config();
00063
00065 virtual ~ PS_Config();
00066
00067 virtual Event & getEvent(const string &event_name);
00068
00069 virtual int readConfigFile(const std::string & file = "");
00070
00071 virtual void assignConfigEntries();
00072
00075 typedef map < string, Event >::iterator EventIter;
00076
00080 ThermalDev thermal_zones[MAX_THERMAL_ZONES];
00081
00086 string SCHEME_NAME;
00087
00089 string SCHEME_DESCRIPTION;
00090
00091
00092
00094 CPUFREQ_CONTROL_MODE CPUFREQ_CONTROL;
00095
00098 int CPU_HIGH_LIMIT;
00099
00101 THERMAL_MANAGEMENT_DELIGATION ENABLE_THERMAL_MANAGEMENT;
00102
00104 unsigned long POLL_INTERVAL;
00105
00108 unsigned long CPU_IDLE_TIMEOUT;
00109
00112 int CPU_IDLE_LIMIT;
00113
00118 int MAX_CPUS_ONLINE;
00119
00122 int CONSIDER_NICE;
00123
00125 int USER_SUSPEND2DISK_DISABLED;
00126
00128 int USER_SUSPEND2RAM_DISABLED;
00129
00131 int USER_STANDBY_DISABLED;
00132
00135 int SUSPEND2DISK_DELAY;
00136
00139 int SUSPEND2RAM_DELAY;
00140
00143 int STANDBY_DELAY;
00144
00147 int DISPLAY_BRIGHTNESS;
00148
00150 int POWER_BUTTON_DELAY;
00151
00152
00153
00154 int BAT_WARN_LIMIT;
00155
00156
00157
00158 int BAT_LOW_LIMIT;
00159
00160
00161
00162 int BAT_CRIT_LIMIT;
00163
00174 int JUMP_CPU_FREQ_MAX_LIMIT;
00175
00177 bool CPUFREQ_ENABLED;
00178
00180 bool DPM_ENABLED;
00181
00191 int CPUFREQ_HYSTERESIS;
00192
00197 string BATTERY_SCHEME;
00198
00203 string AC_SCHEME;
00204
00206 bool ALLOW_THROTTLING;
00207
00209 int MAX_CPU_THROTTLING;
00210
00212 bool ALWAYS_THROTTLE;
00213
00215 CPUFREQ_MODE CPUFREQUENCY;
00216
00218 _COOLING_POLICY COOLING_POLICY;
00219
00222 map < string, Event > eventMap;
00223
00226 std::list < DPM_DEVICE_CLASS > dpmClasses;
00227
00228
00229
00230 private:
00233 void strtointErr(char *str, int line, const char *file);
00234
00245 int checkValue(const std::string &what, int min, int max);
00246
00256 int checkValue(const std::string &what, int min);
00257
00270 int checkValue(int def, const std::string &what, int min, int max);
00271
00283 int checkValue(int def, const std::string &what, int min);
00284
00294 int checkYes(const std::string &what);
00295
00306 int checkYes(int def, const std::string &what);
00307
00313 void splitLine(std::string line, std::list< std::string > &strings);
00314
00316 typedef std::map < std::string, std::string > StringMap;
00317
00319 StringMap data;
00320 };
00321
00322
00324 class SchemeConfig : public PS_Config {
00325 public:
00328 SchemeConfig(const string &file_name, const GeneralConfig &);
00329
00331 virtual ~SchemeConfig();
00332
00334 virtual int readConfigFile(const string &file = "");
00335
00337 string file_name;
00338
00340 SchemeConfig *next;
00341
00342 private:
00344 string file_path;
00345
00346 #ifdef CREATE_DEBUG_OUTPUT
00347 friend ostream & operator<<(ostream &, SchemeConfig &);
00348 #endif
00349 };
00350
00351
00354 class GeneralConfig : public PS_Config {
00355 public:
00357 GeneralConfig();
00358
00360 virtual ~ GeneralConfig();
00361
00370 int readConfFiles();
00371
00378 SchemeConfig *getScheme(const string &scheme_name);
00379
00390 SchemeConfig *getSchemeByNumber(int no);
00391
00402 int setActiveScheme(const string &scheme_name);
00403
00409 string getBatteryScheme();
00410
00416 string getACScheme();
00417
00419 SchemeConfig *current_scheme;
00420
00422 SchemeConfig *AC_scheme;
00423
00425 SchemeConfig *Battery_scheme;
00426
00428 string config_dir;
00429
00431 string script_dir;
00432
00434 string scheme_dir;
00435
00437 string pub_script_dir;
00438
00440 bool disable_CPU_freq;
00441
00442 #ifdef CREATE_DEBUG_OUTPUT
00443 friend ostream & operator<<(ostream & os, const GeneralConfig & gc);
00444 #endif
00445
00446 private:
00448 static const string config_files[6];
00449
00451 SchemeConfig *scheme_configs;
00452
00457 int initSchemes();
00458
00463 bool parseSchemes();
00464 };
00465
00466 #endif // POWERSAVE_CONFIG_H