summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2018-12-10 15:32:50 +0900
committerlokilee73 <changjoo.lee@samsung.com>2018-12-11 11:34:56 +0900
commita2c6e512d6abe676c201048c472df370e940aaa3 (patch)
tree7c48c51d02b5f9d576622d316faf46dc07b95d9a
parent45ba725e383151741273ba2eeef533a5f6dc4f04 (diff)
downloaddevice-tw3-a2c6e512d6abe676c201048c472df370e940aaa3.tar.gz
device-tw3-a2c6e512d6abe676c201048c472df370e940aaa3.tar.bz2
device-tw3-a2c6e512d6abe676c201048c472df370e940aaa3.zip
Add thermal and change display path for tw3
Change-Id: Ib012979941da88fd3852c57bd25fdb594a938a0c Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rwxr-xr-x[-rw-r--r--]CMakeLists.txt1
-rwxr-xr-x[-rw-r--r--]hw/display/display.c18
-rwxr-xr-xhw/thermal/CMakeLists.txt19
-rwxr-xr-xhw/thermal/thermal.c177
4 files changed, 203 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52d1a2a..47b02ce 100644..100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,3 +9,4 @@ ADD_SUBDIRECTORY(hw/external_connection)
ADD_SUBDIRECTORY(hw/touchscreen)
ADD_SUBDIRECTORY(hw/usb_gadget)
ADD_SUBDIRECTORY(hw/usb_client)
+ADD_SUBDIRECTORY(hw/thermal) \ No newline at end of file
diff --git a/hw/display/display.c b/hw/display/display.c
index 6266e67..0125bb3 100644..100755
--- a/hw/display/display.c
+++ b/hw/display/display.c
@@ -29,15 +29,11 @@
#define MODEL_NAME "http://tizen.org/system/model_name"
#ifndef BACKLIGHT_PATH
-#define BACKLIGHT_PATH "/sys/class/backlight/s6e36w1x01-bl"
+#define BACKLIGHT_PATH "/sys/class/backlight/s6e36w3x01-bl"
#endif
-#ifndef TW1_LCD_PATH
-#define TW1_LCD_PATH "/sys/class/lcd/s6e36w1x01"
-#endif
-
-#ifndef TW2_LCD_PATH
-#define TW2_LCD_PATH "/sys/class/lcd/s6e36w2x01"
+#ifndef TW3_LCD_PATH
+#define TW3_LCD_PATH "/sys/class/lcd/s6e36w3x01"
#endif
static int display_get_max_brightness(int *val)
@@ -113,11 +109,9 @@ static int display_get_state(enum display_state *state)
return r;
}
- if (!strncmp(model_name, "TW1", 3)) {
- r = sys_get_int(TW1_LCD_PATH"/lcd_power", &v);
- } else if (!strncmp(model_name, "TW2", 3)) {
- r = sys_get_int(TW2_LCD_PATH"/lcd_power", &v);
- } else
+ if (!strncmp(model_name, "TW3", 3))
+ r = sys_get_int(TW3_LCD_PATH"/lcd_power", &v);
+ else
r = -ENOENT;
if (r < 0) {
diff --git a/hw/thermal/CMakeLists.txt b/hw/thermal/CMakeLists.txt
new file mode 100755
index 0000000..1aa2e45
--- /dev/null
+++ b/hw/thermal/CMakeLists.txt
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(thermal C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(thermal_pkgs REQUIRED hwcommon dlog glib-2.0)
+
+FOREACH(flag ${thermal_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE thermal.c ../udev.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${thermal_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c
new file mode 100755
index 0000000..3027fb0
--- /dev/null
+++ b/hw/thermal/thermal.c
@@ -0,0 +1,177 @@
+/*
+ * device-node
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include <hw/thermal.h>
+#include <hw/shared.h>
+
+#define THERMAL_PATH "/sys/class/sec/temperature/ap_therm"
+
+static struct event_data {
+ ThermalUpdated updated_cb;
+ void *data;
+} edata = { 0, };
+
+static guint timer;
+
+static int thermal_get_state(struct thermal_info *info)
+{
+ int value;
+ FILE *fp;
+ char buf[32];
+ size_t len;
+
+ if (!info)
+ return -EINVAL;
+
+ fp = fopen(THERMAL_PATH, "r");
+ if (!fp) {
+ _E("Failed to open %s(%d)", THERMAL_PATH, errno);
+ return -errno;
+ }
+
+ len = fread(buf, 1, sizeof(buf) - 1, fp);
+ fclose(fp);
+ if (len == 0) {
+ _E("Failed to read %s(%d)", THERMAL_PATH, errno);
+ return -errno;
+ }
+ buf[len] = '\0';
+
+ if (!strstr(buf, "temp:")) {
+ _E("Invalid temparature value (%s)", buf);
+ return -EINVAL;
+ }
+
+ value = atoi(buf + 5); /* 5 == strlen("temp:") */
+
+ _I("AP temparature(%d)", value);
+
+ if (value < 46) {
+ info->state = THERMAL_STATE_NORMAL;
+ info->level = THERMAL_LEVEL_NORMAL;
+ return 0;
+ }
+
+ info->state = THERMAL_STATE_HIGH;
+
+ if (value < 48)
+ info->level = THERMAL_LEVEL_WARNING;
+ else if (value < 53)
+ info->level = THERMAL_LEVEL_CRITICAL;
+ else
+ info->level = THERMAL_LEVEL_POWEROFF;
+
+ return 0;
+}
+
+static gboolean thermal_timeout(gpointer data)
+{
+ struct thermal_info info;
+ int ret;
+
+ ret = thermal_get_state(&info);
+ if (ret < 0) {
+ _E("Failed to read thermal state (%d)", ret);
+ return G_SOURCE_CONTINUE;
+ }
+
+ if (edata.updated_cb)
+ edata.updated_cb(&info, edata.data);
+
+ return G_SOURCE_CONTINUE;
+}
+
+static int thermal_register_changed_event(ThermalUpdated updated_cb, void *data)
+{
+ if (timer)
+ g_source_remove(timer);
+
+ timer = g_timeout_add(10000, thermal_timeout, NULL);
+ if (timer == 0) {
+ _E("Failed to add timer for thermal");
+ return -ENOENT;
+ }
+
+ edata.updated_cb = updated_cb;
+ edata.data = data;
+
+ return 0;
+}
+
+static int thermal_unregister_changed_event(ThermalUpdated updated_cb)
+{
+ if (timer) {
+ g_source_remove(timer);
+ timer = 0;
+ }
+
+ edata.updated_cb = NULL;
+ edata.data = NULL;
+
+ return 0;
+}
+
+static int thermal_open(struct hw_info *info,
+ const char *id, struct hw_common **common)
+{
+ struct thermal_device *thermal_dev;
+
+ if (!info || !common)
+ return -EINVAL;
+
+ thermal_dev = calloc(1, sizeof(struct thermal_device));
+ if (!thermal_dev)
+ return -ENOMEM;
+
+ thermal_dev->common.info = info;
+ thermal_dev->register_changed_event
+ = thermal_register_changed_event;
+ thermal_dev->unregister_changed_event
+ = thermal_unregister_changed_event;
+ thermal_dev->get_state
+ = thermal_get_state;
+
+ *common = (struct hw_common *)thermal_dev;
+ return 0;
+}
+
+static int thermal_close(struct hw_common *common)
+{
+ if (!common)
+ return -EINVAL;
+
+ free(common);
+ return 0;
+}
+
+HARDWARE_MODULE_STRUCTURE = {
+ .magic = HARDWARE_INFO_TAG,
+ .hal_version = HARDWARE_INFO_VERSION,
+ .device_version = THERMAL_HARDWARE_DEVICE_VERSION,
+ .id = THERMAL_HARDWARE_DEVICE_ID,
+ .name = "thermal",
+ .open = thermal_open,
+ .close = thermal_close,
+};