[sensors] Minor tuning of hal definition
* Swap GEOMAGNETIC_FIELD with MAGNETIC_FIELD for more accurate
definition.
* Clarify that string type will be omitted for well defined sensor
types.
* Remove legacy 8-bit restriction to sensor handle. This is an
unnecessary limit for since long time ago. Still leave the define
for code compatibility and change the value to 32.
* update sensors-base.h with companion .hal file change.
Test: test with sensorlogger, all sensor works
Change-Id: I6ff7022146eb25f7efdce87b70bf5ed488a70c6d
This commit is contained in:
@@ -16,7 +16,7 @@ enum {
|
||||
enum {
|
||||
SENSOR_TYPE_META_DATA = 0,
|
||||
SENSOR_TYPE_ACCELEROMETER = 1,
|
||||
SENSOR_TYPE_GEOMAGNETIC_FIELD = 2,
|
||||
SENSOR_TYPE_MAGNETIC_FIELD = 2,
|
||||
SENSOR_TYPE_ORIENTATION = 3,
|
||||
SENSOR_TYPE_GYROSCOPE = 4,
|
||||
SENSOR_TYPE_LIGHT = 5,
|
||||
@@ -59,7 +59,7 @@ enum {
|
||||
SENSOR_FLAG_ON_CHANGE_MODE = 2ull, // 2
|
||||
SENSOR_FLAG_ONE_SHOT_MODE = 4ull, // 4
|
||||
SENSOR_FLAG_SPECIAL_REPORTING_MODE = 6ull, // 6
|
||||
SENSOR_FLAG_SUPPORTS_DATA_INJECTION = 16ull, // 0x10
|
||||
SENSOR_FLAG_DATA_INJECTION = 16ull, // 0x10
|
||||
SENSOR_FLAG_DYNAMIC_SENSOR = 32ull, // 0x20
|
||||
SENSOR_FLAG_ADDITIONAL_INFO = 64ull, // 0x40
|
||||
SENSOR_FLAG_DIRECT_CHANNEL_ASHMEM = 1024ull, // 0x400
|
||||
@@ -69,6 +69,15 @@ enum {
|
||||
SENSOR_FLAG_MASK_DIRECT_CHANNEL = 3072ull, // 0xC00
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SENSOR_FLAG_SHIFT_REPORTING_MODE = 1,
|
||||
SENSOR_FLAG_SHIFT_DATA_INJECTION = 4,
|
||||
SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR = 5,
|
||||
SENSOR_FLAG_SHIFT_ADDITIONAL_INFO = 6,
|
||||
SENSOR_FLAG_SHIFT_DIRECT_REPORT = 7,
|
||||
SENSOR_FLAG_SHIFT_DIRECT_CHANNEL = 10,
|
||||
} sensor_flag_shift_t;
|
||||
|
||||
enum {
|
||||
SENSOR_STATUS_NO_CONTACT = -1, // (-1)
|
||||
SENSOR_STATUS_UNRELIABLE = 0,
|
||||
|
||||
@@ -59,11 +59,10 @@ __BEGIN_DECLS
|
||||
* Handles must be higher than SENSORS_HANDLE_BASE and must be unique.
|
||||
* A Handle identifies a given sensors. The handle is used to activate
|
||||
* and/or deactivate sensors.
|
||||
* In this version of the API there can only be 256 handles.
|
||||
*/
|
||||
#define SENSORS_HANDLE_BASE 0
|
||||
#define SENSORS_HANDLE_BITS 8
|
||||
#define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS)
|
||||
#define SENSORS_HANDLE_BITS 32
|
||||
#define SENSORS_HANDLE_COUNT (1ull<<SENSORS_HANDLE_BITS)
|
||||
|
||||
|
||||
/*
|
||||
@@ -96,8 +95,10 @@ enum {
|
||||
#define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS"
|
||||
|
||||
/*
|
||||
* Availability: SENSORS_DEVICE_API_VERSION_1_4
|
||||
* Sensor HAL modes used in set_operation_mode method
|
||||
* sensor flags legacy names
|
||||
*
|
||||
* please use SENSOR_FLAG_* directly for new implementation.
|
||||
* @see sensor_t
|
||||
*/
|
||||
|
||||
#define SENSOR_FLAG_MASK(nbit, shift) (((1<<(nbit))-1)<<(shift))
|
||||
@@ -106,43 +107,48 @@ enum {
|
||||
/*
|
||||
* Mask and shift for reporting mode sensor flags defined above.
|
||||
*/
|
||||
#define REPORTING_MODE_SHIFT (1)
|
||||
#define REPORTING_MODE_SHIFT SENSOR_FLAG_SHIFT_REPORTING_MODE
|
||||
#define REPORTING_MODE_NBIT (3)
|
||||
#define REPORTING_MODE_MASK SENSOR_FLAG_MASK(REPORTING_MODE_NBIT, REPORTING_MODE_SHIFT)
|
||||
// 0xE
|
||||
#define REPORTING_MODE_MASK SENSOR_FLAG_MASK_REPORTING_MODE
|
||||
|
||||
/*
|
||||
* Mask and shift for data_injection mode sensor flags defined above.
|
||||
*/
|
||||
#define DATA_INJECTION_SHIFT (4)
|
||||
#define DATA_INJECTION_MASK SENSOR_FLAG_MASK_1(DATA_INJECTION_SHIFT) //0x10
|
||||
#define DATA_INJECTION_SHIFT SENSOR_FLAG_SHIFT_DATA_INJECTION
|
||||
#define DATA_INJECTION_MASK SENSOR_FLAG_DATA_INJECTION
|
||||
|
||||
/*
|
||||
* Mask and shift for dynamic sensor flag.
|
||||
*/
|
||||
#define DYNAMIC_SENSOR_SHIFT (5)
|
||||
#define DYNAMIC_SENSOR_MASK SENSOR_FLAG_MASK_1(DYNAMIC_SENSOR_SHIFT) //0x20
|
||||
#define DYNAMIC_SENSOR_SHIFT SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR
|
||||
#define DYNAMIC_SENSOR_MASK SENSOR_FLAG_DYNAMIC_SENSOR
|
||||
|
||||
/*
|
||||
* Mask and shift for sensor additional information support.
|
||||
*/
|
||||
#define ADDITIONAL_INFO_SHIFT (6)
|
||||
#define ADDITIONAL_INFO_MASK SENSOR_FLAG_MASK_1(ADDITIONAL_INFO_SHIFT) //0x40
|
||||
#define ADDITIONAL_INFO_SHIFT SENSOR_FLAG_SHIFT_ADDITIONAL_INFO
|
||||
#define ADDITIONAL_INFO_MASK SENSOR_FLAG_ADDITIONAL_INFO
|
||||
|
||||
/*
|
||||
* Shift for sensor direct report support bits (3 bits denoting maximum rate level)
|
||||
* @see enums SENSOR_DIRECT_RATE_* for definition of direct report rate level.
|
||||
* @see SENSOR_FLAG_MASK_DIRECT_REPORT for mask
|
||||
* Legacy alias of SENSOR_TYPE_MAGNETIC_FIELD.
|
||||
*
|
||||
* Previously, the type of a sensor measuring local magnetic field is named
|
||||
* SENSOR_TYPE_GEOMAGNETIC_FIELD and SENSOR_TYPE_MAGNETIC_FIELD is its alias.
|
||||
* SENSOR_TYPE_MAGNETIC_FIELD is redefined as primary name to avoid confusion.
|
||||
* SENSOR_TYPE_GEOMAGNETIC_FIELD is the alias and is deprecating. New implementation must not use
|
||||
* SENSOR_TYPE_GEOMAGNETIC_FIELD.
|
||||
*/
|
||||
#define SENSOR_FLAG_SHIFT_DIRECT_REPORT (7)
|
||||
/*
|
||||
* Shift for sensor direct channel support bit (2 bits representing direct channel supported)
|
||||
* @see SENSOR_FLAG_DIRECT_CHANNEL_* for details.
|
||||
*/
|
||||
#define SENSOR_FLAG_SHIFT_DIRECT_CHANNEL (10)
|
||||
#define SENSOR_TYPE_GEOMAGNETIC_FIELD SENSOR_TYPE_MAGNETIC_FIELD
|
||||
|
||||
/*
|
||||
* Sensor string types for Android defined sensor types.
|
||||
*
|
||||
* For Android defined sensor types, string type will be override in sensor service and thus no
|
||||
* longer needed to be added to sensor_t data structure.
|
||||
*
|
||||
* These definitions are going to be removed soon.
|
||||
*/
|
||||
#define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer"
|
||||
#define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD
|
||||
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field"
|
||||
#define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation"
|
||||
#define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope"
|
||||
@@ -464,13 +470,14 @@ struct sensor_t {
|
||||
*/
|
||||
uint32_t fifoMaxEventCount;
|
||||
|
||||
/* type of this sensor as a string. Set to corresponding
|
||||
* SENSOR_STRING_TYPE_*.
|
||||
* When defining an OEM specific sensor or sensor manufacturer specific
|
||||
* sensor, use your reserve domain name as a prefix.
|
||||
* ex: com.google.glass.onheaddetector
|
||||
* For sensors of known type, the android framework might overwrite this
|
||||
* string automatically.
|
||||
/* type of this sensor as a string.
|
||||
*
|
||||
* If type is OEM specific or sensor manufacturer specific type
|
||||
* (>=SENSOR_TYPE_DEVICE_PRIVATE_BASE), this string must be defined with reserved domain of
|
||||
* vendor/OEM as a prefix, e.g. com.google.glass.onheaddetector
|
||||
*
|
||||
* For sensors of Android defined types, Android framework will override this value. It is ok to
|
||||
* leave it pointing to an empty string.
|
||||
*/
|
||||
const char* stringType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user