summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXpLoDWilD <xplodgui@gmail.com>2012-07-07 22:58:23 +0200
committerXpLoDWilD <xplodgui@gmail.com>2012-07-07 23:02:29 +0200
commit86d0895f82ca01b07da6e0d1e5e37d26f5114333 (patch)
tree10cdf42ab901982a5d14a00960386ae89c8457ca
parent23280fc439163a1971956167217283c4ae70bce3 (diff)
downloadandroid_hardware_samsung-86d0895f82ca01b07da6e0d1e5e37d26f5114333.tar.gz
android_hardware_samsung-86d0895f82ca01b07da6e0d1e5e37d26f5114333.tar.bz2
android_hardware_samsung-86d0895f82ca01b07da6e0d1e5e37d26f5114333.zip
liblights: Fix reading of previous brightness value
Change-Id: Ie175521033b3a8d96197794cff1a2dce89e516c3
-rw-r--r--exynos4/exynos4x12/liblights/lights.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/exynos4/exynos4x12/liblights/lights.c b/exynos4/exynos4x12/liblights/lights.c
index e8336d2..2e5c029 100644
--- a/exynos4/exynos4x12/liblights/lights.c
+++ b/exynos4/exynos4x12/liblights/lights.c
@@ -89,6 +89,21 @@ static int write_int(char const *path, int value)
}
}
+static int read_int(char const *path)
+{
+ int fd;
+ char buffer[2];
+
+ fd = open(path, O_RDONLY);
+
+ if (fd >= 0) {
+ read(fd, buffer, 1);
+ }
+ close(fd);
+
+ return atoi(buffer);
+}
+
static int write_str(char const *path, const char* value)
{
int fd;
@@ -126,14 +141,14 @@ static int set_light_backlight(struct light_device_t *dev,
struct light_state_t const *state)
{
int err = 0;
- static int s_previous_brightness = -1;
int brightness = rgb_to_brightness(state);
+ int previous_brightness = read_int(PANEL_FILE);
pthread_mutex_lock(&g_lock);
+
err = write_int(PANEL_FILE, brightness);
- if (!s_previous_brightness && (brightness > 0)) {
+ if (!previous_brightness && (brightness > 0)) {
err = write_int(BUTTON_FILE, brightness > 0 ? 1 : 2);
- s_previous_brightness = brightness;
}
pthread_mutex_unlock(&g_lock);