diff options
author | paris_yeh <pyeh@google.com> | 2018-06-01 16:15:24 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-20 14:23:49 -0700 |
commit | 5d825c5c9b9b805b2677b13a891a7edce0802e69 (patch) | |
tree | b2d65413008ec901575e8c291ae338600cf2f87d /util | |
parent | 7fdaa393dfd0b4da381f62ee50e4b1c056d6eda4 (diff) | |
download | chrome-ec-5d825c5c9b9b805b2677b13a891a7edce0802e69.tar.gz |
ec/google: Add command to fetch keyboard ID from EC
Sort k-prefix host commands and descriptions in alphabetical order
BRANCH=master
BUG=b:80168723
TEST=Check 'ectool kbid' on a reworked DUT using keyboard samples
Change-Id: If2ad654e5ef269d03365db7c3286c2281aa9d9ef
Signed-off-by: paris_yeh <pyeh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1097997
Commit-Ready: Paris Yeh <pyeh@chromium.org>
Tested-by: Paris Yeh <pyeh@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Paris Yeh <pyeh@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/util/ectool.c b/util/ectool.c index 3b62effd69..9a266f1366 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -144,10 +144,6 @@ const char help_str[] = " Set the delay before going into hibernation\n" " hostsleepstate\n" " Report host sleep state to the EC\n" - " kbpress\n" - " Simulate key press\n" - " kbfactorytest\n" - " Scan out keyboard if any pins are shorted\n" " i2cprotect <port> [status]\n" " Protect EC's I2C bus\n" " i2cread\n" @@ -160,8 +156,14 @@ const char help_str[] = " Get info about USB type-C accessory attached to port\n" " inventory\n" " Return the list of supported features\n" + " kbfactorytest\n" + " Scan out keyboard if any pins are shorted\n" + " kbid\n" + " Get keyboard ID of supported keyboards\n" " kbinfo\n" " Dump keyboard matrix dimensions\n" + " kbpress\n" + " Simulate key press\n" " keyscan <beat_us> <filename>\n" " Test low-level key scanning\n" " led <name> <query | auto | off | <color> | <color>=<value>...>\n" @@ -6982,6 +6984,37 @@ static int cmd_kbinfo(int argc, char *argv[]) return 0; } +static int cmd_kbid(int argc, char *argv[]) +{ + struct ec_response_keyboard_id response; + int rv; + + if (argc > 1) { + fprintf(stderr, "Too many args\n"); + return -1; + } + + rv = ec_command(EC_CMD_GET_KEYBOARD_ID, 0, NULL, 0, &response, + sizeof(response)); + if (rv < 0) + return rv; + switch (response.keyboard_id) { + case KEYBOARD_ID_UNSUPPORTED: + /* Keyboard ID was not supported */ + printf("Keyboard doesn't support ID\n"); + break; + case KEYBOARD_ID_UNREADABLE: + /* Ghosting ID was detected */ + printf("Reboot and keep hands off the keyboard during" + " next boot-up\n"); + break; + default: + /* Valid keyboard ID value was reported*/ + printf("%x\n", response.keyboard_id); + } + return rv; +} + static int cmd_keyconfig(int argc, char *argv[]) { struct ec_params_mkbp_set_config req; @@ -8013,7 +8046,6 @@ const struct command commands[] = { {"hello", cmd_hello}, {"hibdelay", cmd_hibdelay}, {"hostsleepstate", cmd_hostsleepstate}, - {"kbpress", cmd_kbpress}, {"i2cprotect", cmd_i2c_protect}, {"i2cread", cmd_i2c_read}, {"i2cwrite", cmd_i2c_write}, @@ -8022,10 +8054,12 @@ const struct command commands[] = { {"inventory", cmd_inventory}, {"led", cmd_led}, {"lightbar", cmd_lightbar}, - {"keyconfig", cmd_keyconfig}, + {"kbfactorytest", cmd_keyboard_factory_test}, + {"kbid", cmd_kbid}, {"kbinfo", cmd_kbinfo}, + {"kbpress", cmd_kbpress}, + {"keyconfig", cmd_keyconfig}, {"keyscan", cmd_keyscan}, - {"kbfactorytest", cmd_keyboard_factory_test}, {"motionsense", cmd_motionsense}, {"nextevent", cmd_next_event}, {"panicinfo", cmd_panic_info}, |