diff --git a/liblights/Android.mk b/liblights/Android.mk index 08d7e87c..3acc7ba3 100644 --- a/liblights/Android.mk +++ b/liblights/Android.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2015 The CyanogenMod Project +# Copyright (C) 2015-2016 The CyanogenMod Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,16 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -LOCAL_PATH:= $(call my-dir) - ifneq ($(TARGET_PROVIDES_LIBLIGHT),true) +LOCAL_PATH := $(call my-dir) + include $(CLEAR_VARS) +LOCAL_SRC_FILES := lights.c + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include + +LOCAL_SHARED_LIBRARIES := liblog + LOCAL_MODULE := lights.$(TARGET_BOOTLOADER_BOARD_NAME) LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SHARED_LIBRARIES := liblog -LOCAL_SRC_FILES := lights.c LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/liblights/include/samsung_lights.h b/liblights/include/samsung_lights.h new file mode 100644 index 00000000..b853b0ed --- /dev/null +++ b/liblights/include/samsung_lights.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SAMSUNG_LIGHTS_H +#define SAMSUNG_LIGHTS_H + +/* + * Board specific nodes + * + * If your kernel exposes these controls in another place, you can either + * symlink to the locations given here, or override this header in your + * device tree. + */ +#define PANEL_BRIGHTNESS_NODE "/sys/class/backlight/panel/brightness" +#define BUTTON_BRIGHTNESS_NODE "/sys/class/sec/sec_touchkey/brightness" +#define LED_BLINK_NODE "/sys/class/sec/led/led_blink" + +#endif // SAMSUNG_LIGHTS_H diff --git a/liblights/lights.c b/liblights/lights.c index d439edad..6da32e2e 100644 --- a/liblights/lights.c +++ b/liblights/lights.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2013 The Android Open Source Project - * Copyright (C) 2015 The CyanogenMod Project + * Copyright (C) 2015-2016 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,7 @@ #include -#define PANEL_FILE "/sys/class/backlight/panel/brightness" -#define BUTTON_FILE "/sys/class/sec/sec_touchkey/brightness" -#define LED_BLINK "/sys/class/sec/led/led_blink" +#include "samsung_lights.h" #define COLOR_MASK 0x00ffffff @@ -116,7 +114,7 @@ static int set_light_backlight(struct light_device_t *dev __unused, int brightness = rgb_to_brightness(state); pthread_mutex_lock(&g_lock); - err = write_int(PANEL_FILE, brightness); + err = write_int(PANEL_BRIGHTNESS_NODE, brightness); pthread_mutex_unlock(&g_lock); return err; @@ -130,7 +128,7 @@ static int set_light_buttons(struct light_device_t* dev __unused, pthread_mutex_lock(&g_lock); - err = write_int(BUTTON_FILE, on ? 1 : 0); + err = write_int(BUTTON_BRIGHTNESS_NODE, on ? 1 : 0); pthread_mutex_unlock(&g_lock); @@ -179,7 +177,7 @@ static int write_leds(const struct led_config *led) blink[count+1] = '\0'; pthread_mutex_lock(&g_lock); - err = write_str(LED_BLINK, blink); + err = write_str(LED_BLINK_NODE, blink); pthread_mutex_unlock(&g_lock); return err;