From da0af28a7c1c4a39809fc1daf37c46a346f181d6 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Thu, 18 Nov 2021 15:08:43 +0800 Subject: 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 Change-Id: I8befb1b3044b6ee788cc36b21f682a3450f31185 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3288539 Reviewed-by: Joe Tessler Reviewed-by: Jack Rosenthal Commit-Queue: Joe Tessler (cherry picked from commit bccca05bf8101e6c11443d9ff085c53f95c50a1d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3309106 Tested-by: Joe Tessler Auto-Submit: Joe Tessler Commit-Queue: Rubber Stamper Bot-Commit: Rubber Stamper --- common/led_common.c | 12 ++++++++++++ include/led_common.h | 6 ++++++ 2 files changed, 18 insertions(+) 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 @@ -74,6 +74,12 @@ enum ec_led_state { LED_STATE_RESET = 2, }; +/** + * Check the LED state while receive the auto control + * command. + */ +void board_led_auto_control(void); + /** * Control state of LED. * -- cgit v1.2.1