summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei-Ning Huang <wnhuang@google.com>2017-05-16 13:04:31 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-06-07 05:22:56 -0700
commit5b1d2b878da4e76870642a2fa2caef9d18fc8355 (patch)
treeca385b95bfd7ac92e9796a10d12cd4d03b1a9e5c
parent859a33ff46c78bd47075c9fd57b88b88df593634 (diff)
downloadchrome-ec-5b1d2b878da4e76870642a2fa2caef9d18fc8355.tar.gz
rose: add touchpad related host commands
Add touchpad related host commands: 1) EC_CMD_TP_SELF_TEST: run open short test. 2) EC_CMD_TP_FRAME_INFO: get number of frame and frame size. 3) EC_CMD_TP_FRAME_SNAPSHOT: make a snapshot of the frame. 4) EC_CMD_TP_FRAME_GET: get frame data. BRANCH=none BUG=b:62077098 TEST=`make BOARD=rose -j` `ectool --name=cros_tp tpselftest` and `ectool --name=cros_tp tpframeget` works Change-Id: I43db82278e556b1e6f6301fe88233fe7c4a18a14 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/515282 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r--include/ec_commands.h26
-rw-r--r--util/ectool.c77
2 files changed, 103 insertions, 0 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 67e2f0926d..a2ee8bd15b 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4268,6 +4268,32 @@ struct __ec_align4 ec_params_fp_frame {
};
/*****************************************************************************/
+/* Touchpad MCU commands: range 0x0500-0x05FF */
+
+/* Perform touchpad self test */
+#define EC_CMD_TP_SELF_TEST 0x0500
+
+/* Get number of frame types, and the size of each type */
+#define EC_CMD_TP_FRAME_INFO 0x0501
+
+struct __ec_align4 ec_response_tp_frame_info {
+ uint32_t n_frames;
+ uint32_t frame_sizes[0];
+};
+
+/* Create a snapshot of current frame readings */
+#define EC_CMD_TP_FRAME_SNAPSHOT 0x0502
+
+/* Read the frame */
+#define EC_CMD_TP_FRAME_GET 0x0503
+
+struct __ec_align4 ec_params_tp_frame_get {
+ uint32_t frame_index;
+ uint32_t offset;
+ uint32_t size;
+};
+
+/*****************************************************************************/
/*
* Reserve a range of host commands for board-specific, experimental, or
* special purpose features. These can be (re)used without updating this file.
diff --git a/util/ectool.c b/util/ectool.c
index 039ddcb9d9..c17a4d71e0 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -230,6 +230,10 @@ const char help_str[] =
" Get the threshold temperature values from the thermal engine.\n"
" thermalset <platform-specific args>\n"
" Set the threshold temperature values for the thermal engine.\n"
+ " tpselftest\n"
+ " Run touchpad self test.\n"
+ " tpframeget\n"
+ " Get touchpad frame data.\n"
" tmp006cal <tmp006_index> [params...]\n"
" Get/set TMP006 calibration\n"
" tmp006raw <tmp006_index>\n"
@@ -7138,6 +7142,77 @@ int cmd_pd_write_log(int argc, char *argv[])
return ec_command(EC_CMD_PD_WRITE_LOG_ENTRY, 0, &p, sizeof(p), NULL, 0);
}
+int cmd_tp_self_test(int argc, char* argv[])
+{
+ int rv;
+
+ rv = ec_command(EC_CMD_TP_SELF_TEST, 0, NULL, 0, NULL, 0);
+ if (rv < 0)
+ return rv;
+
+ printf("Touchpad self test: %s\n",
+ rv == EC_RES_SUCCESS ? "passed" : "failed");
+
+ return rv;
+}
+
+int cmd_tp_frame_get(int argc, char* argv[])
+{
+ int i, j;
+ uint32_t remaining = 0, offset = 0;
+ int rv = EC_SUCCESS;
+ uint8_t *data;
+ struct ec_response_tp_frame_info* r;
+ struct ec_params_tp_frame_get p;
+
+ data = malloc(ec_max_insize);
+ r = malloc(ec_max_insize);
+
+ rv = ec_command(EC_CMD_TP_FRAME_INFO, 0, NULL, 0, r, ec_max_insize);
+ if (rv < 0) {
+ fprintf(stderr, "Failed to get toucpad frame info.\n");
+ goto err;
+ }
+
+ rv = ec_command(EC_CMD_TP_FRAME_SNAPSHOT, 0, NULL, 0, NULL, 0);
+ if (rv < 0) {
+ fprintf(stderr, "Failed to snapshot frame.\n");
+ goto err;
+ }
+
+ for (i = 0; i < r->n_frames; i++) {
+ p.frame_index = i;
+ offset = 0;
+ remaining = r->frame_sizes[i];
+
+ while (remaining > 0) {
+ p.offset = offset;
+ p.size = MIN(remaining, ec_max_insize);
+
+ rv = ec_command(EC_CMD_TP_FRAME_GET, 0,
+ &p, sizeof(p), data, p.size);
+ if (rv < 0) {
+ fprintf(stderr, "Failed to get frame data "
+ "at offset 0x%x\n", offset);
+ goto err;
+ }
+
+ for (j = 0; j < p.size; j++)
+ printf("%02x ", data[j]);
+
+ offset += p.size;
+ remaining -= p.size;
+ }
+ printf("\n");
+ }
+
+err:
+ free(data);
+ free(r);
+
+ return rv;
+}
+
/* NULL-terminated list of commands */
const struct command commands[] = {
{"autofanctrl", cmd_thermal_auto_fan_ctrl},
@@ -7235,6 +7310,8 @@ const struct command commands[] = {
{"test", cmd_test},
{"thermalget", cmd_thermal_get_threshold},
{"thermalset", cmd_thermal_set_threshold},
+ {"tpselftest", cmd_tp_self_test},
+ {"tpframeget", cmd_tp_frame_get},
{"tmp006cal", cmd_tmp006cal},
{"tmp006raw", cmd_tmp006raw},
{"usbchargemode", cmd_usb_charge_set_mode},