diff options
author | Javi Ferrer <javi.f.o@gmail.com> | 2015-05-12 19:40:59 +0200 |
---|---|---|
committer | forkbomb <keepcalm444@gmail.com> | 2015-11-25 08:33:40 +1100 |
commit | 948970715990bde9caf07377f928530848d19a36 (patch) | |
tree | 8ed27e6116225749dab0ac6de29b640e9617bfab /libsensors/cm36651_light.c | |
parent | ef3bca4b0959df074d5b0867b95699c330b5779e (diff) | |
download | device_samsung_i9300-948970715990bde9caf07377f928530848d19a36.zip device_samsung_i9300-948970715990bde9caf07377f928530848d19a36.tar.gz device_samsung_i9300-948970715990bde9caf07377f928530848d19a36.tar.bz2 |
i9300: update libsensors from replicant
- Orientation sensor still broken
Change-Id: I7d20afbbc1f8b1ca5d046a38c0c3b7ce824c12cd
Diffstat (limited to 'libsensors/cm36651_light.c')
-rw-r--r-- | libsensors/cm36651_light.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/libsensors/cm36651_light.c b/libsensors/cm36651_light.c index 389f5b6..bab689a 100644 --- a/libsensors/cm36651_light.c +++ b/libsensors/cm36651_light.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Paul Kocialkowski + * Copyright (C) 2013 Paul Kocialkowski <contact@paulk.fr> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include <stdint.h> #include <fcntl.h> #include <errno.h> +#include <math.h> #include <sys/types.h> #include <linux/ioctl.h> #include <linux/input.h> @@ -27,18 +28,18 @@ #include <hardware/sensors.h> #include <hardware/hardware.h> -#define LOG_TAG "exynos_sensors" +#define LOG_TAG "smdk4x12_sensors" #include <utils/Log.h> -#include "exynos_sensors.h" +#include "smdk4x12_sensors.h" struct cm36651_light_data { char path_enable[PATH_MAX]; char path_delay[PATH_MAX]; }; -int cm36651_light_init(struct exynos_sensors_handlers *handlers, - struct exynos_sensors_device *device) +int cm36651_light_init(struct smdk4x12_sensors_handlers *handlers, + struct smdk4x12_sensors_device *device) { struct cm36651_light_data *data = NULL; char path[PATH_MAX] = { 0 }; @@ -85,7 +86,7 @@ error: return -1; } -int cm36651_light_deinit(struct exynos_sensors_handlers *handlers) +int cm36651_light_deinit(struct smdk4x12_sensors_handlers *handlers) { ALOGD("%s(%p)", __func__, handlers); @@ -103,8 +104,7 @@ int cm36651_light_deinit(struct exynos_sensors_handlers *handlers) return 0; } - -int cm36651_light_activate(struct exynos_sensors_handlers *handlers) +int cm36651_light_activate(struct smdk4x12_sensors_handlers *handlers) { struct cm36651_light_data *data; int rc; @@ -127,7 +127,7 @@ int cm36651_light_activate(struct exynos_sensors_handlers *handlers) return 0; } -int cm36651_light_deactivate(struct exynos_sensors_handlers *handlers) +int cm36651_light_deactivate(struct smdk4x12_sensors_handlers *handlers) { struct cm36651_light_data *data; int rc; @@ -150,7 +150,7 @@ int cm36651_light_deactivate(struct exynos_sensors_handlers *handlers) return 0; } -int cm36651_light_set_delay(struct exynos_sensors_handlers *handlers, long int delay) +int cm36651_light_set_delay(struct smdk4x12_sensors_handlers *handlers, long int delay) { struct cm36651_light_data *data; int rc; @@ -171,19 +171,15 @@ int cm36651_light_set_delay(struct exynos_sensors_handlers *handlers, long int d return 0; } -float cm36651_light_convert(int red, int green, int blue, int white) +float cm36651_light_convert(int value) { - return (float) white * 1.7f - 0.5f; + return (float) value * 1.7f - 0.5f; } -int cm36651_light_get_data(struct exynos_sensors_handlers *handlers, +int cm36651_light_get_data(struct smdk4x12_sensors_handlers *handlers, struct sensors_event_t *event) { struct input_event input_event; - int red = 0; - int green = 0; - int blue = 0; - int white = 0; int input_fd; int rc; @@ -196,6 +192,7 @@ int cm36651_light_get_data(struct exynos_sensors_handlers *handlers, if (input_fd < 0) return -EINVAL; + memset(event, 0, sizeof(struct sensors_event_t)); event->version = sizeof(struct sensors_event_t); event->sensor = handlers->handle; event->type = handlers->handle; @@ -206,26 +203,18 @@ int cm36651_light_get_data(struct exynos_sensors_handlers *handlers, break; if (input_event.type == EV_REL) { - if (input_event.code == REL_X) - red = input_event.value; - if (input_event.code == REL_Y) - green = input_event.value; - if (input_event.code == REL_Z) - blue = input_event.value; if (input_event.code == REL_MISC) - white = input_event.value; + event->light = cm36651_light_convert(input_event.value); } else if (input_event.type == EV_SYN) { if (input_event.code == SYN_REPORT) event->timestamp = input_timestamp(&input_event); } } while (input_event.type != EV_SYN); - event->distance = cm36651_light_convert(red, green, blue, white); - return 0; } -struct exynos_sensors_handlers cm36651_light = { +struct smdk4x12_sensors_handlers cm36651_light = { .name = "CM36651 Light", .handle = SENSOR_TYPE_LIGHT, .init = cm36651_light_init, |