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>
This commit is contained in:
Wei-Ning Huang
2017-05-16 13:04:31 +08:00
committed by chrome-bot
parent 859a33ff46
commit 5b1d2b878d
2 changed files with 103 additions and 0 deletions

View File

@@ -4267,6 +4267,32 @@ struct __ec_align4 ec_params_fp_frame {
uint32_t size;
};
/*****************************************************************************/
/* 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

View File

@@ -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},