cpufreq: Rank modules and choose the best one
This commit is contained in:
@@ -17,6 +17,8 @@ const int kCPUPerformanceScaleMax = 1000;
|
|||||||
typedef struct cpufreq_module_info {
|
typedef struct cpufreq_module_info {
|
||||||
module_info info;
|
module_info info;
|
||||||
|
|
||||||
|
float rank;
|
||||||
|
|
||||||
status_t (*increase_performance)(int delta, bool allowBoost);
|
status_t (*increase_performance)(int delta, bool allowBoost);
|
||||||
status_t (*decrease_performance)(int delta);
|
status_t (*decrease_performance)(int delta);
|
||||||
} cpufreq_module_info;
|
} cpufreq_module_info;
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ static cpufreq_module_info sIntelPStates = {
|
|||||||
std_ops,
|
std_ops,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
1.0f,
|
||||||
|
|
||||||
increase_performance,
|
increase_performance,
|
||||||
decrease_performance,
|
decrease_performance,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,13 +63,22 @@ load_cpufreq_module()
|
|||||||
while (true) {
|
while (true) {
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
size_t nameLength = sizeof(name);
|
size_t nameLength = sizeof(name);
|
||||||
|
cpufreq_module_info* current = NULL;
|
||||||
|
|
||||||
if (read_next_module_name(cookie, name, &nameLength) != B_OK)
|
if (read_next_module_name(cookie, name, &nameLength) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (get_module(name, (module_info**)&sCPUPerformanceModule) == B_OK) {
|
if (get_module(name, (module_info**)¤t) == B_OK) {
|
||||||
dprintf("found cpufreq module: %s\n", name);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user