summaryrefslogtreecommitdiffstats
path: root/sensors/input.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/input.c
parent1e0be1496372b29e8c191568c9073d1342577ca9 (diff)
downloaddevice_samsung_n7100-replicant-6.0.zip
device_samsung_n7100-replicant-6.0.tar.gz
device_samsung_n7100-replicant-6.0.tar.bz2
sensors bringupreplicant-6.0
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/input.c')
-rw-r--r--sensors/input.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sensors/input.c b/sensors/input.c
index 5199b28..a370807 100644
--- a/sensors/input.c
+++ b/sensors/input.c
@@ -21,6 +21,7 @@
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
+#include <string.h>
#include <linux/ioctl.h>
#include <linux/input.h>
#include <linux/uinput.h>
@@ -44,7 +45,7 @@ void input_event_set(struct input_event *event, int type, int code, int value)
gettimeofday(&event->time, NULL);
}
-long int timestamp(struct timeval *time)
+int64_t timestamp(struct timeval *time)
{
if (time == NULL)
return -1;
@@ -52,7 +53,7 @@ long int timestamp(struct timeval *time)
return time->tv_sec * 1000000000LL + time->tv_usec * 1000;
}
-long int input_timestamp(struct input_event *event)
+int64_t input_timestamp(struct input_event *event)
{
if (event == NULL)
return -1;
@@ -88,6 +89,7 @@ int uinput_rel_create(const char *name)
rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X);
rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y);
rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z);
+ rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_MISC);
rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN);
if (rc < 0) {
@@ -213,10 +215,10 @@ int sysfs_path_prefix(char *name, char *path_prefix)
return -1;
}
-int sysfs_value_read(char *path)
+int64_t sysfs_value_read(char *path)
{
char buffer[100];
- int value;
+ int64_t value;
int fd = -1;
int rc;
int i;
@@ -236,7 +238,7 @@ int sysfs_value_read(char *path)
while (buffer[i] == ' ' || buffer[i] == '\t')
i++;
- value = atoi(&buffer[i]);
+ value = (int64_t)strtoimax(&buffer[i], NULL, 10);
goto complete;
error:
@@ -249,7 +251,7 @@ complete:
return value;
}
-int sysfs_value_write(char *path, int value)
+int sysfs_value_write(char *path, int64_t value)
{
char buffer[100];
int fd = -1;
@@ -262,7 +264,7 @@ int sysfs_value_write(char *path, int value)
if (fd < 0)
goto error;
- snprintf((char *) &buffer, sizeof(buffer), "%d\n", value);
+ snprintf((char *) &buffer, sizeof(buffer), "%" PRId64 "\n", value);
rc = write(fd, buffer, strlen(buffer));
if (rc < (int) strlen(buffer))