diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2022-05-18 11:27:16 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-19 16:00:04 +0000 |
commit | d58c9c80d1e9f3e3ded6c0d49cdc327ae0599f5c (patch) | |
tree | 7679c6e35a3fda2a107b841ff125730df16f0fc4 /common | |
parent | 4d3cdbe96356bb258d0cecf153027872878019fb (diff) | |
download | chrome-ec-d58c9c80d1e9f3e3ded6c0d49cdc327ae0599f5c.tar.gz |
RGBKBD: Add reset, enable, disable, scale console commands
This patch renames rgbk command to rgb and adds reset, enable, disable and
scale command to the command.
BUG=b:233099161
BRANCH=None
TEST=Vell
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I0f01f99199400489d418234449c9f9b38969647d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3654486
Reviewed-by: Parth Malkan <parthmalkan@google.com>
Commit-Queue: Parth Malkan <parthmalkan@google.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/keyboard_backlight.c | 5 | ||||
-rw-r--r-- | common/rgb_keyboard.c | 54 |
2 files changed, 54 insertions, 5 deletions
diff --git a/common/keyboard_backlight.c b/common/keyboard_backlight.c index b1b3671d3d..8cf400dc34 100644 --- a/common/keyboard_backlight.c +++ b/common/keyboard_backlight.c @@ -21,8 +21,9 @@ static struct kblight_conf kblight; static int current_percent; static uint8_t current_enable; -void __attribute__((weak)) board_kblight_init(void) -{ } +__overridable void board_kblight_init(void) {} + +__overridable void board_kblight_shutdown(void) {} static int kblight_init(void) { diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c index d909d3ad09..4f62271370 100644 --- a/common/rgb_keyboard.c +++ b/common/rgb_keyboard.c @@ -257,6 +257,24 @@ static int rgbkbd_set_global_brightness(uint8_t gcc) return rv; } +static int rgbkbd_set_scale(uint8_t scale) +{ + int e, i, rv = EC_SUCCESS; + + for (i = 0; i < rgbkbd_count; i++) { + struct rgbkbd *ctx = &rgbkbds[i]; + + e = ctx->cfg->drv->set_scale(ctx, 0, scale, get_grid_size(ctx)); + if (e) { + CPRINTS("Failed to set scale of GRID%d to %d (%d)", + i, scale, e); + rv = e; + } + } + + return rv; +} + static int rgbkbd_init(void) { int rv = EC_SUCCESS; @@ -338,6 +356,12 @@ static int rgbkbd_get_enabled(void) return rgbkbds[0].state >= RGBKBD_STATE_ENABLED; } +static void rgbkbd_reset(void) +{ + board_kblight_shutdown(); + board_kblight_init(); +} + const struct kblight_drv kblight_rgbkbd = { .init = rgbkbd_init, .set = rgbkbd_kblight_set, @@ -410,7 +434,7 @@ static enum ec_status hc_rgbkbd(struct host_cmd_handler_args *args) } DECLARE_HOST_COMMAND(EC_CMD_RGBKBD, hc_rgbkbd, EC_VER_MASK(0)); -test_export_static int cc_rgbk(int argc, char **argv) +test_export_static int cc_rgb(int argc, char **argv) { char *end, *comma; struct rgb_s color; @@ -445,6 +469,28 @@ test_export_static int cc_rgbk(int argc, char **argv) rgbkbd_reset_color((struct rgb_s){.r = 0, .g = 0, .b = 0}); ccprintf("Demo set to %d\n", demo); return EC_SUCCESS; + } else if (!strcasecmp(argv[1], "reset")) { + rgbkbd_reset(); + rv = rgbkbd_init(); + if (rv) + return rv; + return rgbkbd_enable(0); + } else if (!strcasecmp(argv[1], "enable")) { + return rgbkbd_enable(1); + } else if (!strcasecmp(argv[1], "disable")) { + return rgbkbd_enable(0); + } else if (!strcasecmp(argv[1], "scale")) { + /* Usage 6 */ + val = strtoi(argv[2], &end, 0); + if (*end || val > RGBKBD_MAX_SCALE) + return EC_ERROR_PARAM2; + return rgbkbd_set_scale(val); + } else if (!strcasecmp(argv[1], "red")) { + color.r = 255; + color.g = 0; + color.b = 0; + rgbkbd_reset_color(color); + return EC_SUCCESS; } else { /* Usage 1 */ if (argc != 2) @@ -497,12 +543,14 @@ test_export_static int cc_rgbk(int argc, char **argv) return rv; } #ifndef TEST_BUILD -DECLARE_CONSOLE_COMMAND(rgbk, cc_rgbk, +DECLARE_CONSOLE_COMMAND(rgb, cc_rgb, "\n" "1. rgbk <global-brightness>\n" "2. rgbk <col,row> <r-bright> <g-bright> <b-bright>\n" "3. rgbk all <r-bright> <g-bright> <b-bright>\n" - "4. rgbk demo <id>\n", + "4. rgbk demo <id>\n" + "5. rgbk reset/enable/disable/red\n" + "6. rgbk scale <val>\n", "Set color of RGB keyboard" ); #endif |