mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 04:20:04 +01:00
Merge branch 'feat/openbsd/chargemode' into 'master'
Draft: openbsd: read hw.battery.chargemode/start/stop and update charge thresholds properties See merge request upower/upower!273
This commit is contained in:
commit
f164419947
1 changed files with 31 additions and 0 deletions
|
|
@ -401,6 +401,8 @@ up_backend_update_acpibat_state(UpDevice* device, struct sensordev s)
|
|||
/* gdouble bif_dvolt; */
|
||||
struct sensor sens;
|
||||
size_t slen = sizeof(sens);
|
||||
int chargemode=-2, chargestart=-1, chargestop=-1;
|
||||
size_t ilen = sizeof(chargemode);
|
||||
int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
|
||||
|
||||
mib[2] = s.num;
|
||||
|
|
@ -446,6 +448,35 @@ up_backend_update_acpibat_state(UpDevice* device, struct sensordev s)
|
|||
capacity = 100.0f;
|
||||
}
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_BATTERY;
|
||||
mib[2] = HW_BATTERY_CHARGEMODE;
|
||||
mib[3] = 0;
|
||||
mib[4] = 0;
|
||||
if (sysctl(mib, 3, &chargemode, &ilen, NULL, 0) < 0)
|
||||
g_error("failed to get hw.battery.chargemode sysctl node");
|
||||
mib[2] = HW_BATTERY_CHARGESTART;
|
||||
if (sysctl(mib, 3, &chargestart, &ilen, NULL, 0) < 0)
|
||||
g_error("failed to get hw.battery.chargestart sysctl node");
|
||||
mib[2] = HW_BATTERY_CHARGESTOP;
|
||||
if (sysctl(mib, 3, &chargestop, &ilen, NULL, 0) < 0)
|
||||
g_error("failed to get hw.battery.chargestop sysctl node");
|
||||
//g_debug("chargestop=%d, chargestart=%d, chargemode=%d", chargestop, chargestart,chargemode);
|
||||
if (chargestop >= 0) {
|
||||
g_object_set(device,
|
||||
"charge-threshold-supported", TRUE,
|
||||
"charge-end-threshold", chargestop,
|
||||
(void*) NULL);
|
||||
if (chargemode >= -1)
|
||||
g_object_set(device,
|
||||
"charge-threshold-enabled", chargemode == 1,
|
||||
(void*) NULL);
|
||||
if (chargestart >= 0)
|
||||
g_object_set(device,
|
||||
"charge-start-threshold", chargestart,
|
||||
(void*) NULL);
|
||||
}
|
||||
|
||||
g_object_set (device,
|
||||
"energy", bst_cap,
|
||||
"energy-full", bif_lastfullcap,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue