diff options
author | Stefan Adolfsson <sadolfsson@google.com> | 2018-04-24 11:34:41 +0200 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-06-19 19:58:36 +0000 |
commit | 52d50d30d9711921d9f7162882b23c6422e2b238 (patch) | |
tree | b2792a86182a52f1a03da34ce2c6c48ecae253a9 | |
parent | 3d22bbe9cd9efe6063bc17de416d888887a27bf9 (diff) | |
download | chrome-ec-52d50d30d9711921d9f7162882b23c6422e2b238.tar.gz |
CEC: Add cecwrite command to ectool
cecwrite can be used to write a sequence of bytes on the CEC bus.
Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org>
BUG=b:76467407
BRANCH=none
TEST=Using EC firmware with CEC support, turn on/off TV:
ectool cecwrite 0x40 0x04
ectool cecwrite 0x40 0x36
CQ-DEPEND=CL:1030214
Reviewed-on: https://chromium-review.googlesource.com/1030215
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I5bc1efcaaf6ea4c7f92d3654d6e0fcc8717ab757
Reviewed-on: https://chromium-review.googlesource.com/1055689
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Commit-Queue: Stefan Adolfsson <sadolfsson@chromium.org>
-rw-r--r-- | util/ectool.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 46852662bd..19250ce008 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -75,6 +75,8 @@ const char help_str[] = " Prints supported version mask for a command number\n" " console\n" " Prints the last output to the EC debug console\n" + " cecwrite [write bytes...]\n" + " Write data on the CEC bus\n" " echash [CMDS]\n" " Various EC hash commands\n" " eventclear <mask>\n" @@ -7675,6 +7677,36 @@ int cmd_wait_event(int argc, char *argv[]) return 0; } +int cmd_cec_write(int argc, char *argv[]) +{ + char *e; + long val; + int i, msg_len; + struct ec_params_cec_write p; + + if (argc < 2 || argc > 17) { + fprintf(stderr, "%s <MSG[0]> [MSG[1] ... MSG[15]]>\n", argv[0]); + return -1; + } + + msg_len = argc - 1; + for (i = 0; i < msg_len; i++) { + val = strtol(argv[i + 1], &e, 16); + if (e && *e) + return -1; + if (val < 0 || val > 0xff) + return -1; + p.msg[i] = (uint8_t)val; + } + + printf("Write to CEC: "); + for (i = 0; i < msg_len; i++) + printf("0x%02x ", p.msg[i]); + printf("\n"); + + return ec_command(EC_CMD_CEC_WRITE_MSG, 0, &p, msg_len, NULL, 0); +} + /* NULL-terminated list of commands */ const struct command commands[] = { {"autofanctrl", cmd_thermal_auto_fan_ctrl}, @@ -7691,6 +7723,7 @@ const struct command commands[] = { {"chipinfo", cmd_chipinfo}, {"cmdversions", cmd_cmdversions}, {"console", cmd_console}, + {"cecwrite", cmd_cec_write}, {"echash", cmd_ec_hash}, {"eventclear", cmd_host_event_clear}, {"eventclearb", cmd_host_event_clear_b}, |