diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2021-11-18 15:08:43 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-30 19:40:07 +0000 |
commit | bccca05bf8101e6c11443d9ff085c53f95c50a1d (patch) | |
tree | f7dc2305dc730c9faa3cb8a362895c3802f51090 | |
parent | fa854d62c1a0280519b24a63e872f37dda09810c (diff) | |
download | chrome-ec-bccca05bf8101e6c11443d9ff085c53f95c50a1d.tar.gz |
led_common: Add board_led_auto_control
Some projects have only power led won't change the led
state immediately as the auto command is called for
they only check the led state while the power state
is changed. Add board_led_auto_control to let them
check led state while receive the auto control command.
BUG=b:198405130
BRANCH=none
TEST=make buildall
Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com>
Change-Id: I8befb1b3044b6ee788cc36b21f682a3450f31185
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3288539
Reviewed-by: Joe Tessler <jrt@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Joe Tessler <jrt@chromium.org>
-rw-r--r-- | common/led_common.c | 12 | ||||
-rw-r--r-- | include/led_common.h | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/common/led_common.c b/common/led_common.c index 85879b148f..6c0e2ac426 100644 --- a/common/led_common.c +++ b/common/led_common.c @@ -47,6 +47,16 @@ int led_auto_control_is_enabled(enum ec_led_id led_id) return (led_auto_control_flags & LED_AUTO_CONTROL_FLAG(led_id)) != 0; } +__attribute__((weak)) void board_led_auto_control(void) +{ + /* + * The projects have only power led won't change the led + * state immediately as the auto command is called for + * they only check the led state while the power state + * is changed. + */ +} + static enum ec_status led_command_control(struct host_cmd_handler_args *args) { const struct ec_params_led_control *p = args->params; @@ -69,6 +79,8 @@ static enum ec_status led_command_control(struct host_cmd_handler_args *args) if (p->flags & EC_LED_FLAGS_AUTO) { led_auto_control(p->led_id, 1); + if (!IS_ENABLED(CONFIG_LED_ONOFF_STATES)) + board_led_auto_control(); } else { if (led_set_brightness(p->led_id, p->brightness) != EC_SUCCESS) return EC_RES_INVALID_PARAM; diff --git a/include/led_common.h b/include/led_common.h index a66455b008..1e4629a606 100644 --- a/include/led_common.h +++ b/include/led_common.h @@ -75,6 +75,12 @@ enum ec_led_state { }; /** + * Check the LED state while receive the auto control + * command. + */ +void board_led_auto_control(void); + +/** * Control state of LED. * * @param led_id ID of LED to control |