more audio hacking
diff --git a/liblight/lights.c b/liblight/lights.c
index 4c97681..c62182f 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -16,14 +16,12 @@
* limitations under the License.
*/
-
-// #define LOG_NDEBUG 0
-
#include <log/log.h>
#include <cutils/properties.h>
#include <dirent.h>
#include <fcntl.h>
+#include <linux/limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
@@ -38,45 +36,16 @@
#include <hardware/lights.h>
-#define CG_COLOR_ID_PROPERTY "ro.boot.hardware.color"
-
-/******************************************************************************/
-static pthread_once_t g_init = PTHREAD_ONCE_INIT;
-static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
-static int rgb_brightness_ratio = 255;
-
-char const*const BACKLIGHT_CLASS
- = "/sys/class/backlight";
-char const*const BACKLIGHT_CLASS_FSTRING
- = "/sys/class/backlight/%s/brightness";
+#define BACKLIGHT_CLASS "/sys/class/backlight"
+#define BACKLIGHT_CLASS_FSTRING "/sys/class/backlight/%s/brightness"
/**
* device methods
*/
-void init_globals(void)
-{
- char color_id_prop[PROPERTY_VALUE_MAX] = {""};
-
- // init the mutex
- pthread_mutex_init(&g_lock, NULL);
-
- // check CG color
- property_get(CG_COLOR_ID_PROPERTY, color_id_prop, "DEF00");
- if (strcmp(color_id_prop, "GRA00") == 0) {
- rgb_brightness_ratio = 25;
- } else if (strcmp(color_id_prop, "SLV00") == 0) {
- rgb_brightness_ratio = 15;
- } else if (strcmp(color_id_prop, "BLU00") == 0) {
- rgb_brightness_ratio = 15;
- } else {
- rgb_brightness_ratio = 20;
- }
-}
-
static bool findFirstBacklightDevice(char *filename) {
struct dirent *de;
- DIR *dir = opendir("/sys/class/backlight");
+ DIR *dir = opendir(BACKLIGHT_CLASS);
if (dir == NULL)
return NULL;
while((de = readdir(dir))) {
@@ -96,14 +65,15 @@
write_brightness(int value)
{
int fd;
- char brightness_path[4096];
- char filename[256];
+ char brightness_path[PATH_MAX];
+ char filename[NAME_MAX];
if (!findFirstBacklightDevice(filename)) {
- ALOGE("CA:: Couldn't find backlight brightness path");
+ ALOGE("Couldn't find backlight brightness path");
return -EINVAL;
}
- snprintf(brightness_path, 4096, BACKLIGHT_CLASS_FSTRING, filename);
+ ALOGI("Opening backlight device: %s", filename);
+ snprintf(brightness_path, PATH_MAX, BACKLIGHT_CLASS_FSTRING, filename);
fd = open(brightness_path, O_WRONLY);
if (fd >= 0) {
char buffer[20];
@@ -139,7 +109,7 @@
return -1;
}
- int brightness = rgb_to_brightness(state) << 4; // Scale up to 4095
+ int brightness = rgb_to_brightness(state) << 2; // Scale up to 1020
write_brightness(brightness);
return 0;
@@ -155,9 +125,6 @@
return 0;
}
-
-/******************************************************************************/
-
/**
* module methods
*/
@@ -167,7 +134,6 @@
struct hw_device_t** device)
{
(void)name;
- pthread_once(&g_init, init_globals);
struct light_device_t *dev = malloc(sizeof(struct light_device_t));