cpufreq: Rank modules and choose the best one

This commit is contained in:
Pawel Dziepak 2013-11-25 00:08:13 +01:00
parent 13a89839fc
commit 1e8ed5558d
3 changed files with 15 additions and 2 deletions

View File

@ -17,6 +17,8 @@ const int kCPUPerformanceScaleMax = 1000;
typedef struct cpufreq_module_info {
module_info info;
float rank;
status_t (*increase_performance)(int delta, bool allowBoost);
status_t (*decrease_performance)(int delta);
} cpufreq_module_info;

View File

@ -222,6 +222,8 @@ static cpufreq_module_info sIntelPStates = {
std_ops,
},
1.0f,
increase_performance,
decrease_performance,
};

View File

@ -63,13 +63,22 @@ load_cpufreq_module()
while (true) {
char name[B_FILE_NAME_LENGTH];
size_t nameLength = sizeof(name);
cpufreq_module_info* current = NULL;
if (read_next_module_name(cookie, name, &nameLength) != B_OK)
break;
if (get_module(name, (module_info**)&sCPUPerformanceModule) == B_OK) {
if (get_module(name, (module_info**)&current) == B_OK) {
dprintf("found cpufreq module: %s\n", name);
break;
if (sCPUPerformanceModule != NULL) {
if (sCPUPerformanceModule->rank < current->rank) {
put_module(sCPUPerformanceModule->info.name);
sCPUPerformanceModule = current;
} else
put_module(name);
} else
sCPUPerformanceModule = current;
}
}