summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Adolfsson <sadolfsson@google.com>2018-04-24 11:34:41 +0200
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-06-19 20:06:18 +0000
commit1384f5301a50c02bd1072ae28535b3ed49ee0825 (patch)
tree1ca4b4dc2bee2c412ce4c7898d8d6930d7345ebc
parentf136319edb37c8282d1ba5257ba90909b0d05120 (diff)
downloadchrome-ec-1384f5301a50c02bd1072ae28535b3ed49ee0825.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> (cherry picked from commit 8dab5788f3563821c703320835b47d6e33a8b72d) Change-Id: I5bc1efcaaf6ea4c7f92d3654d6e0fcc8717ab757 Reviewed-on: https://chromium-review.googlesource.com/1063874 Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Commit-Queue: Stefan Adolfsson <sadolfsson@chromium.org>
-rw-r--r--util/ectool.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index b0dc08f996..9874993fee 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -73,6 +73,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"
@@ -7273,6 +7275,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},
@@ -7288,6 +7320,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},