diff options
author | Yilun Lin <yllin@google.com> | 2019-06-12 11:34:29 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-14 04:26:14 +0000 |
commit | e0f88ac5dd779a2edf32fb7f660be10287f0d510 (patch) | |
tree | fcd76feb26216e274324160dfb36a510886b5f37 | |
parent | 8374923a60c8b63b7bb2c1823e4f5b6078544e44 (diff) | |
download | chrome-ec-e0f88ac5dd779a2edf32fb7f660be10287f0d510.tar.gz |
kukui/led: Reset led prv_chstate once auto-controlled re-enabled.
Reset LED prv_chstate so that the LED light can be updated immediately
when the led controlled status goes from manual to auto.
TEST=Plug charger; see blue led
ectool led battery red=1; see red led
ectool led battery auto; see blue led immediately.
BUG=None
BRANCH=master
Change-Id: I4f5029d708df8f9c31c6c5ee8b51003648a4ff9e
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1654762
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Auto-Submit: Yilun Lin <yllin@chromium.org>
Commit-Queue: Yilun Lin <yllin@chromium.org>
-rw-r--r-- | board/kukui/led.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/board/kukui/led.c b/board/kukui/led.c index 0d7ec4556b..9de4ac0925 100644 --- a/board/kukui/led.c +++ b/board/kukui/led.c @@ -15,6 +15,8 @@ const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); +static enum charge_state prv_chstate = PWR_STATE_INIT; + #define LED_OFF MT6370_LED_ID_OFF #define LED_RED MT6370_LED_ID1 #define LED_GREEN MT6370_LED_ID2 @@ -27,7 +29,6 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); static void kukui_led_set_battery(void) { - static enum charge_state prv_chstate = PWR_STATE_UNCHANGE; enum charge_state chstate; uint8_t br[EC_LED_COLOR_COUNT] = { 0 }; @@ -93,10 +94,21 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) return EC_SUCCESS; } +/* + * Reset prv_chstate so that led can be updated immediately once + * auto-controlled. + */ +static void led_reset_auto_control(void) +{ + prv_chstate = PWR_STATE_INIT; +} + /* Called by hook task every 1 sec */ static void led_second(void) { if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) kukui_led_set_battery(); + else + led_reset_auto_control(); } DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); |