diff options
author | Parth Malkan <parthmalkan@google.com> | 2022-06-28 12:53:07 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-25 18:38:47 +0000 |
commit | 047f56016cd2511810172f9eea03241e6997b0c0 (patch) | |
tree | d8e0bbd727e676e1b68a391652b61ee701bedfb2 | |
parent | 030fcacad7a67a25777fffb4d267c4a3fb50b4c5 (diff) | |
download | chrome-ec-047f56016cd2511810172f9eea03241e6997b0c0.tar.gz |
rgbkbd: Add get_config subcommand to rgbkbd host command
Add a response struct to rgbkbd host command and add GET_CONFIG as a
subcommand. This is used to return RGB keyboard type (number of zones
and LEDs) to the host.
BRANCH=none
BUG=b:232134905
TEST=Test on Taniks and Vell using ectool rgbkbd getconfig command
Cq-Depend: chromium:3784557, chromium:3784558
Cq-Depend: chromium:3784560
Change-Id: Ie5b18ed3be141f2a91326ff2a121649296ea1161
Signed-off-by: Parth Malkan <parthmalkan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3732802
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
(cherry picked from commit 0fedae4fe40f63ceca8467a8b3603a32d2cae7ef)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3784556
Reviewed-by: YH Lin <yueherngl@chromium.org>
-rw-r--r-- | common/rgb_keyboard.c | 8 | ||||
-rw-r--r-- | include/ec_commands.h | 18 | ||||
-rw-r--r-- | include/rgb_keyboard.h | 6 | ||||
-rw-r--r-- | test/rgb_keyboard.c | 2 |
4 files changed, 34 insertions, 0 deletions
diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c index 815e4a3435..fab8f9bb83 100644 --- a/common/rgb_keyboard.c +++ b/common/rgb_keyboard.c @@ -532,8 +532,12 @@ DECLARE_HOST_COMMAND(EC_CMD_RGBKBD_SET_COLOR, hc_rgbkbd_set_color, static enum ec_status hc_rgbkbd(struct host_cmd_handler_args *args) { const struct ec_params_rgbkbd *p = args->params; + struct ec_response_rgbkbd *r = args->response; enum ec_status rv = EC_RES_SUCCESS; + /* Default value is 0 */ + args->response_size = 0; + if (rgbkbd_late_init()) return EC_RES_ERROR; @@ -550,6 +554,10 @@ static enum ec_status hc_rgbkbd(struct host_cmd_handler_args *args) if (rgbkbd_set_scale(p->set_scale.scale, p->set_scale.key)) rv = EC_RES_ERROR; break; + case EC_RGBKBD_SUBCMD_GET_CONFIG: + args->response_size = sizeof(*r); + r->rgbkbd_type = rgbkbd_type; + break; default: rv = EC_RES_INVALID_PARAM; break; diff --git a/include/ec_commands.h b/include/ec_commands.h index d86063ba27..ade6eff070 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -7159,6 +7159,7 @@ enum ec_rgbkbd_subcmd { EC_RGBKBD_SUBCMD_CLEAR = 1, EC_RGBKBD_SUBCMD_DEMO = 2, EC_RGBKBD_SUBCMD_SET_SCALE = 3, + EC_RGBKBD_SUBCMD_GET_CONFIG = 4, EC_RGBKBD_SUBCMD_COUNT }; @@ -7171,6 +7172,15 @@ enum ec_rgbkbd_demo { BUILD_ASSERT(EC_RGBKBD_DEMO_COUNT <= 255); +enum ec_rgbkbd_type { + EC_RGBKBD_TYPE_UNKNOWN = 0, + EC_RGBKBD_TYPE_PER_KEY = 1, /* e.g. Vell */ + EC_RGBKBD_TYPE_FOUR_ZONES_40_LEDS = 2, /* e.g. Taniks */ + EC_RGBKBD_TYPE_FOUR_ZONES_12_LEDS = 3, /* e.g. Osiris */ + EC_RGBKBD_TYPE_FOUR_ZONES_15_LEDS = 4, /* e.g. Mithrax */ + EC_RGBKBD_TYPE_COUNT, +}; + struct ec_rgbkbd_set_scale { uint8_t key; struct rgb_s scale; @@ -7185,6 +7195,14 @@ struct ec_params_rgbkbd { }; } __ec_align1; +struct ec_response_rgbkbd { + /* + * RGBKBD type supported by the device. + */ + + uint8_t rgbkbd_type; /* enum ec_rgbkbd_type */ +} __ec_align1; + struct ec_params_rgbkbd_set_color { /* Specifies the starting key ID whose color is being changed. */ uint8_t start_key; diff --git a/include/rgb_keyboard.h b/include/rgb_keyboard.h index e795389225..4f948542d9 100644 --- a/include/rgb_keyboard.h +++ b/include/rgb_keyboard.h @@ -154,6 +154,12 @@ extern const uint8_t rgbkbd_hsize; extern const uint8_t rgbkbd_vsize; /* + * rgbkbd_type describes the rgb kb type supported. + * i.e. Number of zones and number of LEDs + */ +extern const enum ec_rgbkbd_type rgbkbd_type; + +/* * rgbkbd_map describes a mapping from key IDs to LED IDs. * * Multiple keys can be mapped to one LED and one key can be mapped to multiple diff --git a/test/rgb_keyboard.c b/test/rgb_keyboard.c index a8da437f7c..804f7f12e9 100644 --- a/test/rgb_keyboard.c +++ b/test/rgb_keyboard.c @@ -51,6 +51,8 @@ const uint8_t rgbkbd_count = ARRAY_SIZE(rgbkbds); const uint8_t rgbkbd_hsize = RGB_GRID0_COL + RGB_GRID1_COL; const uint8_t rgbkbd_vsize = RGB_GRID0_ROW; +const enum ec_rgbkbd_type rgbkbd_type = EC_RGBKBD_TYPE_UNKNOWN; + const uint8_t rgbkbd_map[] = { RGBKBD_DELM, RGBKBD_COORD(1, 2), RGBKBD_DELM, |