diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-03-10 18:10:00 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-03-10 18:29:29 -0500 |
commit | 555299af9f0ee71c1ad86a6c6846748861be458b (patch) | |
tree | 2237e2991231cf529420f52c10a91912ed94bf06 /firmware/target/hosted/xduoo | |
parent | b3b8310e4e07902a8280a120948f0c32c85e67de (diff) |
hosted: Consolidate the code that polls the battery charging status
affects all hiby targets, fiiom3k, and ibasso dx50/dx90
As well as deduplicating a small pile of code, this also implements
hysteresis so we're not doing a sysfs read/lookup multiple times
back-to-back every time the power management tick fires.
Change-Id: I2f7672acbb36341becf67e07960c24c681270d09
Diffstat (limited to 'firmware/target/hosted/xduoo')
-rw-r--r-- | firmware/target/hosted/xduoo/power-xduoo.c | 22 | ||||
-rw-r--r-- | firmware/target/hosted/xduoo/power-xduoo.h | 3 | ||||
-rw-r--r-- | firmware/target/hosted/xduoo/powermgmt-xduoo.c | 11 |
3 files changed, 0 insertions, 36 deletions
diff --git a/firmware/target/hosted/xduoo/power-xduoo.c b/firmware/target/hosted/xduoo/power-xduoo.c index 97a8dd4779..0b1e2f816e 100644 --- a/firmware/target/hosted/xduoo/power-xduoo.c +++ b/firmware/target/hosted/xduoo/power-xduoo.c @@ -35,28 +35,6 @@ const char * const sysfs_bat_voltage = const char * const sysfs_bat_capacity = "/sys/class/power_supply/battery/capacity"; -const char * const sysfs_bat_status = - "/sys/class/power_supply/battery/status"; - -const char * const sysfs_pow_supply = - "/sys/class/power_supply/usb/present"; - -unsigned int xduoo_power_input_status(void) -{ - int present = 0; - sysfs_get_int(sysfs_pow_supply, &present); - - return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE; -} - -bool xduoo_power_charging_status(void) -{ - char buf[12] = {0}; - sysfs_get_string(sysfs_bat_status, buf, sizeof(buf)); - - return (strncmp(buf, "Charging", 8) == 0); -} - unsigned int xduoo_power_get_battery_voltage(void) { int battery_voltage; diff --git a/firmware/target/hosted/xduoo/power-xduoo.h b/firmware/target/hosted/xduoo/power-xduoo.h index d573865ed2..ee016bd60b 100644 --- a/firmware/target/hosted/xduoo/power-xduoo.h +++ b/firmware/target/hosted/xduoo/power-xduoo.h @@ -23,9 +23,6 @@ #include <stdbool.h> #include "config.h" -unsigned int xduoo_power_input_status(void); -bool xduoo_power_charging_status(void); unsigned int xduoo_power_get_battery_voltage(void); unsigned int xduoo_power_get_battery_capacity(void); #endif /* _POWER_XDUOO_H_ */ - diff --git a/firmware/target/hosted/xduoo/powermgmt-xduoo.c b/firmware/target/hosted/xduoo/powermgmt-xduoo.c index 35d9e45ffc..855072031e 100644 --- a/firmware/target/hosted/xduoo/powermgmt-xduoo.c +++ b/firmware/target/hosted/xduoo/powermgmt-xduoo.c @@ -44,12 +44,6 @@ const unsigned short const percent_to_volt_charge[11] = 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196 }; -unsigned int power_input_status(void) -{ - /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */ - return xduoo_power_input_status(); -} - #if defined(XDUOO_X3II) int _battery_voltage(void) { @@ -63,8 +57,3 @@ int _battery_level(void) return xduoo_power_get_battery_capacity(); } #endif - -bool charging_state(void) -{ - return xduoo_power_charging_status(); -} |