summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2014-09-29 07:11:13 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-10 18:23:15 +0000
commit86b37e8d9d0f7131f08e1f56343ba5ff7a4dfcf8 (patch)
treed6b4923fa335a2c1c7d2ae4692ad7b2bc1bd904b
parentf97f1074430836d78ce5c4a95e8cd4d63f61d0b0 (diff)
downloadchrome-ec-86b37e8d9d0f7131f08e1f56343ba5ff7a4dfcf8.tar.gz
CHERRY-PICK: charge_state_v2: Send host event if charge state changes
If there is any delay between AC status and the battery charge status it is possible for the power_manager to read the battery state when the AC status event is sent and still see that the battery is not yet charging. This can cause lag in the UI battery icon because the AP is not notified when the battery charge state changes. In order for the host to be able to differentiate the dynamic battery state changing (re-read ACPI _BST by sending Notify 0x80) from the static battery info (re-read ACPI _BIX/_BIF by sending Notify 0x81) it needs a separate host event. BUG=chrome-os-partner:32196 BRANCH=samus TEST=Test AC instertion and removal while watching state on the host to ensure that an event is sent to the host which triggers power manager to re-read the battery status and notice that the charge state has changed if there is any delay after the AC status event: watch -n 0.1 "cat /sys/class/power_supply/AC/online; cat /sys/class/power_supply/BAT0/status; tail -10 /var/log/power_manager/powerd.LATEST" Change-Id: I304a326053a0b7b53a1364138bb6c5eccbf00957 Original-Change-Id: I18ce70719dc231c43c474cefad2068f949675a2b Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220257 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222849 Reviewed-by: Mohammed Habibulla <moch@chromium.org> Commit-Queue: Mohammed Habibulla <moch@chromium.org> Tested-by: Mohammed Habibulla <moch@chromium.org>
-rw-r--r--common/charge_state_v2.c3
-rw-r--r--include/ec_commands.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 1b796c9c27..2c17a838bf 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -212,6 +212,9 @@ static void update_dynamic_battery_info(void)
break;
}
+ /* Tell the AP to re-read battery status if charge state changes */
+ if (*memmap_flags != tmp)
+ host_set_single_event(EC_HOST_EVENT_BATTERY_STATUS);
*memmap_flags = tmp;
/* Poke the AP if the full_capacity changes. */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index e148660644..1339d328eb 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -275,6 +275,9 @@ enum host_event_code {
/* PD MCU triggering host event */
EC_HOST_EVENT_PD_MCU = 22,
+ /* Battery Status flags have changed */
+ EC_HOST_EVENT_BATTERY_STATUS = 23,
+
/*
* The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be