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>2017-05-01 21:20:08 +0000
commit7d87ea86843f06a27b5567d1a7fb7813d9a33033 (patch)
tree378932e3984bcad480d2c081a0813a7bb23b1cae
parent9a0e233d9ce07497c8d8fe4b32cf981c36e2f491 (diff)
downloadchrome-ec-7d87ea86843f06a27b5567d1a7fb7813d9a33033.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, b:36973851 BRANCH=cyan, ultima TEST=run "ectool motionsense lid_angle" verify the value matches the physical lid angle position 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/359409 Reviewed-on: https://chromium-review.googlesource.com/409496 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 844298f4291a7cfc3aa91ba49c40de82f11419ca) Change-Id: I4179172c778f643640561e819216f7adfee679d2 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/489769
-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 a563b1019b..df876563fe 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 1d8b883edc..cbfda0d5bf 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1718,6 +1718,11 @@ enum motionsense_command {
*/
MOTIONSENSE_CMD_SET_ACTIVITY = 13,
+ /*
+ * Lid Angle
+ */
+ MOTIONSENSE_CMD_LID_ANGLE = 14,
+
/* Number of motionsense sub-commands. */
MOTIONSENSE_NUM_CMDS
};
@@ -1832,6 +1837,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 {
@@ -1919,6 +1926,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;
@@ -1982,6 +1993,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 b005688bb7..21803e6260 100644
--- a/include/motion_lid.h
+++ b/include/motion_lid.h
@@ -10,9 +10,6 @@
#include "host_command.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 3325f95c1b..51438d6643 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -3217,7 +3217,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;
@@ -3236,6 +3235,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
@@ -3261,6 +3261,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;
}
@@ -3685,6 +3686,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]);
}