1 /*
2 * Copyright (C) 2010 Motorola, Inc.
3 * Copyright (C) 2008 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #include <hardware/sensors.h>
19
20 #include "nusensors.h"
21
22 /*****************************************************************************/
23
24 /*
25 * The SENSORS Module
26 */
27
28 static const struct sensor_t sSensorList[] = {
29 { "KXTF9 3-axis Accelerometer",
30 "Kionix",
31 1, SENSORS_HANDLE_BASE+ID_A,
32 SENSOR_TYPE_ACCELEROMETER, MAX_RANGE_A, CONVERT_A, 0.57f, 20000, { } },
33 { "Ambient Light sensor",
34 "Maxim",
35 1, SENSORS_HANDLE_BASE+ID_L,
36 SENSOR_TYPE_LIGHT, 208076.8f, 0.05f, 0.003f, 0, { } },
37 { "AK8975 3-axis Magnetic field sensor",
38 "Asahi Kasei",
39 1, SENSORS_HANDLE_BASE+ID_M,
40 SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 30000, { } },
41 { "AK8975 Orientation sensor",
42 "Asahi Kasei",
43 1, SENSORS_HANDLE_BASE+ID_O,
44 SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.05f, 30000, { } },
45 { "BMP085 Pressure sensor",
46 "Bosch",
47 1, SENSORS_HANDLE_BASE+ID_B,
48 SENSOR_TYPE_PRESSURE, 110000.0f, 1.0f, 1.0f, 30000, { } },
49 { "L3G4200D Gyroscope sensor",
50 "ST Micro",
51 1, SENSORS_HANDLE_BASE+ID_G,
52 SENSOR_TYPE_GYROSCOPE, MAX_RANGE_G, CONVERT_G, 6.1f, 1250, { } },
53 };
54
55 static int open_sensors(const struct hw_module_t* module, const char* name,
56 struct hw_device_t** device);
57
sensors__get_sensors_list(struct sensors_module_t * module,struct sensor_t const ** list)58 static int sensors__get_sensors_list(struct sensors_module_t* module,
59 struct sensor_t const** list)
60 {
61 *list = sSensorList;
62 return ARRAY_SIZE(sSensorList);
63 }
64
65 static struct hw_module_methods_t sensors_module_methods = {
66 .open = open_sensors
67 };
68
69 struct sensors_module_t HAL_MODULE_INFO_SYM = {
70 .common = {
71 .tag = HARDWARE_MODULE_TAG,
72 .version_major = 1,
73 .version_minor = 0,
74 .id = SENSORS_HARDWARE_MODULE_ID,
75 .name = "Stingray SENSORS Module",
76 .author = "Motorola",
77 .methods = &sensors_module_methods,
78 },
79 .get_sensors_list = sensors__get_sensors_list
80 };
81
82 /*****************************************************************************/
83
open_sensors(const struct hw_module_t * module,const char * name,struct hw_device_t ** device)84 static int open_sensors(const struct hw_module_t* module, const char* name,
85 struct hw_device_t** device)
86 {
87 return init_nusensors(module, device);
88 }
89