summaryrefslogtreecommitdiffstats
path: root/libsensors/AkmSensor.cpp
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-08-20 14:40:15 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-08-20 21:50:47 +0200
commit54ef57e3f3e9efbe86fadac9de8e67333c95e2a5 (patch)
tree87458190d51a41c2d3c3cc199f93c64f8fba5b51 /libsensors/AkmSensor.cpp
parentcc5dde0fa7ee87e2229fe1c22e1f1935fe454dff (diff)
downloaddevice_samsung_n7000-54ef57e3f3e9efbe86fadac9de8e67333c95e2a5.zip
device_samsung_n7000-54ef57e3f3e9efbe86fadac9de8e67333c95e2a5.tar.gz
device_samsung_n7000-54ef57e3f3e9efbe86fadac9de8e67333c95e2a5.tar.bz2
sensors: Use Samsung-Sensors
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'libsensors/AkmSensor.cpp')
-rw-r--r--libsensors/AkmSensor.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp
index 98a17cb..5f7abd0 100644
--- a/libsensors/AkmSensor.cpp
+++ b/libsensors/AkmSensor.cpp
@@ -32,10 +32,10 @@
/*****************************************************************************/
-int (*akm_is_sensor_enabled)(uint32_t sensor_type);
-int (*akm_enable_sensor)(uint32_t sensor_type);
-int (*akm_disable_sensor)(uint32_t sensor_type);
-int (*akm_set_delay)(uint32_t sensor_type, uint64_t delay);
+int (*is_sensor_enabled)(uint32_t sensor_type);
+int (*enable_sensor)(uint32_t sensor_type);
+int (*disable_sensor)(uint32_t sensor_type);
+int (*set_delay)(uint32_t sensor_type, uint64_t delay);
int stub_is_sensor_enabled(uint32_t sensor_type) {
return 0;
@@ -59,8 +59,8 @@ AkmSensor::AkmSensor()
* creates a uinput device.
*/
if (loadAKMLibrary() == 0) {
- data_name = "compass_sensor";
- data_fd = openInput("compass_sensor");
+ data_name = "compass";
+ data_fd = openInput("compass");
}
memset(mPendingEvents, 0, sizeof(mPendingEvents));
@@ -84,7 +84,7 @@ AkmSensor::AkmSensor()
struct input_absinfo absinfo;
short flags = 0;
- if (akm_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) {
+ if (is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) {
mEnabled |= 1<<Accelerometer;
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) {
mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X;
@@ -96,7 +96,7 @@ AkmSensor::AkmSensor()
mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z;
}
}
- if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) {
+ if (is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) {
mEnabled |= 1<<MagneticField;
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) {
mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X;
@@ -108,7 +108,7 @@ AkmSensor::AkmSensor()
mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z;
}
}
- if (akm_is_sensor_enabled(SENSOR_TYPE_ORIENTATION)) {
+ if (is_sensor_enabled(SENSOR_TYPE_ORIENTATION)) {
mEnabled |= 1<<Orientation;
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_YAW), &absinfo)) {
mPendingEvents[Orientation].orientation.azimuth = absinfo.value;
@@ -125,7 +125,7 @@ AkmSensor::AkmSensor()
}
// disable temperature sensor, since it is not supported
- akm_disable_sensor(SENSOR_TYPE_TEMPERATURE);
+ disable_sensor(SENSOR_TYPE_TEMPERATURE);
}
AkmSensor::~AkmSensor()
@@ -160,9 +160,9 @@ int AkmSensor::enable(int32_t handle, int en)
}
short flags = newState;
if (en)
- err = akm_enable_sensor(sensor_type);
+ err = enable_sensor(sensor_type);
else
- err = akm_disable_sensor(sensor_type);
+ err = disable_sensor(sensor_type);
LOGE_IF(err, "Could not change sensor state (%s)", strerror(-err));
if (!err) {
@@ -190,6 +190,8 @@ int AkmSensor::setDelay(int32_t handle, int64_t ns)
if (sensor_type == 0)
return -EINVAL;
+ set_delay(sensor_type, ns);
+
mDelays[what] = ns;
return update_delay();
}
@@ -215,21 +217,21 @@ int AkmSensor::update_delay()
int AkmSensor::loadAKMLibrary()
{
- mLibAKM = dlopen("libakm.so", RTLD_NOW);
+ mLibAKM = dlopen("libsamsung-sensors.so", RTLD_NOW);
if (!mLibAKM) {
- akm_is_sensor_enabled = stub_is_sensor_enabled;
- akm_enable_sensor = stub_enable_disable_sensor;
- akm_disable_sensor = stub_enable_disable_sensor;
- akm_set_delay = stub_set_delay;
+ is_sensor_enabled = stub_is_sensor_enabled;
+ enable_sensor = stub_enable_disable_sensor;
+ disable_sensor = stub_enable_disable_sensor;
+ set_delay = stub_set_delay;
LOGE("AkmSensor: unable to load AKM Library, %s", dlerror());
return -ENOENT;
}
- *(void **)&akm_is_sensor_enabled = dlsym(mLibAKM, "akm_is_sensor_enabled");
- *(void **)&akm_enable_sensor = dlsym(mLibAKM, "akm_enable_sensor");
- *(void **)&akm_disable_sensor = dlsym(mLibAKM, "akm_disable_sensor");
- *(void **)&akm_set_delay = dlsym(mLibAKM, "akm_set_delay");
+ *(void **)&is_sensor_enabled = dlsym(mLibAKM, "is_sensor_enabled");
+ *(void **)&enable_sensor = dlsym(mLibAKM, "enable_sensor");
+ *(void **)&disable_sensor = dlsym(mLibAKM, "disable_sensor");
+ *(void **)&set_delay = dlsym(mLibAKM, "set_delay");
return 0;
}
@@ -248,7 +250,7 @@ int AkmSensor::readEvents(sensors_event_t* data, int count)
while (count && mInputReader.readEvent(&event)) {
int type = event->type;
- if (type == EV_REL) {
+ if (type == EV_ABS) {
processEvent(event->code, event->value);
mInputReader.next();
} else if (type == EV_SYN) {
@@ -281,11 +283,11 @@ void AkmSensor::processEvent(int code, int value)
switch (code) {
case EVENT_TYPE_ACCEL_X:
mPendingMask |= 1<<Accelerometer;
- mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X;
+ mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y;
break;
case EVENT_TYPE_ACCEL_Y:
mPendingMask |= 1<<Accelerometer;
- mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y;
+ mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X;
break;
case EVENT_TYPE_ACCEL_Z:
mPendingMask |= 1<<Accelerometer;
@@ -293,17 +295,14 @@ void AkmSensor::processEvent(int code, int value)
break;
case EVENT_TYPE_MAGV_X:
- LOGV("AkmSensor: EVENT_TYPE_MAGV_X value =%d", value);
mPendingMask |= 1<<MagneticField;
mPendingEvents[MagneticField].magnetic.x = value * CONVERT_M_X;
break;
case EVENT_TYPE_MAGV_Y:
- LOGV("AkmSensor: EVENT_TYPE_MAGV_Y value =%d", value);
mPendingMask |= 1<<MagneticField;
mPendingEvents[MagneticField].magnetic.y = value * CONVERT_M_Y;
break;
case EVENT_TYPE_MAGV_Z:
- LOGV("AkmSensor: EVENT_TYPE_MAGV_Z value =%d", value);
mPendingMask |= 1<<MagneticField;
mPendingEvents[MagneticField].magnetic.z = value * CONVERT_M_Z;
break;