From 39e99623e0f5040ab002502c130a0858d985f73f Mon Sep 17 00:00:00 2001 From: Jan Altensen Date: Tue, 26 Nov 2019 20:34:28 +0100 Subject: [PATCH] samsung: power: dont depend on liblights_helper * this is partially a revert of 1226350ee7101a4dc42a4903e148f17c4bd54e4b Change-Id: I0ab7f6dc7642f7778f802e18b2f2dda7c11d9b3b --- power/Android.mk | 5 +++-- power/power.c | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/power/Android.mk b/power/Android.mk index 53f60b4..60c521d 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -20,10 +20,11 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := power.c -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/../hidl/light/include LOCAL_SHARED_LIBRARIES := liblog libcutils -LOCAL_STATIC_LIBRARIES := liblights_helper LOCAL_MODULE := power.$(TARGET_BOOTLOADER_BOARD_NAME) LOCAL_MODULE_RELATIVE_PATH := hw diff --git a/power/power.c b/power/power.c index f9b268c..f53f058 100644 --- a/power/power.c +++ b/power/power.c @@ -35,7 +35,7 @@ #include #include -#include +#include "samsung_lights.h" #include "samsung_power.h" @@ -210,6 +210,27 @@ static void send_boostpulse(int boostpulse_fd) } } +static int get_cur_panel_brightness() { + int ret = 0; + int read_status; + // brightness can range from 0 to 255, so max. 3 chars + '\0' + char panel_brightness[4]; + // for strtol + char *dummy; + const int base = 10; + + read_status = sysfs_read(PANEL_BRIGHTNESS_NODE, panel_brightness, sizeof(PANEL_BRIGHTNESS_NODE)); + if (read_status < 0) { + ALOGE("%s: Failed to read panel brightness from %s!\n", __func__, PANEL_BRIGHTNESS_NODE); + return -1; + } + + ret = strtol(panel_brightness, &dummy, base); + ALOGV("%s: Panel brightness is: %d", __func__, ret); + + return ret; +} + /********************************************************** *** POWER FUNCTIONS **********************************************************/ -- 2.20.1