summaryrefslogtreecommitdiffstats
path: root/sensors/akm8963.c
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-02-23 13:44:43 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-02-23 13:44:43 +0100
commita1ae70bdae481f5a09f527b8e49995677132b357 (patch)
tree1e2a62d00c3d359c477e3b008d17a80054533169 /sensors/akm8963.c
parent1e0be1496372b29e8c191568c9073d1342577ca9 (diff)
downloaddevice_samsung_n7100-replicant-6.0-0001.tar.gz
device_samsung_n7100-replicant-6.0-0001.tar.bz2
device_samsung_n7100-replicant-6.0-0001.zip
sensors bringupreplicant-6.0-0001
Various fixes are ported from the i9300 sensors. A list of commits is attached below. Furthermore, paths are adapted for the updated sensor drivers and I got rid of implicit declaration warnings. commit 0f8e8cc Author: Christian Balster <christian.balster@gmail.com> Date: Wed May 20 13:19:48 2015 +0200 i9300: libsensors: add real accuracy reporting for magnetometer Change-Id: I3dd56f4d7fb0de8feca2422c165fe0c3cd92761a commit 2104318 Author: Christian Balster <christian.balster@gmail.com> Date: Wed May 20 17:14:11 2015 +0200 i9300: libsensors: fix typo in accelerometer data Change-Id: Iee501b65c23bed22bfe769496bafc852f939a8ac commit b69dd87 Author: Christian Balster <christian.balster@gmail.com> Date: Wed May 20 17:16:29 2015 +0200 i9300: libsensors: report at least bogus accuracy for gyro Change-Id: I81ff71c8ae6bf25c1aabac4a6d8d6fcf64bd2e0b commit d786475 Author: Christian Balster <christian.balster@gmail.com> Date: Thu May 21 17:46:00 2015 +0200 i9300: libsensors: fix magnetometer offset parameters not being saved also fix a typo Change-Id: I69246a96c53d7ec02ca90d73bc85dec4cbc73343 commit f7d2dfd Author: Christian Balster <christian.balster@gmail.com> Date: Tue Jun 2 15:08:02 2015 +0200 i9300: libsensors: remove unused orientation sensor The Orientation Sensor is deprecated and no longer required. Additionally this implementation is never even used, since Android automatically replaces it by it's own implementation if the sensor HAL doesn't also provide a Rotation Vector sensor. Furthermore the current implementation only uses the accelerometer and magnetometer for the sensor fusion and doesn't make use of the Gyroscope. So should we at some point decide to implement our own complete sensor fusion this would have to be rewritten anyway. Change-Id: I45d8a9afd2089b49131e6cc69cdf2f3dfee46c92 commit fc862f3 Author: Dheeraj CVR <cvr.dheeraj@gmail.com> Date: Thu Jun 11 16:44:25 2015 +0400 libsensors: switch to portable typedefs to match callbacks Using a strict basetype only coding style is not a good idea especially when we are dealing with callbacks which use portable typedef like int64_t. This kind of coding style would most likely end up in overflows at various places especially when dealing with timestamps and sensor delays which are caused when typecasting datatypes of different size. Switch to portable typedefs and get rid of "long". Change-Id: I75b9cace7602345dba9095f046292e6d4db07df4 commit a484daf Author: Christian Balster <christian.balster@gmail.com> Date: Mon Jun 15 17:46:29 2015 +0200 i9300: libsensors: fix possible overflow while setting delay Even though we changed the signature of the set_delay() methods, we can still get an overflow while actually writing the values to sysfs. Let's adapt sysfs_value_read() and sysfs_value_write() too. Change-Id: If8eda7204831f0edabec890d4e3127be520fa3bf commit 594d5b8 Author: Dheeraj CVR <cvr.dheeraj@gmail.com> Date: Thu Jun 11 17:57:26 2015 +0400 libsensors: update sensor flags Change-Id: Ia57026f4e8f5dd270da7619bc25289fc414bce30 Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'sensors/akm8963.c')
-rw-r--r--sensors/akm8963.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/sensors/akm8963.c b/sensors/akm8963.c
index d5cad3f..c3a1851 100644
--- a/sensors/akm8963.c
+++ b/sensors/akm8963.c
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
+#include <string.h>
#include <hardware/sensors.h>
#include <hardware/hardware.h>
@@ -33,7 +34,6 @@
#define AKM8963_CONFIG_PATH "/data/misc/akmd_set.txt"
struct akm8963_data {
- struct smdk4x12_sensors_handlers *orientation_sensor;
sensors_vec_t magnetic;
short magnetic_data[4][3];
@@ -44,7 +44,7 @@ struct akm8963_data {
unsigned char asa[3];
int ho[3];
- long int delay;
+ int64_t delay;
int device_fd;
int uinput_fd;
@@ -363,6 +363,8 @@ void *akm8963_thread(void *thread_data)
write(uinput_fd, &event, sizeof(event));
input_event_set(&event, EV_REL, REL_Z, (int) (data->magnetic.z * 1000));
write(uinput_fd, &event, sizeof(event));
+ input_event_set(&event, EV_REL, REL_MISC, (int) data->magnetic.status);
+ write(uinput_fd, &event, sizeof(event));
input_event_set(&event, EV_SYN, 0, 0);
write(uinput_fd, &event, sizeof(event));
@@ -398,14 +400,6 @@ int akm8963_init(struct smdk4x12_sensors_handlers *handlers,
data = (struct akm8963_data *) calloc(1, sizeof(struct akm8963_data));
- for (i = 0; i < device->handlers_count; i++) {
- if (device->handlers[i] == NULL)
- continue;
-
- if (device->handlers[i]->handle == SENSOR_TYPE_ORIENTATION)
- data->orientation_sensor = device->handlers[i];
- }
-
device_fd = open("/dev/akm8963", O_RDONLY);
if (device_fd < 0) {
ALOGE("%s: Unable to open device", __func__);
@@ -421,13 +415,13 @@ int akm8963_init(struct smdk4x12_sensors_handlers *handlers,
ALOGD("AKM8963 ASA (Sensitivity Adjustment) values are: (%d, %d, %d)",
data->asa[0], data->asa[1], data->asa[2]);
- uinput_fd = uinput_rel_create("magnetic");
+ uinput_fd = uinput_rel_create("magnetic_sensor");
if (uinput_fd < 0) {
ALOGD("%s: Unable to create uinput", __func__);
goto error;
}
- input_fd = input_open("magnetic");
+ input_fd = input_open("magnetic_sensor");
if (input_fd < 0) {
ALOGE("%s: Unable to open magnetic input", __func__);
goto error;
@@ -581,13 +575,13 @@ int akm8963_deactivate(struct smdk4x12_sensors_handlers *handlers)
return 0;
}
-int akm8963_set_delay(struct smdk4x12_sensors_handlers *handlers, long int delay)
+int akm8963_set_delay(struct smdk4x12_sensors_handlers *handlers, int64_t delay)
{
struct akm8963_data *data;
char path_delay[PATH_MAX] = "/sys/class/sensors/ssp_sensor/mag_poll_delay";
int rc;
- ALOGD("%s(%p, %ld)", __func__, handlers, delay);
+ ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay);
if (handlers == NULL || handlers->data == NULL)
return -EINVAL;
@@ -634,8 +628,6 @@ int akm8963_get_data(struct smdk4x12_sensors_handlers *handlers,
event->sensor = handlers->handle;
event->type = handlers->handle;
- event->magnetic.status = SENSOR_STATUS_ACCURACY_MEDIUM;
-
do {
rc = read(input_fd, &input_event, sizeof(input_event));
if (rc < (int) sizeof(input_event))
@@ -652,6 +644,9 @@ int akm8963_get_data(struct smdk4x12_sensors_handlers *handlers,
case REL_Z:
event->magnetic.z = akm8963_convert(input_event.value);
break;
+ case REL_MISC:
+ event->magnetic.status = input_event.value;
+ break;
default:
continue;
}
@@ -661,9 +656,6 @@ int akm8963_get_data(struct smdk4x12_sensors_handlers *handlers,
}
} while (input_event.type != EV_SYN);
- if (data->orientation_sensor != NULL)
- orientation_fill(data->orientation_sensor, NULL, &event->magnetic);
-
return 0;
}