summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-04-20 15:34:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-27 21:27:29 -0700
commit02b42b78b3ff7fd7c1670d660c1fa63e35d4ca3a (patch)
tree9ed095096803fcd36348c890138cbf1fff996ec7
parent3fbf2c47ae847112044c529bb54655841e53014a (diff)
downloadchrome-ec-02b42b78b3ff7fd7c1670d660c1fa63e35d4ca3a.tar.gz
Nami: Add host command handler for keyboard backlight control
This patch adds host command handlers for EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT and CMD_PWM_GET_KEYBOARD_BACKLIGHT. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:74176833 BRANCH=none TEST=Verify ectool pwmsetkblight works. Verify kblight console command returns the value set by ectool and vice versa. Change-Id: I1929c6a3772ab22cb4b3c68638da23aa23727596 Reviewed-on: https://chromium-review.googlesource.com/1022961 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--board/nami/keyboard_backlight.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/board/nami/keyboard_backlight.c b/board/nami/keyboard_backlight.c
index 29f74a8131..a225f96569 100644
--- a/board/nami/keyboard_backlight.c
+++ b/board/nami/keyboard_backlight.c
@@ -8,6 +8,7 @@
#include "console.h"
#include "cros_board_info.h"
#include "hooks.h"
+#include "host_command.h"
#include "lid_switch.h"
#include "lm3509.h"
#include "pwm.h"
@@ -105,6 +106,32 @@ static void kblight_lid_change(void)
}
DECLARE_HOOK(HOOK_LID_CHANGE, kblight_lid_change, HOOK_PRIO_DEFAULT);
+static int hc_set_kblight(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_pwm_set_keyboard_backlight *p = args->params;
+ /* Assume already enabled */
+ if (!kblight_set)
+ return EC_RES_UNAVAILABLE;
+ kblight_set(p->percent);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT,
+ hc_set_kblight, EC_VER_MASK(0));
+
+static int hc_get_kblight(struct host_cmd_handler_args *args)
+{
+ struct ec_response_pwm_get_keyboard_backlight *r = args->response;
+ if (!kblight_get)
+ return EC_RES_UNAVAILABLE;
+ r->percent = kblight_get();
+ /* Assume always enabled */
+ r->enabled = 1;
+ args->response_size = sizeof(*r);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT,
+ hc_get_kblight, EC_VER_MASK(0));
+
static int cc_kblight(int argc, char **argv)
{
int i;