--- /dev/null
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# HAL module implemenation, not prelinked, and stored in
+# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
+
+ifeq ($(TARGET_BOARD_PLATFORM),bigcore)
+ifeq ($(BOARD_USE_PLATFORM_SENSOR_LIB),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Common files.
+common_src_path := ../../common/libsensors
+common_src_files := $(common_src_path)/sensors.cpp \
+ $(common_src_path)/SensorBase.cpp \
+ $(common_src_path)/SensorInputDev.cpp \
+ $(common_src_path)/InputEventReader.cpp \
+ $(common_src_path)/Helpers.cpp \
+ $(common_src_path)/SensorIIODev.cpp \
+
+# Board specific sensors.
+sensor_src_files := $(common_src_path)/HidSensor_Accel3D.cpp \
+ $(common_src_path)/HidSensor_Gyro3D.cpp \
+ $(common_src_path)/HidSensor_Compass3D.cpp \
+ $(common_src_path)/HidSensor_ALS.cpp \
+
+include external/stlport/libstlport.mk
+LOCAL_C_INCLUDES += $(LOCAL_PATH) device/intel/common/libsensors
+
+LOCAL_MODULE := sensors.$(TARGET_DEVICE)
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\"
+LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libstlport
+LOCAL_PRELINK_MODULE := false
+LOCAL_SRC_FILES := $(common_src_files) $(sensor_src_files) BoardConfig.cpp
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # BOARD_USE_PLATFORM_SENSOR_LIB == true
+endif # TARGET_BOARD_PLATFORM == bigcore
--- /dev/null
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <fcntl.h>
+#include <errno.h>
+#include <cutils/log.h>
+
+#include "common.h"
+
+#include "BoardConfig.h"
+#include "SensorConfig.h"
+#include "HidSensor_Accel3D.h"
+#include "HidSensor_Gyro3D.h"
+#include "HidSensor_Compass3D.h"
+#include "HidSensor_ALS.h"
+
+static const struct sensor_t sSensorList[] = {
+ AccelSensor::sSensorInfo_accel3D,
+ GyroSensor::sSensorInfo_gyro3D,
+ CompassSensor::sSensorInfo_compass3D,
+ ALSSensor::sSensorInfo_als,
+};
+
+const struct sensor_t* BoardConfig::sensorList()
+{
+ return sSensorList;
+}
+
+int BoardConfig::sensorListSize()
+{
+ return ARRAY_SIZE(sSensorList);
+}
+
+void BoardConfig::initSensors(SensorBase* sensors[])
+{
+ sensors[accel] = new AccelSensor();
+ sensors[gyro] = new GyroSensor();
+ sensors[compass] = new CompassSensor();
+ sensors[light] = new ALSSensor();
+}
+
+int BoardConfig::handleToDriver(int handle)
+{
+ switch (handle) {
+ case ID_A:
+ return accel;
+ case ID_M:
+ return compass;
+ case ID_PR:
+ case ID_T:
+ return -EINVAL;
+ case ID_GY:
+ return gyro;
+ case ID_L:
+ return light;
+ default:
+ return -EINVAL;
+ }
+ return -EINVAL;
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SENSOR_CONFIG_H
+#define SENSOR_CONFIG_H
+
+#include <hardware/hardware.h>
+#include <hardware/sensors.h>
+#include <cmath>
+
+/* Maps senor id's to the sensor list */
+enum {
+ accel = 0,
+ gyro,
+ compass,
+ light,
+ numSensorDrivers,
+ numFds,
+};
+
+
+
+/*****************************************************************************/
+
+/* Board specific sensor configs. */
+#define GRAVITY 9.80665f
+#define EVENT_TYPE_ACCEL_X REL_X
+#define EVENT_TYPE_ACCEL_Y REL_Y
+#define EVENT_TYPE_ACCEL_Z REL_Z
+
+#define EVENT_TYPE_COMP_X REL_X
+#define EVENT_TYPE_COMP_Y REL_Y
+#define EVENT_TYPE_COMP_Z REL_Z
+
+#define EVENT_TYPE_YAW REL_RX
+#define EVENT_TYPE_PITCH REL_RY
+#define EVENT_TYPE_ROLL REL_RZ
+#define EVENT_TYPE_ORIENT_STATUS REL_WHEEL
+
+#define EVENT_TYPE_MAGV_X REL_DIAL
+#define EVENT_TYPE_MAGV_Y REL_HWHEEL
+#define EVENT_TYPE_MAGV_Z REL_MISC
+
+#define EVENT_TYPE_PROXIMITY ABS_DISTANCE
+#define EVENT_TYPE_LIGHT ABS_MISC
+
+#define EVENT_TYPE_GYRO_X REL_X
+#define EVENT_TYPE_GYRO_Y REL_Y
+#define EVENT_TYPE_GYRO_Z REL_Z
+
+#define EVENT_TYPE_PRESSURE REL_X
+#define EVENT_TYPE_TEMPERATURE REL_Y
+
+// 720 LSG = 1G
+#define LSG (1024.0f)
+#define NUMOFACCDATA (8.0f)
+// conversion of acceleration data to SI units (m/s^2)
+
+#define RANGE_A (2*GRAVITY_EARTH)
+#define RESOLUTION_A (RANGE_A/(256*NUMOFACCDATA))
+#define CONVERT_A (GRAVITY_EARTH / LSG / NUMOFACCDATA)
+#define CONVERT_A_X(x) ((float(x)/1000) * (GRAVITY * -1.0))
+#define CONVERT_A_Y(x) ((float(x)/1000) * (GRAVITY * 1.0))
+#define CONVERT_A_Z(x) ((float(x)/1000) * (GRAVITY * 1.0))
+// conversion of magnetic data to uT units
+#define RANGE_M (2048.0f)
+#define RESOLUTION_M (0.01)
+#define CONVERT_M (1.0f/6.6f)
+#define CONVERT_M_X (-CONVERT_M)
+#define CONVERT_M_Y (-CONVERT_M)
+#define CONVERT_M_Z (CONVERT_M)
+
+/* conversion of orientation data to degree units */
+#define CONVERT_O (1.0f/64.0f)
+#define CONVERT_O_A (CONVERT_O)
+#define CONVERT_O_P (CONVERT_O)
+#define CONVERT_O_R (-CONVERT_O)
+
+// conversion of gyro data to SI units (radian/sec)
+#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f)
+#define CONVERT_GYRO ((2000.0f / 32767.0f) * ((float)M_PI / 180.0f))
+#define CONVERT_GYRO_X (-CONVERT_GYRO)
+#define CONVERT_GYRO_Y (-CONVERT_GYRO)
+#define CONVERT_GYRO_Z (CONVERT_GYRO)
+
+// conversion of pressure and temperature data
+#define CONVERT_PRESSURE (1.0f/100.0f)
+#define CONVERT_TEMPERATURE (1.0f/100.0f)
+
+#define RESOLUTION_GYRO (RANGE_GYRO/(2000*NUMOFACCDATA))
+#define SENSOR_STATE_MASK (0x7FFF)
+
+// Proximity Threshold
+#define PROXIMITY_THRESHOLD_GP2A 5.0f
+
+//Used in timespec_to_ns calculations
+#define NSEC_PER_SEC 1000000000L
+
+#define BIT(x) (1 << (x))
+
+inline unsigned int set_bit_range(int start, int end)
+{
+ int i;
+ unsigned int value = 0;
+
+ for (i = start; i < end; ++i)
+ value |= BIT(i);
+ return value;
+}
+
+inline float convert_from_vtf_format(int size, int exponent, unsigned int value)
+{
+ int divider=1;
+ int i;
+ float sample;
+ int mul = 1.0;
+
+ value = value & set_bit_range(0, size*8);
+ if (value & BIT(size*8-1)) {
+ value = ((1LL << (size*8)) - value);
+ mul = -1.0;
+ }
+ sample = value * 1.0;
+ if (exponent < 0) {
+ exponent = abs(exponent);
+ for (i = 0; i < exponent; ++i) {
+ divider = divider*10;
+ }
+ return mul * sample/divider;
+ } else {
+ return mul * sample * pow(10.0, exponent);
+ }
+}
+
+// G to m/s2
+#define CONVERT_FROM_VTF16(s,d,x) (convert_from_vtf_format(s,d,x))
+#define CONVERT_A_G_VTF16E14_X(s,d,x) (convert_from_vtf_format(s,d,x)*GRAVITY)
+#define CONVERT_A_G_VTF16E14_Y(s,d,x) (convert_from_vtf_format(s,d,x)*GRAVITY)
+#define CONVERT_A_G_VTF16E14_Z(s,d,x) (convert_from_vtf_format(s,d,x)*GRAVITY)
+
+// Degree/sec to radian/sec
+#define CONVERT_G_D_VTF16E14_X(s,d,x) (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+#define CONVERT_G_D_VTF16E14_Y(s,d,x) (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+#define CONVERT_G_D_VTF16E14_Z(s,d,x) (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+
+// Milli gauss to micro tesla
+#define CONVERT_M_MG_VTF16E14_X(s,d,x) (convert_from_vtf_format(s,d,x)/10)
+#define CONVERT_M_MG_VTF16E14_Y(s,d,x) (convert_from_vtf_format(s,d,x)/10)
+#define CONVERT_M_MG_VTF16E14_Z(s,d,x) (convert_from_vtf_format(s,d,x)/10)
+
+/*****************************************************************************/
+
+#endif // SENSOR_CONFIG_H