Files
OpenCellular/include/motion_sense.h
Alec Berg 242f195771 rambi: glimmer: Disable key scanning in suspend when lid is open
Added ability to disable the keyboard to wake from suspend when the lid
is outside a certain angle range. This has been added to glimmer by
defining CONFIG_LID_ANGLE_KEY_SCAN in its board.h.

Also modified the lid angle calculation to include a reliability
flag which can be used to tell when the hinge aligns too closely
with gravity and the lid angle value is unreliable.

BUG=none
BRANCH=rambi
TEST=Tested on a glimmer:

In S3, verified that when the lid is open past ~180 deg, the keyboard
does not wake the machine. Also verified that if you align hinge with
gravity, the keyboard enabled/disabled status remains the same (since
we can't actually trust the lid angle value).

Change-Id: I45b2c7c3c4bbcae61d3a0f8b5baa461ab8dabfb0
Original-Change-Id: If1a1592d259902d38941936961854b81b3a75b95
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/190061
Reviewed-on: https://chromium-review.googlesource.com/191612
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-03-27 18:44:14 +00:00

96 lines
2.2 KiB
C

/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Header for motion_sense.c */
#ifndef __CROS_EC_MOTION_SENSE_H
#define __CROS_EC_MOTION_SENSE_H
#include "gpio.h"
#include "math_util.h"
/* Anything outside of lid angle range [-180, 180] should work. */
#define LID_ANGLE_UNRELIABLE 500.0F
/**
* 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.
*/
struct accel_orientation {
/*
* Rotation matrix to rotate the lid sensor into the same reference
* frame as the base sensor.
*/
matrix_3x3_t rot_align;
/* Rotation matrix to rotate positive 90 degrees around the hinge. */
matrix_3x3_t rot_hinge_90;
/*
* Rotation matrix to rotate 180 degrees around the hinge. The value
* here should be rot_hinge_90 ^ 2.
*/
matrix_3x3_t rot_hinge_180;
/*
* Rotation matrix to rotate base sensor into the standard reference
* frame.
*/
matrix_3x3_t rot_standard_ref;
/* Vector pointing along hinge axis. */
vector_3_t hinge_axis;
};
/* Link global structure for orientation. This must be defined in board.c. */
extern
#ifndef CONFIG_ACCEL_CALIBRATE
const
#endif
struct accel_orientation acc_orient;
/**
* Get last calculated lid angle.
*
* @return lid angle in degrees in range [-180, 180].
*/
int motion_get_lid_angle(void);
#ifdef CONFIG_ACCEL_CALIBRATE
/**
* Get the last measured lid acceleration vector.
*
* @param v Pointer to location to store vector.
* @param adjusted If false use the raw vector, if true use the adjusted vector.
*/
void motion_get_accel_lid(vector_3_t *v, int adjusted);
/**
* Get the last measured base acceleration vector.
*
* @param v Pointer to location to store vector.
*/
void motion_get_accel_base(vector_3_t *v);
#endif
/**
* Interrupt function for lid accelerometer.
*
* @param signal GPIO signal that caused interrupt
*/
void accel_int_lid(enum gpio_signal signal);
/**
* Interrupt function for base accelerometer.
*
* @param signal GPIO signal that caused interrupt
*/
void accel_int_base(enum gpio_signal signal);
#endif /* __CROS_EC_MOTION_SENSE_H */