summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSue Chen <sue.chen@quanta.corp-partner.google.com>2021-11-18 15:08:43 +0800
committerCommit Bot <commit-bot@chromium.org>2021-11-30 23:04:08 +0000
commitda0af28a7c1c4a39809fc1daf37c46a346f181d6 (patch)
tree375490c0f66a9c4505690e68affd868bafeef886
parent17c9d24d8f95dacd1b684c50466ca2996f7bd9e4 (diff)
downloadchrome-ec-da0af28a7c1c4a39809fc1daf37c46a346f181d6.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> (cherry picked from commit bccca05bf8101e6c11443d9ff085c53f95c50a1d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3309106 Tested-by: Joe Tessler <jrt@chromium.org> Auto-Submit: Joe Tessler <jrt@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
-rw-r--r--common/led_common.c12
-rw-r--r--include/led_common.h6
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