diff options
Diffstat (limited to 'common/battery.c')
-rw-r--r-- | common/battery.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/battery.c b/common/battery.c index 9d7277479c..9d380efe86 100644 --- a/common/battery.c +++ b/common/battery.c @@ -21,6 +21,12 @@ #define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) +/* + * See config.h for details. + * TODO: Allow host (powerd) to update it. + */ +static int batt_full_factor = CONFIG_BATT_FULL_FACTOR; + #ifdef CONFIG_BATTERY_V2 /* * Store battery information in these 2 structures. Main (lid) battery is always @@ -557,6 +563,22 @@ DECLARE_HOOK(HOOK_INIT, battery_init, HOOK_PRIO_DEFAULT); #endif /* HAS_TASK_HOSTCMD */ #endif /* CONFIG_BATTERY_V2 */ +void battery_compensate_params(struct batt_params *batt) +{ + int remain = batt->remaining_capacity; + int full = batt->full_capacity; + + if ((batt->flags & BATT_FLAG_BAD_FULL_CAPACITY) || + (batt->flags & BATT_FLAG_BAD_REMAINING_CAPACITY)) + return; + + if (remain <= 0 || full <= 0) + return; + + if (remain * 100 > full * batt_full_factor) + batt->remaining_capacity = full; +} + __attribute__((weak)) int get_battery_manufacturer_name(char *dest, int size) { strzcpy(dest, "<unkn>", size); |