summaryrefslogtreecommitdiff
path: root/common/motion_lid.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-10-21 16:35:12 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-11-08 17:11:28 -0800
commit9b67ffcd527c6244a9f1946072f40e8e9fd9b940 (patch)
tree34b363bfdbe8a74123724b7cf6cd44a417e91376 /common/motion_lid.c
parent8bb2d9fbf0d0a8d6810a9f08dd0437cfa3745db2 (diff)
downloadchrome-ec-9b67ffcd527c6244a9f1946072f40e8e9fd9b940.tar.gz
common: Add tablet_mode API
Simple API to set/get the tablet mode. It can be set via lid angle calculation or if a board has a dedicated HAL sensor/GPIO. Merged from glados branch, add MKBP switch support. BUG=chromium:606718 BRANCH=gru TEST=Check with Cave that both mode works. Reviewed-on: https://chromium-review.googlesource.com/402089 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit c940f36ceabcf2425284001298f03ebdb4c3079e) Change-Id: I2ee5130f3e0a1307ec3ea543f7a32d66bc32b31d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404915 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/motion_lid.c')
-rw-r--r--common/motion_lid.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c
index 3f68480484..3209492a65 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -17,6 +17,7 @@
#include "motion_lid.h"
#include "motion_sense.h"
#include "power.h"
+#include "tablet_mode.h"
#include "timer.h"
#include "task.h"
#include "util.h"
@@ -57,7 +58,6 @@
#define TABLET_ZONE_LID_ANGLE FLOAT_TO_FP(300)
#define LAPTOP_ZONE_LID_ANGLE FLOAT_TO_FP(240)
-static int tablet_mode = 1;
#endif
#ifdef CONFIG_LID_ANGLE_INVALID_CHECK
@@ -148,7 +148,7 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
fp_t denominator;
int reliable = 1;
#ifdef CONFIG_LID_ANGLE_TABLET_MODE
- int new_tablet_mode = tablet_mode;
+ int new_tablet_mode = tablet_get_mode();
#endif
/*
@@ -234,8 +234,8 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
new_tablet_mode = 1;
else if (last_lid_angle_fp < LAPTOP_ZONE_LID_ANGLE)
new_tablet_mode = 0;
- if (tablet_mode != new_tablet_mode) {
- tablet_mode = new_tablet_mode;
+ if (tablet_get_mode() != new_tablet_mode) {
+ tablet_set_mode(new_tablet_mode);
hook_notify(HOOK_TABLET_MODE_CHANGE);
}
#endif /* CONFIG_LID_ANGLE_TABLET_MODE */
@@ -283,13 +283,6 @@ void motion_lid_calc(void)
#endif
}
-#ifdef CONFIG_LID_ANGLE_TABLET_MODE
-int motion_lid_in_tablet_mode(void)
-{
- return tablet_mode;
-}
-#endif
-
/*****************************************************************************/
/* Host commands */