summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin K Wong <kevin.k.wong@intel.com>2015-11-18 23:59:42 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-11-21 23:59:51 +0000
commita52bfc1876ebfb46667bae4b7fc4a4af2b04678f (patch)
treef4c8a5dc30e9328734369d8f6fc9e28d722a8f4e
parente695782c029be7513a2ae41ac1887bd65a22eaac (diff)
downloadchrome-ec-a52bfc1876ebfb46667bae4b7fc4a4af2b04678f.tar.gz
UPSTREAM: ectool: provide lid angle info
Added new host command to support returning lid angle. New output from ectool: System with lid angle support: ------------------------------------------ localhost ~ # ectool motionsense lid_angle Lid angle: 72 System without lid angle support: ------------------------------------------ localhost ~ # ectool motionsense lid_angle EC result 3 (INVALID_PARAM) BUG=b:27849483 BRANCH=samus TEST=run "ectool motionsense lid_angle" verify the value matches the physical lid angle position Change-Id: I4179172c778f643640561e819216f7adfee679d2 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/313345 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit e24ac972e21d60a65d15e957605e8b78bd25e039) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/378321
-rw-r--r--common/motion_lid.c9
-rw-r--r--include/ec_commands.h21
-rw-r--r--include/motion_lid.h3
-rw-r--r--util/ectool.c21
4 files changed, 50 insertions, 4 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c
index f88d5d0915..405d48e621 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -233,6 +233,15 @@ int host_cmd_motion_lid(struct host_cmd_handler_args *args)
break;
+ case MOTIONSENSE_CMD_LID_ANGLE:
+#ifdef CONFIG_LID_ANGLE
+ out->lid_angle.value = motion_lid_get_angle();
+ args->response_size = sizeof(out->lid_angle);
+#else
+ return EC_RES_INVALID_PARAM;
+#endif
+ break;
+
default:
return EC_RES_INVALID_PARAM;
}
diff --git a/include/ec_commands.h b/include/ec_commands.h
index cfa9dd418d..98ef8b90c3 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1447,6 +1447,11 @@ enum motionsense_command {
*/
MOTIONSENSE_CMD_SET_ACTIVITY = 13,
+ /*
+ * Lid Angle
+ */
+ MOTIONSENSE_CMD_LID_ANGLE = 14,
+
/* Number of motionsense sub-commands. */
MOTIONSENSE_NUM_CMDS
};
@@ -1560,6 +1565,8 @@ struct ec_motion_sense_activity {
/* Set Calibration information */
#define MOTION_SENSE_SET_OFFSET 1
+#define LID_ANGLE_UNRELIABLE 500
+
struct ec_params_motion_sense {
uint8_t cmd;
union {
@@ -1647,6 +1654,10 @@ struct ec_params_motion_sense {
} fifo_read;
struct ec_motion_sense_activity set_activity;
+
+ /* Used for MOTIONSENSE_CMD_LID_ANGLE */
+ struct {
+ } lid_angle;
};
} __packed;
@@ -1710,6 +1721,16 @@ struct ec_response_motion_sense {
struct {
} set_activity;
+
+
+ /* Used for MOTIONSENSE_CMD_LID_ANGLE */
+ struct {
+ /*
+ * Angle between 0 and 360 degree if available,
+ * LID_ANGLE_UNRELIABLE otherwise.
+ */
+ uint16_t value;
+ } lid_angle;
};
} __packed;
diff --git a/include/motion_lid.h b/include/motion_lid.h
index c80f0c0d9a..155c7735c9 100644
--- a/include/motion_lid.h
+++ b/include/motion_lid.h
@@ -11,9 +11,6 @@
#include "host_command.h"
#include "math_util.h"
-/* Anything outside of lid angle range [-180, 180] should work. */
-#define LID_ANGLE_UNRELIABLE 500
-
/**
* This structure defines all of the data needed to specify the orientation
* of the base and lid accelerometers in order to calculate the lid angle.
diff --git a/util/ectool.c b/util/ectool.c
index a9125ddd91..8a24649ba4 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -2435,7 +2435,6 @@ static int cmd_lightbar(int argc, char **argv)
sizeof(((struct ec_response_motion_sense *)0)->fifo_info) \
+ sizeof(uint16_t) * ECTOOL_MAX_SENSOR}
-
static const struct {
uint8_t outsize;
uint8_t insize;
@@ -2454,6 +2453,7 @@ static const struct {
MS_SIZES(sensor_offset),
MS_SIZES(list_activities),
MS_SIZES(set_activity),
+ MS_SIZES(lid_angle),
};
BUILD_ASSERT(ARRAY_SIZE(ms_command_sizes) == MOTIONSENSE_NUM_CMDS);
#undef MS_SIZES
@@ -2479,6 +2479,7 @@ static int ms_help(const char *cmd)
cmd);
printf(" %s set_activity NUM ACT EN - enable/disable activity\n",
cmd);
+ printf(" %s lid_angle - print lid angle\n", cmd);
return 0;
}
@@ -2903,6 +2904,24 @@ static int cmd_motionsense(int argc, char **argv)
return rv;
return 0;
}
+
+ if (argc == 2 && !strcasecmp(argv[1], "lid_angle")) {
+ param.cmd = MOTIONSENSE_CMD_LID_ANGLE;
+ rv = ec_command(EC_CMD_MOTION_SENSE_CMD, 2,
+ &param, ms_command_sizes[param.cmd].outsize,
+ resp, ms_command_sizes[param.cmd].insize);
+ if (rv < 0)
+ return rv;
+
+ printf("Lid angle: ");
+ if (resp->lid_angle.value == LID_ANGLE_UNRELIABLE)
+ printf("unreliable\n");
+ else
+ printf("%d\n", resp->lid_angle.value);
+
+ return 0;
+ }
+
return ms_help(argv[0]);
}