Fix SSD2092 wake, fuel-gauge jump, XLibre rotation, media keys, and popup rendering
This commit is contained in:
1 parent
7f3b3c2c0c
commit
dbc0275979
43 files changed
+3388
-115
No files matched your search
@@ -40,13 +40,15 @@ geminux_profile_params_t geminux_policy_params(geminux_profile_t prof, bool on_a
|
||||
geminux_profile_params_t out;
|
||||
out.governor = "schedutil";
|
||||
if (prof == POWER_PROFILE_ECO) {
|
||||
out.governor = "schedutil";
|
||||
out.a72_online = false;
|
||||
out.a53_ll_max_khz = 624000UL;
|
||||
out.a53_max_khz = 832000UL;
|
||||
out.a53_ll_max_khz = 715000UL;
|
||||
out.a53_max_khz = 962000UL;
|
||||
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.governor = "performance";
|
||||
out.a72_online = true;
|
||||
out.a53_ll_max_khz = 1547000UL;
|
||||
out.a53_max_khz = 1846000UL;
|
||||
@@ -54,9 +56,10 @@ geminux_profile_params_t geminux_policy_params(geminux_profile_t prof, bool on_a
|
||||
out.dim_timeout_s = on_ac ? 600 : 180;
|
||||
out.suspend_timeout_s = 0;
|
||||
} else {
|
||||
out.governor = "schedutil";
|
||||
out.a72_online = true;
|
||||
out.a53_ll_max_khz = on_ac ? 897000UL : 806000UL;
|
||||
out.a53_max_khz = on_ac ? 1209000UL : 1092000UL;
|
||||
out.a53_ll_max_khz = on_ac ? 1547000UL : 897000UL;
|
||||
out.a53_max_khz = on_ac ? 1846000UL : 1209000UL;
|
||||
out.a72_max_khz = 2002000UL;
|
||||
out.dim_timeout_s = on_ac ? 300 : 120;
|
||||
out.suspend_timeout_s = on_ac ? 0 : 300;
|
||||
@@ -140,3 +143,62 @@ bool geminux_should_suspend_on_lid(const geminux_power_policy_t *p) {
|
||||
if (p->on_ac_power && p->inhibit_ac_lid) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool geminux_fg_r_valid(uint32_t r_uohm) {
|
||||
return r_uohm >= 50000U && r_uohm <= 1500000U;
|
||||
}
|
||||
|
||||
static bool geminux_fg_full_valid(uint32_t full_uah) {
|
||||
return full_uah >= 1000000U && full_uah <= 10000000U;
|
||||
}
|
||||
|
||||
bool geminux_fg_state_parse(const char *text, uint32_t *r_uohm, uint32_t *full_uah) {
|
||||
if (!text || !r_uohm || !full_uah) return false;
|
||||
uint32_t r = 0, full = 0;
|
||||
bool got_r = false, got_full = false;
|
||||
const char *p = text;
|
||||
while (*p) {
|
||||
const char *nl = strchr(p, '\n');
|
||||
size_t len = nl ? (size_t)(nl - p) : strlen(p);
|
||||
size_t start = 0;
|
||||
while (start < len && (p[start] == ' ' || p[start] == '\t')) {
|
||||
start++;
|
||||
}
|
||||
while (len > start && (p[len - 1] == '\r' || p[len - 1] == ' ' || p[len - 1] == '\t')) {
|
||||
len--;
|
||||
}
|
||||
size_t trim_len = len - start;
|
||||
if (trim_len > 0 && trim_len < 96) {
|
||||
char line[96];
|
||||
memcpy(line, p + start, trim_len);
|
||||
line[trim_len] = '\0';
|
||||
unsigned long long val = 0;
|
||||
char tail = '\0';
|
||||
if (sscanf(line, "learned_resistance_uohm=%llu%c", &val, &tail) == 1 &&
|
||||
val <= 0xffffffffULL) {
|
||||
r = (uint32_t)val;
|
||||
got_r = true;
|
||||
} else if (sscanf(line, "learned_full_uah=%llu%c", &val, &tail) == 1 &&
|
||||
val <= 0xffffffffULL) {
|
||||
full = (uint32_t)val;
|
||||
got_full = true;
|
||||
}
|
||||
}
|
||||
p = nl ? (nl + 1) : (p + strlen(p));
|
||||
}
|
||||
if (!got_r || !got_full || !geminux_fg_r_valid(r) || !geminux_fg_full_valid(full)) {
|
||||
return false;
|
||||
}
|
||||
*r_uohm = r;
|
||||
*full_uah = full;
|
||||
return true;
|
||||
}
|
||||
|
||||
int geminux_fg_state_format(uint32_t r_uohm, uint32_t full_uah, char *buf, size_t sz) {
|
||||
if (!buf || sz == 0 || !geminux_fg_r_valid(r_uohm) || !geminux_fg_full_valid(full_uah)) {
|
||||
return -1;
|
||||
}
|
||||
int n = snprintf(buf, sz, "learned_resistance_uohm=%u\nlearned_full_uah=%u\n",
|
||||
r_uohm, full_uah);
|
||||
return (n > 0 && (size_t)n < sz) ? 0 : -1;
|
||||
}
|
||||
Reference in new issue
Block a user