• 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   Vendor10,
48   Unknown,
49 };
50 
51 /**
52  * The group IDs that the SEE sensor driver supports placing nanoapps into such
53  * that they can be targeted separately by the sensor driver.
54  */
55 enum NanoappGroupIds {
56   MicroImage = 1 << 0,
57   BigImage = 1 << 1,
58 };
59 
60 /**
61  * Exposes SLPI-specific methods used by platform code and the SLPI-specific
62  * PlatformSensorTypeHelpers implementation to transform sensor types as needed.
63  */
64 class PlatformSensorTypeHelpersBase {
65  public:
66   /**
67    * Obtains the temperature sensor type of the specified sensor type.
68    *
69    * @param sensorType The sensor type to obtain its temperature sensor type
70    *     for.
71    * @return The temperature sensor type or CHRE_SENSOR_TYPE_INVALID if not
72    *     supported by CHRE.
73    */
74   static uint8_t getTempSensorType(uint8_t sensorType);
75 
76   /**
77    * Maps a sensorType to its SensorSampleType.
78    *
79    * @param sensorType The type of the sensor to obtain its SensorSampleType
80    *     for.
81    * @return The SensorSampleType of the sensorType.
82    */
83   static SensorSampleType getSensorSampleTypeFromSensorType(uint8_t sensorType);
84 
85   /**
86    * @param sensorType The sensor type.
87    * @return The corresponding runtime-calibrated sensor type. If the sensor
88    *     does not have one or is already runtime-calibrated, then the input
89    *     sensorType is returned.
90    */
91   static uint8_t toCalibratedSensorType(uint8_t sensorType);
92 
93   /**
94    * @return Whether the given sensor type reports bias events.
95    */
96   static bool reportsBias(uint8_t sensorType);
97 
98   /**
99    * Rewrites a big-image sensorType to its regular CHRE counterpart leaving
100    * regular CHRE sensor types unchanged.
101    */
102   static void rewriteToChreSensorType(uint8_t *sensorType);
103 };
104 
105 }  // namespace chre
106 
107 #endif  // CHRE_TARGET_PLATFORM_SENSOR_TYPE_HELPERS_BASE_H_
108