• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_TARGET_PLATFORM_SENSOR_TYPE_HELPERS_BASE_H_
18 #define CHRE_TARGET_PLATFORM_SENSOR_TYPE_HELPERS_BASE_H_
19 
20 #define CHRE_SLPI_SENSOR_TYPE_BIG_IMAGE_ACCEL CHRE_VENDOR_SENSOR_TYPE(3)
21 #define CHRE_SLPI_SENSOR_TYPE_BIG_IMAGE_UNCAL_ACCEL CHRE_VENDOR_SENSOR_TYPE(6)
22 #define CHRE_SLPI_SENSOR_TYPE_BIG_IMAGE_UNCAL_GYRO CHRE_VENDOR_SENSOR_TYPE(7)
23 #define CHRE_SLPI_SENSOR_TYPE_BIG_IMAGE_UNCAL_MAG CHRE_VENDOR_SENSOR_TYPE(8)
24 #define CHRE_SLPI_SENSOR_TYPE_BIG_IMAGE_LIGHT CHRE_VENDOR_SENSOR_TYPE(9)
25 
26 namespace chre {
27 
28 /**
29  * This SensorSampleType is designed to help classify sensor's data type in
30  * event handling.
31  */
32 enum class SensorSampleType {
33   Byte,
34   Float,
35   Occurrence,
36   ThreeAxis,
37   Vendor0,
38   Vendor1,
39   Vendor2,
40   Vendor3,
41   Vendor4,
42   Vendor5,
43   Vendor6,
44   Vendor7,
45   Vendor8,
46   Vendor9,
47   Unknown,
48 };
49 
50 /**
51  * Exposes SLPI-specific methods used by platform code and the SLPI-specific
52  * PlatformSensorTypeHelpers implementation to transform sensor types as needed.
53  */
54 class PlatformSensorTypeHelpersBase {
55  public:
56   /**
57    * Obtains the temperature sensor type of the specified sensor type.
58    *
59    * @param sensorType The sensor type to obtain its temperature sensor type
60    *     for.
61    * @return The temperature sensor type or CHRE_SENSOR_TYPE_INVALID if not
62    *     supported by CHRE.
63    */
64   static uint8_t getTempSensorType(uint8_t sensorType);
65 
66   /**
67    * Maps a sensorType to its SensorSampleType.
68    *
69    * @param sensorType The type of the sensor to obtain its SensorSampleType
70    *     for.
71    * @return The SensorSampleType of the sensorType.
72    */
73   static SensorSampleType getSensorSampleTypeFromSensorType(uint8_t sensorType);
74 
75   /**
76    * @param sensorType The sensor type.
77    * @return The corresponding runtime-calibrated sensor type. If the sensor
78    *     does not have one or is already runtime-calibrated, then the input
79    *     sensorType is returned.
80    */
81   static uint8_t toCalibratedSensorType(uint8_t sensorType);
82 
83   /**
84    * @param sensorType The sensor type.
85    * @return The corresponding uncalibrated sensor type. If the sensor does not
86    *     have one or is already uncalibrated, then the input sensorType is
87    *     returned.
88    */
89   static uint8_t toUncalibratedSensorType(uint8_t sensorType);
90 
91   /**
92    * @return Whether the given sensor type reports bias events.
93    */
94   static bool reportsBias(uint8_t sensorType);
95 };
96 
97 }  // namespace chre
98 
99 #endif  // CHRE_TARGET_PLATFORM_SENSOR_TYPE_HELPERS_BASE_H_
100