Initial commit: Geminux 0.1.0 (helio) for Planet Computers Gemini PDA (MT6797X)
This commit is contained in:
commit
034c1f61b1
816 files changed
+223435
No files matched your search
@@ -0,0 +1,95 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "geminux-power-policy.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void geminux_policy_init(geminux_power_policy_t *p) {
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->profile = POWER_PROFILE_BALANCED;
|
||||
p->lid_suspend_enabled = true;
|
||||
}
|
||||
|
||||
bool geminux_policy_set_profile_name(geminux_power_policy_t *p, const char *name) {
|
||||
if (!p || !name) return false;
|
||||
if (strcmp(name, "eco") == 0) {
|
||||
p->profile = POWER_PROFILE_ECO;
|
||||
return true;
|
||||
}
|
||||
if (strcmp(name, "balanced") == 0) {
|
||||
p->profile = POWER_PROFILE_BALANCED;
|
||||
return true;
|
||||
}
|
||||
if (strcmp(name, "performance") == 0) {
|
||||
p->profile = POWER_PROFILE_PERFORMANCE;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *geminux_policy_profile_name(geminux_profile_t prof) {
|
||||
switch (prof) {
|
||||
case POWER_PROFILE_ECO: return "eco";
|
||||
case POWER_PROFILE_PERFORMANCE: return "performance";
|
||||
case POWER_PROFILE_BALANCED:
|
||||
default: return "balanced";
|
||||
}
|
||||
}
|
||||
|
||||
geminux_profile_params_t geminux_policy_params(geminux_profile_t prof, bool on_ac) {
|
||||
geminux_profile_params_t out;
|
||||
out.governor = "schedutil";
|
||||
if (prof == POWER_PROFILE_ECO) {
|
||||
out.a72_online = false;
|
||||
out.a53_max_khz = 1391000UL;
|
||||
out.a72_max_khz = 0UL;
|
||||
out.dim_timeout_s = on_ac ? 180 : 60;
|
||||
out.suspend_timeout_s = on_ac ? 0 : 180;
|
||||
} else if (prof == POWER_PROFILE_PERFORMANCE) {
|
||||
out.a72_online = true;
|
||||
out.a53_max_khz = 1846000UL;
|
||||
out.a72_max_khz = 2600000UL;
|
||||
out.dim_timeout_s = on_ac ? 600 : 180;
|
||||
out.suspend_timeout_s = 0;
|
||||
} else {
|
||||
out.a72_online = true;
|
||||
out.a53_max_khz = 1547000UL;
|
||||
out.a72_max_khz = 2002000UL;
|
||||
out.dim_timeout_s = on_ac ? 300 : 120;
|
||||
out.suspend_timeout_s = on_ac ? 0 : 300;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool geminux_policy_add_inhibit(geminux_power_policy_t *p, const char *tag) {
|
||||
if (!p || !tag || !tag[0]) return false;
|
||||
for (int i = 0; i < p->inhibit_count; i++) {
|
||||
if (strcmp(p->inhibitors[i], tag) == 0) return true;
|
||||
}
|
||||
if (p->inhibit_count >= GEMINUX_MAX_INHIBITORS) return false;
|
||||
snprintf(p->inhibitors[p->inhibit_count], sizeof(p->inhibitors[0]), "%s", tag);
|
||||
p->inhibit_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool geminux_policy_del_inhibit(geminux_power_policy_t *p, const char *tag) {
|
||||
if (!p || !tag || !tag[0]) return false;
|
||||
for (int i = 0; i < p->inhibit_count; i++) {
|
||||
if (strcmp(p->inhibitors[i], tag) == 0) {
|
||||
for (int j = i; j + 1 < p->inhibit_count; j++) {
|
||||
memcpy(p->inhibitors[j], p->inhibitors[j + 1], sizeof(p->inhibitors[0]));
|
||||
}
|
||||
p->inhibit_count--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool geminux_should_suspend_on_lid(const geminux_power_policy_t *p) {
|
||||
if (!p || !p->lid_closed || !p->lid_suspend_enabled) return false;
|
||||
if (p->hdmi_connected) return false;
|
||||
if (p->inhibit_count > 0) return false;
|
||||
if (p->on_ac_power && p->inhibit_ac_lid) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user