Home | History | Annotate | Download | only in libsensors
      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 #ifndef ANDROID_SENSORS_H
     18 #define ANDROID_SENSORS_H
     19 
     20 #include <stdint.h>
     21 #include <errno.h>
     22 #include <sys/cdefs.h>
     23 #include <sys/types.h>
     24 
     25 #include <linux/input.h>
     26 
     27 #include <hardware/hardware.h>
     28 #include <hardware/sensors.h>
     29 
     30 __BEGIN_DECLS
     31 
     32 /*****************************************************************************/
     33 
     34 int init_nusensors(hw_module_t const* module, hw_device_t** device);
     35 
     36 /*****************************************************************************/
     37 
     38 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
     39 
     40 #define ID_A  (0)
     41 #define ID_M  (1)
     42 #define ID_O  (2)
     43 #define ID_P  (3)
     44 #define ID_L  (4)
     45 
     46 /*****************************************************************************/
     47 
     48 /*
     49  * The SENSORS Module
     50  */
     51 
     52 /* the CM3602 is a binary proximity sensor that triggers around 9 cm on
     53  * this hardware */
     54 #define PROXIMITY_THRESHOLD_CM  9.0f
     55 
     56 /*****************************************************************************/
     57 
     58 #define AKM_DEVICE_NAME     "/dev/akm8973_aot"
     59 #define CM_DEVICE_NAME      "/dev/cm3602"
     60 #define LS_DEVICE_NAME      "/dev/lightsensor"
     61 
     62 #define EVENT_TYPE_ACCEL_X          ABS_X
     63 #define EVENT_TYPE_ACCEL_Y          ABS_Z
     64 #define EVENT_TYPE_ACCEL_Z          ABS_Y
     65 #define EVENT_TYPE_ACCEL_STATUS     ABS_WHEEL
     66 
     67 #define EVENT_TYPE_YAW              ABS_RX
     68 #define EVENT_TYPE_PITCH            ABS_RY
     69 #define EVENT_TYPE_ROLL             ABS_RZ
     70 #define EVENT_TYPE_ORIENT_STATUS    ABS_RUDDER
     71 
     72 #define EVENT_TYPE_MAGV_X           ABS_HAT0X
     73 #define EVENT_TYPE_MAGV_Y           ABS_HAT0Y
     74 #define EVENT_TYPE_MAGV_Z           ABS_BRAKE
     75 
     76 #define EVENT_TYPE_TEMPERATURE      ABS_THROTTLE
     77 #define EVENT_TYPE_STEP_COUNT       ABS_GAS
     78 #define EVENT_TYPE_PROXIMITY        ABS_DISTANCE
     79 #define EVENT_TYPE_LIGHT            ABS_MISC
     80 
     81 // 720 LSG = 1G
     82 #define LSG                         (720.0f)
     83 
     84 
     85 // conversion of acceleration data to SI units (m/s^2)
     86 #define CONVERT_A                   (GRAVITY_EARTH / LSG)
     87 #define CONVERT_A_X                 (-CONVERT_A)
     88 #define CONVERT_A_Y                 (CONVERT_A)
     89 #define CONVERT_A_Z                 (-CONVERT_A)
     90 
     91 // conversion of magnetic data to uT units
     92 #define CONVERT_M                   (1.0f/16.0f)
     93 #define CONVERT_M_X                 (-CONVERT_M)
     94 #define CONVERT_M_Y                 (-CONVERT_M)
     95 #define CONVERT_M_Z                 (CONVERT_M)
     96 
     97 #define CONVERT_O                   (1.0f)
     98 #define CONVERT_O_Y                 (CONVERT_O)
     99 #define CONVERT_O_P                 (CONVERT_O)
    100 #define CONVERT_O_R                 (-CONVERT_O)
    101 
    102 #define SENSOR_STATE_MASK           (0x7FFF)
    103 
    104 /*****************************************************************************/
    105 
    106 __END_DECLS
    107 
    108 #endif  // ANDROID_SENSORS_H
    109