• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 #include <hardware/sensors.h>
18 
19 #include "nusensors.h"
20 
21 /*****************************************************************************/
22 
23 /*
24  * The SENSORS Module
25  */
26 
27 /*
28  * the AK8973 has a 8-bit ADC but the firmware seems to average 16 samples,
29  * or at least makes its calibration on 12-bits values. This increases the
30  * resolution by 4 bits.
31  */
32 
33 static const struct sensor_t sSensorList[] = {
34         { "BMA150 3-axis Accelerometer",
35                 "Bosh",
36                 1, SENSORS_HANDLE_BASE+ID_A,
37                 SENSOR_TYPE_ACCELEROMETER, 4.0f*9.81f, (4.0f*9.81f)/256.0f, 0.2f, 0, { } },
38         { "AK8973 3-axis Magnetic field sensor",
39                 "Asahi Kasei",
40                 1, SENSORS_HANDLE_BASE+ID_M,
41                 SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, 1.0f/16.0f, 6.8f, 0, { } },
42         { "AK8973 Orientation sensor",
43                 "Asahi Kasei",
44                 1, SENSORS_HANDLE_BASE+ID_O,
45                 SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 7.0f, 0, { } },
46         { "CM3602 Proximity sensor",
47                 "Capella Microsystems",
48                 1, SENSORS_HANDLE_BASE+ID_P,
49                 SENSOR_TYPE_PROXIMITY,
50                 PROXIMITY_THRESHOLD_CM, PROXIMITY_THRESHOLD_CM,
51                 0.5f, 0, { } },
52         { "CM3602 Light sensor",
53                 "Capella Microsystems",
54                 1, SENSORS_HANDLE_BASE+ID_L,
55                 SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.5f, 0, { } },
56 };
57 
58 static int open_sensors(const struct hw_module_t* module, const char* name,
59         struct hw_device_t** device);
60 
sensors__get_sensors_list(struct sensors_module_t * module,struct sensor_t const ** list)61 static int sensors__get_sensors_list(struct sensors_module_t* module,
62         struct sensor_t const** list)
63 {
64     *list = sSensorList;
65     return ARRAY_SIZE(sSensorList);
66 }
67 
68 static struct hw_module_methods_t sensors_module_methods = {
69     .open = open_sensors
70 };
71 
72 const struct sensors_module_t HAL_MODULE_INFO_SYM = {
73     .common = {
74         .tag = HARDWARE_MODULE_TAG,
75         .version_major = 1,
76         .version_minor = 0,
77         .id = SENSORS_HARDWARE_MODULE_ID,
78         .name = "AK8973A & CM3602 Sensors Module",
79         .author = "The Android Open Source Project",
80         .methods = &sensors_module_methods,
81     },
82     .get_sensors_list = sensors__get_sensors_list
83 };
84 
85 /*****************************************************************************/
86 
open_sensors(const struct hw_module_t * module,const char * name,struct hw_device_t ** device)87 static int open_sensors(const struct hw_module_t* module, const char* name,
88         struct hw_device_t** device)
89 {
90     return init_nusensors(module, device);
91 }
92