diff options
author | Dave Parker <dparker@chromium.org> | 2013-08-29 10:13:53 -0700 |
---|---|---|
committer | Caroline Tice <cmtice@chromium.org> | 2013-08-29 22:48:36 +0000 |
commit | a795b1ffe05a7c7f41f66783b711c332dd92bfb0 (patch) | |
tree | c184112e74e0ffa90a53882f2633c274b9f38707 | |
parent | a7106021ed89992bc5ebd69ac000c7b90cde7276 (diff) | |
download | chrome-ec-a795b1ffe05a7c7f41f66783b711c332dd92bfb0.tar.gz |
Peppy: Make power LED turn amber when entering suspend
This fixes some jank in how the power LED works when going into
suspend. Previously the power LED could turn off for up to three
seconds before flashing amber when entering suspend.
BUG=chrome-os-partner:21622
BRANCH=peppy
TEST=Manual. Enter suspend and observe that LED goes from blue
to amber without turning off first.
Change-Id: Ib0bf9e998d250b0731405394d3ebb50d90de7cda
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167388
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/led_peppy.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/common/led_peppy.c b/common/led_peppy.c index 88cdf7c237..ffdcdb8359 100644 --- a/common/led_peppy.c +++ b/common/led_peppy.c @@ -109,23 +109,43 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) brightness_range[EC_LED_COLOR_YELLOW] = 1; } -static void peppy_led_set_power(int ticks) +static void peppy_led_set_power(void) { + static int power_ticks; + static int previous_state_suspend; + + power_ticks++; + + if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { + /* Reset ticks if entering suspend so LED turns amber + * as soon as possible. */ + if (!previous_state_suspend) + power_ticks = 0; + + /* Blink once every four seconds. */ + peppy_led_set_color_power( + (power_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? + LED_AMBER : LED_OFF); + + previous_state_suspend = 1; + return; + } + + previous_state_suspend = 0; + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) peppy_led_set_color_power(LED_OFF); else if (chipset_in_state(CHIPSET_STATE_ON)) peppy_led_set_color_power(LED_BLUE); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) - /* Blink once every four seconds. */ - peppy_led_set_color_power( - (ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? - LED_AMBER : LED_OFF); } -static void peppy_led_set_battery(int ticks) +static void peppy_led_set_battery(void) { + static int battery_ticks; uint32_t chflags = charge_get_flags(); + battery_ticks++; + switch (charge_get_state()) { case PWR_STATE_CHARGE: peppy_led_set_color_battery(LED_AMBER); @@ -138,13 +158,13 @@ static void peppy_led_set_battery(int ticks) break; case PWR_STATE_ERROR: peppy_led_set_color_battery( - (ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? + (battery_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? LED_AMBER : LED_OFF); break; case PWR_STATE_IDLE: /* External power connected in IDLE. */ if (chflags & CHARGE_FLAG_FORCE_IDLE) peppy_led_set_color_battery( - (ticks & 0x4) ? LED_BLUE : LED_OFF); + (battery_ticks & 0x4) ? LED_BLUE : LED_OFF); else peppy_led_set_color_battery(LED_BLUE); break; @@ -157,14 +177,10 @@ static void peppy_led_set_battery(int ticks) /* Called by hook task every 250mSec */ static void led_tick(void) { - static int ticks; - - ticks++; - if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - peppy_led_set_power(ticks); + peppy_led_set_power(); if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - peppy_led_set_battery(ticks); + peppy_led_set_battery(); } DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); |