pass: Remove unnecessary modules
authorWook Song <wook16.song@samsung.com>
Mon, 21 Nov 2016 05:48:00 +0000 (14:48 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 16 Jan 2017 11:35:37 +0000 (20:35 +0900)
This patch removes the dispaly, extcon, and power modules of deviced and
applies change 24b34852276fd4d6872e7d6d32387d8d4f8efdf7 ("power: systemd
dbus method and signal are used to check if booting is done") of
deviced to pass. Several dependencies between the core and these modules
are also eliminated.

Signed-off-by: Wook Song <wook16.song@samsung.com>
41 files changed:
CMakeLists.txt
packaging/pass.spec
scripts/pass.conf
src/core/boot.c [moved from src/power/boot.c with 99% similarity]
src/core/boot.h [moved from src/power/boot.h with 100% similarity]
src/core/main.c
src/display/auto-brightness.c [deleted file]
src/display/core.c [deleted file]
src/display/core.h [deleted file]
src/display/device-interface.c [deleted file]
src/display/device-interface.h [deleted file]
src/display/display-actor.c [deleted file]
src/display/display-actor.h [deleted file]
src/display/display-common.conf [deleted file]
src/display/display-dbus.c [deleted file]
src/display/display-ivi.conf [deleted file]
src/display/display-mobile.conf [deleted file]
src/display/display-ops.c [deleted file]
src/display/display-ops.h [deleted file]
src/display/display-tv.conf [deleted file]
src/display/display-wearable.conf [deleted file]
src/display/dpms-wayland-none.c [deleted file]
src/display/dpms-x-none.c [deleted file]
src/display/input.c [deleted file]
src/display/key-filter.c [deleted file]
src/display/lock-detector.c [deleted file]
src/display/lock-detector.h [deleted file]
src/display/poll.c [deleted file]
src/display/poll.h [deleted file]
src/display/setting.c [deleted file]
src/display/setting.h [deleted file]
src/display/state-tv.c [deleted file]
src/display/util.h [deleted file]
src/extcon/cradle.c [deleted file]
src/extcon/earjack.c [deleted file]
src/extcon/extcon.c [deleted file]
src/extcon/extcon.h [deleted file]
src/extcon/hdmi.c [deleted file]
src/power/power-handler.c [deleted file]
src/power/power-handler.h [deleted file]
src/shared/dbus.h

index e80927e..de19eec 100644 (file)
@@ -75,37 +75,16 @@ SET(SRCS
        src/core/main.c
        src/core/sig-handler.c
        src/core/udev.c
+       src/core/boot.c
        src/proc/cpu-info.c
        src/proc/proc-handler.c
-       src/time/time-handler.c
 )
 
-IF(EXTCON_MODULE STREQUAL on)
-       ADD_SOURCE(src/extcon EXTCON_SRCS)
-       SET(SRCS ${SRCS} ${EXTCON_SRCS})
-ENDIF()
-
 IF(LED_MODULE STREQUAL on)
        ADD_SOURCE(src/led LED_SRCS)
        SET(SRCS ${SRCS} ${LED_SRCS})
 ENDIF()
 
-IF(POWER_MODULE STREQUAL on)
-       ADD_SOURCE(src/power POWER_SRCS)
-       SET(SRCS ${SRCS} ${POWER_SRCS})
-ENDIF()
-
-IF(DISPLAY_MODULE STREQUAL on)
-       ADD_SOURCE(src/display DISPLAY_SRCS)
-       SET(SRCS ${SRCS} ${DISPLAY_SRCS})
-
-       IF("${DPMS}" STREQUAL "x")
-               SET(SRCS ${SRCS} src/display/dpms-x-none.c)
-       ELSEIF("${DPMS}" STREQUAL "wayland")
-               SET(SRCS ${SRCS} src/display/dpms-wayland-none.c)
-       ENDIF()
-ENDIF()
-
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced)
@@ -127,13 +106,6 @@ SET(PKG_MODULES
        mount
 )
 
-IF(DISPLAY_MODULE STREQUAL on)
-       IF("${DPMS}" STREQUAL "x")
-               SET(PKG_MODULES ${PKG_MODULES} x11 xext)
-       ENDIF()
-       SET(PKG_MODULES ${PKG_MODULES} libinput capi-system-sensor)
-ENDIF()
-
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
 
@@ -179,10 +151,6 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/deviced/ DESTINATION include/$
                PATTERN "*_doc.h" EXCLUDE
                PATTERN "*.h")
 
-IF(DISPLAY_MODULE STREQUAL on)
-       INSTALL_CONF(src/display display)
-ENDIF()
-
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${PROJECT_NAME}.conf DESTINATION /etc/dbus-1/system.d)
 
 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
index beec011..41c0397 100644 (file)
@@ -9,9 +9,6 @@
 %define libdaemon_name lib%{daemon_name}
 
 # display, extcon, power, usb are always enable
-%define display_module on
-%define extcon_module on
-%define power_module on
 
 # Support two pattern combination vibration
 %define standard_mix off
@@ -53,15 +50,6 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(eventsystem)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(hwcommon)
-%if %{?display_module} == on
-%if %{with x}
-BuildRequires:  pkgconfig(x11)
-BuildRequires:  pkgconfig(xext)
-%endif
-BuildRequires:  pkgconfig(libinput)
-BuildRequires: pkgconfig(capi-system-sensor)
-%endif
-
 Requires: %{name}-tools = %{version}-%{release}
 %{?systemd_requires}
 Requires(post): /usr/bin/vconftool
@@ -116,10 +104,7 @@ PASS systemd daemon.
        -DDPMS=%{DPMS} \
        -DENGINEER_MODE=%{engineer_mode} \
        -DPROFILE=%{profile} \
-       -DDISPLAY_MODULE=%{display_module} \
-       -DEXTCON_MODULE=%{extcon_module} \
        -DSTANDARD_MIX=%{standard_mix} \
-       -DPOWER_MODULE=%{power_module} \
        #eol
 
 %build
@@ -159,6 +144,3 @@ systemctl daemon-reload
 %{_unitdir}/sockets.target.wants/%{daemon_name}.socket
 %{_unitdir}/%{daemon_name}.service
 %{_unitdir}/%{daemon_name}.socket
-%if %{?display_module} == on
-%config %{_sysconfdir}/deviced/display.conf
-%endif
index 5432b90..b155179 100644 (file)
@@ -2,36 +2,7 @@
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
     <policy user="root">
-        <allow own="org.tizen.system.deviced"/>
-        <allow send_destination="org.tizen.system.deviced"/>
-    </policy>
-
-    <policy context="default">
-        <allow send_destination="org.tizen.system.deviced"/>
-
-        <deny send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.display"/>
-        <deny send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.power"/>
-        <deny send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.storage"/>
-        <deny send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.Led"/>
-
-        <check send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.display"
-                privilege="http://tizen.org/privilege/display"/>
-        <check send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.power"
-                privilege="http://tizen.org/privilege/power"/>
-        <check send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.storage"
-                privilege="http://tizen.org/privilege/externalstorage"/>
-        <check send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.storage"
-                privilege="http://tizen.org/privilege/mediastorage"/>
-        <check send_destination="org.tizen.system.deviced"
-                send_interface="org.tizen.system.deviced.Led"
-                privilege="http://tizen.org/privilege/led"/>
+        <allow own="org.tizen.system.pass"/>
+        <allow send_destination="org.tizen.system.pass"/>
     </policy>
 </busconfig>
similarity index 99%
rename from src/power/boot.c
rename to src/core/boot.c
index 33a72ce..9082fea 100644 (file)
@@ -24,7 +24,6 @@
 #include "core/log.h"
 #include "core/device-notifier.h"
 #include "core/common.h"
-#include "display/poll.h"
 #include "core/edbus-handler.h"
 #include "shared/deviced-systemd.h"
 
@@ -105,8 +104,10 @@ static void booting_done_received(void *data, DBusMessage *msg)
 
        remove_booting_done_handler(NULL);
 
+       /*
        _I("real booting done, unlock LCD_OFF");
        pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
+       */
 
        _I("signal booting done");
        broadcast_edbus_signal(DEVICED_PATH_CORE,
similarity index 100%
rename from src/power/boot.h
rename to src/core/boot.h
index f0ba440..c9de427 100644 (file)
 #include <fcntl.h>
 #include <sys/reboot.h>
 
-#include "display/core.h"
 #include "log.h"
 #include "common.h"
 #include "edbus-handler.h"
 #include "devices.h"
 #include "shared/dbus.h"
-#include "power/boot.h"
+#include "boot.h"
 #include "device-notifier.h"
 
 #define PIDFILE_PATH           "/var/run/.deviced.pid"
@@ -61,6 +60,7 @@ static int deviced_main(int argc, char **argv)
 
        edbus_init(NULL);
        devices_init(NULL);
+       add_booting_done_handler(NULL);
        ret = booting_finished();
        if (ret == 1) {
                _I("notify relaunch");
diff --git a/src/display/auto-brightness.c b/src/display/auto-brightness.c
deleted file mode 100644 (file)
index 6740d61..0000000
+++ /dev/null
@@ -1,663 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 <stdbool.h>
-#include <stdio.h>
-#include <math.h>
-#include <limits.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <vconf.h>
-#include <sensor.h>
-#include <Ecore.h>
-
-#include "util.h"
-#include "core.h"
-#include "display-ops.h"
-#include "device-node.h"
-#include "setting.h"
-#include "core/device-notifier.h"
-#include "core/config-parser.h"
-
-#define METHOD_CHECK_SUPPORTED "CheckSupported"
-
-#define DISP_FORCE_SHIFT       12
-#define DISP_FORCE_CMD(prop, force)    (((force) << DISP_FORCE_SHIFT) | prop)
-
-#define SAMPLING_INTERVAL      1       /* 1 sec */
-#define MAX_SAMPLING_COUNT     3
-#define MAX_FAULT              5
-#define DEFAULT_AUTOMATIC_BRT  5
-#define AUTOMATIC_DEVIDE_VAL   10
-#define AUTOMATIC_DELAY_TIME   0.5     /* 0.5 sec */
-
-#define RADIAN_VALUE           (57.2957)
-#define ROTATION_90            90
-#define WORKING_ANGLE_MIN      0
-#define WORKING_ANGLE_MAX      20
-
-#define BOARD_CONF_FILE "/etc/deviced/display.conf"
-
-#define ON_LUX         -1
-#define OFF_LUX                -1
-#define ON_COUNT       1
-#define OFF_COUNT      1
-
-static int (*_default_action) (int);
-static Ecore_Timer *alc_timeout_id = 0;
-static Ecore_Timer *update_timeout;
-static sensor_listener_h light_listener;
-static sensor_listener_h accel_listener;
-static int fault_count;
-static int automatic_brt = DEFAULT_AUTOMATIC_BRT;
-static int min_brightness = PM_MIN_BRIGHTNESS;
-static char *min_brightness_name = 0;
-
-/* light sensor */
-static float lmax, lmin;
-
-static bool update_working_position(void)
-{
-       sensor_event_s data;
-       int ret;
-       float x, y, z, pitch, realg;
-
-       if (!display_conf.accel_sensor_on)
-               return false;
-
-       ret = sensor_listener_read_data(accel_listener, &data);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Fail to get accelerometer data! %d", ret);
-               return true;
-       }
-
-       x = data.values[0];
-       y = data.values[1];
-       z = data.values[2];
-
-       realg = (float)sqrt((x * x) + (y * y) + (z * z));
-       pitch = ROTATION_90 - abs((int) (asin(z / realg) * RADIAN_VALUE));
-
-       _D("accel data [%f, %f, %f] - %f", x, y, z, pitch);
-
-       if (pitch >= WORKING_ANGLE_MIN && pitch <= WORKING_ANGLE_MAX)
-               return true;
-       return false;
-}
-
-static void alc_set_brightness(int setting, int value, float light)
-{
-       static float old;
-       int position, tmp_value = 0, ret;
-
-       ret = backlight_ops.get_brightness(&tmp_value);
-       if (ret < 0) {
-               _E("Fail to get display brightness!");
-               return;
-       }
-
-       if (value < min_brightness)
-               value = min_brightness;
-
-       if (tmp_value != value) {
-               if (!setting && min_brightness == PM_MIN_BRIGHTNESS &&
-                   display_conf.accel_sensor_on == true) {
-                       position = update_working_position();
-                       if (!position && (old > light)) {
-                               _D("It's not working position, "
-                                   "LCD isn't getting dark!");
-                               return;
-                       }
-               }
-               int diff, step;
-
-               diff = value - tmp_value;
-               if (abs(diff) < display_conf.brightness_change_step)
-                       step = (diff > 0 ? 1 : -1);
-               else
-                       step = (int)ceil(diff /
-                           (float)display_conf.brightness_change_step);
-
-               _D("%d", step);
-               while (tmp_value != value) {
-                       if (step == 0) break;
-
-                       tmp_value += step;
-                       if ((step > 0 && tmp_value > value) ||
-                           (step < 0 && tmp_value < value))
-                               tmp_value = value;
-
-                       backlight_ops.set_default_brt(tmp_value);
-                       backlight_ops.update();
-               }
-               _I("load light data:%f ,auto brt %d,min brightness %d,"
-                   "brightness %d", light, automatic_brt, min_brightness, value);
-               old = light;
-       }
-}
-
-static bool check_brightness_changed(int value)
-{
-       int i;
-       static int values[MAX_SAMPLING_COUNT], count = 0;
-
-       if (count >= MAX_SAMPLING_COUNT || count < 0)
-               count = 0;
-
-       values[count++] = value;
-
-       for (i = 0; i < MAX_SAMPLING_COUNT - 1; i++)
-               if (values[i] != values[i+1])
-                       return false;
-       return true;
-}
-
-static bool alc_update_brt(bool setting)
-{
-       int value = 0;
-       int ret = -1;
-       sensor_event_s light_data;
-       int index;
-       float light;
-
-       ret = sensor_listener_read_data(light_listener, &light_data);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to read light sensor data(%d)",ret);
-               goto out;
-       }
-
-       index = light_data.value_count - 1;
-       if (index < 0 || light_data.values[index] < 0) {
-               _E("Invalid light sensor data");
-               goto out;
-       }
-
-       light = light_data.values[index];
-       ret = backlight_ops.get_brightness_by_light_sensor(
-                       lmax, lmin, light, &value);
-       if (ret == -ENOTSUP) {
-               _E("Not supported to handle the light data");
-               goto out;
-       }
-
-       if (ret < 0 || value < PM_MIN_BRIGHTNESS || value > PM_MAX_BRIGHTNESS) {
-               _E("fail to load light data : light(%f), value(%d), ret(%d)", light, value, ret);
-               goto out;
-       }
-
-       fault_count = 0;
-
-       if (display_conf.continuous_sampling &&
-               !check_brightness_changed(value) &&
-               !setting)
-               return true;
-
-       alc_set_brightness(setting, value, light);
-
-       return true;
-
-out:
-       fault_count++;
-
-       if ((fault_count > MAX_FAULT) && !(pm_status_flag & PWROFF_FLAG)) {
-               if (alc_timeout_id) {
-                       ecore_timer_del(alc_timeout_id);
-                       alc_timeout_id = NULL;
-               }
-               vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
-                   SETTING_BRIGHTNESS_AUTOMATIC_OFF);
-               _E("Fault counts is over %d, disable automatic brightness", MAX_FAULT);
-               return false;
-       }
-       return true;
-}
-
-static bool alc_handler(void *data)
-{
-       if (pm_cur_state != S_NORMAL) {
-               if (alc_timeout_id > 0)
-                       ecore_timer_del(alc_timeout_id);
-               alc_timeout_id = NULL;
-               return EINA_FALSE;
-       }
-
-       if (!alc_update_brt(false))
-               return EINA_FALSE;
-
-       if (alc_timeout_id != 0)
-               return EINA_TRUE;
-
-       return EINA_FALSE;
-}
-
-static int alc_action(int timeout)
-{
-       /* sampling timer add */
-       if (alc_timeout_id == 0 && !(pm_status_flag & PWRSV_FLAG)) {
-               display_info.update_auto_brightness(true);
-
-               alc_timeout_id =
-                   ecore_timer_add(display_conf.lightsensor_interval,
-                           (Ecore_Task_Cb)alc_handler, NULL);
-       }
-
-       if (_default_action != NULL)
-               return _default_action(timeout);
-
-       /* unreachable code */
-       return -1;
-}
-
-static int connect_sensor(void)
-{
-       int ret;
-       sensor_h sensor;
-       sensor_h *list;
-       int cnt;
-
-       _I("connect with sensor fw");
-       /* light sensor */
-       ret = sensor_get_sensor_list(SENSOR_LIGHT, &list, &cnt);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to get light sensor list(%d)", ret);
-               goto error;
-       }
-
-       /* TODO
-        * Sensor apis will be fixed
-        * to provide which sensor is effective among sensors */
-       if (cnt == 3) /* three light sensors exist */
-               sensor = list[2];
-       else
-               sensor = list[0];
-
-       free(list);
-
-       ret = sensor_get_min_range(sensor, &lmin);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to get light sensor min range (%d)", ret);
-               goto error;
-       }
-       ret = sensor_get_max_range(sensor, &lmax);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to get light sensor max range (%d)", ret);
-               goto error;
-       }
-       _I("Light sensor min(%f), max(%f)", lmin, lmax);
-
-       ret = sensor_create_listener(sensor, &light_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to create listener(light)!");
-               goto error;
-       }
-       sensor_listener_set_option(light_listener, SENSOR_OPTION_ALWAYS_ON);
-       ret = sensor_listener_start(light_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to start light sensor!");
-               sensor_destroy_listener(light_listener);
-               light_listener = 0;
-               goto error;
-       }
-
-       if (!display_conf.accel_sensor_on)
-               goto success;
-
-       /* accelerometer sensor */
-       ret = sensor_get_default_sensor(SENSOR_ACCELEROMETER, &sensor);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to get default accel sensor!");
-               goto error;
-       }
-       ret = sensor_create_listener(&sensor, &accel_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to create listener(accel)!");
-               goto error;
-       }
-       sensor_listener_set_option(accel_listener, SENSOR_OPTION_ALWAYS_ON);
-       ret = sensor_listener_start(accel_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               _E("Failed to start accel sensor!");
-               sensor_destroy_listener(accel_listener);
-               accel_listener = 0;
-               goto error;
-       }
-
-success:
-       fault_count = 0;
-       return 0;
-
-error:
-       if (light_listener > 0) {
-               sensor_listener_stop(light_listener);
-               sensor_destroy_listener(light_listener);
-               light_listener = 0;
-       }
-       if (display_conf.accel_sensor_on && accel_listener > 0) {
-               sensor_listener_stop(accel_listener);
-               sensor_destroy_listener(accel_listener);
-               accel_listener = 0;
-       }
-       return -EIO;
-}
-
-static int disconnect_sensor(void)
-{
-       _I("disconnect with sensor fw");
-       /* light sensor*/
-       if (light_listener > 0) {
-               sensor_listener_stop(light_listener);
-               sensor_destroy_listener(light_listener);
-               light_listener = 0;
-       }
-
-       /* accelerometer sensor*/
-       if (display_conf.accel_sensor_on && accel_listener > 0) {
-               sensor_listener_stop(accel_listener);
-               sensor_destroy_listener(accel_listener);
-               accel_listener = 0;
-       }
-
-       if (_default_action != NULL) {
-               states[S_NORMAL].action = _default_action;
-               _default_action = NULL;
-       }
-       if (alc_timeout_id > 0) {
-               ecore_timer_del(alc_timeout_id);
-               alc_timeout_id = NULL;
-       }
-
-       return 0;
-}
-
-void set_brightness_changed_state(void)
-{
-       if (pm_status_flag & PWRSV_FLAG) {
-               pm_status_flag |= BRTCH_FLAG;
-               _D("brightness changed in low battery,"
-                   "escape dim state (light)");
-       }
-}
-
-static int set_autobrightness_state(int status)
-{
-       int ret = -1;
-       int brt = -1;
-       int default_brt = -1;
-
-       if (status == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
-               if (connect_sensor() < 0)
-                       return -1;
-
-               /* escape dim state if it's in low battery.*/
-               set_brightness_changed_state();
-
-               /* change alc action func */
-               if (_default_action == NULL)
-                       _default_action = states[S_NORMAL].action;
-               states[S_NORMAL].action = alc_action;
-
-               display_info.update_auto_brightness(true);
-
-               alc_timeout_id =
-                   ecore_timer_add(display_conf.lightsensor_interval,
-                           (Ecore_Task_Cb)alc_handler, NULL);
-       } else if (status == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
-               _I("auto brightness paused!");
-               disconnect_sensor();
-       } else {
-               disconnect_sensor();
-               /* escape dim state if it's in low battery.*/
-               set_brightness_changed_state();
-
-               ret = get_setting_brightness(&default_brt);
-               if (ret != 0 || (default_brt < PM_MIN_BRIGHTNESS || default_brt > PM_MAX_BRIGHTNESS)) {
-                       _I("fail to read vconf value for brightness");
-                       brt = PM_DEFAULT_BRIGHTNESS;
-                       if (default_brt < PM_MIN_BRIGHTNESS || default_brt > PM_MAX_BRIGHTNESS)
-                               vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
-                       default_brt = brt;
-               }
-
-               backlight_ops.set_default_brt(default_brt);
-               backlight_ops.update();
-       }
-
-       return 0;
-}
-
-static void set_alc_function(keynode_t *key_nodes, void *data)
-{
-       int status, ret;
-
-       if (key_nodes == NULL) {
-               _E("wrong parameter, key_nodes is null");
-               return;
-       }
-
-       status = vconf_keynode_get_int(key_nodes);
-
-       switch (status) {
-       case SETTING_BRIGHTNESS_AUTOMATIC_OFF:
-       case SETTING_BRIGHTNESS_AUTOMATIC_ON:
-       case SETTING_BRIGHTNESS_AUTOMATIC_PAUSE:
-               ret = set_autobrightness_state(status);
-               _D("set auto brightness : %d", ret);
-               break;
-       default:
-               _E("invalid value! %d", status);
-       }
-}
-
-static void set_alc_automatic_brt(keynode_t *key_nodes, void *data)
-{
-       if (key_nodes == NULL) {
-               _E("wrong parameter, key_nodes is null");
-               return;
-       }
-       automatic_brt = vconf_keynode_get_int(key_nodes) / AUTOMATIC_DEVIDE_VAL;
-       _D("automatic brt : %d", automatic_brt);
-
-       alc_update_brt(true);
-}
-
-static Eina_Bool update_handler(void *data)
-{
-       int ret, on;
-
-       update_timeout = NULL;
-
-       if (pm_cur_state != S_NORMAL)
-               return EINA_FALSE;
-
-       ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &on);
-       if (ret < 0 || on != SETTING_BRIGHTNESS_AUTOMATIC_ON)
-               return EINA_FALSE;
-
-       _D("auto brightness is working!");
-       alc_update_brt(true);
-
-       return EINA_FALSE;
-}
-
-static void update_auto_brightness(bool update)
-{
-       if (update_timeout) {
-               ecore_timer_del(update_timeout);
-               update_timeout = NULL;
-       }
-
-       if (update) {
-               update_timeout = ecore_timer_add(AUTOMATIC_DELAY_TIME,
-                   update_handler, NULL);
-       }
-}
-
-static int prepare_lsensor(void *data)
-{
-       int status, ret;
-       int brt = -1;
-
-       ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &status);
-
-       if (ret == 0 && status == SETTING_BRIGHTNESS_AUTOMATIC_ON)
-               set_autobrightness_state(status);
-
-       /* add auto_brt_setting change handler */
-       vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
-                                set_alc_function, NULL);
-
-       vconf_get_int(VCONFKEY_SETAPPL_LCD_AUTOMATIC_BRIGHTNESS, &brt);
-       if (brt < PM_MIN_BRIGHTNESS || brt > PM_MAX_BRIGHTNESS) {
-               _E("Failed to get automatic brightness!");
-       } else {
-               automatic_brt = brt / AUTOMATIC_DEVIDE_VAL;
-               _I("automatic brt init success %d", automatic_brt);
-       }
-
-       vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_AUTOMATIC_BRIGHTNESS,
-                               set_alc_automatic_brt, NULL);
-
-       return 0;
-}
-
-static void update_brightness_direct(void)
-{
-       int ret, status;
-
-       ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &status);
-       if (ret == 0 && status == SETTING_BRIGHTNESS_AUTOMATIC_ON)
-               alc_update_brt(true);
-}
-
-static int set_autobrightness_min(int val, char *name)
-{
-       if (!name)
-               return -EINVAL;
-
-       if (val < PM_MIN_BRIGHTNESS || val > PM_MAX_BRIGHTNESS)
-               return -EINVAL;
-
-       min_brightness = val;
-
-       if (min_brightness_name) {
-               free(min_brightness_name);
-               min_brightness_name = 0;
-       }
-       min_brightness_name = strndup(name, strlen(name));
-
-       update_brightness_direct();
-
-       _I("auto brightness min value changed! (%d, %s)",
-           min_brightness, min_brightness_name);
-
-       return 0;
-}
-
-static void reset_autobrightness_min(const char *sender, void *data)
-{
-       if (!sender)
-               return;
-
-       if (!min_brightness_name)
-               return;
-
-       if (strcmp(sender, min_brightness_name))
-               return;
-
-       _I("change to default %d -> %d, %s", min_brightness,
-           PM_MIN_BRIGHTNESS, min_brightness_name);
-       min_brightness = PM_MIN_BRIGHTNESS;
-       if (min_brightness_name) {
-               free(min_brightness_name);
-               min_brightness_name = 0;
-       }
-
-       update_brightness_direct();
-}
-
-static int lcd_changed_cb(void *data)
-{
-       int lcd_state;
-
-       if (!data)
-               return 0;
-       lcd_state = *(int *)data;
-       if (lcd_state == S_LCDOFF && alc_timeout_id > 0) {
-               ecore_timer_del(alc_timeout_id);
-               alc_timeout_id = NULL;
-       }
-
-       return 0;
-}
-
-static int booting_done_cb(void *data)
-{
-       int state;
-
-       if (!data)
-               return 0;
-
-       state = *(int *)data;
-       if (state != true)
-               return 0;
-
-       /* get light data from sensor fw */
-       prepare_lsensor(NULL);
-
-       return 0;
-}
-
-static void exit_lsensor(void)
-{
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
-           set_alc_function);
-
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_AUTOMATIC_BRIGHTNESS,
-           set_alc_automatic_brt);
-
-       set_autobrightness_state(SETTING_BRIGHTNESS_AUTOMATIC_OFF);
-}
-
-static void auto_brightness_init(void *data)
-{
-       display_info.update_auto_brightness = update_auto_brightness;
-       display_info.set_autobrightness_min = set_autobrightness_min;
-       display_info.reset_autobrightness_min = reset_autobrightness_min;
-
-       register_notifier(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done_cb);
-}
-
-static void auto_brightness_exit(void *data)
-{
-       exit_lsensor();
-
-       unregister_notifier(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
-       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done_cb);
-}
-
-static const struct display_ops display_autobrightness_ops = {
-       .name     = "auto-brightness",
-       .init     = auto_brightness_init,
-       .exit     = auto_brightness_exit,
-};
-
-DISPLAY_OPS_REGISTER(&display_autobrightness_ops)
diff --git a/src/display/core.c b/src/display/core.c
deleted file mode 100644 (file)
index 0aa2bd2..0000000
+++ /dev/null
@@ -1,2342 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-
-/**
- * @file       core.c
- * @brief      Power manager main loop.
- *
- * This file includes Main loop, the FSM, signal processing.
- */
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <vconf-keys.h>
-#include <Ecore.h>
-
-#include "util.h"
-#include "core.h"
-#include "device-node.h"
-#include "lock-detector.h"
-#include "display-ops.h"
-#include "core/devices.h"
-#include "core/device-notifier.h"
-#include "core/udev.h"
-#include "core/list.h"
-#include "core/common.h"
-#include "core/edbus-handler.h"
-#include "core/config-parser.h"
-#include "core/launch.h"
-#include "extcon/extcon.h"
-#include "power/power-handler.h"
-#include "dd-display.h"
-
-#define PM_STATE_LOG_FILE              "/var/log/pm_state.log"
-#define DISPLAY_CONF_FILE              "/etc/deviced/display.conf"
-
-/**
- * @addtogroup POWER_MANAGER
- * @{
- */
-
-#define SET_BRIGHTNESS_IN_BOOTLOADER   "/usr/bin/save_blenv SLP_LCD_BRIGHT"
-#define LOCK_SCREEN_INPUT_TIMEOUT      10000
-#define LOCK_SCREEN_CONTROL_TIMEOUT    5000
-#define DD_LCDOFF_INPUT_TIMEOUT                3000
-#define ALWAYS_ON_TIMEOUT                      3600000
-
-#define GESTURE_STR            "gesture"
-#define POWER_KEY_STR          "powerkey"
-#define TOUCH_STR              "touch"
-#define EVENT_STR              "event"
-#define TIMEOUT_STR            "timeout"
-#define UNKNOWN_STR            "unknown"
-
-unsigned int pm_status_flag;
-static int trans_condition;
-
-static void (*power_saving_func) (int onoff);
-static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-
-int pm_cur_state;
-int pm_old_state;
-Ecore_Timer *timeout_src_id;
-int system_wakeup_flag = false;
-static unsigned int custom_normal_timeout = 0;
-static unsigned int custom_dim_timeout = 0;
-static int custom_holdkey_block = false;
-static int custom_change_pid = -1;
-static char *custom_change_name;
-static bool hallic_open = true;
-static Ecore_Timer *lock_timeout_id;
-static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT;
-static struct timeval lcdon_tv;
-static int lcd_paneloff_mode = false;
-static int stay_touchscreen_off = false;
-static dd_list *lcdon_ops;
-static bool lcdon_broadcast = false;
-
-static bool touch_blocked = false;
-
-/* default transition, action fuctions */
-static int default_trans(int evt);
-static int default_action(int timeout);
-static int default_check(int curr, int next);
-
-static Eina_Bool del_normal_cond(void *data);
-static Eina_Bool del_dim_cond(void *data);
-static Eina_Bool del_off_cond(void *data);
-
-static int default_proc_change_state(unsigned int cond, pid_t pid);
-static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
-
-struct state states[S_END] = {
-       { S_START,    "S_START",    NULL,          NULL,           NULL,          NULL            },
-       { S_NORMAL,   "S_NORMAL",   default_trans, default_action, default_check, del_normal_cond },
-       { S_LCDDIM,   "S_LCDDIM",   default_trans, default_action, default_check, del_dim_cond    },
-       { S_LCDOFF,   "S_LCDOFF",   default_trans, default_action, default_check, del_off_cond    },
-       { S_STANDBY,  "S_STANDBY",  NULL,          NULL,           NULL,          NULL            },
-       { S_SLEEP,    "S_SLEEP",    default_trans, default_action, default_check, NULL            },
-       { S_POWEROFF, "S_POWEROFF", NULL,          NULL,           NULL,          NULL            },
-};
-
-static int trans_table[S_END][EVENT_END] = {
-       /* Timeout,   Input */
-       { S_START,    S_START    }, /* S_START */
-       { S_LCDDIM,   S_NORMAL   }, /* S_NORMAL */
-       { S_LCDOFF,   S_NORMAL   }, /* S_LCDDIM */
-       { S_SLEEP,    S_NORMAL   }, /* S_LCDOFF */
-       { S_SLEEP,    S_STANDBY  }, /* S_STANDBY */
-       { S_LCDOFF,   S_NORMAL   }, /* S_SLEEP */
-       { S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
-};
-
-enum signal_type {
-       SIGNAL_INVALID = 0,
-       SIGNAL_PRE,
-       SIGNAL_POST,
-       SIGNAL_MAX,
-};
-
-static const char *lcdon_sig_lookup[SIGNAL_MAX] = {
-       [SIGNAL_PRE]  = "LCDOn",
-       [SIGNAL_POST] = "LCDOnCompleted",
-};
-static const char *lcdoff_sig_lookup[SIGNAL_MAX] = {
-       [SIGNAL_PRE]  = "LCDOff",
-       [SIGNAL_POST] = "LCDOffCompleted",
-};
-
-#define SHIFT_UNLOCK           4
-#define SHIFT_CHANGE_STATE     7
-#define CHANGE_STATE_BIT       0xF00   /* 1111 0000 0000 */
-#define SHIFT_LOCK_FLAG        16
-#define SHIFT_CHANGE_TIMEOUT   20
-#define CUSTOM_TIMEOUT_BIT     0x1
-#define CUSTOM_HOLDKEY_BIT     0x2
-#define HOLD_KEY_BLOCK_BIT     0x1
-#define TIMEOUT_NONE           (-1)
-
-#define S_COVER_TIMEOUT                        8000
-#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT)
-#define BOOTING_DONE_WATING_TIME       60000   /* 1 minute */
-#define LOCK_TIME_WARNING              60      /* 60 seconds */
-
-#define ACTIVE_ACT "active"
-#define INACTIVE_ACT "inactive"
-
-#define LOCK_SCREEN_WATING_TIME                0.3     /* 0.3 second */
-#define LONG_PRESS_INTERVAL             2       /* 2 seconds */
-#define SAMPLING_INTERVAL              1       /* 1 sec */
-#define BRIGHTNESS_CHANGE_STEP         10
-#define LCD_ALWAYS_ON                  0
-#define ACCEL_SENSOR_ON                        1
-#define CONTINUOUS_SAMPLING            1
-#define LCDOFF_TIMEOUT                 500     /* milli second */
-
-#define DIFF_TIMEVAL_MS(a, b) \
-       (((a.tv_sec * 1000000 + a.tv_usec) - \
-       (b.tv_sec * 1000000 + b.tv_usec)) \
-       / 1000)
-
-struct display_config display_conf = {
-       .lock_wait_time         = LOCK_SCREEN_WATING_TIME,
-       .longpress_interval     = LONG_PRESS_INTERVAL,
-       .lightsensor_interval   = SAMPLING_INTERVAL,
-       .lcdoff_timeout         = LCDOFF_TIMEOUT,
-       .brightness_change_step = BRIGHTNESS_CHANGE_STEP,
-       .lcd_always_on          = LCD_ALWAYS_ON,
-       .framerate_app          = {0, 0, 0, 0},
-       .control_display        = 0,
-       .powerkey_doublepress   = 0,
-       .accel_sensor_on        = ACCEL_SENSOR_ON,
-       .continuous_sampling    = CONTINUOUS_SAMPLING,
-       .timeout_enable         = true,
-       .input_support          = true,
-};
-
-struct display_function_info display_info = {
-       .update_auto_brightness         = NULL,
-       .set_autobrightness_min         = NULL,
-       .reset_autobrightness_min       = NULL,
-       .face_detection                 = NULL,
-};
-
-typedef struct _pm_lock_node {
-       pid_t pid;
-       Ecore_Timer *timeout_id;
-       time_t time;
-       bool holdkey_block;
-       struct _pm_lock_node *next;
-       bool background;
-} PmLockNode;
-
-static PmLockNode *cond_head[S_END];
-
-static void set_process_active(bool flag, pid_t pid)
-{
-       char str[6];
-       char *arr[2];
-       int ret;
-
-       if (pid >= INTERNAL_LOCK_BASE)
-               return;
-
-       snprintf(str, sizeof(str), "%d", (int)pid);
-
-       arr[0] = (flag ? ACTIVE_ACT : INACTIVE_ACT);
-       arr[1] = str;
-
-       /* Send dbug to resourced */
-       ret = broadcast_edbus_signal(RESOURCED_PATH_PROCESS,
-           RESOURCED_INTERFACE_PROCESS, RESOURCED_METHOD_ACTIVE, "si", arr);
-       if (ret < 0)
-               _E("Fail to send dbus signal to resourced!!");
-}
-
-bool check_lock_state(int state)
-{
-       PmLockNode *t = cond_head[state];
-
-       while (t) {
-               if (t->background == false)
-                       return true;
-               t = t->next;
-       }
-
-       return false;
-}
-
-void change_state_action(enum state_t state, int (*func)(int timeout))
-{
-       _I("[%s] action is changed", states[state].name);
-       states[state].action = func;
-}
-
-void change_state_trans(enum state_t state, int (*func)(int evt))
-{
-       _I("[%s] trans is changed", states[state].name);
-       states[state].trans = func;
-}
-
-void change_state_check(enum state_t state, int (*func)(int curr, int next))
-{
-       _I("[%s] check is changed", states[state].name);
-       states[state].check = func;
-}
-
-void change_state_name(enum state_t state, char *name)
-{
-       _I("[%s] name is changed", states[state].name);
-       states[state].name = name;
-}
-
-void change_trans_table(enum state_t state, enum state_t next)
-{
-       _I("[%s] timeout trans table is changed", states[state].name);
-       trans_table[state][EVENT_TIMEOUT] = next;
-}
-
-void change_proc_change_state(int (*func)(unsigned int cond, pid_t pid))
-{
-       _I("proc change state is changed");
-       proc_change_state = func;
-}
-
-static void broadcast_lcd_on(enum signal_type type, enum device_flags flags)
-{
-       char *arr[1];
-       const char *signal;
-
-       if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) {
-               _E("invalid signal type %d", type);
-               return;
-       }
-
-       if (flags & LCD_ON_BY_GESTURE)
-               arr[0] = GESTURE_STR;
-       else if (flags & LCD_ON_BY_POWER_KEY)
-               arr[0] = POWER_KEY_STR;
-       else if (flags & LCD_ON_BY_EVENT)
-               arr[0] = EVENT_STR;
-       else if (flags & LCD_ON_BY_TOUCH)
-               arr[0] = TOUCH_STR;
-       else
-               arr[0] = UNKNOWN_STR;
-
-       signal = lcdon_sig_lookup[type];
-       _I("lcdstep : broadcast %s %s", signal, arr[0]);
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-               signal, "s", arr);
-}
-
-static void broadcast_lcd_off(enum signal_type type, enum device_flags flags)
-{
-       char *arr[1];
-       const char *signal;
-
-       if (type <= SIGNAL_INVALID || type >= SIGNAL_MAX) {
-               _E("invalid signal type %d", type);
-               return;
-       }
-
-       signal = lcdoff_sig_lookup[type];
-
-       if (flags & LCD_OFF_BY_POWER_KEY)
-               arr[0] = POWER_KEY_STR;
-       else if (flags & LCD_OFF_BY_TIMEOUT)
-               arr[0] = TIMEOUT_STR;
-       else if (flags & LCD_OFF_BY_EVENT)
-               arr[0] = EVENT_STR;
-       else
-               arr[0] = UNKNOWN_STR;
-
-       _I("lcdstep : broadcast %s", signal);
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-               signal, "s", arr);
-}
-
-static unsigned long get_lcd_on_flags(void)
-{
-       unsigned long flags = NORMAL_MODE;
-
-       if (lcd_paneloff_mode)
-               flags |= LCD_PANEL_OFF_MODE;
-
-       if (stay_touchscreen_off)
-               flags |= TOUCH_SCREEN_OFF_MODE;
-
-       return flags;
-}
-
-bool touch_event_blocked(void)
-{
-       return touch_blocked;
-}
-
-void lcd_on_procedure(int state, enum device_flags flag)
-{
-       dd_list *l = NULL;
-       const struct device_ops *ops = NULL;
-       unsigned long flags = get_lcd_on_flags();
-       flags |= flag;
-
-       /* send LCDOn dbus signal */
-       if (!lcdon_broadcast) {
-               broadcast_lcd_on(SIGNAL_PRE, flags);
-               lcdon_broadcast = true;
-       }
-
-       if (!(flags & LCD_PHASED_TRANSIT_MODE)) {
-               /* Update brightness level */
-               if (state == LCD_DIM)
-                       backlight_ops.dim();
-               else if (state == LCD_NORMAL)
-                       backlight_ops.update();
-       }
-
-       DD_LIST_FOREACH(lcdon_ops, l, ops)
-               ops->start(flags);
-
-       broadcast_lcd_on(SIGNAL_POST, flags);
-
-       if (CHECK_OPS(keyfilter_ops, backlight_enable))
-               keyfilter_ops->backlight_enable(true);
-
-       touch_blocked = false;
-}
-
-inline void lcd_off_procedure(enum device_flags flag)
-{
-       dd_list *l = NULL;
-       const struct device_ops *ops = NULL;
-       unsigned long flags = NORMAL_MODE;
-       flags |= flag;
-
-       touch_blocked = true;
-
-       if (lcdon_broadcast) {
-               broadcast_lcd_off(SIGNAL_PRE, flags);
-               lcdon_broadcast = false;
-       }
-       if (CHECK_OPS(keyfilter_ops, backlight_enable))
-               keyfilter_ops->backlight_enable(false);
-
-       DD_LIST_REVERSE_FOREACH(lcdon_ops, l, ops)
-               ops->stop(flags);
-
-       broadcast_lcd_off(SIGNAL_POST, flags);
-}
-
-void set_stay_touchscreen_off(int val)
-{
-       _D("stay touch screen off : %d", val);
-       stay_touchscreen_off = val;
-
-       lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
-       set_setting_pmstate(LCD_NORMAL);
-}
-
-void set_lcd_paneloff_mode(int val)
-{
-       _D("lcd paneloff mode : %d", val);
-       lcd_paneloff_mode = val;
-
-       lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
-       set_setting_pmstate(LCD_NORMAL);
-}
-
-int low_battery_state(int val)
-{
-       switch (val) {
-       case VCONFKEY_SYSMAN_BAT_POWER_OFF:
-       case VCONFKEY_SYSMAN_BAT_CRITICAL_LOW:
-       case VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF:
-               return true;
-       }
-       return false;
-}
-
-int get_hallic_open(void)
-{
-       return hallic_open;
-}
-
-static int refresh_app_cond()
-{
-       trans_condition = 0;
-
-       if (check_lock_state(S_NORMAL))
-               trans_condition = trans_condition | MASK_NORMAL;
-       if (check_lock_state(S_LCDDIM))
-               trans_condition = trans_condition | MASK_DIM;
-       if (check_lock_state(S_LCDOFF))
-               trans_condition = trans_condition | MASK_OFF;
-
-       return 0;
-}
-
-static void makeup_trans_condition(void)
-{
-       check_processes(S_NORMAL);
-       check_processes(S_LCDDIM);
-       check_processes(S_LCDOFF);
-       refresh_app_cond();
-}
-
-static PmLockNode *find_node(enum state_t s_index, pid_t pid)
-{
-       PmLockNode *t = cond_head[s_index];
-
-       while (t != NULL) {
-               if (t->pid == pid)
-                       break;
-               t = t->next;
-       }
-       return t;
-}
-
-static PmLockNode *add_node(enum state_t s_index, pid_t pid, Ecore_Timer *timeout_id,
-               bool holdkey_block)
-{
-       PmLockNode *n;
-       time_t now;
-
-       n = (PmLockNode *) malloc(sizeof(PmLockNode));
-       if (n == NULL) {
-               _E("Not enough memory, add cond. fail");
-               return NULL;
-       }
-
-       time(&now);
-       n->pid = pid;
-       n->timeout_id = timeout_id;
-       n->time = now;
-       n->holdkey_block = holdkey_block;
-       n->next = cond_head[s_index];
-       n->background = false;
-       cond_head[s_index] = n;
-
-       refresh_app_cond();
-       return n;
-}
-
-static int del_node(enum state_t s_index, PmLockNode *n)
-{
-       PmLockNode *t;
-       PmLockNode *prev;
-
-       if (n == NULL)
-               return 0;
-
-       t = cond_head[s_index];
-       prev = NULL;
-       while (t != NULL) {
-               if (t == n) {
-                       if (prev != NULL)
-                               prev->next = t->next;
-                       else
-                               cond_head[s_index] = cond_head[s_index]->next;
-                       /* delete timer */
-                       if (t->timeout_id)
-                               ecore_timer_del(t->timeout_id);
-                       free(t);
-                       break;
-               }
-               prev = t;
-               t = t->next;
-       }
-       refresh_app_cond();
-       return 0;
-}
-
-static void print_node(int next)
-{
-       PmLockNode *n;
-       char buf[30];
-       time_t now;
-       double diff;
-
-       if (next <= S_START || next >= S_END)
-               return;
-
-       time(&now);
-       n = cond_head[next];
-       while (n != NULL) {
-               diff = difftime(now, n->time);
-               ctime_r(&n->time, buf);
-
-               if (diff > LOCK_TIME_WARNING)
-                       _W("over %.0f s, pid: %5d, lock time: %s", diff, n->pid, buf);
-               else
-                       _I("pid: %5d, lock time: %s", n->pid, buf);
-
-               n = n->next;
-       }
-}
-
-void get_pname(pid_t pid, char *pname)
-{
-       char buf[PATH_MAX];
-       int cmdline, r;
-
-       if (pid >= INTERNAL_LOCK_BASE)
-               snprintf(buf, PATH_MAX, "/proc/%d/cmdline", getpid());
-       else
-               snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
-
-       cmdline = open(buf, O_RDONLY);
-       if (cmdline < 0) {
-               pname[0] = '\0';
-               _E("%d does not exist now(may be dead without unlock)", pid);
-               return;
-       }
-
-       r = read(cmdline, pname, PATH_MAX);
-       if ((r >= 0) && (r < PATH_MAX))
-               pname[r] = '\0';
-       else
-               pname[0] = '\0';
-
-       close(cmdline);
-}
-
-static void del_state_cond(void *data, enum state_t state)
-{
-       PmLockNode *tmp = NULL;
-       char pname[PATH_MAX];
-       pid_t pid;
-
-       if (!data)
-               return;
-
-       /* A passed data is a pid_t type data, not a 64bit data. */
-       pid = (pid_t)((intptr_t)data);
-       _I("delete prohibit dim condition by timeout (%d)", pid);
-
-       tmp = find_node(state, pid);
-       del_node(state, tmp);
-       get_pname(pid, pname);
-       set_unlock_time(pname, state);
-
-       if (!timeout_src_id)
-               states[pm_cur_state].trans(EVENT_TIMEOUT);
-
-       if (state == S_LCDOFF)
-               set_process_active(EINA_FALSE, pid);
-}
-
-static Eina_Bool del_normal_cond(void *data)
-{
-       del_state_cond(data, S_NORMAL);
-       return EINA_FALSE;
-}
-
-static Eina_Bool del_dim_cond(void *data)
-{
-       del_state_cond(data, S_LCDDIM);
-       return EINA_FALSE;
-}
-
-static Eina_Bool del_off_cond(void *data)
-{
-       del_state_cond(data, S_LCDOFF);
-       return EINA_FALSE;
-}
-
-/* timeout handler  */
-Eina_Bool timeout_handler(void *data)
-{
-       _I("Time out state %s\n", states[pm_cur_state].name);
-
-       if (timeout_src_id) {
-               ecore_timer_del(timeout_src_id);
-               timeout_src_id = NULL;
-       }
-
-       states[pm_cur_state].trans(EVENT_TIMEOUT);
-       return EINA_FALSE;
-}
-
-void reset_timeout(int timeout)
-{
-       if (!display_conf.timeout_enable)
-               return;
-
-       _I("Reset Timeout (%d)ms", timeout);
-       if (timeout_src_id != 0) {
-               ecore_timer_del(timeout_src_id);
-               timeout_src_id = NULL;
-       }
-
-       if (trans_table[pm_cur_state][EVENT_TIMEOUT] == pm_cur_state)
-               return;
-
-       if (timeout > 0)
-               timeout_src_id = ecore_timer_add(MSEC_TO_SEC((double)timeout),
-                   (Ecore_Task_Cb)timeout_handler, NULL);
-       else if (timeout == 0)
-               states[pm_cur_state].trans(EVENT_TIMEOUT);
-}
-
-/* get configurations from setting */
-static int get_lcd_timeout_from_settings(void)
-{
-       int i;
-       int val = 0;
-
-       for (i = 0; i < S_END; i++) {
-               switch (states[i].state) {
-               case S_NORMAL:
-                       get_run_timeout(&val);
-                       break;
-               case S_LCDDIM:
-                       get_dim_timeout(&val);
-                       break;
-               case S_LCDOFF:
-                       val = display_conf.lcdoff_timeout;
-                       break;
-               default:
-                       /* This state doesn't need to set time out. */
-                       val = 0;
-                       break;
-               }
-               if (val > 0)
-                       states[i].timeout = val;
-
-               _I("%s state : %d ms timeout", states[i].name,
-                       states[i].timeout);
-       }
-
-       return 0;
-}
-
-static void update_display_time(void)
-{
-       int run_timeout, val;
-
-       /* first priority : s cover */
-       if (!hallic_open) {
-               states[S_NORMAL].timeout = S_COVER_TIMEOUT;
-               _I("S cover closed : timeout is set by normal(%d ms)",
-                   S_COVER_TIMEOUT);
-               return;
-       }
-
-       /* second priority : custom timeout */
-       if (custom_normal_timeout > 0) {
-               states[S_NORMAL].timeout = custom_normal_timeout;
-               states[S_LCDDIM].timeout = custom_dim_timeout;
-               _I("CUSTOM : timeout is set by normal(%d ms), dim(%d ms)",
-                   custom_normal_timeout, custom_dim_timeout);
-               return;
-       }
-
-       /* third priority : lock state */
-       if ((get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
-           !get_lock_screen_bg_state()) {
-               /* timeout is different according to key or event. */
-               states[S_NORMAL].timeout = lock_screen_timeout;
-               _I("LOCK : timeout is set by normal(%d ms)",
-                   lock_screen_timeout);
-               return;
-       }
-
-       /* default setting */
-       get_run_timeout(&run_timeout);
-
-       /* for sdk
-        * if the run_timeout is zero, it regards AlwaysOn state
-        */
-       if (run_timeout == 0 || display_conf.lcd_always_on) {
-               run_timeout = ALWAYS_ON_TIMEOUT;
-               _I("LCD Always On");
-       }
-
-       states[S_NORMAL].timeout = run_timeout;
-
-       get_dim_timeout(&val);
-       states[S_LCDDIM].timeout = val;
-
-       _I("Normal: NORMAL timeout is set by %d ms", states[S_NORMAL].timeout);
-       _I("Normal: DIM timeout is set by %d ms", states[S_LCDDIM].timeout);
-}
-
-static void update_display_locktime(int time)
-{
-       lock_screen_timeout = time;
-       update_display_time();
-}
-
-
-void set_dim_state(bool on)
-{
-       _I("dim state is %d", on);
-       update_display_time();
-       states[pm_cur_state].trans(EVENT_INPUT);
-}
-
-
-void lcd_on_direct(enum device_flags flags)
-{
-       int ret, call_state;
-
-       if (power_ops.get_power_lock_support()
-           && pm_cur_state == S_SLEEP)
-               power_ops.power_lock();
-
-#ifdef MICRO_DD
-       _D("lcd is on directly");
-       gettimeofday(&lcdon_tv, NULL);
-       lcd_on_procedure(LCD_NORMAL, flags);
-       reset_timeout(DD_LCDOFF_INPUT_TIMEOUT);
-#else
-       ret = vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
-       if ((ret >= 0 && call_state != VCONFKEY_CALL_OFF) ||
-           (get_lock_screen_state() == VCONFKEY_IDLE_LOCK)) {
-               _D("LOCK state, lcd is on directly");
-               lcd_on_procedure(LCD_NORMAL, flags);
-       }
-       reset_timeout(display_conf.lcdoff_timeout);
-#endif
-       update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
-}
-
-static inline bool check_lcd_on(void)
-{
-       if (backlight_ops.get_lcd_power() != DPMS_ON)
-               return true;
-
-       return false;
-}
-
-int custom_lcdon(int timeout)
-{
-       struct state *st;
-
-       if (timeout <= 0)
-               return -EINVAL;
-
-       if (check_lcd_on() == true)
-               lcd_on_direct(LCD_ON_BY_GESTURE);
-
-       _I("custom lcd on %d ms", timeout);
-       if (set_custom_lcdon_timeout(timeout) == true)
-               update_display_time();
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_NORMAL;
-       st = &states[pm_cur_state];
-
-       /* enter action */
-       if (st->action) {
-               st->action(st->timeout);
-       }
-
-       return 0;
-}
-
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
-       struct state *st;
-
-       pm_old_state = pm_cur_state;
-       pm_cur_state = next;
-
-       st = &states[pm_cur_state];
-
-       if (st && st->action) {
-               if (timeout < 0)
-                       st->action(st->timeout);
-               else
-                       st->action(timeout);
-       }
-}
-
-static int default_proc_change_state(unsigned int cond, pid_t pid)
-{
-       enum state_t next;
-
-       next = GET_COND_STATE(cond);
-       if (pm_cur_state == next) {
-               _I("current state (%d) == next state (%d)", pm_cur_state, next);
-               return 0;
-       }
-
-       _I("Change State to %s (%d)", states[next].name, pid);
-
-       switch (next) {
-       case S_NORMAL:
-               if (check_lcd_on())
-                       lcd_on_direct(LCD_ON_BY_EVENT);
-               update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDDIM:
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_LCDOFF:
-               if (backlight_ops.get_lcd_power() != DPMS_OFF)
-                       lcd_off_procedure(LCD_OFF_BY_EVENT);
-               if (set_custom_lcdon_timeout(0))
-                       update_display_time();
-               default_proc_change_state_action(next, -1);
-               break;
-       case S_SLEEP:
-               _I("Dangerous requests.");
-               /* at first LCD_OFF and then goto sleep */
-               /* state transition */
-               default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
-               delete_condition(S_LCDOFF);
-               default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/* update transition condition for application requrements */
-static void update_lock_timer(PMMsg *data,
-               PmLockNode *node, Ecore_Timer *timeout_id)
-{
-       time_t now;
-
-       if (data->timeout > 0) {
-               time(&now);
-               node->time = now;
-       }
-
-       if (node->timeout_id) {
-               ecore_timer_del(node->timeout_id);
-               node->timeout_id = timeout_id;
-       }
-}
-
-static void proc_condition_lock(PMMsg *data)
-{
-       PmLockNode *tmp;
-       Ecore_Timer *cond_timeout_id = NULL;
-       char pname[PATH_MAX];
-       pid_t pid = data->pid;
-       enum state_t state;
-       int holdkey_block;
-
-       state = GET_COND_STATE(data->cond);
-       if (!state)
-               return;
-
-       get_pname(pid, pname);
-
-       if (state == S_LCDOFF &&
-               pm_cur_state == S_SLEEP)
-               proc_change_state(data->cond, getpid());
-
-       if (data->timeout > 0) {
-               /* To pass a pid_t data through the timer infrastructure
-                * without memory allocation, a pid_t data becomes typecast
-                * to intptr_t and void *(64bit) type. */
-               cond_timeout_id = ecore_timer_add(
-                               MSEC_TO_SEC((double)data->timeout),
-                               states[state].timeout_cb,
-                               (void*)((intptr_t)pid));
-               if (!cond_timeout_id)
-                       _E("Failed to register display timer");
-       }
-
-       holdkey_block = GET_COND_FLAG(data->cond) & PM_FLAG_BLOCK_HOLDKEY;
-
-       tmp = find_node(state, pid);
-       if (!tmp)
-               add_node(state, pid, cond_timeout_id, holdkey_block);
-       else {
-               update_lock_timer(data, tmp, cond_timeout_id);
-               tmp->holdkey_block = holdkey_block;
-       }
-
-       if (state == S_LCDOFF)
-               set_process_active(EINA_TRUE, pid);
-
-       /* for debug */
-       _SD("[%s] locked by pid %d - process %s holdkeyblock %d\n",
-                       states[state].name, pid, pname, holdkey_block);
-       set_lock_time(pname, state);
-
-       device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)true);
-}
-
-static void proc_condition_unlock(PMMsg *data)
-{
-       pid_t pid = data->pid;
-       enum state_t state;
-       PmLockNode *tmp;
-       char pname[PATH_MAX];
-
-       state = GET_COND_STATE(data->cond);
-       if (!state)
-               return;
-
-       get_pname(pid, pname);
-
-       tmp = find_node(state, pid);
-       del_node(state, tmp);
-
-       if (state == S_LCDOFF)
-               set_process_active(EINA_FALSE, pid);
-
-       _SD("[%s] unlocked by pid %d - process %s\n",
-                       states[state].name, pid, pname);
-       set_unlock_time(pname, state);
-
-       device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)false);
-}
-
-static int proc_condition(PMMsg *data)
-{
-       unsigned int flags;
-
-       if (IS_COND_REQUEST_LOCK(data->cond))
-               proc_condition_lock(data);
-
-       if (IS_COND_REQUEST_UNLOCK(data->cond))
-               proc_condition_unlock(data);
-
-       if (!display_conf.timeout_enable)
-               return 0;
-
-       flags = GET_COND_FLAG(data->cond);
-       if (flags == 0) {
-               /* guard time for suspend */
-               if (pm_cur_state == S_LCDOFF) {
-                       reset_timeout(states[S_LCDOFF].timeout);
-                       _I("Margin timeout (%d ms)", states[S_LCDOFF].timeout);
-               }
-       } else {
-               if (flags & PM_FLAG_RESET_TIMER) {
-                       reset_timeout(states[pm_cur_state].timeout);
-                       _I("Reset timeout (%d ms)", states[pm_cur_state].timeout);
-               }
-       }
-
-       if (!timeout_src_id)
-               states[pm_cur_state].trans(EVENT_TIMEOUT);
-
-       return 0;
-}
-
-/* If some changed, return 1 */
-int check_processes(enum state_t prohibit_state)
-{
-       PmLockNode *t = cond_head[prohibit_state];
-       PmLockNode *tmp = NULL;
-       int ret = 0;
-
-       while (t != NULL) {
-               if (t->pid < INTERNAL_LOCK_BASE && kill(t->pid, 0) == -1) {
-                       _E("%d process does not exist, delete the REQ"
-                               " - prohibit state %d ",
-                               t->pid, prohibit_state);
-                       if (t->pid == custom_change_pid) {
-                               get_lcd_timeout_from_settings();
-                               custom_normal_timeout = custom_dim_timeout = 0;
-                               custom_change_pid = -1;
-                       }
-                       tmp = t;
-                       ret = 1;
-               }
-               t = t->next;
-
-               if (tmp != NULL) {
-                       del_node(prohibit_state, tmp);
-                       tmp = NULL;
-               }
-       }
-
-       return ret;
-}
-
-int check_holdkey_block(enum state_t state)
-{
-       PmLockNode *t = cond_head[state];
-       int ret = 0;
-
-       _I("check holdkey block : state of %s", states[state].name);
-
-       if (custom_holdkey_block == true) {
-               _I("custom hold key blocked by pid(%d)",
-                       custom_change_pid);
-               return 1;
-       }
-
-       while (t != NULL) {
-               if (t->holdkey_block == true) {
-                       ret = 1;
-                       _I("Hold key blocked by pid(%d)!", t->pid);
-                       break;
-               }
-               t = t->next;
-       }
-
-       return ret;
-}
-
-int delete_condition(enum state_t state)
-{
-       PmLockNode *t = cond_head[state];
-       PmLockNode *tmp = NULL;
-       pid_t pid;
-       char pname[PATH_MAX];
-
-       _I("delete condition : state of %s", states[state].name);
-
-       while (t != NULL) {
-               if (t->timeout_id > 0) {
-                       ecore_timer_del(t->timeout_id);
-                       t->timeout_id = NULL;
-               }
-               tmp = t;
-               t = t->next;
-               pid = tmp->pid;
-               if (state == S_LCDOFF)
-                       set_process_active(EINA_FALSE, pid);
-               _I("delete node of pid(%d)", pid);
-               del_node(state, tmp);
-               get_pname(pid, pname);
-               set_unlock_time(pname, state-1);
-       }
-
-       return 0;
-}
-
-void update_lcdoff_source(int source)
-{
-       switch (source) {
-       case VCONFKEY_PM_LCDOFF_BY_TIMEOUT:
-               _I("LCD OFF by timeout");
-               break;
-       case VCONFKEY_PM_LCDOFF_BY_POWERKEY:
-               _I("LCD OFF by powerkey");
-               break;
-       default:
-               _E("Invalid value(%d)", source);
-               return;
-       }
-       vconf_set_int(VCONFKEY_PM_LCDOFF_SOURCE, source);
-}
-
-#ifdef ENABLE_PM_LOG
-
-typedef struct _pm_history {
-       time_t time;
-       enum pm_log_type log_type;
-       int keycode;
-} pm_history;
-
-static int max_history_count = MAX_LOG_COUNT;
-static pm_history pm_history_log[MAX_LOG_COUNT] = {{0, }, };
-static int history_count = 0;
-
-static const char history_string[PM_LOG_MAX][15] = {
-       "PRESS", "LONG PRESS", "RELEASE", "LCD ON", "LCD ON FAIL",
-       "LCD DIM", "LCD DIM FAIL", "LCD OFF", "LCD OFF FAIL", "SLEEP"};
-
-void pm_history_init()
-{
-       memset(pm_history_log, 0x0, sizeof(pm_history_log));
-       history_count = 0;
-       max_history_count = MAX_LOG_COUNT;
-}
-
-void pm_history_save(enum pm_log_type log_type, int code)
-{
-       time_t now;
-
-       time(&now);
-       pm_history_log[history_count].time = now;
-       pm_history_log[history_count].log_type = log_type;
-       pm_history_log[history_count].keycode = code;
-       history_count++;
-
-       if (history_count >= max_history_count)
-               history_count = 0;
-}
-
-void pm_history_print(int fd, int count)
-{
-       int start_index, index, i;
-       int ret;
-       char buf[255];
-       char time_buf[30];
-
-       if (count <= 0 || count > max_history_count)
-               return;
-
-       start_index = (history_count - count + max_history_count)
-                   % max_history_count;
-
-       for (i = 0; i < count; i++) {
-               index = (start_index + i) % max_history_count;
-
-               if (pm_history_log[index].time == 0)
-                       continue;
-
-               if (pm_history_log[index].log_type < PM_LOG_MIN ||
-                   pm_history_log[index].log_type >= PM_LOG_MAX)
-                       continue;
-               ctime_r(&pm_history_log[index].time, time_buf);
-               snprintf(buf, sizeof(buf), "[%3d] %15s %3d %s",
-                       index,
-                       history_string[pm_history_log[index].log_type],
-                       pm_history_log[index].keycode,
-                       time_buf);
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-       }
-}
-#endif
-
-void print_info(int fd)
-{
-       int s_index = 0;
-       char buf[255];
-       int i = 1;
-       int ret;
-       char pname[PATH_MAX];
-
-       if (fd < 0)
-               return;
-
-       snprintf(buf, sizeof(buf),
-               "\n==========================================="
-               "===========================\n");
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-       snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
-                states[S_NORMAL].timeout,
-                states[S_LCDDIM].timeout, states[S_LCDOFF].timeout);
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
-                (trans_condition & MASK_NORMAL) ? states[S_NORMAL].name : "-",
-                (trans_condition & MASK_DIM) ? states[S_LCDDIM].name : "-",
-                (trans_condition & MASK_OFF) ? states[S_LCDOFF].name : "-");
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       snprintf(buf, sizeof(buf), "Current State: %s\n",
-               states[pm_cur_state].name);
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       for (s_index = S_NORMAL; s_index < S_END; s_index++) {
-               PmLockNode *t;
-               char time_buf[30];
-               t = cond_head[s_index];
-
-               while (t != NULL) {
-                       get_pname((pid_t)t->pid, pname);
-                       ctime_r(&t->time, time_buf);
-                       snprintf(buf, sizeof(buf),
-                                " %d: [%s] locked by pid %d %s %s",
-                                i++, states[s_index].name, t->pid, pname, time_buf);
-                       ret = write(fd, buf, strlen(buf));
-                       if (ret < 0)
-                               _E("write() failed (%d)", errno);
-                       t = t->next;
-               }
-       }
-
-       print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
-       pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(void)
-{
-       int fd, ret;
-       char buf[255];
-       time_t now_time;
-       char time_buf[30];
-
-       _D("internal state is saved!");
-
-       time(&now_time);
-       ctime_r(&now_time, time_buf);
-
-       fd = open(PM_STATE_LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, 0644);
-       if (fd != -1) {
-               snprintf(buf, sizeof(buf),
-                       "\npm_state_log now-time : %d(s) %s\n\n",
-                       (int)now_time, time_buf);
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-
-               snprintf(buf, sizeof(buf), "pm_status_flag: %x\n", pm_status_flag);
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-
-               snprintf(buf, sizeof(buf), "screen lock status : %d\n",
-                       get_lock_screen_state());
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-               print_info(fd);
-               close(fd);
-       }
-
-       fd = open("/dev/console", O_WRONLY);
-       if (fd != -1) {
-               print_info(fd);
-               close(fd);
-       }
-}
-
-/* SIGHUP signal handler
- * For debug... print info to syslog
- */
-static void sig_hup(int signo)
-{
-       save_display_log();
-}
-
-int check_lcdoff_direct(void)
-{
-       int ret, lock, cradle;
-       int hdmi_state;
-
-       if (pm_old_state != S_NORMAL)
-               return false;
-
-       if (pm_cur_state != S_LCDDIM)
-               return false;
-
-       lock = get_lock_screen_state();
-       if (lock != VCONFKEY_IDLE_LOCK && hallic_open)
-               return false;
-
-       hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI);
-       if (hdmi_state)
-               return false;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &cradle);
-       if (ret >= 0 && cradle == DOCK_SOUND)
-               return false;
-
-       _D("Goto LCDOFF direct(%d,%d,%d)", lock, hdmi_state, cradle);
-
-       return true;
-}
-
-int check_lcdoff_lock_state(void)
-{
-       if (cond_head[S_LCDOFF] != NULL)
-               return true;
-
-       return false;
-}
-
-/*
- * default transition function
- *   1. call check
- *   2. transition
- *   3. call enter action function
- */
-static int default_trans(int evt)
-{
-       struct state *st = &states[pm_cur_state];
-       int next_state;
-
-       next_state = (enum state_t)trans_table[pm_cur_state][evt];
-
-       /* check conditions */
-       while (st->check && !st->check(pm_cur_state, next_state)) {
-               /* There is a condition. */
-               _I("(%s) locked. Trans to (%s) failed", states[pm_cur_state].name,
-                      states[next_state].name);
-               if (!check_processes(pm_cur_state)) {
-                       /* This is valid condition
-                        * The application that sent the condition is running now. */
-                       return -1;
-               }
-       }
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = next_state;
-       st = &states[pm_cur_state];
-
-       /* enter action */
-       if (st->action) {
-               if (pm_cur_state == S_LCDOFF)
-                       update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
-
-               if (pm_cur_state == S_NORMAL || pm_cur_state == S_LCDOFF)
-                       if (set_custom_lcdon_timeout(0) == true)
-                               update_display_time();
-
-               if (check_lcdoff_direct() == true) {
-                       /* enter next state directly */
-                       states[pm_cur_state].trans(EVENT_TIMEOUT);
-               } else {
-                       st->action(st->timeout);
-               }
-       }
-
-       return 0;
-}
-
-static Eina_Bool lcd_on_expired(void *data)
-{
-       int lock_state, ret;
-
-       if (lock_timeout_id)
-               lock_timeout_id = NULL;
-
-       /* check state of lock */
-       ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
-
-       if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK)
-               return EINA_FALSE;
-
-       /* lock screen is not launched yet, but lcd is on */
-       if (check_lcd_on() == true)
-               lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
-
-       return EINA_FALSE;
-}
-
-static inline void stop_lock_timer(void)
-{
-       if (lock_timeout_id) {
-               ecore_timer_del(lock_timeout_id);
-               lock_timeout_id = NULL;
-       }
-}
-
-static void check_lock_screen(void)
-{
-       int lock_setting, lock_state, app_state, ret;
-
-       stop_lock_timer();
-
-       ret = vconf_get_int(VCONFKEY_CALL_STATE, &app_state);
-       if (ret >= 0 && app_state != VCONFKEY_CALL_OFF)
-               goto lcd_on;
-
-       /* check setting of lock screen is enabled. */
-       ret = vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT,
-           &lock_setting);
-
-       /* check state of lock */
-       ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
-
-       if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK)
-               goto lcd_on;
-
-       /* Use time to check lock is done. */
-       lock_timeout_id = ecore_timer_add(display_conf.lock_wait_time,
-           (Ecore_Task_Cb)lcd_on_expired, (void*)NULL);
-
-       return;
-
-lcd_on:
-       if (check_lcd_on() == true)
-               lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
-}
-
-/* default enter action function */
-static int default_action(int timeout)
-{
-       int wakeup_count = -1;
-       time_t now;
-       double diff;
-       static time_t last_update_time = 0;
-       static int last_timeout = 0;
-       struct timeval now_tv;
-
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("display is not started!");
-               return -EINVAL;
-       }
-
-       if (pm_cur_state != S_SLEEP) {
-               if (pm_cur_state == S_NORMAL &&
-                   lcdon_tv.tv_sec != 0) {
-                       gettimeofday(&now_tv, NULL);
-                       timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
-                       lcdon_tv.tv_sec = 0;
-               }
-               /* set timer with current state timeout */
-               reset_timeout(timeout);
-
-               if (pm_cur_state == S_NORMAL) {
-                       time(&last_update_time);
-                       last_timeout = timeout;
-               } else {
-                       _I("timout set: %s state %d ms",
-                           states[pm_cur_state].name, timeout);
-               }
-       }
-
-       if (pm_cur_state != pm_old_state && pm_cur_state != S_SLEEP) {
-               if (power_ops.get_power_lock_support())
-                       power_ops.power_lock();
-               set_setting_pmstate(pm_cur_state);
-               device_notify(DEVICE_NOTIFIER_LCD, &pm_cur_state);
-       }
-
-       if (pm_old_state == S_NORMAL && pm_cur_state != S_NORMAL) {
-               time(&now);
-               diff = difftime(now, last_update_time);
-               _I("S_NORMAL is changed to %s [%d ms, %.0f s]",
-                   states[pm_cur_state].name, last_timeout, diff);
-       }
-
-       switch (pm_cur_state) {
-       case S_NORMAL:
-               /*
-                * normal state : backlight on and restore
-                * the previous brightness
-                */
-               if (pm_old_state == S_LCDOFF || pm_old_state == S_SLEEP)
-                       check_lock_screen();
-               else if (pm_old_state == S_LCDDIM)
-                       backlight_ops.update();
-
-               if (check_lcd_on() == true)
-                       lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
-               break;
-
-       case S_LCDDIM:
-               if (pm_old_state == S_NORMAL &&
-                   backlight_ops.get_custom_status())
-                       backlight_ops.save_custom_brightness();
-               /* lcd dim state : dim the brightness */
-               backlight_ops.dim();
-
-               if (pm_old_state == S_LCDOFF || pm_old_state == S_SLEEP)
-                       lcd_on_procedure(LCD_DIM, NORMAL_MODE);
-               break;
-
-       case S_LCDOFF:
-               if (pm_old_state != S_SLEEP && pm_old_state != S_LCDOFF) {
-                       stop_lock_timer();
-                       /* lcd off state : turn off the backlight */
-                       if (backlight_ops.get_lcd_power() != DPMS_OFF)
-                               lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-               }
-
-               if (backlight_ops.get_lcd_power() != DPMS_OFF
-                   || lcd_paneloff_mode)
-                       lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-               break;
-
-       case S_SLEEP:
-               if (pm_old_state != S_SLEEP && pm_old_state != S_LCDOFF)
-                       stop_lock_timer();
-
-               if (backlight_ops.get_lcd_power() != DPMS_OFF)
-                       lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-
-               if (!power_ops.get_power_lock_support()) {
-                       /* sleep state : set system mode to SUSPEND */
-                       if (power_ops.get_wakeup_count(&wakeup_count) < 0)
-                               _E("wakeup count read error");
-
-                       if (wakeup_count < 0) {
-                               _I("Wakup Event! Can not enter suspend mode.");
-                               goto go_lcd_off;
-                       }
-
-                       if (power_ops.set_wakeup_count(wakeup_count) < 0) {
-                               _E("wakeup count write error");
-                               goto go_lcd_off;
-                       }
-               }
-               goto go_suspend;
-       }
-
-       return 0;
-
-go_suspend:
-#ifdef ENABLE_PM_LOG
-       pm_history_save(PM_LOG_SLEEP, pm_cur_state);
-#endif
-       if (power_ops.get_power_lock_support()) {
-               if (power_ops.enable_autosleep)
-                       power_ops.enable_autosleep();
-
-               if (power_ops.power_unlock() < 0)
-                       _E("power unlock state error!");
-       } else {
-               power_ops.suspend();
-               _I("system wakeup!!");
-               system_wakeup_flag = true;
-               /* Resume !! */
-               if (power_ops.check_wakeup_src() == EVENT_DEVICE)
-                       /* system waked up by devices */
-                       states[pm_cur_state].trans(EVENT_DEVICE);
-               else
-                       /* system waked up by user input */
-                       states[pm_cur_state].trans(EVENT_INPUT);
-       }
-       return 0;
-
-go_lcd_off:
-       if (!power_ops.get_power_lock_support()) {
-               /* Resume !! */
-               states[pm_cur_state].trans(EVENT_DEVICE);
-       }
-       return 0;
-}
-
-/*
- * default check function
- *   return
- *    0 : can't transit, others : transitable
- */
-static int default_check(int curr, int next)
-{
-       int trans_cond;
-       int lock_state = -1;
-       int app_state = -1;
-
-       makeup_trans_condition();
-
-       trans_cond = trans_condition & MASK_BIT;
-
-       vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
-       if (lock_state == VCONFKEY_IDLE_LOCK && curr != S_LCDOFF) {
-               vconf_get_int(VCONFKEY_CALL_STATE, &app_state);
-               if (app_state == VCONFKEY_CALL_OFF) {
-                       _I("default_check:LOCK STATE, it's transitable");
-                       return 1;
-               }
-       }
-
-       if (next == S_NORMAL) /* S_NORMAL is exceptional */
-               return 1;
-
-       switch (curr) {
-       case S_NORMAL:
-               trans_cond = trans_cond & MASK_NORMAL;
-               break;
-       case S_LCDDIM:
-               trans_cond = trans_cond & MASK_DIM;
-               break;
-       case S_LCDOFF:
-               trans_cond = trans_cond & MASK_OFF;
-               break;
-       default:
-               trans_cond = 0;
-               break;
-       }
-
-       if (trans_cond != 0) {
-               print_node(curr);
-               return 0;
-       }
-
-       return 1;               /* transitable */
-}
-
-static void default_saving_mode(int onoff)
-{
-       if (onoff) {
-               pm_status_flag |= PWRSV_FLAG;
-       } else {
-               pm_status_flag &= ~PWRSV_FLAG;
-       }
-       if (pm_cur_state == S_NORMAL)
-               backlight_ops.update();
-}
-
-static int poll_callback(int condition, PMMsg *data)
-{
-       static time_t last_t;
-       time_t now;
-
-       if (status != DEVICE_OPS_STATUS_START) {
-               _E("display logic is not started!");
-               return -ECANCELED;
-       }
-
-       if (condition == INPUT_POLL_EVENT) {
-               if (pm_cur_state == S_LCDOFF || pm_cur_state == S_SLEEP)
-                       _I("Power key input");
-               time(&now);
-               if (last_t != now ||
-                   pm_cur_state == S_LCDOFF ||
-                   pm_cur_state == S_SLEEP) {
-                       states[pm_cur_state].trans(EVENT_INPUT);
-                       last_t = now;
-               }
-       }
-
-       if (condition == PM_CONTROL_EVENT) {
-               proc_condition(data);
-
-               if (IS_COND_REQUEST_CHANGE(data->cond))
-                       proc_change_state(data->cond, data->pid);
-       }
-
-       return 0;
-}
-
-static int update_setting(int key_idx, int val)
-{
-       char buf[PATH_MAX];
-
-       switch (key_idx) {
-       case SETTING_TO_NORMAL:
-               update_display_time();
-               states[pm_cur_state].trans(EVENT_INPUT);
-               break;
-       case SETTING_HALLIC_OPEN:
-               hallic_open = val;
-               update_display_time();
-               if (pm_cur_state == S_NORMAL || pm_cur_state == S_LCDDIM)
-                       states[pm_cur_state].trans(EVENT_INPUT);
-               else if (pm_cur_state == S_SLEEP && hallic_open)
-                       proc_change_state(S_LCDOFF, getpid());
-               break;
-       case SETTING_LOW_BATT:
-               if (low_battery_state(val)) {
-                       if (!(pm_status_flag & CHRGR_FLAG))
-                               power_saving_func(true);
-                       pm_status_flag |= LOWBT_FLAG;
-               } else {
-                       if (pm_status_flag & PWRSV_FLAG)
-                               power_saving_func(false);
-                       pm_status_flag &= ~LOWBT_FLAG;
-                       pm_status_flag &= ~BRTCH_FLAG;
-                       vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM,
-                           false);
-               }
-               break;
-       case SETTING_CHARGING:
-               if (val) {
-                       if (pm_status_flag & LOWBT_FLAG) {
-                               power_saving_func(false);
-                               pm_status_flag &= ~LOWBT_FLAG;
-                       }
-                       pm_status_flag |= CHRGR_FLAG;
-               } else {
-                       int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
-                       vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
-                               &bat_state);
-                       if (low_battery_state(bat_state)) {
-                               power_saving_func(true);
-                               pm_status_flag |= LOWBT_FLAG;
-                       }
-                       pm_status_flag &= ~CHRGR_FLAG;
-               }
-               break;
-       case SETTING_BRT_LEVEL:
-               if (pm_status_flag & PWRSV_FLAG) {
-                       pm_status_flag |= BRTCH_FLAG;
-                       vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM,
-                           true);
-                       _I("brightness changed in low battery,"
-                               "escape dim state");
-               }
-               backlight_ops.set_default_brt(val);
-               snprintf(buf, sizeof(buf), "%d", val);
-               _D("Brightness set in bl : %d", val);
-               launch_evenif_exist(SET_BRIGHTNESS_IN_BOOTLOADER, buf);
-               break;
-       case SETTING_LOCK_SCREEN:
-               set_lock_screen_state(val);
-               if (val == VCONFKEY_IDLE_UNLOCK) {
-                       if (CHECK_OPS(keyfilter_ops, backlight_enable))
-                               keyfilter_ops->backlight_enable(false);
-               }
-
-               /* LCD on if lock screen show before waiting time */
-               if (pm_cur_state == S_NORMAL &&
-                   val == VCONFKEY_IDLE_LOCK &&
-                   backlight_ops.get_lcd_power() != DPMS_ON)
-                       lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
-               stop_lock_timer();
-               update_display_time();
-               if (pm_cur_state == S_NORMAL) {
-                       states[pm_cur_state].trans(EVENT_INPUT);
-               }
-               break;
-       case SETTING_LOCK_SCREEN_BG:
-               set_lock_screen_bg_state(val);
-               update_display_time();
-               if (pm_cur_state == S_NORMAL) {
-                       states[pm_cur_state].trans(EVENT_INPUT);
-               }
-               break;
-       case SETTING_POWEROFF:
-               switch (val) {
-               case POWER_OFF_NONE:
-               case POWER_OFF_POPUP:
-                       pm_status_flag &= ~PWROFF_FLAG;
-                       break;
-               case POWER_OFF_DIRECT:
-               case POWER_OFF_RESTART:
-                       pm_status_flag |= PWROFF_FLAG;
-                       break;
-               }
-               break;
-       case SETTING_POWER_CUSTOM_BRIGHTNESS:
-               if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON)
-                       backlight_ops.set_custom_status(true);
-               else
-                       backlight_ops.set_custom_status(false);
-               break;
-
-       default:
-               return -1;
-       }
-       return 0;
-}
-
-static void check_seed_status(void)
-{
-       int ret = -1;
-       int tmp = 0;
-       int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
-       int brt = 0;
-       int lock_state = -1;
-
-       /* Charging check */
-       if ((get_charging_status(&tmp) == 0) && (tmp > 0)) {
-               pm_status_flag |= CHRGR_FLAG;
-       }
-
-       ret = get_setting_brightness(&tmp);
-       if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
-               _I("fail to read vconf value for brightness");
-               brt = PM_DEFAULT_BRIGHTNESS;
-               if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)
-                       vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
-               tmp = brt;
-       }
-       _I("Set brightness from Setting App. %d", tmp);
-       backlight_ops.set_default_brt(tmp);
-
-       vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
-       if (low_battery_state(bat_state)) {
-               if (!(pm_status_flag & CHRGR_FLAG)) {
-                       power_saving_func(true);
-                       pm_status_flag |= LOWBT_FLAG;
-               }
-       }
-
-       /* lock screen check */
-       ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
-       set_lock_screen_state(lock_state);
-       if (lock_state == VCONFKEY_IDLE_LOCK) {
-               states[S_NORMAL].timeout = lock_screen_timeout;
-               _I("LCD NORMAL timeout is set by %d ms"
-                       " for lock screen", lock_screen_timeout);
-       }
-
-       return;
-}
-
-static void init_lcd_operation(void)
-{
-       const struct device_ops *ops = NULL;
-
-       ops = find_device("touchscreen");
-       if (!check_default(ops))
-               DD_LIST_APPEND(lcdon_ops, ops);
-
-       ops = find_device("touchkey");
-       if (!check_default(ops))
-               DD_LIST_APPEND(lcdon_ops, ops);
-
-       ops = find_device("display");
-       if (!check_default(ops))
-               DD_LIST_APPEND(lcdon_ops, ops);
-}
-
-static void exit_lcd_operation(void)
-{
-       dd_list *l = NULL;
-       dd_list *l_next = NULL;
-       const struct device_ops *ops = NULL;
-
-       DD_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops)
-               DD_LIST_REMOVE_LIST(lcdon_ops, l);
-}
-
-enum {
-       INIT_SETTING = 0,
-       INIT_INTERFACE,
-       INIT_POLL,
-       INIT_FIFO,
-       INIT_DBUS,
-       INIT_END
-};
-
-static const char *errMSG[INIT_END] = {
-       [INIT_SETTING] = "setting init error",
-       [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error",
-       [INIT_POLL] = "input devices poll init error",
-       [INIT_FIFO] = "FIFO poll init error",
-       [INIT_DBUS] = "d-bus init error",
-};
-
-int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name)
-{
-       if (on == 0 && dim == 0) {
-               _I("LCD timeout changed : default setting");
-               custom_normal_timeout = custom_dim_timeout = 0;
-       } else if (on < 0 || dim < 0) {
-               _E("fail to set value (%d,%d)", on, dim);
-               return -EINVAL;
-       } else {
-               _I("LCD timeout changed : on(%ds), dim(%ds)", on, dim);
-               custom_normal_timeout = SEC_TO_MSEC(on);
-               custom_dim_timeout = SEC_TO_MSEC(dim);
-       }
-       /* Apply new backlight time */
-       update_display_time();
-       if (pm_cur_state == S_NORMAL)
-               states[pm_cur_state].trans(EVENT_INPUT);
-
-       if (holdkey_block) {
-               custom_holdkey_block = true;
-               _I("hold key disabled !");
-       } else {
-               custom_holdkey_block = false;
-               _I("hold key enabled !");
-       }
-
-       if (custom_change_name) {
-               free(custom_change_name);
-               custom_change_name = 0;
-       }
-
-       if (custom_normal_timeout == 0 &&
-           custom_dim_timeout == 0 &&
-           !holdkey_block)
-               return 0;
-
-       custom_change_name = strndup(name, strlen(name));
-       if (!custom_change_name) {
-               _E("Malloc falied!");
-               custom_normal_timeout = custom_dim_timeout = 0;
-               custom_holdkey_block = false;
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-void reset_lcd_timeout(const char *sender, void *data)
-{
-       if (!sender)
-               return;
-
-       if (!custom_change_name)
-               return;
-
-       if (strcmp(sender, custom_change_name))
-               return;
-
-       _I("reset lcd timeout %s: set default timeout", sender);
-
-       free(custom_change_name);
-       custom_change_name = 0;
-       custom_normal_timeout = custom_dim_timeout = 0;
-       custom_holdkey_block = false;
-
-       update_display_time();
-       if (pm_cur_state == S_NORMAL) {
-               states[pm_cur_state].trans(EVENT_INPUT);
-       }
-}
-
-static int booting_done(void *data)
-{
-       static bool done = false;
-
-       if (data != NULL) {
-               done = *(int*)data;
-               if (done)
-                       return 0;
-               _I("booting done, unlock LCD_OFF");
-               pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
-       }
-
-       return 0;
-}
-
-static int process_background(void *data)
-{
-       pid_t pid;
-       PmLockNode *node;
-
-       pid = *(pid_t *)data;
-
-       node = find_node(S_NORMAL, pid);
-       if (node) {
-               node->background = true;
-               _I("%d pid is background, then PM will be unlocked LCD_NORMAL", pid);
-       }
-
-       return 0;
-}
-
-static int process_foreground(void *data)
-{
-       pid_t pid;
-       PmLockNode *node;
-
-       pid = *(pid_t *)data;
-
-       node = find_node(S_NORMAL, pid);
-       if (node) {
-               node->background = false;
-               _I("%d pid is foreground, then PM will be maintained locked LCD_NORMAL", pid);
-       }
-
-       return 0;
-}
-
-static int display_load_config(struct parse_result *result, void *user_data)
-{
-       struct display_config *c = user_data;
-
-       _D("%s,%s,%s", result->section, result->name, result->value);
-
-       if (!c)
-               return -EINVAL;
-
-       if (!MATCH(result->section, "Display"))
-               return 0;
-
-       if (MATCH(result->name, "LockScreenWaitingTime")) {
-               SET_CONF(c->lock_wait_time, atof(result->value));
-               _D("lock wait time is %.3f", c->lock_wait_time);
-       } else if (MATCH(result->name, "LongPressInterval")) {
-               SET_CONF(c->longpress_interval, atof(result->value));
-               _D("long press interval is %.3f", c->longpress_interval);
-       } else if (MATCH(result->name, "LightSensorSamplingInterval")) {
-               SET_CONF(c->lightsensor_interval, atof(result->value));
-               _D("lightsensor interval is %.3f", c->lightsensor_interval);
-       } else if (MATCH(result->name, "LCDOffTimeout")) {
-               SET_CONF(c->lcdoff_timeout, atoi(result->value));
-               _D("lcdoff timeout is %d ms", c->lcdoff_timeout);
-       } else if (MATCH(result->name, "BrightnessChangeStep")) {
-               SET_CONF(c->brightness_change_step, atoi(result->value));
-               _D("brightness change step is %d", c->brightness_change_step);
-       } else if (MATCH(result->name, "LCDAlwaysOn")) {
-               c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("LCD always on is %d", c->lcd_always_on);
-       } else if (MATCH(result->name, "ChangedFrameRateAllowed")) {
-               if (strstr(result->value, "setting")) {
-                       c->framerate_app[REFRESH_SETTING] = 1;
-                       _D("framerate app is Setting");
-               }
-               if (strstr(result->value, "all")) {
-                       memset(c->framerate_app, 1, sizeof(c->framerate_app));
-                       _D("framerate app is All");
-               }
-       } else if (MATCH(result->name, "ControlDisplay")) {
-               c->control_display = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("ControlDisplay is %d", c->control_display);
-       } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) {
-               c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress);
-       } else if (MATCH(result->name, "AccelSensorOn")) {
-               c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("AccelSensorOn is %d", c->accel_sensor_on);
-       } else if (MATCH(result->name, "ContinuousSampling")) {
-               c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("ContinuousSampling is %d", c->continuous_sampling);
-       } else if (MATCH(result->name, "TimeoutEnable")) {
-               c->timeout_enable = (MATCH(result->value, "yes") ? true : false);
-               _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled");
-       } else if (MATCH(result->name, "InputSupport")) {
-               c->input_support = (MATCH(result->value, "yes") ? true : false);
-               _D("Input is %s", c->input_support ? "supported" : "NOT supported");
-       }
-
-       return 0;
-}
-
-static bool check_wm_ready(void)
-{
-       if (access("/run/.wm_ready", F_OK) == 0) {
-               _I("Window manager is ready");
-               return true;
-       }
-
-       _I("Window manager is not ready");
-       return false;
-}
-
-static gboolean lcd_on_wm_ready(gpointer data)
-{
-       int timeout;
-
-       if (!check_wm_ready())
-               return G_SOURCE_CONTINUE;
-
-       switch (pm_cur_state) {
-       case S_NORMAL:
-       case S_LCDDIM:
-               lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
-               if (display_conf.timeout_enable) {
-                       timeout = states[S_NORMAL].timeout;
-                       /* check minimun lcd on time */
-                       if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
-                               timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
-                       reset_timeout(timeout);
-               }
-               break;
-       default:
-               break;
-       }
-
-       return G_SOURCE_REMOVE;
-}
-
-static void add_timer_for_wm_ready(void)
-{
-       guint id = g_timeout_add(500/* milliseconds */, lcd_on_wm_ready, NULL);
-       if (id == 0)
-               _E("Failed to add wm_ready timeout");
-}
-
-/**
- * Power manager Main
- *
- */
-static int display_probe(void *data)
-{
-       /**
-        * load display service
-        * if there is no display shared library,
-        * deviced does not provide any method and function of display.
-        */
-       return display_service_load();
-}
-
-static void display_init(void *data)
-{
-       int ret, i;
-       unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
-       int timeout = 0;
-       bool wm_ready;
-
-       _I("Start power manager");
-
-       signal(SIGHUP, sig_hup);
-
-       power_saving_func = default_saving_mode;
-
-       /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
-       if (ret < 0)
-               _W("Failed to load %s, %d Use default value!",
-                   DISPLAY_CONF_FILE, ret);
-
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-       register_notifier(DEVICE_NOTIFIER_PROCESS_BACKGROUND, process_background);
-       register_notifier(DEVICE_NOTIFIER_PROCESS_FOREGROUND, process_foreground);
-
-       for (i = INIT_SETTING; i < INIT_END; i++) {
-               switch (i) {
-               case INIT_SETTING:
-                       ret = init_setting(update_setting);
-                       break;
-               case INIT_INTERFACE:
-                       if (display_conf.timeout_enable)
-                               get_lcd_timeout_from_settings();
-                       ret = init_sysfs(flags);
-                       break;
-               case INIT_POLL:
-                       _I("input init");
-                       pm_callback = poll_callback;
-                       if (display_conf.input_support)
-                               ret = init_input();
-                       else
-                               ret = 0;
-                       break;
-               case INIT_DBUS:
-                       _I("dbus init");
-                       ret = init_pm_dbus();
-                       break;
-               }
-               if (ret != 0) {
-                       _E("%s", errMSG[i]);
-                       break;
-               }
-       }
-
-       if (i == INIT_END) {
-               display_ops_init(NULL);
-#ifdef ENABLE_PM_LOG
-               pm_history_init();
-#endif
-               init_lcd_operation();
-               check_seed_status();
-
-               /* wm_ready needs to be checked
-                * since display manager can be launched later than deviced.
-                * In the case, display cannot be turned on at the first booting */
-               wm_ready = check_wm_ready();
-               if (wm_ready)
-                       lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
-               else
-                       add_timer_for_wm_ready();
-
-               if (display_conf.lcd_always_on) {
-                       _I("LCD always on!");
-                       trans_table[S_NORMAL][EVENT_TIMEOUT] = S_NORMAL;
-               }
-
-               if (flags & WITHOUT_STARTNOTI) {        /* start without noti */
-                       _I("Start Power managing without noti");
-                       pm_cur_state = S_NORMAL;
-                       set_setting_pmstate(pm_cur_state);
-
-                       if (display_conf.timeout_enable) {
-                               timeout = states[S_NORMAL].timeout;
-                               /* check minimun lcd on time */
-                               if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
-                                       timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
-
-                               reset_timeout(timeout);
-                       }
-
-                       status = DEVICE_OPS_STATUS_START;
-                       /*
-                        * Lock lcd off until booting is done.
-                        * deviced guarantees all booting script is executing.
-                        * Last script of booting unlocks this suspend blocking state.
-                        */
-                       pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
-                           STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
-               }
-
-               if (display_conf.input_support)
-                       if (CHECK_OPS(keyfilter_ops, init))
-                               keyfilter_ops->init();
-       }
-}
-
-static void display_exit(void *data)
-{
-       int i = INIT_END;
-
-       status = DEVICE_OPS_STATUS_STOP;
-
-       /* Set current state to S_NORMAL */
-       pm_cur_state = S_NORMAL;
-       set_setting_pmstate(pm_cur_state);
-       /* timeout is not needed */
-       reset_timeout(TIMEOUT_NONE);
-
-       if (CHECK_OPS(keyfilter_ops, exit))
-               keyfilter_ops->exit();
-
-       display_ops_exit(NULL);
-
-       for (i = i - 1; i >= INIT_SETTING; i--) {
-               switch (i) {
-               case INIT_SETTING:
-                       exit_setting();
-                       break;
-               case INIT_INTERFACE:
-                       exit_sysfs();
-                       break;
-               case INIT_POLL:
-                       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-                       unregister_notifier(DEVICE_NOTIFIER_PROCESS_BACKGROUND, process_background);
-                       unregister_notifier(DEVICE_NOTIFIER_PROCESS_FOREGROUND, process_foreground);
-
-                       exit_input();
-                       break;
-               }
-       }
-
-       exit_lcd_operation();
-       free_lock_info_list();
-
-       /* free display service */
-       display_service_free();
-
-       _I("Stop power manager");
-}
-
-static int display_start(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       backlight_ops.standby(true);
-               else
-                       /* normal lcd on */
-                       backlight_ops.on(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       if (status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
-
-       return 0;
-}
-
-static int display_stop(enum device_flags flags)
-{
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               backlight_ops.off(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       if (status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
-
-       return 0;
-}
-
-static int display_status(void)
-{
-       return status;
-}
-
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       .name     = "display",
-       .probe    = display_probe,
-       .init     = display_init,
-       .exit     = display_exit,
-       .start    = display_start,
-       .stop     = display_stop,
-       .status   = display_status,
-};
-
-DEVICE_OPS_REGISTER(&display_device_ops)
-
-/**
- * @}
- */
diff --git a/src/display/core.h b/src/display/core.h
deleted file mode 100644 (file)
index 45e96d6..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/**
- * @file       core.h
- * @brief       Power manager main loop header file
- */
-#ifndef __POWER_MANAGER_H__
-#define __POWER_MANAGER_H__
-
-#include "poll.h"
-#include "device-interface.h"
-#include "setting.h"
-
-#define WITHOUT_STARTNOTI      0x1
-#define MASK_BIT    0x7                /* 111 */
-#define MASK_NORMAL 0x1                /* 001 */
-#define MASK_DIM    0x2                /* 010 */
-#define MASK_OFF    0x4                /* 100 */
-
-#define VCALL_FLAG             0x00000001
-#define LOWBT_FLAG             0x00000100
-#define CHRGR_FLAG             0x00000200
-#define PWRSV_FLAG             0x00000400
-#define BRTCH_FLAG             0x00002000
-#define PWROFF_FLAG            0x00004000
-#define DIMSTAY_FLAG   0x00008000
-
-#define DEFAULT_NORMAL_TIMEOUT 30
-
-#define MASK32                 0xffffffff
-
-#define CHECK_OPS(d, op) (d != NULL && d->op != NULL)
-
-#ifdef ENABLE_PM_LOG
-#define MAX_LOG_COUNT 250
-
-enum pm_log_type {
-       PM_LOG_MIN = 0,
-       PM_LOG_KEY_PRESS = PM_LOG_MIN,  /* key log */
-       PM_LOG_KEY_LONG_PRESS,
-       PM_LOG_KEY_RELEASE,
-       PM_LOG_LCD_ON,                  /* lcd log */
-       PM_LOG_LCD_ON_FAIL,
-       PM_LOG_LCD_DIM,
-       PM_LOG_LCD_DIM_FAIL,
-       PM_LOG_LCD_OFF,
-       PM_LOG_LCD_OFF_FAIL,
-       PM_LOG_SLEEP,
-       PM_LOG_MAX
-};
-
-void pm_history_save(enum pm_log_type, int);
-#endif
-
-extern unsigned int pm_status_flag;
-
-/*
- * State enumeration
- */
-enum state_t {
-       S_START,
-       S_NORMAL,               /*< normal state */
-       S_LCDON = S_NORMAL, /*< LCD on == normal state*/
-       S_LCDDIM,               /*< LCD dimming */
-       S_LCDOFF,               /*< LCD off */
-       S_STANDBY,              /*< Standby */
-       S_SLEEP,                /*< system suspend */
-       S_SUSPEND = S_SLEEP, /*< Suspend == Sleep state */
-       S_POWEROFF,             /*< Power off */
-       S_END
-};
-
-/*
- * Global variables
- *   pm_cur_state   : current state
- *   states      : state definitions
- *   trans_table : state transition table
- */
-extern int pm_cur_state;
-extern int pm_old_state;
-
-/*
- * @brief State structure
- */
-struct state {
-       enum state_t state;           /**< state number */
-       char *name;                   /**< state name (string) */
-       int (*trans) (int evt);       /**< transition function pointer */
-       int (*action) (int timeout);  /**< enter action */
-       int (*check) (int curr, int next); /**< transition check function */
-       Ecore_Task_Cb timeout_cb;
-       int timeout;
-};
-extern struct state states[S_END];
-
-/*
- * @brief Configuration structure
- */
-struct display_config {
-       double lock_wait_time;
-       double longpress_interval;
-       double lightsensor_interval;
-       int lcdoff_timeout;
-       int brightness_change_step;
-       int lcd_always_on;
-       int framerate_app[4];
-       int control_display;
-       int powerkey_doublepress;
-       int alpm_on;
-       int accel_sensor_on;
-       int continuous_sampling;
-       bool timeout_enable;
-       bool input_support;
-};
-
-/*
- * Global variables
- *   display_conf : configuration of display
- */
-extern struct display_config display_conf;
-
-/*
- * @brief Display Extension features
- */
-struct display_function_info {
-       void (*update_auto_brightness)(bool);
-       int (*set_autobrightness_min)(int, char *);
-       void (*reset_autobrightness_min)(const char *, void *data);
-       int (*face_detection)(int, int, int);
-};
-
-extern struct display_function_info display_info;
-
-struct display_keyfilter_ops {
-       void (*init)(void);
-       void (*exit)(void);
-       int (*check)(void *, int);
-       void (*set_powerkey_ignore)(int);
-       int (*powerkey_lcdoff)(void);
-       void (*backlight_enable)(bool);
-};
-
-extern const struct display_keyfilter_ops *keyfilter_ops;
-
-/* If the bit in a condition variable is set,
- *  we cannot transit the state until clear this bit. */
-int check_processes(enum state_t prohibit_state);
-extern struct state state[S_END];
-void reset_lcd_timeout(const char *sender, void *data);
-int check_lcdoff_lock_state(void);
-
-/* setting.c */
-int get_lock_screen_bg_state(void);
-int set_custom_lcdon_timeout(int timeout);
-void set_lock_screen_state(int state);
-void set_lock_screen_bg_state(bool state);
-
-/* core.c */
-void change_state_action(enum state_t state, int (*func)(int timeout));
-void change_state_trans(enum state_t state, int (*func)(int evt));
-void change_state_check(enum state_t state, int (*func)(int curr, int next));
-void change_state_name(enum state_t state, char *name);
-void change_trans_table(enum state_t state, enum state_t next);
-void change_proc_change_state(int (*func)(unsigned int cond, pid_t pid));
-
-bool check_lock_state(int state);
-
-int delete_condition(enum state_t state);
-void update_lcdoff_source(int source);
-int low_battery_state(int val);
-int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name);
-void save_display_log(void);
-int custom_lcdon(int timeout);
-void set_stay_touchscreen_off(int val);
-void set_lcd_paneloff_mode(int val);
-void lcd_on_direct(enum device_flags flags);
-void lcd_off_procedure(enum device_flags flag);
-int check_holdkey_block(enum state_t state);
-bool touch_event_blocked(void);
-
-/* poll.c */
-int check_dimstay(int next_state, int flag);
-
-/* display-dbus.c */
-int init_pm_dbus(void);
-
-/**
- * @}
- */
-
-#endif
diff --git a/src/display/device-interface.c b/src/display/device-interface.c
deleted file mode 100644 (file)
index f43256b..0000000
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2015 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 <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <math.h>
-#include <assert.h>
-#include <errno.h>
-#include <hw/display.h>
-
-#include "core/log.h"
-#include "core/devices.h"
-#include "core/common.h"
-#include "util.h"
-#include "device-interface.h"
-#include "vconf.h"
-#include "core.h"
-#include "device-node.h"
-
-#define TOUCH_ON       1
-#define TOUCH_OFF      0
-
-#define LCD_PHASED_MIN_BRIGHTNESS      1
-#define LCD_PHASED_MAX_BRIGHTNESS      100
-#define LCD_PHASED_CHANGE_STEP         5
-#define LCD_PHASED_DELAY               35000 /* microsecond */
-
-#define POWER_AUTOSLEEP_PATH    "/sys/power/autosleep"
-#define POWER_LOCK_PATH         "/sys/power/wake_lock"
-#define POWER_UNLOCK_PATH       "/sys/power/wake_unlock"
-#define POWER_WAKEUP_PATH       "/sys/power/wakeup_count"
-#define POWER_STATE_PATH        "/sys/power/state"
-
-enum {
-       POWER_UNLOCK = 0,
-       POWER_LOCK,
-};
-
-struct _backlight_ops backlight_ops;
-struct _power_ops power_ops;
-
-static bool custom_status;
-static int custom_brightness;
-static int force_brightness;
-static int default_brightness;
-
-static struct display_device *display_dev;
-
-#ifdef PROFILE_TV
-#include <sys/ioctl.h>
-#define PANEL_PATH          "/dev/tztv_frc"
-#define FRC_IOCTL_CTRL_PVCC    _IOWR('f', 0xAD, int)
-static int bl_onoff(int on)
-{
-       int fd, ret;
-       int value;
-
-       switch (on) {
-       case DPMS_ON:
-               value = 1;
-               break;
-       case DPMS_OFF:
-       case DPMS_STANDBY:
-               value = 0;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       fd = open(PANEL_PATH, O_RDWR);
-       if (fd == -1) {
-               ret = -errno;
-               _E("Failed to open panel path (%s, ret:%d)", PANEL_PATH, ret);
-               return ret;
-       }
-
-       ret = ioctl(fd, FRC_IOCTL_CTRL_PVCC, &value);
-       close(fd);
-
-       if (ret < 0) {
-               ret = -errno;
-               _E("ioctl() failed (%d)", ret);
-               return ret;
-       }
-
-       return 0;
-}
-#else
-static int bl_onoff(int on)
-{
-       return dpms_set_power(on);
-}
-#endif
-
-static int bl_brt(int brightness, int delay)
-{
-       int ret = -1;
-       int prev;
-
-       if (!display_dev ||
-           !display_dev->get_brightness ||
-           !display_dev->set_brightness) {
-               _E("there is no display device");
-               return -ENOENT;
-       }
-
-       if (delay > 0)
-               usleep(delay);
-
-       if (force_brightness > 0 && brightness != PM_DIM_BRIGHTNESS) {
-               _I("brightness(%d), force brightness(%d)",
-                   brightness, force_brightness);
-               brightness = force_brightness;
-       }
-
-       ret = display_dev->get_brightness(&prev);
-
-       /* Update new brightness to vconf */
-       if (!ret && (brightness != prev)) {
-               vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, brightness);
-       }
-
-       /* Update device brightness */
-       ret = display_dev->set_brightness(brightness);
-
-       _I("set brightness %d, %d", brightness, ret);
-
-       return ret;
-}
-
-static int system_suspend(void)
-{
-       int ret;
-
-       _I("system suspend");
-       ret = sys_set_str(POWER_STATE_PATH, "mem");
-       _I("system resume (result : %d)", ret);
-       return 0;
-}
-
-static int system_enable_autosleep(void)
-{
-       _I("system autosleep enabled");
-       return sys_set_str(POWER_AUTOSLEEP_PATH, "mem");
-}
-
-static int system_power_lock(void)
-{
-       _I("system power lock");
-       return sys_set_str(POWER_LOCK_PATH, "mainlock");
-}
-
-static int system_power_unlock(void)
-{
-       _I("system power unlock");
-       return sys_set_str(POWER_UNLOCK_PATH, "mainlock");
-}
-
-static int system_get_power_lock_support(void)
-{
-       static int power_lock_support = -1;
-       int ret;
-
-       if (power_lock_support >= 0)
-               goto out;
-
-       ret = sys_check_node(POWER_LOCK_PATH);
-       if (ret < 0)
-               power_lock_support = false;
-       else
-               power_lock_support = true;
-
-       _I("system power lock : %s",
-                       (power_lock_support ? "support" : "not support"));
-
-out:
-       return power_lock_support;
-}
-
-static int get_lcd_power(void)
-{
-       enum dpms_state state;
-       int ret;
-
-       ret = dpms_get_power(&state);
-       if (ret < 0)
-               return ret;
-
-       return state;
-}
-
-void change_brightness(int start, int end, int step)
-{
-       int diff, val;
-       int ret = -1;
-       int prev;
-
-       if (!display_dev ||
-           !display_dev->get_brightness) {
-               _E("there is no display device");
-               return;
-       }
-
-       if ((pm_status_flag & PWRSV_FLAG) &&
-           !(pm_status_flag & BRTCH_FLAG))
-               return;
-
-       ret = display_dev->get_brightness(&prev);
-       if (ret < 0) {
-               _E("fail to get brightness : %d", ret);
-               return;
-       }
-
-       if (prev == end)
-               return;
-
-       _D("start %d end %d step %d", start, end, step);
-
-       diff = end - start;
-
-       if (abs(diff) < step)
-               val = (diff > 0 ? 1 : -1);
-       else
-               val = (int)ceil((double)diff / step);
-
-       while (start != end) {
-               if (val == 0) break;
-
-               start += val;
-               if ((val > 0 && start > end) ||
-                   (val < 0 && start < end))
-                       start = end;
-
-               bl_brt(start, LCD_PHASED_DELAY);
-       }
-}
-
-#ifdef PROFILE_TV
-static int backlight_on(enum device_flags flags)
-{
-       int ret;
-
-       _I("LCD on %x", flags);
-
-       ret = bl_onoff(DPMS_ON);
-       if (ret < 0)
-               _E("Failed to turn on backlight (%d)", ret);
-
-       return ret;
-}
-
-static int backlight_off(enum device_flags flags)
-{
-       int ret;
-
-       _I("LCD off %x", flags);
-
-       ret = bl_onoff(DPMS_OFF);
-       if (ret < 0)
-               _E("Failed to turn off backlight (%d)", ret);
-
-       return ret;
-}
-#else
-static int backlight_on(enum device_flags flags)
-{
-       int ret = -1;
-       int i;
-
-       _D("LCD on %x", flags);
-
-       for (i = 0; i < PM_LCD_RETRY_CNT; i++) {
-               ret = bl_onoff(DPMS_ON);
-               if (get_lcd_power() == DPMS_ON) {
-#ifdef ENABLE_PM_LOG
-                       pm_history_save(PM_LOG_LCD_ON, pm_cur_state);
-#endif
-                       break;
-               } else {
-#ifdef ENABLE_PM_LOG
-                       pm_history_save(PM_LOG_LCD_ON_FAIL, pm_cur_state);
-#endif
-                       _E("Failed to LCD on, through OAL");
-                       ret = -1;
-               }
-       }
-
-       if (flags & LCD_PHASED_TRANSIT_MODE)
-               change_brightness(LCD_PHASED_MIN_BRIGHTNESS,
-                   default_brightness, LCD_PHASED_CHANGE_STEP);
-
-       return ret;
-}
-
-static int backlight_off(enum device_flags flags)
-{
-       int ret = -1;
-       int i;
-
-       _D("LCD off %x", flags);
-
-       if (flags & LCD_PHASED_TRANSIT_MODE)
-               change_brightness(default_brightness,
-                   LCD_PHASED_MIN_BRIGHTNESS, LCD_PHASED_CHANGE_STEP);
-
-       for (i = 0; i < PM_LCD_RETRY_CNT; i++) {
-               usleep(30000);
-               ret = bl_onoff(DPMS_OFF);
-               if (get_lcd_power() == DPMS_OFF) {
-#ifdef ENABLE_PM_LOG
-                       pm_history_save(PM_LOG_LCD_OFF, pm_cur_state);
-#endif
-                       break;
-               } else {
-#ifdef ENABLE_PM_LOG
-                       pm_history_save(PM_LOG_LCD_OFF_FAIL, pm_cur_state);
-#endif
-                       _E("Failed to LCD off, through OAL");
-                       ret = -1;
-               }
-       }
-       return ret;
-}
-#endif
-
-static int backlight_dim(void)
-{
-       int ret;
-
-       ret = bl_brt(PM_DIM_BRIGHTNESS, 0);
-#ifdef ENABLE_PM_LOG
-       if (!ret)
-               pm_history_save(PM_LOG_LCD_DIM, pm_cur_state);
-       else
-               pm_history_save(PM_LOG_LCD_DIM_FAIL, pm_cur_state);
-#endif
-       return ret;
-}
-
-static int set_custom_status(bool on)
-{
-       custom_status = on;
-       return 0;
-}
-
-static bool get_custom_status(void)
-{
-       return custom_status;
-}
-
-static int save_custom_brightness(void)
-{
-       int ret, brightness;
-
-       if (!display_dev ||
-           !display_dev->get_brightness) {
-               _E("there is no display device");
-               return -ENOENT;
-       }
-
-       ret = display_dev->get_brightness(&brightness);
-
-       custom_brightness = brightness;
-
-       return ret;
-}
-
-static int custom_backlight_update(void)
-{
-       int ret = 0;
-
-       if (custom_brightness < PM_MIN_BRIGHTNESS ||
-           custom_brightness > PM_MAX_BRIGHTNESS)
-               return -EINVAL;
-
-       if ((pm_status_flag & PWRSV_FLAG) && !(pm_status_flag & BRTCH_FLAG)) {
-               ret = backlight_dim();
-       } else {
-               _I("custom brightness restored! %d", custom_brightness);
-               ret = bl_brt(custom_brightness, 0);
-       }
-
-       return ret;
-}
-
-static int set_force_brightness(int level)
-{
-       if (level < 0 ||  level > PM_MAX_BRIGHTNESS)
-               return -EINVAL;
-
-       force_brightness = level;
-
-       return 0;
-}
-
-static int backlight_update(void)
-{
-       int ret = 0;
-
-       if (get_custom_status()) {
-               _I("custom brightness mode! brt no updated");
-               return 0;
-       }
-       if ((pm_status_flag & PWRSV_FLAG) && !(pm_status_flag & BRTCH_FLAG)) {
-               ret = backlight_dim();
-       } else {
-               ret = bl_brt(default_brightness, 0);
-       }
-       return ret;
-}
-
-static int backlight_standby(int force)
-{
-       int ret = -1;
-
-       if ((get_lcd_power() == DPMS_ON) || force) {
-               _I("LCD standby");
-               ret = bl_onoff(DPMS_STANDBY);
-       }
-
-       return ret;
-}
-
-static int set_default_brt(int level)
-{
-       if (level < PM_MIN_BRIGHTNESS || level > PM_MAX_BRIGHTNESS)
-               level = PM_DEFAULT_BRIGHTNESS;
-
-       default_brightness = level;
-
-       return 0;
-}
-
-static int check_wakeup_src(void)
-{
-       /*  TODO if nedded.
-        * return wackeup source. user input or device interrupts? (EVENT_DEVICE or EVENT_INPUT)
-        */
-       return EVENT_DEVICE;
-}
-
-static int get_wakeup_count(int *cnt)
-{
-       int ret;
-       int wakeup_count;
-
-       if (!cnt)
-               return -EINVAL;
-
-       ret = sys_get_int(POWER_WAKEUP_PATH, &wakeup_count);
-       if (ret < 0)
-               return ret;
-
-       *cnt = wakeup_count;
-       return 0;
-}
-
-static int set_wakeup_count(int cnt)
-{
-       int ret;
-
-       ret = sys_set_int(POWER_WAKEUP_PATH, cnt);
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-static int get_max_brightness(void)
-{
-       static int max = -1;
-       int ret;
-
-       if (max > 0)
-               return max;
-
-       if (!display_dev) {
-               _E("there is no display device");
-               return -ENOENT;
-       }
-
-       if (!display_dev->get_max_brightness) {
-               max = DEFAULT_DISPLAY_MAX_BRIGHTNESS;
-               return max;
-       }
-
-       ret = display_dev->get_max_brightness(&max);
-       if (ret < 0) {
-               _E("Failed to get max brightness (%d)", ret);
-               return ret;
-       }
-
-       return max;
-}
-
-static int set_brightness(int val)
-{
-       int max;
-
-       if (!display_dev || !display_dev->set_brightness) {
-               _E("there is no display device");
-               return -ENOENT;
-       }
-
-       max = get_max_brightness();
-       if (max < 0) {
-               _E("Failed to get max brightness");
-               return max;
-       }
-
-       /* Maximum Brightness to users is 100.
-        * Thus real brightness need to be calculated */
-       val = val * max / 100;
-
-       return display_dev->set_brightness(val);
-}
-
-static int get_brt_normalized(int brt_raw)
-{
-       int quotient, remainder;
-       int max;
-
-       max = get_max_brightness();
-       if (max < 0) {
-               _E("Failed to get max brightness");
-               return max;
-       }
-
-       /* Maximum Brightness to users is 100.
-        * Thus the brightness value need to be calculated using real brightness.
-        *    ex) Let's suppose that the maximum brightness of driver is 255.
-        *      case 1) When the user sets the brightness to 41,
-        *              real brightness is
-        *                 41 * 255 / 100 = 104.55 = 104 (rounded off)
-        *      case 2) When the user gets the brightness,
-        *              the driver returns the brightness 104.
-        *              Thus the brightness to users is
-        *                 104 * 100 / 255 = 40.7843.... = 41 (rounded up)
-        */
-       quotient = brt_raw * 100 / max;
-       remainder = brt_raw * 100 % max;
-       if (remainder > 0)
-               quotient++;
-
-       return quotient;
-}
-
-static int get_brightness(int *val)
-{
-       int brt, ret;
-
-       if (!display_dev || !display_dev->get_brightness) {
-               _E("there is no display device");
-               return -ENOENT;
-       }
-
-       ret = display_dev->get_brightness(&brt);
-       if (ret < 0) {
-               _E("failed to get brightness (%d)", ret);
-               return ret;
-       }
-
-       *val = get_brt_normalized(brt);
-       return 0;
-}
-
-static int get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brt)
-{
-       int brt_raw;
-       int ret;
-
-       if (!display_dev || !display_dev->get_auto_brightness)
-               return -ENOTSUP;
-
-       ret = display_dev->get_auto_brightness(lmax, lmin, light, &brt_raw);
-       if (ret < 0) {
-               _E("failed to get brightness by light sensor(%d)", ret);
-               return ret;
-       }
-
-       *brt = get_brt_normalized(brt_raw);
-       return 0;
-}
-
-static int get_frame_rate(int *rate)
-{
-       if (!rate)
-               return -EINVAL;
-
-       if (!display_dev || !display_dev->get_frame_rate)
-               return -ENOTSUP;
-
-       return display_dev->get_frame_rate(rate);
-}
-
-static int set_frame_rate(int rate)
-{
-       int ret;
-       static int fmin = -1, fmax = -1;
-
-       if (!display_dev ||
-               !display_dev->set_frame_rate)
-               return -ENOTSUP;
-
-       if (display_dev->get_min_frame_rate) {
-               if (fmin < 0) {
-                       ret = display_dev->get_min_frame_rate(&fmin);
-                       if (ret < 0) {
-                               _E("Failed to get min frate rate (%d)", ret);
-                               return ret;
-                       }
-               }
-               if (rate < fmin) {
-                       _E("Invalid rate(%d)! (Valid rate: %d <= rate)", rate, fmin);
-                       return -EINVAL;
-               }
-       }
-
-       if (display_dev->get_max_frame_rate) {
-               if (fmax < 0) {
-                       ret = display_dev->get_max_frame_rate(&fmax);
-                       if (ret < 0) {
-                               _E("Failed to get max frate rate (%d)", ret);
-                               return ret;
-                       }
-               }
-               if (rate > fmax) {
-                       _E("Invalid rate(%d)! (Valid rate: rate <= %d)", rate, fmax);
-                       return -EINVAL;
-               }
-       }
-
-       return display_dev->set_frame_rate(rate);
-}
-
-static void _init_ops(void)
-{
-       backlight_ops.off = backlight_off;
-       backlight_ops.dim = backlight_dim;
-       backlight_ops.on = backlight_on;
-       backlight_ops.update = backlight_update;
-       backlight_ops.standby = backlight_standby;
-       backlight_ops.set_default_brt = set_default_brt;
-       backlight_ops.get_lcd_power = get_lcd_power;
-       backlight_ops.set_custom_status = set_custom_status;
-       backlight_ops.get_custom_status = get_custom_status;
-       backlight_ops.save_custom_brightness = save_custom_brightness;
-       backlight_ops.custom_update = custom_backlight_update;
-       backlight_ops.set_force_brightness = set_force_brightness;
-       backlight_ops.set_brightness = set_brightness;
-       backlight_ops.get_brightness = get_brightness;
-       backlight_ops.get_brightness_by_light_sensor = get_brightness_by_light_sensor;
-       backlight_ops.get_frame_rate = get_frame_rate;
-       backlight_ops.set_frame_rate = set_frame_rate;
-
-       power_ops.suspend = system_suspend;
-       power_ops.enable_autosleep = system_enable_autosleep;
-       power_ops.power_lock = system_power_lock;
-       power_ops.power_unlock = system_power_unlock;
-       power_ops.get_power_lock_support = system_get_power_lock_support;
-       power_ops.check_wakeup_src = check_wakeup_src;
-       power_ops.get_wakeup_count = get_wakeup_count;
-       power_ops.set_wakeup_count = set_wakeup_count;
-}
-
-int display_service_load(void)
-{
-       struct hw_info *info;
-       int r;
-
-       if (display_dev)
-               return 0;
-
-       r = hw_get_info(DISPLAY_HARDWARE_DEVICE_ID,
-                       (const struct hw_info **)&info);
-       if (r < 0) {
-               _I("display shared library is not supported: %d", r);
-               return 0;
-       }
-
-       if (!info->open) {
-               _E("fail to open display device : open(NULL)");
-               return -EPERM;
-       }
-
-       r = info->open(info, NULL, (struct hw_common **)&display_dev);
-       if (r < 0) {
-               _E("fail to get display device structure : %d", r);
-               return -EPERM;
-       }
-
-       _D("display device structure load success");
-       return 0;
-}
-
-int display_service_free(void)
-{
-       struct hw_info *info;
-
-       if (!display_dev)
-               return -ENOENT;
-
-       info = display_dev->common.info;
-
-       assert(info);
-
-       info->close((struct hw_common *)display_dev);
-       display_dev = NULL;
-
-       return 0;
-}
-
-int init_sysfs(unsigned int flags)
-{
-       _init_ops();
-       return 0;
-}
-
-int exit_sysfs(void)
-{
-       int fd;
-       const struct device_ops *ops = NULL;
-
-       fd = open("/tmp/sem.pixmap_1", O_RDONLY);
-       if (fd == -1) {
-               _E("X server disable");
-               backlight_on(NORMAL_MODE);
-       }
-
-       backlight_update();
-
-       ops = find_device("touchscreen");
-       if (!check_default(ops))
-               ops->start(NORMAL_MODE);
-
-       ops = find_device("touchkey");
-       if (!check_default(ops))
-               ops->start(NORMAL_MODE);
-
-       if (fd != -1)
-               close(fd);
-
-       return 0;
-}
diff --git a/src/display/device-interface.h b/src/display/device-interface.h
deleted file mode 100644 (file)
index d5b05fb..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/**
- * @file       device-interface.h
- * @brief      backlight, touch, power devices interface module header
- */
-#ifndef __DEVICE_INTERFACE_H__
-#define __DEVICE_INTERFACE_H__
-
-#include <stdbool.h>
-#include "core/devices.h"
-
-#define FLAG_X_DPMS            0x2
-
-#define DEFAULT_DISPLAY 0
-
-#define PM_MAX_BRIGHTNESS       100
-#define PM_MIN_BRIGHTNESS       1
-#define PM_DEFAULT_BRIGHTNESS  60
-#define PM_DIM_BRIGHTNESS      0
-
-#define PM_LCD_RETRY_CNT       3
-
-#define DISP_INDEX_SHIFT       16
-#define DISP_CMD(prop, index)  ((index << DISP_INDEX_SHIFT) | prop)
-
-#define DEFAULT_DISPLAY_COUNT           1
-#define DEFAULT_DISPLAY_MAX_BRIGHTNESS  100
-
-/*
- * Event type enumeration
- */
-enum {
-       EVENT_TIMEOUT = 0,      /*< time out event from timer */
-       EVENT_DEVICE = EVENT_TIMEOUT,   /*< wake up by devices except input devices */
-       EVENT_INPUT,            /*< input event from noti service */
-       EVENT_END,
-};
-
-int init_sysfs(unsigned int);
-int exit_sysfs(void);
-int display_service_load(void);
-int display_service_free(void);
-
-struct _backlight_ops {
-       int (*off)(enum device_flags);
-       int (*dim)(void);
-       int (*on)(enum device_flags);
-       int (*update)(void);
-       int (*standby)(int);
-       int (*set_default_brt)(int level);
-       int (*get_lcd_power)(void);
-       int (*set_custom_status)(bool on);
-       bool (*get_custom_status)(void);
-       int (*save_custom_brightness)(void);
-       int (*custom_update)(void);
-       int (*set_force_brightness)(int level);
-       int (*set_brightness)(int val);
-       int (*get_brightness)(int *val);
-       int (*get_brightness_by_light_sensor)(float lmax, float lmin, float light, int *brt);
-       int (*get_frame_rate)(int *rate);
-       int (*set_frame_rate)(int rate);
-};
-
-struct _power_ops {
-       int (*suspend)(void);
-       int (*enable_autosleep)(void);
-       int (*power_lock)(void);
-       int (*power_unlock)(void);
-       int (*get_power_lock_support)(void);
-       int (*check_wakeup_src)(void);
-       int (*get_wakeup_count)(int *cnt);
-       int (*set_wakeup_count)(int cnt);
-};
-
-extern struct _backlight_ops backlight_ops;
-extern struct _power_ops power_ops;
-
-enum dpms_state {
-       DPMS_ON,       /* In use */
-       DPMS_STANDBY,  /* Blanked, low power */
-       DPMS_SUSPEND,  /* Blanked, lower power */
-       DPMS_OFF,      /* Shut off, awaiting activity */
-};
-
-int dpms_set_power(enum dpms_state state);
-int dpms_get_power(enum dpms_state *state);
-
-#endif
diff --git a/src/display/display-actor.c b/src/display/display-actor.c
deleted file mode 100644 (file)
index cf84602..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014 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 "util.h"
-#include "display-actor.h"
-#include "core/list.h"
-#include "core/common.h"
-
-static dd_list *actor_head;
-
-void display_add_actor(struct display_actor_ops *actor)
-{
-       DD_LIST_APPEND(actor_head, actor);
-}
-
-static struct display_actor_ops *display_find_actor(enum display_actor_id id)
-{
-       dd_list *elem;
-       struct display_actor_ops *actor;
-
-       DD_LIST_FOREACH(actor_head, elem, actor) {
-               if (actor->id == id)
-                       return actor;
-       }
-       return NULL;
-}
-
-int display_set_caps(enum display_actor_id id, unsigned int caps)
-{
-       struct display_actor_ops *actor;
-
-       if (id <= 0 || !caps)
-               return -EINVAL;
-
-       actor = display_find_actor(id);
-       if (!actor)
-               return -EINVAL;
-
-       actor->caps |= caps;
-
-       return 0;
-}
-
-int display_reset_caps(enum display_actor_id id, unsigned int caps)
-{
-       struct display_actor_ops *actor;
-
-       if (id <= 0 || !caps)
-               return -EINVAL;
-
-       actor = display_find_actor(id);
-       if (!actor)
-               return -EINVAL;
-
-       actor->caps &= ~caps;
-
-       return 0;
-}
-
-unsigned int display_get_caps(enum display_actor_id id)
-{
-       struct display_actor_ops *actor;
-
-       if (id <= 0)
-               return 0;
-
-       actor = display_find_actor(id);
-       if (!actor)
-               return 0;
-
-       return actor->caps;
-}
-
-int display_has_caps(unsigned int total_caps, unsigned int caps)
-{
-       if (!total_caps || !caps)
-               return false;
-
-       if ((total_caps & caps) == caps)
-               return true;
-
-       return false;
-}
diff --git a/src/display/display-actor.h b/src/display/display-actor.h
deleted file mode 100644 (file)
index e0dd570..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014 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.
- */
-
-
-#ifndef __DISPLAY_ACTOR_H__
-#define __DISPLAY_ACTOR_H__
-
-#include <errno.h>
-#include "core/common.h"
-
-enum display_actor_id {
-       DISPLAY_ACTOR_POWER_KEY = 1,
-       DISPLAY_ACTOR_MENU_KEY,
-       DISPLAY_ACTOR_API,
-       DISPLAY_ACTOR_GESTURE,
-};
-
-struct display_actor_ops {
-       enum display_actor_id id;
-       unsigned int caps;
-};
-
-enum display_capability {
-       DISPLAY_CAPA_BRIGHTNESS         = 1 << 0,
-       DISPLAY_CAPA_LCDON              = 1 << 1,
-       DISPLAY_CAPA_LCDOFF             = 1 << 2,
-       DISPLAY_CAPA_POWEROFF           = 1 << 3,
-};
-
-void display_add_actor(struct display_actor_ops *actor);
-int display_set_caps(enum display_actor_id id, unsigned int caps);
-int display_reset_caps(enum display_actor_id id, unsigned int caps);
-unsigned int display_get_caps(enum display_actor_id id);
-int display_has_caps(unsigned int total_caps, unsigned int caps);
-
-#endif
diff --git a/src/display/display-common.conf b/src/display/display-common.conf
deleted file mode 100644 (file)
index 0457f54..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Display]
-# If this value is yes, LCD is turned off by lcd timeout.
-# If this value is no, LCD is turned off just by external requests.
-# Default value is yes.
-TimeoutEnable=no               # yes or no
-
-# If this value is yes, input events such as screen touchs
-# and/or HW key inputs are supported.
-# Default value is yes.
-InputSupport=no                        # yes or no
diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c
deleted file mode 100644 (file)
index 49ffee4..0000000
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-
-/**
- * @file       display-dbus.c
- * @brief      dbus interface
- *
- */
-
-#include <error.h>
-#include <stdbool.h>
-#include <Ecore.h>
-#include <device-node.h>
-
-#include "core/log.h"
-#include "util.h"
-#include "core.h"
-#include "core/common.h"
-#include "core/devices.h"
-#include "dd-display.h"
-#include "display-actor.h"
-#include "display-ops.h"
-
-#define TELEPHONY_PATH                 "/org/tizen/telephony/SAMSUNG_QMI"
-#define TELEPHONY_INTERFACE_SIM                "org.tizen.telephony.Sim"
-#define SIGNAL_SIM_STATUS              "Status"
-#define SIM_CARD_NOT_PRESENT           (0x01)
-
-#define DISPLAY_DIM_BRIGHTNESS  0
-#define DUMP_MODE_WATING_TIME   600000
-
-static DBusMessage *edbus_start(E_DBus_Object *obj, DBusMessage *msg)
-{
-       static const struct device_ops *display_device_ops = NULL;
-
-       if (!display_device_ops)
-               display_device_ops = find_device("display");
-       if (NOT_SUPPORT_OPS(display_device_ops))
-               return dbus_message_new_method_return(msg);
-
-       display_device_ops->start(CORE_LOGIC_MODE);
-       return dbus_message_new_method_return(msg);
-}
-
-static DBusMessage *edbus_stop(E_DBus_Object *obj, DBusMessage *msg)
-{
-       static const struct device_ops *display_device_ops = NULL;
-
-       if (!display_device_ops)
-               display_device_ops = find_device("display");
-       if (NOT_SUPPORT_OPS(display_device_ops))
-               return dbus_message_new_method_return(msg);
-
-       display_device_ops->stop(CORE_LOGIC_MODE);
-       return dbus_message_new_method_return(msg);
-}
-
-static DBusMessage *edbus_lockstate(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusError err;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       char *state_str;
-       char *option1_str;
-       char *option2_str;
-       int timeout;
-       pid_t pid;
-       int state;
-       int flag;
-       int ret;
-       unsigned int caps;
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                   DBUS_TYPE_STRING, &state_str,
-                   DBUS_TYPE_STRING, &option1_str,
-                   DBUS_TYPE_STRING, &option2_str,
-                   DBUS_TYPE_INT32, &timeout, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!state_str || timeout < 0) {
-               _E("message is invalid!");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-       if (kill(pid, 0) == -1) {
-               _E("%d process does not exist, dbus ignored!", pid);
-               ret = -ESRCH;
-               goto out;
-       }
-
-       if (!strcmp(state_str, PM_LCDON_STR))
-               state = LCD_NORMAL;
-       else if (!strcmp(state_str, PM_LCDDIM_STR))
-               state = LCD_DIM;
-       else if (!strcmp(state_str, PM_LCDOFF_STR))
-               state = LCD_OFF;
-       else {
-               _E("%s state is invalid, dbus ignored!", state_str);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!strcmp(option1_str, STAYCURSTATE_STR))
-               flag = STAY_CUR_STATE;
-       else if (!strcmp(option1_str, GOTOSTATENOW_STR))
-               flag = GOTO_STATE_NOW;
-       else {
-               _E("%s option is invalid. set default option!", option1_str);
-               flag = STAY_CUR_STATE;
-       }
-
-       if (!strcmp(option2_str, HOLDKEYBLOCK_STR))
-               flag |= HOLD_KEY_BLOCK;
-
-       if (flag & GOTO_STATE_NOW) {
-               caps = display_get_caps(DISPLAY_ACTOR_API);
-
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON) &&
-                   state == LCD_NORMAL) {
-                       _D("No lcdon capability!");
-                       ret = -EPERM;
-                       goto out;
-               }
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF) &&
-                   state == LCD_OFF) {
-                       _D("No lcdoff capability!");
-                       ret = -EPERM;
-                       goto out;
-               }
-       }
-
-       if (check_dimstay(state, flag) == true) {
-               _E("LCD state can not be changed to OFF state now!");
-               flag &= ~GOTO_STATE_NOW;
-               flag |= STAY_CUR_STATE;
-       }
-
-       ret = pm_lock_internal(pid, state, flag, timeout);
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_unlockstate(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusError err;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       char *state_str;
-       char *option_str;
-       pid_t pid;
-       int state;
-       int flag;
-       int ret;
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                   DBUS_TYPE_STRING, &state_str,
-                   DBUS_TYPE_STRING, &option_str, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!state_str) {
-               _E("message is invalid!");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-       if (kill(pid, 0) == -1) {
-               _E("%d process does not exist, dbus ignored!", pid);
-               ret = -ESRCH;
-               goto out;
-       }
-
-       if (!strcmp(state_str, PM_LCDON_STR))
-               state = LCD_NORMAL;
-       else if (!strcmp(state_str, PM_LCDDIM_STR))
-               state = LCD_DIM;
-       else if (!strcmp(state_str, PM_LCDOFF_STR))
-               state = LCD_OFF;
-       else {
-               _E("%s state is invalid, dbus ignored!", state_str);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!strcmp(option_str, SLEEP_MARGIN_STR))
-               flag = PM_SLEEP_MARGIN;
-       else if (!strcmp(option_str, RESET_TIMER_STR))
-               flag = PM_RESET_TIMER;
-       else if (!strcmp(option_str, KEEP_TIMER_STR))
-               flag = PM_KEEP_TIMER;
-       else {
-               _E("%s option is invalid. set default option!", option_str);
-               flag = PM_RESET_TIMER;
-       }
-
-       ret = pm_unlock_internal(pid, state, flag);
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_changestate(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusError err;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       char *state_str;
-       pid_t pid;
-       int state;
-       int ret;
-       unsigned int caps;
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                   DBUS_TYPE_STRING, &state_str, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!state_str) {
-               _E("message is invalid!");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-       if (kill(pid, 0) == -1) {
-               _E("%d process does not exist, dbus ignored!", pid);
-               ret = -ESRCH;
-               goto out;
-       }
-
-       if (!strcmp(state_str, PM_LCDON_STR))
-               state = LCD_NORMAL;
-       else if (!strcmp(state_str, PM_LCDDIM_STR))
-               state = LCD_DIM;
-       else if (!strcmp(state_str, PM_LCDOFF_STR))
-               state = LCD_OFF;
-       else if (!strcmp(state_str, PM_STANDBY_STR))
-               state = STANDBY;
-       else if (!strcmp(state_str, PM_SUSPEND_STR))
-               state = SUSPEND;
-       else {
-               _E("%s state is invalid, dbus ignored!", state_str);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       caps = display_get_caps(DISPLAY_ACTOR_API);
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON) &&
-           state == LCD_NORMAL) {
-               _D("No lcdon capability!");
-               ret = -EPERM;
-               goto out;
-       }
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF) &&
-           state == LCD_OFF) {
-               _D("No lcdoff capability!");
-               ret = -EPERM;
-               goto out;
-       }
-
-       if (check_dimstay(state, GOTO_STATE_NOW) == true) {
-               _E("LCD state can not be changed to OFF state!");
-               ret = -EBUSY;
-               goto out;
-       }
-
-       ret = pm_change_internal(pid, state);
-
-       if (!ret && state == LCD_OFF)
-               update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_getdisplaycount(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = DEFAULT_DISPLAY_COUNT;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_getmaxbrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = DEFAULT_DISPLAY_MAX_BRIGHTNESS;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_setmaxbrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       ret = -ENOTSUP;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_getbrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int brt, ret;
-
-       ret = backlight_ops.get_brightness(&brt);
-       if (ret >= 0)
-               ret = brt;
-
-       _I("get brightness %d, %d", brt, ret);
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_setbrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int brt, autobrt, ret, caps;
-
-       caps = display_get_caps(DISPLAY_ACTOR_API);
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_BRIGHTNESS)) {
-               _D("No brightness changing capability!");
-               ret = -EPERM;
-               goto error;
-       }
-
-       dbus_message_iter_init(msg, &iter);
-       dbus_message_iter_get_basic(&iter, &brt);
-
-       if (brt == DISPLAY_DIM_BRIGHTNESS) {
-               _E("application can not set this value(DIM VALUE:%d)", brt);
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
-               _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
-               autobrt = SETTING_BRIGHTNESS_AUTOMATIC_OFF;
-       }
-
-       if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
-               _E("auto_brightness state is ON, can not change the brightness value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       ret = backlight_ops.set_brightness(brt);
-       if (ret < 0)
-               goto error;
-       if (vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt) != 0)
-               _E("Failed to set VCONFKEY_SETAPPL_LCD_BRIGHTNESS value");
-
-       if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, brt) != 0)
-               _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
-
-       _I("set brightness %d, %d", brt, ret);
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_holdbrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int brt, autobrt, ret, caps;
-
-       caps = display_get_caps(DISPLAY_ACTOR_API);
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_BRIGHTNESS)) {
-               _D("No brightness changing capability!");
-               ret = -EPERM;
-               goto error;
-       }
-
-       dbus_message_iter_init(msg, &iter);
-       dbus_message_iter_get_basic(&iter, &brt);
-
-       if (brt == DISPLAY_DIM_BRIGHTNESS) {
-               _E("application can not set this value(DIM VALUE:%d)", brt);
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
-               _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
-               autobrt = SETTING_BRIGHTNESS_AUTOMATIC_OFF;
-       }
-
-       vconf_set_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON);
-
-       ret = backlight_ops.set_brightness(brt);
-       if (ret < 0)
-               goto error;
-
-       if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
-               _D("Auto brightness will be paused");
-               vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_PAUSE);
-       }
-
-       if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, brt) != 0)
-               _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
-
-       _I("hold brightness %d, %d", brt, ret);
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-
-}
-
-static DBusMessage *edbus_releasebrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int bat, charger, changed, setting, brt, autobrt, ret = 0;
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat) != 0) {
-               _E("Failed to get VCONFKEY_SYSMAN_BATTERY_STATUS_LOW value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &charger) != 0) {
-               _E("Failed to get VCONFKEY_SYSMAN_CHARGER_STATUS value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, &changed) != 0) {
-               _E("Failed to get VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &setting) != 0) {
-               _E("Failed to get VCONFKEY_SETAPPL_LCD_BRIGHTNESS value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
-               _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
-               ret = -EPERM;
-               goto error;
-       }
-
-       vconf_set_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, VCONFKEY_PM_CUSTOM_BRIGHTNESS_OFF);
-
-       ret = backlight_ops.get_brightness(&brt);
-       if (ret < 0)
-               brt = ret;
-
-       // check dim state
-       if (low_battery_state(bat) &&
-           charger == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED && !changed) {
-               _D("batt warning low : brightness is not changed!");
-               if (brt != 0) {
-                       backlight_ops.set_brightness(0);
-               }
-               goto error;
-       }
-
-       if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
-               if (brt != setting) {
-                       backlight_ops.set_brightness(setting);
-                       if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, setting) != 0) {
-                               _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
-                       }
-               }
-       } else if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
-               _D("Auto brightness will be enable");
-               vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
-       }
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_setrefreshrate(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int app, val, ret, control;
-
-       ret = dbus_message_get_args(msg, NULL,
-                       DBUS_TYPE_INT32, &app,
-                       DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
-       if (!ret) {
-               _I("there is no message");
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (app < 0 || app >= ARRAY_SIZE(display_conf.framerate_app) || val < 0) {
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (!display_conf.framerate_app[app]) {
-               _I("This case(%d) is not support in this target", app);
-               ret = -EPERM;
-               goto error;
-       }
-
-       control = display_conf.control_display;
-
-       if (control)
-               backlight_ops.off(NORMAL_MODE);
-
-       _D("app : %d, value : %d", app, val);
-       ret = backlight_ops.set_frame_rate(val);
-       if (ret < 0)
-               _E("Failed to set frame rate (%d)", ret);
-
-       if (control)
-               backlight_ops.on(NORMAL_MODE);
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static DBusMessage *edbus_setautobrightnessmin(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int val, ret;
-       pid_t pid;
-       const char *sender;
-
-       sender = dbus_message_get_sender(msg);
-       if (!sender) {
-               _E("invalid sender name!");
-               ret = -EINVAL;
-               goto error;
-       }
-       if (!display_info.set_autobrightness_min) {
-               ret = -EIO;
-               goto error;
-       }
-       dbus_message_iter_init(msg, &iter);
-       dbus_message_iter_get_basic(&iter, &val);
-
-       pid = get_edbus_sender_pid(msg);
-       ret = display_info.set_autobrightness_min(val, (char *)sender);
-       if (ret) {
-               _W("fail to set autobrightness min %d, %d by %d", val, ret, pid);
-               goto error;
-       }
-       if (display_info.reset_autobrightness_min) {
-               register_edbus_watch(sender,
-                   display_info.reset_autobrightness_min, NULL);
-               _I("set autobrightness min %d by %d", val, pid);
-       }
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_setlcdtimeout(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int on, dim, holdkey_block, ret;
-       pid_t pid;
-       const char *sender;
-
-       sender = dbus_message_get_sender(msg);
-       if (!sender) {
-               _E("invalid sender name!");
-               ret = -EINVAL;
-               goto error;
-       }
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &on,
-                   DBUS_TYPE_INT32, &dim, DBUS_TYPE_INT32, &holdkey_block,
-                   DBUS_TYPE_INVALID);
-
-       pid = get_edbus_sender_pid(msg);
-       ret = set_lcd_timeout(on, dim, holdkey_block, sender);
-       if (ret) {
-               _W("fail to set lcd timeout %d by %d", ret, pid);
-       } else {
-               register_edbus_watch(sender,
-                   reset_lcd_timeout, NULL);
-               _I("set lcd timeout on %d, dim %d, holdblock %d by %d",
-                   on, dim, holdkey_block, pid);
-       }
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_lockscreenbgon(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       char *on;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &on,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to update lcdscreen bg on state %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (!strcmp(on, "true"))
-               update_pm_setting(SETTING_LOCK_SCREEN_BG, true);
-       else if (!strcmp(on, "false"))
-               update_pm_setting(SETTING_LOCK_SCREEN_BG, false);
-       else
-               ret = -EINVAL;
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_dumpmode(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       char *on;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &on,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to get dumpmode state %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (!strcmp(on, "on"))
-               pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
-                   STAY_CUR_STATE, DUMP_MODE_WATING_TIME);
-       else if (!strcmp(on, "off"))
-               pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
-                   PM_SLEEP_MARGIN);
-       else
-               ret = -EINVAL;
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_savelog(E_DBus_Object *obj, DBusMessage *msg)
-{
-       save_display_log();
-       return dbus_message_new_method_return(msg);
-}
-
-static DBusMessage *edbus_powerkeyignore(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       int on;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &on,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to get powerkey ignore %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (CHECK_OPS(keyfilter_ops, set_powerkey_ignore))
-               keyfilter_ops->set_powerkey_ignore(on == 1 ? true : false);
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_powerkeylcdoff(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret;
-
-       if (CHECK_OPS(keyfilter_ops, powerkey_lcdoff))
-               ret = keyfilter_ops->powerkey_lcdoff();
-       else
-               ret = -ENOSYS;
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_customlcdon(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       int timeout;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &timeout,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to get custom lcd timeout %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       ret = custom_lcdon(timeout);
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_staytouchscreenoff(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       int val;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to get stay touchscreen off state %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       set_stay_touchscreen_off(val);
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_lcdpaneloffmode(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0;
-       int val;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to get lcd panel off mode %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       set_lcd_paneloff_mode(val);
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_actorcontrol(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int ret = 0, val, actor;
-       char *op;
-
-       ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &op,
-                   DBUS_TYPE_INT32, &actor, DBUS_TYPE_INT32, &val,
-                   DBUS_TYPE_INVALID);
-
-       if (!ret) {
-               _E("fail to update actor control %d", ret);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       if (!strcmp(op, "set"))
-               ret = display_set_caps(actor, val);
-       else if (!strcmp(op, "reset"))
-               ret = display_reset_caps(actor, val);
-       else
-               ret = -EINVAL;
-
-error:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *edbus_getcustombrightness(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       int status = 0;
-
-       status = backlight_ops.get_custom_status();
-
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &status);
-       return reply;
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { "start",           NULL,  NULL, edbus_start },
-       { "stop",            NULL,  NULL, edbus_stop },
-       { "lockstate",     "sssi",   "i", edbus_lockstate },
-       { "unlockstate",     "ss",   "i", edbus_unlockstate },
-       { "changestate",      "s",   "i", edbus_changestate },
-       { "ChangeState",      "s",   "i", edbus_changestate },
-       { "getbrightness",   NULL,   "i", edbus_getbrightness },        /* deprecated */
-       { "setbrightness",    "i",   "i", edbus_setbrightness },        /* deprecated */
-       { "setframerate",    "ii",   "i", edbus_setrefreshrate },       /* deprecated */
-       { "setautobrightnessmin", "i", "i", edbus_setautobrightnessmin },
-       { "setlcdtimeout",  "iii",   "i", edbus_setlcdtimeout },
-       { "LockScreenBgOn",   "s",   "i", edbus_lockscreenbgon },
-       { "GetDisplayCount", NULL,   "i", edbus_getdisplaycount },
-       { "GetMaxBrightness", NULL,  "i", edbus_getmaxbrightness },
-       { "SetMaxBrightness", "i",   "i", edbus_setmaxbrightness },
-       { "GetBrightness",   NULL,   "i", edbus_getbrightness },
-       { "SetBrightness",    "i",   "i", edbus_setbrightness },
-       { "HoldBrightness",   "i",   "i", edbus_holdbrightness },
-       { "ReleaseBrightness", NULL, "i", edbus_releasebrightness },
-       { "SetRefreshRate",  "ii",   "i", edbus_setrefreshrate },
-       { "Dumpmode",         "s",   "i", edbus_dumpmode },
-       { "SaveLog",         NULL,  NULL, edbus_savelog },
-       { "PowerKeyIgnore",   "i",  NULL, edbus_powerkeyignore },
-       { "PowerKeyLCDOff",  NULL,   "i", edbus_powerkeylcdoff },
-       { "CustomLCDOn",      "i",   "i", edbus_customlcdon },
-       { "StayTouchScreenOff", "i", "i", edbus_staytouchscreenoff },
-       { "LCDPanelOffMode",  "i",   "i", edbus_lcdpaneloffmode },
-       { "ActorControl",   "sii",   "i", edbus_actorcontrol },
-       { "CustomBrightness", NULL,  "i", edbus_getcustombrightness },
-       { "CurrentBrightness", NULL, "i", edbus_getbrightness }, /* deprecated. It is remained for tizen 2.4 */
-       /* Add methods here */
-};
-
-static void sim_signal_handler(void *data, DBusMessage *msg)
-{
-       DBusError err;
-       int ret, val;
-       static int state = false;
-
-       if (!find_display_feature("auto-brightness")) {
-               _D("auto brightness is not supported!");
-               return;
-       }
-
-       if (state)
-               return;
-
-       ret = dbus_message_is_signal(msg, TELEPHONY_INTERFACE_SIM,
-           SIGNAL_SIM_STATUS);
-       if (!ret) {
-               _E("there is no power off popup signal");
-               return;
-       }
-
-       dbus_error_init(&err);
-
-       ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val,
-           DBUS_TYPE_INVALID);
-       if (!ret) {
-               _E("no message : [%s:%s]", err.name, err.message);
-               dbus_error_free(&err);
-       }
-
-       if (val != SIM_CARD_NOT_PRESENT) {
-               state = true;
-               vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
-                   PM_DEFAULT_BRIGHTNESS);
-               _I("SIM card is inserted at first!");
-       }
-}
-
-/*
- * Default capability
- * api      := LCDON | LCDOFF | BRIGHTNESS
- * gesture  := LCDON
- */
-static struct display_actor_ops display_api_actor = {
-       .id     = DISPLAY_ACTOR_API,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_BRIGHTNESS,
-};
-
-static struct display_actor_ops display_gesture_actor = {
-       .id     = DISPLAY_ACTOR_GESTURE,
-       .caps   = DISPLAY_CAPA_LCDON,
-};
-
-int init_pm_dbus(void)
-{
-       int ret;
-
-       display_add_actor(&display_api_actor);
-       display_add_actor(&display_gesture_actor);
-
-       ret = register_edbus_method(DEVICED_PATH_DISPLAY,
-                   edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0) {
-               _E("Failed to register edbus method! %d", ret);
-               return ret;
-       }
-/*
- * Auto-brightness feature has been implemented in wearable-device.
- * But UX is not determined yet. Thus this logic can be modified
- * when UX concept related to sim is changed
- */
-       ret = register_edbus_signal_handler(TELEPHONY_PATH,
-                   TELEPHONY_INTERFACE_SIM, SIGNAL_SIM_STATUS,
-                   sim_signal_handler);
-       if (ret < 0 && ret != -EEXIST) {
-               _E("Failed to register signal handler! %d", ret);
-               return ret;
-       }
-       return 0;
-}
diff --git a/src/display/display-ivi.conf b/src/display/display-ivi.conf
deleted file mode 100644 (file)
index b10488c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-[Display]
-# If this value is yes, LCD is always on except pressing power key.
-# Default value is no, LCD is turned off by lcd timeout.
-LCDAlwaysOn=yes                        # yes or no
-
-# If this value is yes, LCD is turned off by lcd timeout.
-# If this value is no, LCD is turned off just by external requests.
-# Default value is yes.
-TimeoutEnable=no               # yes or no
-
-# If this value is yes, input events such as screen touchs
-# and/or HW key inputs are supported.
-# Default value is yes.
-InputSupport=no                        # yes or no
-
-# Use Accelator sensor when autobrightness is on.
-AccelSensorOn=no        # yes or no
diff --git a/src/display/display-mobile.conf b/src/display/display-mobile.conf
deleted file mode 100644 (file)
index 5abea3e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-[Display]
-# deviced is pending lcd on until lock screen shows.
-# This is the maximum pending time.
-LockScreenWaitingTime=0.3      #second
-
-# Power-off popup is launched when power key is long pressed.
-# This is duration of pressing power key.
-LongPressInterval=0.4          #second
-
-# This is polling time of auto brightness.
-LightSensorSamplingInterval=1  #second
-
-# display state is changed to SLEEP state after this time.
-# If this value is large, it causes power consumption problem.
-LCDOffTimeout=500              # milli second
-
-# This is n step of auto brightness.
-# If brightness is change from a to b, brightness's changed n times from a to b.
-BrightnessChangeStep=10
-
-# If this value is yes, LCD is always on except pressing power key.
-# Default value is no, LCD is turned off by lcd timeout.
-LCDAlwaysOn=no                 # yes or no
-
-# Just below application only allow to change display frame rate.
-# refer to enum refresh_app
-ChangedFrameRateAllowed=setting        # setting
-ControlDisplay=yes             # yes or no
-
-# LCD is not turned off when this value is yes and key double pressed
-PowerKeyDoublePressSupport=no  # yes or no
diff --git a/src/display/display-ops.c b/src/display/display-ops.c
deleted file mode 100644 (file)
index df6cca8..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 "util.h"
-#include "display-ops.h"
-#include "core/list.h"
-#include "core/common.h"
-
-static dd_list *disp_head;
-
-void add_display(const struct display_ops *disp)
-{
-       DD_LIST_APPEND(disp_head, disp);
-}
-
-void remove_display(const struct display_ops *disp)
-{
-       DD_LIST_REMOVE(disp_head, disp);
-}
-
-const struct display_ops *find_display_feature(const char *name)
-{
-       dd_list *elem;
-       const struct display_ops *disp;
-
-       DD_LIST_FOREACH(disp_head, elem, disp) {
-               if (!strcmp(disp->name, name))
-                       return disp;
-       }
-       return NULL;
-}
-
-void display_ops_init(void *data)
-{
-       dd_list *elem;
-       const struct display_ops *disp;
-
-       DD_LIST_FOREACH(disp_head, elem, disp) {
-               _D("[%s] initialize", disp->name);
-               if (disp->init)
-                       disp->init(data);
-       }
-}
-
-void display_ops_exit(void *data)
-{
-       dd_list *elem;
-       const struct display_ops *disp;
-
-       DD_LIST_FOREACH(disp_head, elem, disp) {
-               _D("[%s] deinitialize", disp->name);
-               if (disp->exit)
-                       disp->exit(data);
-       }
-}
diff --git a/src/display/display-ops.h b/src/display/display-ops.h
deleted file mode 100644 (file)
index 1c1102d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-
-#ifndef __DISPLAY_OPS_H__
-#define __DISPLAY_OPS_H__
-
-#include <errno.h>
-#include "core/common.h"
-
-struct display_ops {
-       char *name;
-       void (*init) (void *data);
-       void (*exit) (void *data);
-};
-
-void display_ops_init(void *data);
-void display_ops_exit(void *data);
-
-#define DISPLAY_OPS_REGISTER(disp)     \
-static void __CONSTRUCTOR__ module_init(void)  \
-{      \
-       add_display(disp);      \
-}      \
-static void __DESTRUCTOR__ module_exit(void)   \
-{      \
-       remove_display(disp);   \
-}
-
-void add_display(const struct display_ops *disp);
-void remove_display(const struct display_ops *disp);
-const struct display_ops *find_display_feature(const char *name);
-
-#endif
diff --git a/src/display/display-tv.conf b/src/display/display-tv.conf
deleted file mode 100644 (file)
index 20d092c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Display]
-# If this value is yes, LCD is always on except pressing power key.
-# Default value is no, LCD is turned off by lcd timeout.
-LCDAlwaysOn=yes                        # yes or no
-
-# If this value is yes, LCD is turned off by lcd timeout.
-# If this value is no, LCD is turned off just by external requests.
-# Default value is yes.
-TimeoutEnable=no               # yes or no
-
-# If this value is yes, input events such as screen touchs
-# and/or HW key inputs are supported.
-# Default value is yes.
-InputSupport=no                        # yes or no
diff --git a/src/display/display-wearable.conf b/src/display/display-wearable.conf
deleted file mode 100644 (file)
index 237c2a0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-[Display]
-# deviced is pending lcd on until lock screen shows.
-# This is the maximum pending time.
-LockScreenWaitingTime=0.3      #second
-
-# Power-off popup is launched when power key is long pressed.
-# This is duration of pressing power key.
-LongPressInterval=0.4            #second
-
-# This is polling time of auto brightness.
-LightSensorSamplingInterval=1  #second
-
-# display state is changed to SLEEP state after this time.
-# If this value is large, it causes power consumption problem.
-LCDOffTimeout=500              # milli second
-
-# This is n step of auto brightness.
-# If brightness is change from a to b, brightness's changed n times from a to b.
-BrightnessChangeStep=10
-
-# If this value is yes, LCD is always on except pressing power key.
-# Default value is no, LCD is turned off by lcd timeout.
-LCDAlwaysOn=no                 # yes or no
-
-# Just below application only allow to change display frame rate.
-# refer to enum refresh_app
-ChangedFrameRateAllowed=all            # all
-ControlDisplay=no              # yes or no
-
-# LCD is not turned off when this value is yes and key double pressed
-PowerKeyDoublePressSupport=yes  # yes or no
-
-# Use Accelator sensor when autobrightness is on.
-AccelSensorOn=no               # yes or no
-
-# Use Continuous Sampling when autobrightness is on.
-ContinuousSampling=no          # yes or no
diff --git a/src/display/dpms-wayland-none.c b/src/display/dpms-wayland-none.c
deleted file mode 100644 (file)
index 52b0ea6..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 "core/edbus-handler.h"
-#include "device-interface.h"
-
-#define ENLIGHTENMENT_BUS_NAME          "org.enlightenment.wm"
-#define ENLIGHTENMENT_OBJECT_PATH       "/org/enlightenment/wm"
-#define ENLIGHTENMENT_INTERFACE_NAME    ENLIGHTENMENT_BUS_NAME".dpms"
-
-int dpms_set_power(enum dpms_state state)
-{
-       char *arr[1];
-       char str[32];
-       int ret;
-
-       snprintf(str, sizeof(str), "%d", state);
-       arr[0] = str;
-       ret = dbus_method_sync(ENLIGHTENMENT_BUS_NAME,
-                       ENLIGHTENMENT_OBJECT_PATH,
-                       ENLIGHTENMENT_INTERFACE_NAME,
-                       "set", "u", arr);
-
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
-int dpms_get_power(enum dpms_state *state)
-{
-       int ret;
-
-       if (!state)
-               return -EINVAL;
-
-       ret = dbus_method_sync(ENLIGHTENMENT_BUS_NAME,
-                       ENLIGHTENMENT_OBJECT_PATH,
-                       ENLIGHTENMENT_INTERFACE_NAME,
-                       "get", NULL, NULL);
-       if (ret < 0)
-               return ret;
-
-       *state = ret;
-       return 0;
-}
diff --git a/src/display/dpms-x-none.c b/src/display/dpms-x-none.c
deleted file mode 100644 (file)
index 5acdd2e..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 <stdbool.h>
-#include <errno.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/dpms.h>
-
-#include "core/log.h"
-#include "core/common.h"
-#include "device-interface.h"
-
-static CARD16 modes[] = {
-       [DPMS_ON] = DPMSModeOn,
-       [DPMS_STANDBY] = DPMSModeStandby,
-       [DPMS_SUSPEND] = DPMSModeSuspend,
-       [DPMS_OFF] = DPMSModeOff,
-};
-
-static CARD16 dpms_state_to_DPMSMode(enum dpms_state state)
-{
-       if (state < 0 || state > DPMS_OFF)
-               state = DPMS_OFF;
-
-       return modes[state];
-}
-
-static enum dpms_state DPMSMode_to_dpms_state(CARD16 state)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(modes); ++i) {
-               if (modes[i] == state)
-                       return i;
-       }
-
-       return DPMS_OFF;
-}
-
-int dpms_set_power(enum dpms_state state)
-{
-       Display *dpy;
-
-       if (state < DPMS_ON || state > DPMS_OFF)
-               return -EINVAL;
-
-       dpy = XOpenDisplay(NULL);
-       if (!dpy) {
-               _E("fail to open display");
-               return -EPERM;
-       }
-
-       DPMSEnable(dpy);
-       DPMSForceLevel(dpy, dpms_state_to_DPMSMode(state));
-
-       XCloseDisplay(dpy);
-       return 0;
-}
-
-int dpms_get_power(enum dpms_state *state)
-{
-       Display *dpy;
-       int dummy;
-       CARD16 dpms_state = DPMSModeOff;
-       BOOL onoff;
-
-       if (!state)
-               return -EINVAL;
-
-       dpy = XOpenDisplay(NULL);
-       if (dpy == NULL) {
-               _E("fail to open display");
-               return -EPERM;
-       }
-
-       if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
-               if (DPMSCapable(dpy))
-                       DPMSInfo(dpy, &dpms_state, &onoff);
-       }
-
-       XCloseDisplay(dpy);
-
-       *state = DPMSMode_to_dpms_state(dpms_state);
-       return 0;
-}
diff --git a/src/display/input.c b/src/display/input.c
deleted file mode 100644 (file)
index a65e5f4..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 <fcntl.h>
-#include <sys/stat.h>
-#include <linux/input.h>
-#include <libinput.h>
-#include <Ecore.h>
-#include "util.h"
-#include "core.h"
-#include "poll.h"
-
-#define SEAT_NAME   "seat0"
-
-static struct udev *udev;
-static struct libinput *li;
-static Ecore_Fd_Handler *efd;
-
-int (*pm_callback) (int, PMMsg *);
-
-static inline void process_event(struct libinput_event *ev)
-{
-       static const struct device_ops *display_device_ops;
-       struct input_event input;
-       struct libinput *li;
-       struct libinput_event_keyboard *k;
-       unsigned int time;
-       int fd;
-
-       if (!pm_callback)
-               return;
-
-       if (!display_device_ops) {
-               display_device_ops = find_device("display");
-               if (!display_device_ops)
-                       return;
-       }
-
-       /* do not operate when display stops */
-       if (device_get_status(display_device_ops)
-                       != DEVICE_OPS_STATUS_START) {
-               _E("display status is stop");
-               return;
-       }
-
-       switch (libinput_event_get_type(ev)) {
-       case LIBINPUT_EVENT_DEVICE_ADDED:
-               return;
-       case LIBINPUT_EVENT_KEYBOARD_KEY:
-               k = libinput_event_get_keyboard_event(ev);
-               time = libinput_event_keyboard_get_time(k);
-               li = libinput_event_get_context(ev);
-
-               input.time.tv_sec = MSEC_TO_SEC(time);
-               input.time.tv_usec = MSEC_TO_USEC(time % 1000);
-               input.type = EV_KEY;
-               input.code = libinput_event_keyboard_get_key(k);
-               input.value = libinput_event_keyboard_get_key_state(k);
-
-               fd = libinput_get_fd(li);
-               _D("time %d.%d type %d code %d value %d fd %d",
-                               input.time.tv_sec, input.time.tv_usec, input.type,
-                               input.code, input.value, fd);
-
-               if (CHECK_OPS(keyfilter_ops, check) &&
-                   keyfilter_ops->check(&input, fd) != 0)
-                       return;
-               break;
-       case LIBINPUT_EVENT_POINTER_MOTION:
-       case LIBINPUT_EVENT_POINTER_BUTTON:
-       case LIBINPUT_EVENT_POINTER_AXIS:
-               li = libinput_event_get_context(ev);
-               input.type = EV_REL;
-
-               fd = libinput_get_fd(li);
-               _D("time %d.%d type %d code %d value %d fd %d",
-                               input.time.tv_sec, input.time.tv_usec, input.type,
-                               input.code, input.value, fd);
-
-               if (CHECK_OPS(keyfilter_ops, check) &&
-                   keyfilter_ops->check(&input, fd) != 0)
-                       return;
-               break;
-       case LIBINPUT_EVENT_TOUCH_DOWN:
-       case LIBINPUT_EVENT_TOUCH_UP:
-       case LIBINPUT_EVENT_TOUCH_MOTION:
-       case LIBINPUT_EVENT_TOUCH_FRAME:
-               if (touch_event_blocked())
-                       return ;
-               break;
-       default:
-               break;
-       }
-
-       /* lcd on or update lcd timeout */
-       (*pm_callback) (INPUT_POLL_EVENT, NULL);
-}
-
-static Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
-{
-       struct libinput_event *ev;
-       struct libinput *input = (struct libinput *)data;
-
-       if (!input)
-               return ECORE_CALLBACK_RENEW;
-
-       libinput_dispatch(input);
-
-       while ((ev = libinput_get_event(input))) {
-               process_event(ev);
-
-               libinput_event_destroy(ev);
-               libinput_dispatch(input);
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int open_restricted(const char *path, int flags, void *user_data)
-{
-       int fd;
-       unsigned int clockid = CLOCK_MONOTONIC;
-
-       if (!path)
-               return -EINVAL;
-
-       fd = open(path, flags);
-       if (fd >= 0) {
-               /* TODO Why does fd change the clock? */
-               if (ioctl(fd, EVIOCSCLOCKID, &clockid) < 0)
-                       _E("fail to change clock %s", path);
-       }
-
-       return fd < 0 ? -errno : fd;
-}
-
-static void close_restricted(int fd, void *user_data)
-{
-       close(fd);
-}
-
-static const struct libinput_interface interface = {
-       .open_restricted = open_restricted,
-       .close_restricted = close_restricted,
-};
-
-int init_input(void)
-{
-       int ret;
-       int fd;
-
-       udev = udev_new();
-       if (!udev) {
-               _E("fail to create udev library context");
-               return -EPERM;
-       }
-
-       li = libinput_udev_create_context(&interface, NULL, udev);
-       if (!li) {
-               _E("fail to create a new libinput context from udev");
-               return -EPERM;
-       }
-
-       ret = libinput_udev_assign_seat(li, SEAT_NAME);
-       if (ret < 0) {
-               _E("fail to assign a seat");
-               return -EPERM;
-       }
-
-       fd = libinput_get_fd(li);
-       if (fd < 0) {
-               _E("fail to get file descriptor from libinput context");
-               return -EPERM;
-       }
-
-       /* add to poll handler */
-       efd = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
-                       input_handler,
-                       (void *)((intptr_t)li), NULL, NULL);
-       if (!efd) {
-               _E("fail to add fd handler");
-               /* TODO Does it really need close()? */
-               close(fd);
-               return -EPERM;
-       }
-
-       return 0;
-}
-
-int exit_input(void)
-{
-       if (efd)
-               ecore_main_fd_handler_del(efd);
-
-       if (li)
-               libinput_unref(li);
-
-       if (udev)
-               udev_unref(udev);
-
-       return 0;
-}
diff --git a/src/display/key-filter.c b/src/display/key-filter.c
deleted file mode 100644 (file)
index eaafc9b..0000000
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 <unistd.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <vconf.h>
-#include <Ecore.h>
-#include "util.h"
-#include "core.h"
-#include "poll.h"
-#include "device-node.h"
-#include "display-actor.h"
-#include "core/common.h"
-#include "core/devices.h"
-#include "core/device-notifier.h"
-#include "core/edbus-handler.h"
-#include "power/power-handler.h"
-#include "led/touch-key.h"
-
-#include <linux/input.h>
-#ifndef KEY_SCREENLOCK
-#define KEY_SCREENLOCK         0x98
-#endif
-#ifndef SW_GLOVE
-#define SW_GLOVE               0x16
-#endif
-
-#define PREDEF_LEAVESLEEP      "leavesleep"
-#define POWEROFF_ACT                   "poweroff"
-#define PWROFF_POPUP_ACT               "pwroff-popup"
-#define USEC_PER_SEC                   1000000
-#define COMBINATION_INTERVAL           0.5     /* 0.5 second */
-
-#define KEY_MAX_DELAY_TIME             700     /* ms */
-
-#define KEY_RELEASED           0
-#define KEY_PRESSED            1
-#define KEY_BEING_PRESSED      2
-
-#define KEY_COMBINATION_STOP           0
-#define KEY_COMBINATION_START          1
-#define KEY_COMBINATION_SCREENCAPTURE  2
-
-#define SIGNAL_CHANGE_HARDKEY          "ChangeHardkey"
-#define SIGNAL_LCDON_BY_POWERKEY       "LCDOnByPowerkey"
-#define SIGNAL_LCDOFF_BY_POWERKEY      "LCDOffByPowerkey"
-
-#define TOUCH_RELEASE          (-1)
-
-#define GLOVE_MODE     1
-
-int __WEAK__ get_glove_state(void);
-void __WEAK__ switch_glove_key(int val);
-
-static struct timeval pressed_time;
-static Ecore_Timer *longkey_timeout_id = NULL;
-static Ecore_Timer *combination_timeout_id = NULL;
-static int cancel_lcdoff;
-static int key_combination = KEY_COMBINATION_STOP;
-static int menu_pressed = false;
-static bool touch_pressed = false;
-static int skip_lcd_off = false;
-static bool powerkey_pressed = false;
-static const struct device_ops *touchled;
-
-static inline int current_state_in_on(void)
-{
-       return (pm_cur_state == S_LCDDIM || pm_cur_state == S_NORMAL);
-}
-
-static inline void restore_custom_brightness(void)
-{
-       if (pm_cur_state == S_LCDDIM &&
-           backlight_ops.get_custom_status())
-               backlight_ops.custom_update();
-}
-
-static int power_execute(void *data)
-{
-       static const struct device_ops *ops = NULL;
-
-       FIND_DEVICE_INT(ops, POWER_OPS_NAME);
-
-       return ops->execute(data);
-}
-
-static void longkey_pressed()
-{
-       char *opt;
-       unsigned int caps;
-
-       _I("Power key long pressed!");
-       cancel_lcdoff = 1;
-
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
-
-       if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
-               /* change state - LCD on */
-               pm_change_internal(getpid(), LCD_NORMAL);
-               (*pm_callback)(INPUT_POLL_EVENT, NULL);
-       }
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
-               _D("No poweroff capability!");
-               return;
-       }
-
-       opt = PWROFF_POPUP_ACT;
-       power_execute(opt);
-}
-
-static Eina_Bool longkey_pressed_cb(void *data)
-{
-       longkey_pressed();
-       longkey_timeout_id = NULL;
-
-       return EINA_FALSE;
-}
-
-static Eina_Bool combination_failed_cb(void *data)
-{
-       key_combination = KEY_COMBINATION_STOP;
-       combination_timeout_id = NULL;
-
-       return EINA_FALSE;
-}
-
-static unsigned long timediff_usec(struct timeval t1, struct timeval t2)
-{
-       unsigned long udiff;
-
-       udiff = (t2.tv_sec - t1.tv_sec) * USEC_PER_SEC;
-       udiff += (t2.tv_usec - t1.tv_usec);
-
-       return udiff;
-}
-
-static void stop_key_combination(void)
-{
-       key_combination = KEY_COMBINATION_STOP;
-       if (combination_timeout_id > 0) {
-               ecore_timer_del(combination_timeout_id);
-               combination_timeout_id = NULL;
-       }
-}
-
-static inline void check_key_pair(int code, int new, int *old)
-{
-       if (new == *old)
-               _E("key pair is not matched! (%d, %d)", code, new);
-       else
-               *old = new;
-}
-
-static inline void broadcast_lcdon_by_powerkey(void)
-{
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-           SIGNAL_LCDON_BY_POWERKEY, NULL, NULL);
-}
-
-static inline void broadcast_lcdoff_by_powerkey(void)
-{
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-           SIGNAL_LCDOFF_BY_POWERKEY, NULL, NULL);
-}
-
-static inline bool switch_on_lcd(void)
-{
-       if (current_state_in_on())
-               return false;
-
-       if (backlight_ops.get_lcd_power() == DPMS_ON)
-               return false;
-
-       broadcast_lcdon_by_powerkey();
-
-       lcd_on_direct(LCD_ON_BY_POWER_KEY);
-
-       return true;
-}
-
-static inline void switch_off_lcd(void)
-{
-       if (!current_state_in_on())
-               return;
-
-       if (backlight_ops.get_lcd_power() == DPMS_OFF)
-               return;
-
-       broadcast_lcdoff_by_powerkey();
-
-       lcd_off_procedure(LCD_OFF_BY_POWER_KEY);
-}
-
-static void process_combination_key(struct input_event *pinput)
-{
-       if (pinput->value == KEY_PRESSED) {
-               if (key_combination == KEY_COMBINATION_STOP) {
-                       key_combination = KEY_COMBINATION_START;
-                       combination_timeout_id = ecore_timer_add(
-                           COMBINATION_INTERVAL,
-                           (Ecore_Task_Cb)combination_failed_cb, NULL);
-               } else if (key_combination == KEY_COMBINATION_START) {
-                       if (combination_timeout_id > 0) {
-                               ecore_timer_del(combination_timeout_id);
-                               combination_timeout_id = NULL;
-                       }
-                       if (longkey_timeout_id > 0) {
-                               ecore_timer_del(longkey_timeout_id);
-                               longkey_timeout_id = NULL;
-                       }
-                       _I("capture mode");
-                       key_combination = KEY_COMBINATION_SCREENCAPTURE;
-                       skip_lcd_off = true;
-               }
-               menu_pressed = true;
-       } else if (pinput->value == KEY_RELEASED) {
-               if (key_combination != KEY_COMBINATION_SCREENCAPTURE)
-                       stop_key_combination();
-               menu_pressed = false;
-       }
-}
-
-
-static int process_menu_key(struct input_event *pinput)
-{
-       int caps;
-
-       caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
-               if (current_state_in_on()) {
-                       process_combination_key(pinput);
-                       return false;
-               }
-               _D("No lcd-on capability!");
-               return true;
-       } else if (pinput->value == KEY_PRESSED) {
-               switch_on_lcd();
-       }
-
-       process_combination_key(pinput);
-
-       return false;
-}
-
-static int decide_lcdoff(void)
-{
-       /* It's not needed if it's already LCD off state */
-       if (!current_state_in_on() &&
-           backlight_ops.get_lcd_power() != DPMS_ON)
-               return false;
-
-       /*
-        * This flag is set at the moment
-        * that LCD is turned on by power key
-        * LCD has not to turned off in the situation.
-        */
-       if (skip_lcd_off)
-               return false;
-
-       /* LCD is not turned off when powerkey is pressed,not released */
-       if (powerkey_pressed)
-               return false;
-
-       /* LCD-off is blocked at the moment poweroff popup shows */
-       if (cancel_lcdoff)
-               return false;
-
-       /* LCD-off is blocked at the moment volumedown key is pressed */
-       if (menu_pressed)
-               return false;
-
-       /* LCD-off is blocked when powerkey and volmedown key are pressed */
-       if (key_combination == KEY_COMBINATION_SCREENCAPTURE)
-               return false;
-
-       return true;
-}
-
-static int lcdoff_powerkey(void)
-{
-       int ignore = true;
-
-       if (decide_lcdoff() == true) {
-               check_processes(S_NORMAL);
-               check_processes(S_LCDDIM);
-
-               if (!check_holdkey_block(S_NORMAL) &&
-                   !check_holdkey_block(S_LCDDIM)) {
-                       if (display_info.update_auto_brightness)
-                               display_info.update_auto_brightness(false);
-                       switch_off_lcd();
-                       delete_condition(S_NORMAL);
-                       delete_condition(S_LCDDIM);
-                       update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
-                       pm_change_internal(getpid(), LCD_OFF);
-               }
-       } else {
-               ignore = false;
-       }
-       cancel_lcdoff = 0;
-
-       return ignore;
-}
-
-static int process_power_key(struct input_event *pinput)
-{
-       int ignore = true;
-       static int value = KEY_RELEASED;
-       unsigned int caps;
-
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
-
-       switch (pinput->value) {
-       case KEY_RELEASED:
-               powerkey_pressed = false;
-               check_key_pair(pinput->code, pinput->value, &value);
-
-               if (!display_conf.powerkey_doublepress) {
-                       if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
-                               ignore = lcdoff_powerkey();
-                       else
-                               _D("No lcdoff capability!");
-               } else if (skip_lcd_off) {
-                       ignore = false;
-               }
-
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
-                       ignore = true;
-
-               stop_key_combination();
-               if (longkey_timeout_id > 0) {
-                       ecore_timer_del(longkey_timeout_id);
-                       longkey_timeout_id = NULL;
-               }
-
-               break;
-       case KEY_PRESSED:
-               powerkey_pressed = true;
-               if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
-                       skip_lcd_off = switch_on_lcd();
-               } else {
-                       _D("No lcdon capability!");
-                       skip_lcd_off = false;
-               }
-               check_key_pair(pinput->code, pinput->value, &value);
-               _I("power key pressed");
-               pressed_time.tv_sec = (pinput->time).tv_sec;
-               pressed_time.tv_usec = (pinput->time).tv_usec;
-               if (key_combination == KEY_COMBINATION_STOP) {
-                       /* add long key timer */
-                       longkey_timeout_id = ecore_timer_add(
-                                   display_conf.longpress_interval,
-                                   (Ecore_Task_Cb)longkey_pressed_cb, NULL);
-                       key_combination = KEY_COMBINATION_START;
-                       combination_timeout_id = ecore_timer_add(
-                                   COMBINATION_INTERVAL,
-                                   (Ecore_Task_Cb)combination_failed_cb, NULL);
-               } else if (key_combination == KEY_COMBINATION_START) {
-                       if (combination_timeout_id > 0) {
-                               ecore_timer_del(combination_timeout_id);
-                               combination_timeout_id = NULL;
-                       }
-                       _I("capture mode");
-                       key_combination = KEY_COMBINATION_SCREENCAPTURE;
-                       skip_lcd_off = true;
-                       ignore = false;
-               }
-               if (skip_lcd_off)
-                       ignore = false;
-               cancel_lcdoff = 0;
-
-               break;
-       case KEY_BEING_PRESSED:
-               if (timediff_usec(pressed_time, pinput->time) >
-                   (display_conf.longpress_interval * USEC_PER_SEC))
-                       longkey_pressed();
-               break;
-       }
-       return ignore;
-}
-
-static int process_screenlock_key(struct input_event *pinput)
-{
-       if (pinput->value != KEY_RELEASED) {
-               stop_key_combination();
-               return true;
-       }
-
-       if (!current_state_in_on())
-               return false;
-
-       check_processes(S_NORMAL);
-       check_processes(S_LCDDIM);
-
-       if (!check_holdkey_block(S_NORMAL) && !check_holdkey_block(S_LCDDIM)) {
-               delete_condition(S_NORMAL);
-               delete_condition(S_LCDDIM);
-               update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
-
-               /* LCD off forcly */
-               pm_change_internal(-1, LCD_OFF);
-       }
-
-       return true;
-}
-
-static void sound_vibrate_hardkey(void)
-{
-       /* device notify(vibrator) */
-       /* sound(dbus) */
-       /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangedHardKey signal */
-       broadcast_edbus_signal(DEVICED_PATH_KEY, DEVICED_INTERFACE_KEY,
-                       SIGNAL_CHANGE_HARDKEY, NULL, NULL);
-}
-
-static void process_hardkey_backlight(struct input_event *pinput)
-{
-       int opt;
-
-       _E("pinput->value : %d", pinput->value);
-       if (pinput->value == KEY_PRESSED) {
-               if (touch_pressed) {
-                       _I("Touch is pressed, then hard key is not working!");
-                       return;
-               }
-               /* Sound & Vibrate only in unlock state */
-               if (get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK
-                   || get_lock_screen_bg_state())
-                       sound_vibrate_hardkey();
-
-               if (touchled && touchled->execute) {
-                       opt = TOUCHLED_PRESS;
-                       touchled->execute(&opt);
-               }
-       } else if (pinput->value == KEY_RELEASED) {
-               /* if lockscreen is idle lock */
-               if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
-                       _D("Lock state, key backlight is off when phone is unlocked!");
-                       return;
-               }
-
-               if (touchled && touchled->execute) {
-                       opt = TOUCHLED_RELEASE;
-                       touchled->execute(&opt);
-               }
-       }
-}
-
-static int check_key(struct input_event *pinput, int fd)
-{
-       int ignore = true;
-
-       switch (pinput->code) {
-       case KEY_MENU:
-               ignore = process_menu_key(pinput);
-               break;
-       case KEY_POWER:
-               ignore = process_power_key(pinput);
-               break;
-       case KEY_SCREENLOCK:
-               ignore = process_screenlock_key(pinput);
-               break;
-       case KEY_BACK:
-       case KEY_PHONE:
-               stop_key_combination();
-               if (current_state_in_on()) {
-                       process_hardkey_backlight(pinput);
-                       ignore = false;
-               }
-               break;
-       case KEY_VOLUMEUP:
-       case KEY_VOLUMEDOWN:
-       case KEY_CAMERA:
-       case KEY_EXIT:
-       case KEY_CONFIG:
-       case KEY_MEDIA:
-       case KEY_MUTE:
-       case KEY_PLAYPAUSE:
-       case KEY_PLAYCD:
-       case KEY_PAUSECD:
-       case KEY_STOPCD:
-       case KEY_NEXTSONG:
-       case KEY_PREVIOUSSONG:
-       case KEY_REWIND:
-       case KEY_FASTFORWARD:
-               stop_key_combination();
-               if (current_state_in_on())
-                       ignore = false;
-               break;
-       case 0x1DB:
-       case 0x1DC:
-       case 0x1DD:
-       case 0x1DE:
-               stop_key_combination();
-               break;
-       default:
-               stop_key_combination();
-               ignore = false;
-       }
-#ifdef ENABLE_PM_LOG
-       if (pinput->value == KEY_PRESSED)
-               pm_history_save(PM_LOG_KEY_PRESS, pinput->code);
-       else if (pinput->value == KEY_RELEASED)
-               pm_history_save(PM_LOG_KEY_RELEASE, pinput->code);
-#endif
-       return ignore;
-}
-
-static int check_key_filter(void *data, int fd)
-{
-       struct input_event *pinput = data;
-       int ignore = true;
-       static int old_fd, code, value;
-
-       assert(pinput);
-
-       switch (pinput->type) {
-       case EV_KEY:
-               if (pinput->code == BTN_TOUCH &&
-                       pinput->value == KEY_RELEASED)
-                       touch_pressed = false;
-               /*
-                * Normally, touch press/release events don't occur
-                * in lcd off state. But touch release events can occur
-                * in the state abnormally. Then touch events are ignored
-                * when lcd is off state.
-                */
-               if (pinput->code == BTN_TOUCH && !current_state_in_on())
-                       break;
-               if (pinput->code == code && pinput->value == value) {
-                       _E("Same key(%d, %d) is polled [%d,%d]",
-                               code, value, old_fd, fd);
-               }
-               old_fd = fd;
-               code = pinput->code;
-               value = pinput->value;
-
-               ignore = check_key(pinput, fd);
-               restore_custom_brightness();
-
-               break;
-       case EV_REL:
-               ignore = false;
-               break;
-       case EV_ABS:
-               if (current_state_in_on())
-                       ignore = false;
-               restore_custom_brightness();
-
-               touch_pressed =
-                       (pinput->value == TOUCH_RELEASE ? false : true);
-               break;
-       case EV_SW:
-               if (!get_glove_state || !switch_glove_key)
-                       break;
-               if (pinput->code == SW_GLOVE &&
-                       get_glove_state() == GLOVE_MODE) {
-                       switch_glove_key(pinput->value);
-               }
-               break;
-       }
-
-       if (ignore)
-               return 1;
-
-       return 0;
-}
-
-/*
- * Default capability
- * powerkey := LCDON | LCDOFF | POWEROFF
- * homekey  := LCDON
- */
-static struct display_actor_ops display_powerkey_actor = {
-       .id     = DISPLAY_ACTOR_POWER_KEY,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_POWEROFF,
-};
-
-static struct display_actor_ops display_menukey_actor = {
-       .id     = DISPLAY_ACTOR_MENU_KEY,
-       .caps   = DISPLAY_CAPA_LCDON,
-};
-
-static void keyfilter_init(void)
-{
-       display_add_actor(&display_powerkey_actor);
-       display_add_actor(&display_menukey_actor);
-
-       touchled = find_device(TOUCHLED_NAME);
-}
-
-static void key_backlight_enable(bool enable)
-{
-       int opt;
-
-       if (!touchled || !touchled->execute)
-               return;
-
-       if (enable)
-               opt = TOUCHLED_DIRECT_ON;
-       else
-               opt = TOUCHLED_DIRECT_OFF;
-
-       touchled->execute(&opt);
-}
-
-static const struct display_keyfilter_ops normal_keyfilter_ops = {
-       .init                   = keyfilter_init,
-       .check                  = check_key_filter,
-       .set_powerkey_ignore    = NULL,
-       .powerkey_lcdoff        = NULL,
-       .backlight_enable       = key_backlight_enable,
-};
-const struct display_keyfilter_ops *keyfilter_ops = &normal_keyfilter_ops;
diff --git a/src/display/lock-detector.c b/src/display/lock-detector.c
deleted file mode 100644 (file)
index 62623f0..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-
-/**
- * @file       lock-detector.c
- * @brief
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include "util.h"
-#include "core.h"
-#include "core/list.h"
-
-struct lock_info {
-       unsigned long hash;
-       char *name;
-       int state;
-       int count;
-       long locktime;
-       long unlocktime;
-       long time;
-};
-
-#define LIMIT_COUNT    128
-
-static dd_list *lock_info_list;
-
-static long get_time(void)
-{
-       struct timeval now;
-       gettimeofday(&now, NULL);
-       return (long)(now.tv_sec * 1000 + now.tv_usec / 1000);
-}
-
-static void shrink_lock_info_list(void)
-{
-       dd_list *l, *l_prev;
-       struct lock_info *info;
-       unsigned int count;
-
-       count = DD_LIST_LENGTH(lock_info_list);
-       if (count <= LIMIT_COUNT)
-               return;
-       _D("list is shrink : count %d", count);
-
-       DD_LIST_REVERSE_FOREACH_SAFE(lock_info_list, l, l_prev, info) {
-               if (info->locktime == 0) {
-                       DD_LIST_REMOVE_LIST(lock_info_list, l);
-                       if (info->name)
-                               free(info->name);
-                       free(info);
-                       count--;
-               }
-               if (count <= (LIMIT_COUNT / 2))
-                       break;
-       }
-}
-
-int set_lock_time(const char *pname, int state)
-{
-       struct lock_info *info;
-       dd_list *l;
-       unsigned long val;
-
-       if (!pname)
-               return -EINVAL;
-
-       if (state < S_NORMAL || state > S_SLEEP)
-               return -EINVAL;
-
-       val = g_str_hash(pname);
-
-       DD_LIST_FOREACH(lock_info_list, l, info)
-               if (info->hash == val &&
-                   !strncmp(info->name, pname, strlen(pname)+1) &&
-                   info->state == state) {
-                       info->count += 1;
-                       if (info->locktime == 0)
-                               info->locktime = get_time();
-                       info->unlocktime = 0;
-                       DD_LIST_REMOVE(lock_info_list, info);
-                       DD_LIST_PREPEND(lock_info_list, info);
-                       return 0;
-               }
-
-       info = malloc(sizeof(struct lock_info));
-       if (!info) {
-               _E("Malloc is failed for lock_info!");
-               return -ENOMEM;
-       }
-
-       info->hash = val;
-       info->name = strndup(pname, strlen(pname));
-       info->state = state;
-       info->count = 1;
-       info->locktime = get_time();
-       info->unlocktime = 0;
-       info->time = 0;
-
-       DD_LIST_APPEND(lock_info_list, info);
-
-       return 0;
-}
-
-int set_unlock_time(const char *pname, int state)
-{
-       bool find = false;
-       long diff;
-       struct lock_info *info;
-       dd_list *l;
-       unsigned long val;
-
-       if (!pname)
-               return -EINVAL;
-
-       if (state < S_NORMAL || state > S_SLEEP)
-               return -EINVAL;
-
-       val = g_str_hash(pname);
-
-       DD_LIST_FOREACH(lock_info_list, l, info)
-               if (info->hash == val &&
-                   !strncmp(info->name, pname, strlen(pname)+1) &&
-                   info->state == state) {
-                       DD_LIST_REMOVE(lock_info_list, info);
-                       DD_LIST_PREPEND(lock_info_list, info);
-                       find = true;
-                       break;
-               }
-
-       if (!find)
-               return -EINVAL;
-
-       if (info->locktime == 0)
-               return -EINVAL;
-
-       /* update time */
-       info->unlocktime = get_time();
-       diff = info->unlocktime - info->locktime;
-       if (diff > 0)
-               info->time += diff;
-       info->locktime = 0;
-
-       if (DD_LIST_LENGTH(lock_info_list) > LIMIT_COUNT)
-               shrink_lock_info_list();
-
-       return 0;
-}
-
-void free_lock_info_list(void)
-{
-       dd_list *l, *l_next;
-       struct lock_info *info;
-
-       if (!lock_info_list)
-               return;
-
-       DD_LIST_FOREACH_SAFE(lock_info_list, l, l_next, info) {
-               DD_LIST_REMOVE(lock_info_list, info);
-               if (info->name)
-                       free(info->name);
-               free(info);
-       }
-       lock_info_list = NULL;
-}
-
-void print_lock_info_list(int fd)
-{
-       struct lock_info *info;
-       dd_list *l;
-       char buf[255];
-       int ret;
-
-       if (!lock_info_list)
-               return;
-
-       snprintf(buf, sizeof(buf),
-           "current time : %ld ms\n", get_time());
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       snprintf(buf, sizeof(buf),
-           "[%10s %6s] %6s %10s %10s %10s %s\n", "hash", "state",
-           "count", "locktime", "unlocktime", "time", "process name");
-       ret = write(fd, buf, strlen(buf));
-       if (ret < 0)
-               _E("write() failed (%d)", errno);
-
-       DD_LIST_FOREACH(lock_info_list, l, info) {
-               long time = 0;
-               if (info->locktime != 0 && info->unlocktime == 0)
-                       time = get_time() - info->locktime;
-               snprintf(buf, sizeof(buf),
-                   "[%10lu %6d] %6d %10ld %10ld %10ld %s\n",
-                   info->hash,
-                   info->state,
-                   info->count,
-                   info->locktime,
-                   info->unlocktime,
-                   info->time + time,
-                   info->name);
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-       }
-}
diff --git a/src/display/lock-detector.h b/src/display/lock-detector.h
deleted file mode 100644 (file)
index 6900f3f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/**
- * @file       lock-detector.h
- * @brief
- *
- */
-
-#ifndef _LOCK_DETECTOR_H_
-#define _LOCK_DETECTOR_H_
-
-int set_lock_time(const char *pname, int state);
-int set_unlock_time(const char *pname, int state);
-void free_lock_info_list(void);
-void print_lock_info_list(int fd);
-
-#endif //_LOCK_DETECTOR_H_
diff --git a/src/display/poll.c b/src/display/poll.c
deleted file mode 100644 (file)
index 1381f98..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-
-/**
- * @file       poll.c
- * @brief       Power Manager poll implementation
- *
- */
-
-#include <stdio.h>
-#include "util.h"
-#include "core.h"
-#include "poll.h"
-
-#define SHIFT_UNLOCK                    4
-#define SHIFT_UNLOCK_PARAMETER          12
-#define SHIFT_CHANGE_STATE              8
-#define SHIFT_CHANGE_TIMEOUT            20
-#define LOCK_FLAG_SHIFT                 16
-#define __HOLDKEY_BLOCK_BIT              0x1
-#define HOLDKEY_BLOCK_BIT               (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT)
-
-static PMMsg recv_data;
-
-int check_dimstay(int next_state, int flag)
-{
-       if (next_state != LCD_OFF)
-               return false;
-
-       if (!(flag & GOTO_STATE_NOW))
-               return false;
-
-       if (!(pm_status_flag & DIMSTAY_FLAG))
-               return false;
-
-       return true;
-}
-
-static enum state_t get_state(int s_bits)
-{
-       switch (s_bits) {
-       case LCD_NORMAL:
-               return S_NORMAL;
-       case LCD_DIM:
-               return S_LCDDIM;
-       case LCD_OFF:
-               return S_LCDOFF;
-       case STANDBY:
-               return S_STANDBY;
-       case SUSPEND:
-               return S_SLEEP;
-       default:
-               return -EINVAL;
-       }
-}
-
-static bool state_supported(enum state_t st)
-{
-       if (states[st].trans)
-               return true;
-       return false;
-}
-
-int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout)
-{
-       int cond;
-
-       if (!pm_callback)
-               return -1;
-
-       cond = get_state(s_bits);
-       if (cond < 0)
-               return cond;
-
-       if (!state_supported(cond))
-               return -ENOTSUP;
-
-       cond = SET_COND_REQUEST(cond, PM_REQUEST_LOCK);
-
-       if (flag & GOTO_STATE_NOW)
-               /* if the flag is true, go to the locking state directly */
-               cond = SET_COND_FLAG(cond, PM_REQUEST_CHANGE);
-
-       if (flag & HOLD_KEY_BLOCK)
-               cond = SET_COND_FLAG(cond, PM_FLAG_BLOCK_HOLDKEY);
-
-       recv_data.pid = pid;
-       recv_data.cond = cond;
-       recv_data.timeout = timeout;
-
-       (*pm_callback)(PM_CONTROL_EVENT, &recv_data);
-
-       return 0;
-}
-
-int pm_unlock_internal(pid_t pid, int s_bits, int flag)
-{
-       int cond;
-
-       if (!pm_callback)
-               return -1;
-
-       cond = get_state(s_bits);
-       if (cond < 0)
-               return cond;
-
-       if (!state_supported(cond))
-               return -ENOTSUP;
-
-       cond = SET_COND_REQUEST(cond, PM_REQUEST_UNLOCK);
-
-       if (flag & PM_KEEP_TIMER)
-               cond = SET_COND_FLAG(cond, PM_FLAG_KEEP_TIMER);
-
-       if (flag & PM_RESET_TIMER)
-               cond = SET_COND_FLAG(cond, PM_FLAG_RESET_TIMER);
-
-       recv_data.pid = pid;
-       recv_data.cond = cond;
-       recv_data.timeout = 0;
-
-       (*pm_callback)(PM_CONTROL_EVENT, &recv_data);
-
-       return 0;
-}
-
-int pm_change_internal(pid_t pid, int s_bits)
-{
-       int cond;
-
-       if (!pm_callback)
-               return -1;
-
-       cond = get_state(s_bits);
-       if (cond < 0)
-               return cond;
-
-       if (!state_supported(cond))
-               return -ENOTSUP;
-
-       cond = SET_COND_REQUEST(cond, PM_REQUEST_CHANGE);
-
-       recv_data.pid = pid;
-       recv_data.cond = cond;
-       recv_data.timeout = 0;
-
-       (*pm_callback)(PM_CONTROL_EVENT, &recv_data);
-
-       return 0;
-}
diff --git a/src/display/poll.h b/src/display/poll.h
deleted file mode 100644 (file)
index 7beb910..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/**
- * @file       poll.h
- * @brief      Power Manager input device poll implementation
- *
- */
-
-#ifndef __PM_POLL_H__
-#define __PM_POLL_H__
-
-#include <Ecore.h>
-#include "core/edbus-handler.h"
-/**
- * @addtogroup POWER_MANAGER
- * @{
- */
-
-enum {
-       INPUT_POLL_EVENT = -9,
-       SIDEKEY_POLL_EVENT,
-       PWRKEY_POLL_EVENT,
-       PM_CONTROL_EVENT,
-};
-
-enum {
-       INTERNAL_LOCK_BASE = 100000,
-       INTERNAL_LOCK_BATTERY,
-       INTERNAL_LOCK_BATTERY_FULL,
-       INTERNAL_LOCK_BOOTING,
-       INTERNAL_LOCK_DUMPMODE,
-       INTERNAL_LOCK_HDMI,
-       INTERNAL_LOCK_ODE,
-       INTERNAL_LOCK_POPUP,
-       INTERNAL_LOCK_SOUNDDOCK,
-       INTERNAL_LOCK_TIME,
-       INTERNAL_LOCK_USB,
-       INTERNAL_LOCK_POWEROFF,
-       INTERNAL_LOCK_SUSPEND,
-       INTERNAL_LOCK_COOL_DOWN,
-       INTERNAL_LOCK_LOWBAT,
-};
-
-#define SIGNAL_NAME_LCD_CONTROL                "lcdcontol"
-
-#define LCD_NORMAL  0x01       /**< NORMAL state */
-#define LCD_DIM     0x02       /**< LCD dimming state */
-#define LCD_OFF     0x04       /**< LCD off state */
-#define SUSPEND     0x08       /**< Suspend state */
-#define POWER_OFF   0x10       /**< Sleep state */
-#define STANDBY     0x20       /**< Standby state */
-
-
-#define STAY_CUR_STATE 0x1
-#define GOTO_STATE_NOW 0x2
-#define HOLD_KEY_BLOCK  0x4
-
-#define PM_SLEEP_MARGIN        0x0     /**< keep guard time for unlock */
-#define PM_RESET_TIMER 0x1     /**< reset timer for unlock */
-#define PM_KEEP_TIMER          0x2     /**< keep timer for unlock */
-
-/**
- * display lock condition (unsigned integer)
- *
- *     xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
- *     reserved  flags   request   state
- *
- */
-
-enum cond_request_e {
-       PM_REQUEST_LOCK     = 1 << 0,
-       PM_REQUEST_UNLOCK   = 1 << 1,
-       PM_REQUEST_CHANGE   = 1 << 2,
-};
-
-enum cond_flags_e {
-       PM_FLAG_BLOCK_HOLDKEY  = 1 << 0,
-       PM_FLAG_RESET_TIMER    = 1 << 1,
-       PM_FLAG_KEEP_TIMER     = 1 << 2,
-};
-
-#define SHIFT_STATE            0
-#define SHIFT_REQUEST          8
-#define SHIFT_FLAGS            16
-#define COND_MASK              0xff /* 11111111 */
-#define SET_COND_REQUEST(cond, req)      ((cond) | ((req) << SHIFT_REQUEST))
-#define SET_COND_FLAG(cond, flags)       ((cond) | ((flags) << SHIFT_FLAGS))
-#define IS_COND_REQUEST_LOCK(cond)       (((cond) >> SHIFT_REQUEST) & COND_MASK & PM_REQUEST_LOCK)
-#define IS_COND_REQUEST_UNLOCK(cond)     (((cond) >> SHIFT_REQUEST) & COND_MASK & PM_REQUEST_UNLOCK)
-#define IS_COND_REQUEST_CHANGE(cond)     (((cond) >> SHIFT_REQUEST) & COND_MASK & PM_REQUEST_CHANGE)
-#define GET_COND_STATE(cond)             ((cond) & COND_MASK)
-#define GET_COND_FLAG(cond)              (((cond) >> SHIFT_FLAGS) & COND_MASK)
-
-
-#define PM_LOCK_STR    "lock"
-#define PM_UNLOCK_STR  "unlock"
-#define PM_CHANGE_STR  "change"
-
-#define PM_LCDOFF_STR  "lcdoff"
-#define PM_LCDDIM_STR  "lcddim"
-#define PM_LCDON_STR   "lcdon"
-#define PM_STANDBY_STR "standby"
-#define PM_SUSPEND_STR "suspend"
-
-#define STAYCURSTATE_STR "staycurstate"
-#define GOTOSTATENOW_STR "gotostatenow"
-
-#define HOLDKEYBLOCK_STR "holdkeyblock"
-#define STANDBYMODE_STR  "standbymode"
-
-#define SLEEP_MARGIN_STR "sleepmargin"
-#define RESET_TIMER_STR  "resettimer"
-#define KEEP_TIMER_STR   "keeptimer"
-
-typedef struct {
-       pid_t pid;
-       unsigned int cond;
-       unsigned int timeout;
-       unsigned int timeout2;
-} PMMsg;
-
-extern int (*pm_callback) (int, PMMsg *);
-
-int init_input(void);
-int exit_input(void);
-
-extern int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout);
-extern int pm_unlock_internal(pid_t pid, int s_bits, int flag);
-extern int pm_change_internal(pid_t pid, int s_bits);
-
-/**
- * @}
- */
-
-#endif                         /*__PM_POLL_H__ */
diff --git a/src/display/setting.c b/src/display/setting.c
deleted file mode 100644 (file)
index fbc0359..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 <errno.h>
-#include <stdbool.h>
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "core.h"
-#include "util.h"
-#include "setting.h"
-
-#define LCD_DIM_RATIO          0.3
-#define LCD_MAX_DIM_TIMEOUT    7000
-#define LCD_MIN_DIM_TIMEOUT    500
-
-static const char *setting_keys[SETTING_GET_END] = {
-       [SETTING_TO_NORMAL] = VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL,
-       [SETTING_BRT_LEVEL] = VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
-       [SETTING_LOCK_SCREEN] = VCONFKEY_IDLE_LOCK_STATE,
-       [SETTING_POWER_CUSTOM_BRIGHTNESS] = VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS,
-};
-
-static int lock_screen_state = VCONFKEY_IDLE_UNLOCK;
-static bool lock_screen_bg_state = false;
-static int force_lcdtimeout = 0;
-static int custom_on_timeout = 0;
-static int custom_normal_timeout = 0;
-static int custom_dim_timeout = 0;
-
-int (*update_pm_setting) (int key_idx, int val);
-
-static void display_state_send_system_event(int state)
-{
-       bundle *b;
-       const char *str;
-
-       if (state == S_NORMAL)
-               str = EVT_VAL_DISPLAY_NORMAL;
-       else if (state == S_LCDDIM)
-               str = EVT_VAL_DISPLAY_DIM;
-       else if (state == S_LCDOFF)
-               str = EVT_VAL_DISPLAY_OFF;
-       else
-               return;
-
-       _I("eventsystem (%s)", str);
-
-       b = bundle_create();
-       bundle_add_str(b, EVT_KEY_DISPLAY_STATE, str);
-       eventsystem_send_system_event(SYS_EVENT_DISPLAY_STATE, b);
-       bundle_free(b);
-}
-
-int set_force_lcdtimeout(int timeout)
-{
-       if (timeout < 0)
-               return -EINVAL;
-
-       force_lcdtimeout = timeout;
-
-       return 0;
-}
-
-int get_lock_screen_state(void)
-{
-       return lock_screen_state;
-}
-
-void set_lock_screen_state(int state)
-{
-       switch (state) {
-       case VCONFKEY_IDLE_LOCK:
-       case VCONFKEY_IDLE_UNLOCK:
-               lock_screen_state = state;
-               break;
-       default:
-               lock_screen_state = VCONFKEY_IDLE_UNLOCK;
-       }
-}
-
-int get_lock_screen_bg_state(void)
-{
-       return lock_screen_bg_state;
-}
-
-void set_lock_screen_bg_state(bool state)
-{
-       _I("state is %d", state);
-       lock_screen_bg_state = state;
-}
-
-int get_charging_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val);
-}
-
-int get_lowbatt_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, val);
-}
-
-int get_usb_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, val);
-}
-
-int set_setting_pmstate(int val)
-{
-       display_state_send_system_event(val);
-       return vconf_set_int(VCONFKEY_PM_STATE, val);
-}
-
-int get_setting_brightness(int *level)
-{
-       return vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, level);
-}
-
-void get_dim_timeout(int *dim_timeout)
-{
-       int vconf_timeout, on_timeout, val, ret;
-
-       if (custom_dim_timeout > 0) {
-               *dim_timeout = custom_dim_timeout;
-               return;
-       }
-
-       ret = vconf_get_int(setting_keys[SETTING_TO_NORMAL], &vconf_timeout);
-       if (ret != 0) {
-               _E("Failed ro get setting timeout!");
-               vconf_timeout = DEFAULT_NORMAL_TIMEOUT;
-       }
-
-       if (force_lcdtimeout > 0)
-               on_timeout = SEC_TO_MSEC(force_lcdtimeout);
-       else
-               on_timeout = SEC_TO_MSEC(vconf_timeout);
-
-       val = (double)on_timeout * LCD_DIM_RATIO;
-       if (val > LCD_MAX_DIM_TIMEOUT)
-               val = LCD_MAX_DIM_TIMEOUT;
-
-       *dim_timeout = val;
-}
-
-void get_run_timeout(int *timeout)
-{
-       int dim_timeout = -1;
-       int vconf_timeout = -1;
-       int on_timeout;
-       int ret;
-
-       if (custom_normal_timeout > 0) {
-               *timeout = custom_normal_timeout;
-               return;
-       }
-
-       ret = vconf_get_int(setting_keys[SETTING_TO_NORMAL], &vconf_timeout);
-       if (ret != 0) {
-               _E("Failed ro get setting timeout!");
-               vconf_timeout = DEFAULT_NORMAL_TIMEOUT;
-       }
-
-       if (force_lcdtimeout > 0)
-               on_timeout = SEC_TO_MSEC(force_lcdtimeout);
-       else
-               on_timeout = SEC_TO_MSEC(vconf_timeout);
-
-       if (on_timeout == 0) {
-               *timeout = on_timeout;
-               return;
-       }
-
-       get_dim_timeout(&dim_timeout);
-       *timeout = on_timeout - dim_timeout;
-}
-
-int set_custom_lcdon_timeout(int timeout)
-{
-       int changed = (custom_on_timeout == timeout ? false : true);
-
-       custom_on_timeout = timeout;
-
-       if (timeout <= 0) {
-               custom_normal_timeout = 0;
-               custom_dim_timeout = 0;
-               return changed;
-       }
-
-       custom_dim_timeout = (double)timeout * LCD_DIM_RATIO;
-       custom_normal_timeout = timeout - custom_dim_timeout;
-
-       _I("custom normal(%d), dim(%d)", custom_normal_timeout,
-           custom_dim_timeout);
-
-       return changed;
-}
-
-static int setting_cb(keynode_t *key_nodes, void *data)
-{
-       keynode_t *tmp = key_nodes;
-       int index;
-
-       index = (int)((intptr_t)data);
-       if (index > SETTING_END) {
-               _E("Unknown setting key: %s, idx=%d",
-                      vconf_keynode_get_name(tmp), index);
-               return -1;
-       }
-       if (update_pm_setting != NULL) {
-               update_pm_setting(index, vconf_keynode_get_int(tmp));
-       }
-
-       return 0;
-}
-
-int init_setting(int (*func) (int key_idx, int val))
-{
-       int i;
-
-       if (func != NULL)
-               update_pm_setting = func;
-
-       for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) {
-               /*
-                * To pass an index data through the vconf infratstructure
-                * without memory allocation, an index data becomes typecast
-                * to proper pointer size on each architecture.
-                */
-               vconf_notify_key_changed(setting_keys[i], (void *)setting_cb,
-                                        (void *)((intptr_t)i));
-       }
-
-       return 0;
-}
-
-int exit_setting(void)
-{
-       int i;
-       for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) {
-               vconf_ignore_key_changed(setting_keys[i], (void *)setting_cb);
-       }
-
-       return 0;
-}
diff --git a/src/display/setting.h b/src/display/setting.h
deleted file mode 100644 (file)
index 9763c97..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/*
- * @file       setting.h
- * @brief      Power manager setting module header
- */
-#ifndef __PM_SETTING_H__
-#define __PM_SETTING_H__
-
-#include <vconf.h>
-
-/*
- * @addtogroup POWER_MANAGER
- * @{
- */
-
-enum {
-       SETTING_BEGIN = 0,
-       SETTING_TO_NORMAL = SETTING_BEGIN,
-       SETTING_BRT_LEVEL,
-       SETTING_LOCK_SCREEN,
-       SETTING_POWER_CUSTOM_BRIGHTNESS,
-       SETTING_GET_END,
-       SETTING_PM_STATE = SETTING_GET_END,
-       SETTING_LOW_BATT,
-       SETTING_CHARGING,
-       SETTING_POWEROFF,
-       SETTING_HALLIC_OPEN,
-       SETTING_LOCK_SCREEN_BG,
-       SETTING_END
-};
-
-extern int (*update_pm_setting) (int key_idx, int val);
-
-int get_setting_brightness(int *level);
-
-/*
- * @brief setting initialization function
- *
- * get the variables if it exists. otherwise, set the default.
- * and register some callback functions.
- *
- * @internal
- * @param[in] func configuration change callback function
- * @return 0 : success, -1 : error
- */
-extern int init_setting(int (*func) (int key_idx, int val));
-
-extern int exit_setting();
-
-/*
- * get normal state timeout from SLP-setting SLP_SETTING_LCD_TIMEOUT_NORMAL
- *
- * @internal
- * @param[out] timeout timeout variable pointer
- */
-void get_run_timeout(int *timeout);
-
-/*
- * get LCD dim state timeout from environment variable.
- *
- * @internal
- * @param[out] dim_timeout timeout variable pointer
- */
-void get_dim_timeout(int *dim_timeout);
-/*
- * get USB connection status from SLP-setting SLP_SETTING_USB_STATUS
- *
- * @internal
- * @param[out] val usb connection status variable pointer, 0 is disconnected, others is connected.
- * @return 0 : success, -1 : error
- */
-extern int get_usb_status(int *val);
-
-/*
- * set Current power manager state at SLP-setting "memory/pwrmgr/state"
- *
- * @internal
- * @param[in] val current power manager state.
- * @return 0 : success, -1 : error
- */
-extern int set_setting_pmstate(int val);
-
-/*
- * get charging status at SLP-setting "memory/Battery/Charger"
- *
- * @internal
- * @param[in] val charging or not (1 or 0 respectively).
- * @return 0 : success, -1 : error
- */
-extern int get_charging_status(int *val);
-
-/*
- * get current battery low status at SLP-setting "memory/Battery/Status/Low"
- *
- * @internal
- * @param[in] val current low battery status
- * @return 0 : success, -1 : error
- */
-extern int get_lowbatt_status(int *val);
-
-int get_lock_screen_state(void);
-
-/*
- * @}
- */
-
-#endif
diff --git a/src/display/state-tv.c b/src/display/state-tv.c
deleted file mode 100644 (file)
index d496f16..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdbool.h>
-#include <time.h>
-#include <Ecore.h>
-#include "core/common.h"
-#include "core/log.h"
-#include "core/device-notifier.h"
-#include "core/devices.h"
-#include "power/power-handler.h"
-#include "core.h"
-#include "poll.h"
-#include "device-interface.h"
-#include "util.h"
-
-#define PRE_STATE_CHANGE_TIMEOUT   500*1000 /* 500ms */
-#define SIGNAL_CHANGE_STATE        "ChangeState"
-#define SIGNAL_PRE_CHANGE_STATE    "PreChangeState"
-#define SIGNAL_WAKEUP              "WakeUp"
-#define SIGNAL_PRE_WAKEUP          "PreWakeUp"
-#define SIGNAL_POST_WAKEUP         "PostWakeUp"
-#define SIGNAL_EARLY_WAKEUP        "EarlyWakeUp"
-
-static Ecore_Timer *standby_timer;
-
-static int change_state(pid_t pid, int type, enum state_t st)
-{
-       int ret;
-
-       if (type == PM_CONTROL_EVENT && states[st].check) {
-               ret = states[pm_cur_state].check(pm_cur_state, st);
-               if (ret != 0) {
-                       _E("(%s) State Locked. Cannot be changed to (%s)",
-                                       states[pm_cur_state].name, states[st].name);
-                       return ret;
-               }
-       }
-
-       if (states[st].trans) {
-               ret = states[st].trans(type);
-               if (ret < 0) {
-                       _E("Failed to trans state (%s, ret:%d)", states[st].name, ret);
-                       return ret;
-               }
-       }
-
-       _I("Success to change state (%s) requested by pid(%d)", states[st].name, pid);
-
-       return 0;
-}
-
-static int tv_proc_change_state(unsigned int cond, pid_t pid)
-{
-       enum state_t next;
-       int ret;
-
-       next = GET_COND_STATE(cond);
-       if (pm_cur_state == next) {
-               _I("current state (%d) == next state (%d)", pm_cur_state, next);
-               return 0;
-       }
-
-       if (pid < INTERNAL_LOCK_BASE) { /* Request from other process*/
-               if (next == S_SUSPEND || next == S_POWEROFF) {
-                       _E("Do not change to suspend or power off directly");
-                       return -EPERM;
-               }
-       }
-
-       _I("Change State to %s (%d)", states[next].name, pid);
-
-       ret = change_state(pid, PM_CONTROL_EVENT, next);
-       if (ret != 0) {
-               _E("Failed to change state (%d)", ret);
-               return ret;
-       }
-
-       return 0;
-}
-
-unsigned long long get_uptime(void)
-{
-       struct timespec t;
-       clock_gettime(CLOCK_MONOTONIC, &t);
-       return t.tv_sec;
-}
-
-static int lcdon_check(int curr, int next)
-{
-       /* do not changed to next state if who lock the normal mode */
-       check_processes(pm_cur_state);
-       if (check_lock_state(pm_cur_state)) {
-               _I("S_LCDON Lock state");
-               return 1;
-       }
-
-       return 0;
-}
-
-static int lcdon_pre(void *data)
-{
-       char *arr[1];
-
-       /* TODO: cancel suspend */
-
-       /* That will unlock callback registration in case of getting back to normal
-        * from partial poweroff. If someone start poweroff with standby lock and then
-        * unlock, change state to lcdon, registration of poweroff callback would be blocked
-        * as unblocking is done when resuming from suspend.
-        */
-       device_notify(DEVICE_NOTIFIER_POWER_RESUME, NULL);
-
-       if (pm_cur_state == S_STANDBY) {
-               arr[0] = states[S_LCDON].name;
-               _I("send pre state change NORMAL");
-               broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                               SIGNAL_PRE_CHANGE_STATE, "s", arr);
-               /*Give time to process callback */
-               usleep(PRE_STATE_CHANGE_TIMEOUT);
-       }
-
-       return 0;
-}
-
-static int lcdon_post(void *data)
-{
-       char *arr[1];
-
-       arr[0] = states[S_LCDON].name;
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       SIGNAL_CHANGE_STATE, "s", arr);
-
-       /* TODO: set_power */
-
-       return 0;
-}
-
-static int lcdon_action(int timeout)
-{
-       if (pm_cur_state != pm_old_state &&
-               pm_cur_state != S_SLEEP)
-               set_setting_pmstate(pm_cur_state);
-
-       if (pm_old_state != S_LCDOFF ||
-               pm_old_state != S_SLEEP) {
-               _I("pm_old_state (%s). Skip lcd on", states[pm_old_state].name);
-               return 0;
-       }
-
-       /* TODO: post resume */
-
-       backlight_ops.on(0);
-
-       return 0;
-}
-
-static int lcdon_trans(int evt)
-{
-       int ret;
-       struct state *st;
-
-       ret = lcdon_pre(NULL);
-       if (ret < 0) {
-               _E("S_LCDON pre-operation failed(%d)", ret);
-               return ret;
-       }
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_LCDON;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       ret = lcdon_post(NULL);
-       if (ret < 0)
-               _E("S_LCDON post-operation failed(%d)", ret);
-
-       return 0;
-}
-
-static int lcdoff_check(int curr, int next)
-{
-       /* LCD OFF can change to LCD ON and STANDBY state */
-       return 0;
-}
-
-static int lcdoff_pre(void *data)
-{
-       return 0;
-}
-
-static int lcdoff_post(void *data)
-{
-       char *arr[1];
-
-       /* broadcast to other application */
-       arr[0] = states[S_LCDOFF].name;
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       SIGNAL_CHANGE_STATE, "s", arr);
-
-       return 0;
-}
-
-static int lcdoff_action(int timeout)
-{
-       if (pm_cur_state != pm_old_state &&
-               pm_cur_state != S_SLEEP)
-               set_setting_pmstate(pm_cur_state);
-
-       if (pm_old_state == S_SUSPEND ||
-               pm_old_state == S_LCDOFF)
-               return 0;
-
-       backlight_ops.off(0);
-
-       return 0;
-}
-
-static int lcdoff_trans(int evt)
-{
-       int ret;
-       struct state *st;
-
-       ret = lcdoff_pre(NULL);
-       if (ret < 0) {
-               _E("S_LCDOFF pre-operation failed (%d)", ret);
-               return ret;
-       }
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_LCDOFF;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       ret = lcdoff_post(NULL);
-       if (ret < 0)
-               _E("S_LCDOFF post-operation failed (%d)", ret);
-
-       return 0;
-}
-
-static int standby_check(int curr, int next)
-{
-       /* STANDBY can change to LCD ON or POWER OFF state */
-       if (next == S_LCDOFF)
-               return -EPERM;
-
-       /* do not change to next state if who lock the standby mode */
-       check_processes(S_LCDOFF);
-       if (check_lock_state(S_LCDOFF)) {
-               _I("S_LCDOFF Lock state");
-               return 1;
-       }
-
-       /* TODO: Instant on timer */
-
-       return 0;
-}
-
-static int standby_pre(void *data)
-{
-       return 0;
-}
-
-static int standby_post(void *data)
-{
-       char *arr[1];
-
-       /* broadcast to other application */
-       arr[0] = states[S_STANDBY].name;
-       broadcast_edbus_signal(DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       SIGNAL_CHANGE_STATE, "s", arr);
-
-       backlight_ops.off(0);
-
-       /* Set power */
-
-       return 0;
-}
-
-static int poweroff_trans(int evt);
-
-static Eina_Bool standby_go_next_state(void *data)
-{
-       int ret;
-
-       if (standby_timer) {
-               ecore_timer_del(standby_timer);
-               standby_timer = NULL;
-       }
-
-       ret = pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND);
-       if (ret < 0) {
-               _E("Failed to change state to S_SUSPEND. Now Power off !!");
-               poweroff_trans(0);
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static int standby_action(int timeout)
-{
-       if (pm_cur_state != pm_old_state &&
-               pm_cur_state != S_SLEEP)
-               set_setting_pmstate(pm_cur_state);
-
-       backlight_ops.off(0);
-
-       standby_timer = ecore_timer_add(0,
-                       standby_go_next_state, NULL);
-       if (!standby_timer)
-               _E("Failed to add timer to go to next state of S_STANDBY");
-
-       return 0;
-}
-
-static int standby_trans(int evt)
-{
-       int ret;
-       struct state *st;
-
-       ret = standby_pre(NULL);
-       if (ret < 0) {
-               _E("S_STANDBY pre-operation failed(%d)", ret);
-               return ret;
-       }
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_STANDBY;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       ret = standby_post(NULL);
-       if (ret < 0)
-               _E("S_STANDBY post-operation failed(%d)", ret);
-
-       return 0;
-}
-
-static int suspend_check(int curr, int next)
-{
-       /* DO NOT USE THIS FUNCTION */
-       return 0;
-}
-
-static int suspend_pre(void *data)
-{
-       return 0;
-}
-
-static int suspend_post(void *data)
-{
-       char *arr[1];
-       int ret;
-       unsigned int cond = 0;
-
-       /* TODO: count InstandOn */
-
-       cond = S_LCDON;
-       ret = tv_proc_change_state(cond, INTERNAL_LOCK_SUSPEND);
-       if (ret < 0)
-               _E("Fail to change state to next_state(%s)", states[cond].name);
-
-       /* Broadcast pre-wakeup signal */
-       arr[0] = "0";
-       broadcast_edbus_signal(DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
-                       SIGNAL_PRE_WAKEUP, "i", arr);
-
-       /* Notify resume state */
-       device_notify(DEVICE_NOTIFIER_POWER_RESUME, NULL);
-
-       return 0;
-}
-
-static int suspend_action(int timeout)
-{
-       struct state *st;
-
-       if (pm_cur_state != pm_old_state &&
-               pm_cur_state != S_SLEEP)
-               set_setting_pmstate(pm_cur_state);
-
-       /* TODO: set wakeup count */
-
-       /* sleep state : set system mode to SUSPEND */
-       power_ops.suspend();
-
-       _I("system wakeup!!");
-
-       /* Resume !! */
-       /* system waked up by devices */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_LCDOFF;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       return 0;
-}
-
-static int suspend_trans(int evt)
-{
-       int ret;
-       struct state *st;
-
-       ret = suspend_pre(NULL);
-       if (ret < 0) {
-               _E("S_SUSPEND pre-operation failed(%d)", ret);
-               return ret;
-       }
-
-       /* state transition */
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_LCDOFF;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       pm_old_state = pm_cur_state;
-       pm_cur_state = S_SUSPEND;
-       st = &states[pm_cur_state];
-
-       if (st->action)
-               st->action(0);
-
-       ret = suspend_post(NULL);
-       if (ret < 0)
-               _E("S_SUSPEND post-operation failed(%d)", ret);
-
-       return 0;
-}
-
-static int poweroff_check(int curr, int next)
-{
-       /* DO NOT USE THIS FUNCTION */
-       return 0;
-}
-
-static int poweroff_action(int timeout)
-{
-       static const struct device_ops *ops;
-
-       FIND_DEVICE_INT(ops, POWER_OPS_NAME);
-
-       return ops->execute(POWER_POWEROFF);
-}
-
-static int poweroff_trans(int evt)
-{
-       struct state *st;
-       st = &states[S_POWEROFF];
-       if (st->action)
-               st->action(0);
-       return 0;
-}
-
-static int display_lock_changed(void *data)
-{
-       bool state = (bool)data;
-
-       if (pm_cur_state != S_STANDBY)
-               return 0;
-
-       if (!state)
-               standby_go_next_state(NULL);
-
-       return 0;
-}
-
-static void set_tv_operations(enum state_t st,
-               char *name,
-               int (*check) (int curr, int next),
-               int (*trans) (int evt),
-               int (*action) (int timeout))
-{
-       change_state_name(st, name);
-       change_state_check(st, check);
-       change_state_trans(st, trans);
-       change_state_action(st, action);
-}
-
-struct _tv_states {
-       enum state_t state;
-       char *name;
-       int (*check)(int curr, int next);
-       int (*trans)(int evt);
-       int (*action)(int timeout);
-} tv_states[] = {
-       { S_LCDON,    "S_LCDON",    lcdon_check,    lcdon_trans,    lcdon_action    },
-       { S_LCDDIM,   "S_LCDDIM",   NULL,           NULL,           NULL            },
-       { S_LCDOFF,   "S_LCDOFF",   lcdoff_check,   lcdoff_trans,   lcdoff_action   },
-       { S_STANDBY,  "S_STANDBY",  standby_check,  standby_trans,  standby_action  },
-       { S_SUSPEND,  "S_SUSPEND",  suspend_check,  suspend_trans,  suspend_action  },
-       { S_POWEROFF, "S_POWEROFF", poweroff_check, poweroff_trans, poweroff_action },
-};
-
-static void __CONSTRUCTOR__ state_tv_init(void)
-{
-       int i;
-
-       _I("TV Profile !!");
-
-       for (i = 0 ; i < ARRAY_SIZE(tv_states) ; i++)
-               set_tv_operations(tv_states[i].state,
-                               tv_states[i].name,
-                               tv_states[i].check,
-                               tv_states[i].trans,
-                               tv_states[i].action);
-
-       change_proc_change_state(tv_proc_change_state);
-
-       register_notifier(DEVICE_NOTIFIER_DISPLAY_LOCK, display_lock_changed);
-}
-
-static void __DESTRUCTOR__ state_tv_deinit(void)
-{
-       unregister_notifier(DEVICE_NOTIFIER_DISPLAY_LOCK, display_lock_changed);
-}
diff --git a/src/display/util.h b/src/display/util.h
deleted file mode 100644 (file)
index a55f130..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-
-/**
- * @file       util.h
- * @brief      Utilities header for Power manager
- */
-#ifndef __DEF_UTIL_H__
-#define __DEF_UTIL_H__
-
-/**
- * @addtogroup POWER_MANAGER
- * @{
- */
-#ifdef ENABLE_DEVICED_DLOG
-#define ENABLE_DLOG
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "POWER_MANAGER"
-#include "shared/log-macro.h"
-
-#define SEC_TO_MSEC(x) ((x)*1000)
-#define MSEC_TO_SEC(x) ((x)/1000)
-
-/**
- * @}
- */
-#endif
diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c
deleted file mode 100644 (file)
index 9b83013..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 <vconf.h>
-
-#include "core/log.h"
-#include "core/device-notifier.h"
-#include "core/edbus-handler.h"
-#include "core/udev.h"
-#include "display/core.h"
-#include "extcon/extcon.h"
-
-#define METHOD_GET_CRADLE      "GetCradle"
-#define SIGNAL_CRADLE_STATE    "ChangedCradle"
-
-static struct extcon_ops cradle_extcon_ops;
-
-static void cradle_send_broadcast(int status)
-{
-       static int old;
-       char *arr[1];
-       char str_status[32];
-
-       if (old == status)
-               return;
-
-       _I("broadcast cradle status %d", status);
-       old = status;
-       snprintf(str_status, sizeof(str_status), "%d", status);
-       arr[0] = str_status;
-
-       broadcast_edbus_signal(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
-                       SIGNAL_CRADLE_STATE, "i", arr);
-}
-
-static int cradle_update(int status)
-{
-       _I("jack - cradle changed %d", status);
-       pm_change_internal(getpid(), LCD_NORMAL);
-       cradle_send_broadcast(status);
-       if (vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status) != 0) {
-               _E("failed to set vconf status");
-               return -EIO;
-       }
-
-       if (status == DOCK_SOUND)
-               pm_lock_internal(getpid(), LCD_DIM, STAY_CUR_STATE, 0);
-       else if (status == DOCK_NONE)
-               pm_unlock_internal(getpid(), LCD_DIM, PM_SLEEP_MARGIN);
-
-       return 0;
-}
-
-static int display_changed(void *data)
-{
-       enum state_t state;
-       int cradle;
-
-       if (!data)
-               return 0;
-
-       state = *(int *)data;
-       if (state != S_NORMAL)
-               return 0;
-
-       cradle = cradle_extcon_ops.status;
-       if (cradle == DOCK_SOUND) {
-               pm_lock_internal(getpid(), LCD_DIM, STAY_CUR_STATE, 0);
-               _I("sound dock is connected! dim lock is on.");
-       }
-
-       return 0;
-}
-
-static DBusMessage *dbus_cradle_handler(E_DBus_Object *obj, DBusMessage *msg)
-{
-       return make_reply_message(msg, cradle_extcon_ops.status);
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { METHOD_GET_CRADLE,     NULL, "i", dbus_cradle_handler },
-};
-
-static void cradle_init(void *data)
-{
-       int ret;
-
-       register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-
-       ret = register_edbus_method(DEVICED_PATH_SYSNOTI,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus method(%d)", ret);
-}
-
-static void cradle_exit(void *data)
-{
-       unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-}
-
-static struct extcon_ops cradle_extcon_ops = {
-       .name   = EXTCON_CABLE_DOCK,
-       .init   = cradle_init,
-       .exit   = cradle_exit,
-       .update = cradle_update,
-};
-
-EXTCON_OPS_REGISTER(cradle_extcon_ops)
diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c
deleted file mode 100644 (file)
index eb73b22..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2014 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 <vconf.h>
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "core/log.h"
-#include "display/poll.h"
-#include "extcon/extcon.h"
-
-#define SIGNAL_EARJACK_STATE   "ChangedEarjack"
-#define GET_EARJACK_STATE              "Earjack"
-
-static void earjack_send_broadcast(int status)
-{
-       static int old = 0;
-       char *arr[1];
-       char str_status[32];
-
-       if (old == status)
-               return;
-
-       _I("broadcast earjack status %d", status);
-       old = status;
-       snprintf(str_status, sizeof(str_status), "%d", status);
-       arr[0] = str_status;
-
-       broadcast_edbus_signal(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
-                       SIGNAL_EARJACK_STATE, "i", arr);
-}
-
-static void earjack_send_system_event(int status)
-{
-       bundle *b;
-       const char *str;
-
-       if (status)
-               str = EVT_VAL_EARJACK_CONNECTED;
-       else
-               str = EVT_VAL_EARJACK_DISCONNECTED;
-
-       b = bundle_create();
-       bundle_add_str(b, EVT_KEY_EARJACK_STATUS, str);
-       eventsystem_send_system_event(SYS_EVENT_EARJACK_STATUS, b);
-       bundle_free(b);
-}
-
-static int earjack_update(int status)
-{
-       _I("jack - earjack changed %d", status);
-       vconf_set_int(VCONFKEY_SYSMAN_EARJACK, status);
-       earjack_send_broadcast(status);
-       earjack_send_system_event(status);
-       if (status != 0)
-               pm_change_internal(getpid(), LCD_NORMAL);
-
-       return 0;
-}
-
-static struct extcon_ops earjack_extcon_ops = {
-       .name   = EXTCON_CABLE_HEADPHONE_OUT,
-       .update = earjack_update,
-};
-
-EXTCON_OPS_REGISTER(earjack_extcon_ops)
diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c
deleted file mode 100755 (executable)
index dd55e74..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 <hw/external_connection.h>
-
-#include "core/log.h"
-#include "core/list.h"
-#include "core/common.h"
-#include "core/devices.h"
-#include "core/config-parser.h"
-#include "core/device-notifier.h"
-#include "core/edbus-handler.h"
-#include "core/udev.h"
-#include "extcon.h"
-
-#define EXTCON_PATH "/sys/class/extcon"
-#define STATE_NAME  "STATE"
-
-#define BUF_MAX 256
-
-static dd_list *extcon_list;
-
-static struct external_connection_device *extcon_dev;
-
-void add_extcon(struct extcon_ops *dev)
-{
-       DD_LIST_APPEND(extcon_list, dev);
-}
-
-void remove_extcon(struct extcon_ops *dev)
-{
-       DD_LIST_REMOVE(extcon_list, dev);
-}
-
-static struct extcon_ops *find_extcon(const char *name)
-{
-       dd_list *l;
-       struct extcon_ops *dev;
-
-       if (!name)
-               return NULL;
-
-       DD_LIST_FOREACH(extcon_list, l, dev) {
-               if (!strcmp(dev->name, name))
-                       return dev;
-       }
-
-       return NULL;
-}
-
-int extcon_get_status(const char *name)
-{
-       struct extcon_ops *dev;
-
-       if (!name)
-               return -EINVAL;
-
-       dev = find_extcon(name);
-       if (!dev)
-               return -ENOENT;
-
-       return dev->status;
-}
-
-static int extcon_update(const char *name, const char *value)
-{
-       struct extcon_ops *dev;
-       int status;
-
-       if (!name || !value)
-               return -EINVAL;
-
-       dev = find_extcon(name);
-       if (!dev)
-               return -EINVAL;
-
-       status = atoi(value);
-
-       /* Do not invoke update func. if it's the same value */
-       if (dev->status == status)
-               return 0;
-
-       _I("Changed %s device : %d -> %d", name, dev->status, status);
-
-       dev->status = status;
-       if (dev->update)
-               dev->update(status);
-
-       return 0;
-}
-
-static int extcon_parsing_value(const char *value)
-{
-       char *s, *p;
-       char name[NAME_MAX];
-
-       if (!value)
-               return -EINVAL;
-
-       s = (char*)value;
-       while (s && *s != '\0') {
-               p = strchr(s, '=');
-               if (!p)
-                       break;
-               memset(name, 0, sizeof(name));
-               memcpy(name, s, p-s);
-               /* name is env_name and p+1 is env_value */
-               extcon_update(name, p+1);
-               s = strchr(p, '\n');
-               if (!s)
-                       break;
-               s += 1;
-       }
-
-       return 0;
-}
-
-static void uevent_extcon_handler(struct udev_device *dev)
-{
-       const char *env_value;
-       int ret;
-
-       env_value = udev_device_get_property_value(dev, STATE_NAME);
-       if (!env_value)
-               return;
-
-       ret = extcon_parsing_value(env_value);
-       if (ret < 0)
-               _E("fail to parse extcon value : %d", ret);
-}
-
-static int extcon_load_uevent(struct parse_result *result, void *user_data)
-{
-       if (!result)
-               return 0;
-
-       if (!result->name || !result->value)
-               return 0;
-
-       extcon_update(result->name, result->value);
-
-       return 0;
-}
-
-static int get_extcon_init_state(void)
-{
-       DIR *dir;
-       struct dirent entry;
-       struct dirent *result;
-       char node[BUF_MAX];
-       int ret;
-
-       dir = opendir(EXTCON_PATH);
-       if (!dir) {
-               ret = -errno;
-               _E("Cannot open dir (%s, errno:%d)", EXTCON_PATH, ret);
-               return ret;
-       }
-
-       ret = -ENOENT;
-       while (readdir_r(dir, &entry, &result) == 0 && result != NULL) {
-               if (result->d_name[0] == '.')
-                       continue;
-               snprintf(node, sizeof(node), "%s/%s/state",
-                               EXTCON_PATH, result->d_name);
-               _I("checking node (%s)", node);
-               if (access(node, F_OK) != 0)
-                       continue;
-
-               ret = config_parse(node, extcon_load_uevent, NULL);
-               if (ret < 0)
-                       _E("fail to parse %s data : %d", node, ret);
-       }
-
-       if (dir)
-               closedir(dir);
-
-       return 0;
-}
-
-static DBusMessage *dbus_get_extcon_status(E_DBus_Object *obj,
-               DBusMessage *msg)
-{
-       DBusError err;
-       struct extcon_ops *dev;
-       char *str;
-       int ret;
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                               DBUS_TYPE_STRING, &str,
-                               DBUS_TYPE_INVALID)) {
-               _E("fail to get message : %s - %s", err.name, err.message);
-               dbus_error_free(&err);
-               ret = -EINVAL;
-               goto error;
-       }
-
-       dev = find_extcon(str);
-       if (!dev) {
-               _E("fail to matched extcon device : %s", str);
-               ret = -ENOENT;
-               goto error;
-       }
-
-       ret = dev->status;
-       _D("Extcon device : %s, status : %d", dev->name, dev->status);
-
-error:
-       return make_reply_message(msg, ret);
-}
-
-static DBusMessage *dbus_enable_device(E_DBus_Object *obj, DBusMessage *msg)
-{
-       char *device;
-       int ret;
-
-       if (!dbus_message_get_args(msg, NULL,
-                   DBUS_TYPE_STRING, &device, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       ret = extcon_update(device, "1");
-
-out:
-       return make_reply_message(msg, ret);
-}
-
-static DBusMessage *dbus_disable_device(E_DBus_Object *obj, DBusMessage *msg)
-{
-       char *device;
-       int ret;
-
-       if (!dbus_message_get_args(msg, NULL,
-                   DBUS_TYPE_STRING, &device, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       ret = extcon_update(device, "0");
-
-out:
-       return make_reply_message(msg, ret);
-}
-
-static struct uevent_handler uh = {
-       .subsystem = EXTCON_SUBSYSTEM,
-       .uevent_func = uevent_extcon_handler,
-};
-
-static const struct edbus_method edbus_methods[] = {
-       { "GetStatus", "s",  "i", dbus_get_extcon_status },
-       { "enable",    "s", NULL, dbus_enable_device },  /* for devicectl */
-       { "disable",   "s", NULL, dbus_disable_device }, /* for devicectl */
-};
-
-/* used by HAL */
-static void extcon_changed(struct connection_info *info, void *data)
-{
-       if (!info)
-               return;
-
-       if (!info->name || !info->state)
-               return;
-
-       /* call to update */
-       extcon_update(info->name, info->state);
-}
-
-static int extcon_probe(void *data)
-{
-       struct hw_info *info;
-       int ret;
-
-       if (extcon_dev)
-               return 0;
-
-       ret = hw_get_info(EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID,
-                       (const struct hw_info **)&info);
-       if (ret == 0) {
-               if (!info->open) {
-                       _E("Failed to open extcon device; open(NULL)");
-                       return -ENODEV;
-               }
-
-               ret = info->open(info, NULL, (struct hw_common **)&extcon_dev);
-               if (ret < 0) {
-                       _E("Failed to get extcon device structure (%d)", ret);
-                       return ret;
-               }
-
-               _I("extcon device structure load success");
-               return 0;
-       }
-
-       /**
-        * find extcon class.
-        * if there is no extcon class,
-        * deviced does not control extcon devices.
-        */
-       if (access(EXTCON_PATH, R_OK) != 0) {
-               _E("there is no extcon class");
-               return -ENODEV;
-       }
-
-       return 0;
-}
-
-static void extcon_init(void *data)
-{
-       int ret;
-       dd_list *l;
-       struct extcon_ops *dev;
-
-       if (!extcon_list)
-               return;
-
-       /* initialize extcon devices */
-       DD_LIST_FOREACH(extcon_list, l, dev) {
-               _I("[extcon] init (%s)", dev->name);
-               if (dev->init)
-                       dev->init(data);
-       }
-
-       if (extcon_dev) { /* HAL is used */
-               if (extcon_dev->register_changed_event)
-                       extcon_dev->register_changed_event(extcon_changed, NULL);
-
-               if (extcon_dev->get_current_state)
-                       extcon_dev->get_current_state(extcon_changed, NULL);
-
-       } else {
-               /* register extcon uevent */
-               ret = register_kernel_uevent_control(&uh);
-               if (ret < 0)
-                       _E("fail to register extcon uevent : %d", ret);
-
-               /* load the initialize value by accessing the node directly */
-               ret = get_extcon_init_state();
-               if (ret < 0)
-                       _E("fail to init extcon nodes : %d", ret);
-       }
-
-       /* register extcon object first */
-       ret = register_edbus_interface_and_method(DEVICED_PATH_EXTCON,
-                       DEVICED_INTERFACE_EXTCON,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus interface and method(%d)", ret);
-}
-
-static void extcon_exit(void *data)
-{
-       dd_list *l;
-       struct extcon_ops *dev;
-       struct hw_info *info;
-       int ret;
-
-       if (extcon_dev) {
-               if (extcon_dev->unregister_changed_event)
-                       extcon_dev->unregister_changed_event(extcon_changed);
-
-               info = extcon_dev->common.info;
-               if (!info)
-                       free(extcon_dev);
-               else
-                       info->close((struct hw_common *)extcon_dev);
-               extcon_dev = NULL;
-
-       } else {
-               /* unreigster extcon uevent */
-               ret = unregister_kernel_uevent_control(&uh);
-               if (ret < 0)
-                       _E("fail to unregister extcon uevent : %d", ret);
-       }
-
-       /* deinitialize extcon devices */
-       DD_LIST_FOREACH(extcon_list, l, dev) {
-               _I("[extcon] deinit (%s)", dev->name);
-               if (dev->exit)
-                       dev->exit(data);
-       }
-}
-
-static const struct device_ops extcon_device_ops = {
-       .name   = "extcon",
-       .probe  = extcon_probe,
-       .init   = extcon_init,
-       .exit   = extcon_exit,
-};
-
-DEVICE_OPS_REGISTER(&extcon_device_ops)
diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h
deleted file mode 100755 (executable)
index eb10fc9..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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.
- */
-
-
-#ifndef __EXTCON_H__
-#define __EXTCON_H__
-
-#include "core/common.h"
-
-/**
- * Extcon cable name is shared with kernel extcon class.
- * So do not change below strings.
- */
-#define EXTCON_CABLE_USB              "USB"
-#define EXTCON_CABLE_USB_HOST         "USB-Host"
-#define EXTCON_CABLE_TA               "TA"
-#define EXTCON_CABLE_HDMI             "HDMI"
-#define EXTCON_CABLE_DOCK             "Dock"
-#define EXTCON_CABLE_MIC_IN           "Microphone"
-#define EXTCON_CABLE_HEADPHONE_OUT    "Headphone"
-
-struct extcon_ops {
-       const char *name;
-       int status;
-       void (*init)(void *data);
-       void (*exit)(void *data);
-       int (*update)(int status);
-};
-
-#define EXTCON_OPS_REGISTER(dev) \
-static void __CONSTRUCTOR__ extcon_init(void) \
-{ \
-       /**
-        * If there is no predefined status value,
-        * default status will set as a negative value(-1).
-        * It will be updated as the initial value in booting time.
-        */ \
-       if (!dev.status) \
-               dev.status = -1; \
-       add_extcon(&dev); \
-} \
-static void __DESTRUCTOR__ extcon_exit(void) \
-{ \
-       remove_extcon(&dev); \
-}
-
-void add_extcon(struct extcon_ops *dev);
-void remove_extcon(struct extcon_ops *dev);
-
-int extcon_get_status(const char *name);
-
-#endif /* __EXTCON_H__ */
diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c
deleted file mode 100644 (file)
index 9cdfb48..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2015 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 <vconf.h>
-#include "core/log.h"
-#include "core/device-notifier.h"
-#include "core/edbus-handler.h"
-#include "display/core.h"
-#include "extcon.h"
-
-#define METHOD_GET_HDMI                "GetHDMI"
-#define SIGNAL_HDMI_STATE      "ChangedHDMI"
-
-static struct extcon_ops hdmi_extcon_ops;
-
-static void hdmi_send_broadcast(int status)
-{
-       static int old;
-       char *arr[1];
-       char str_status[32];
-
-       if (old == status)
-               return;
-
-       _I("broadcast hdmi status %d", status);
-       old = status;
-       snprintf(str_status, sizeof(str_status), "%d", status);
-       arr[0] = str_status;
-
-       broadcast_edbus_signal(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
-                       SIGNAL_HDMI_STATE, "i", arr);
-}
-
-static int hdmi_update(int status)
-{
-       _I("jack - hdmi changed %d", status);
-       pm_change_internal(getpid(), LCD_NORMAL);
-       vconf_set_int(VCONFKEY_SYSMAN_HDMI, status);
-       hdmi_send_broadcast(status);
-
-       if (status == 1)
-               pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
-       else
-               pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN);
-
-       return 0;
-}
-
-static int display_changed(void *data)
-{
-       enum state_t state;
-       int hdmi;
-
-       if (!data)
-               return 0;
-
-       state = *(int *)data;
-       if (state != S_NORMAL)
-               return 0;
-
-       hdmi = hdmi_extcon_ops.status;
-       if (hdmi == 0) {
-               pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
-               _I("hdmi is connected! dim lock is on.");
-       }
-       return 0;
-}
-
-static DBusMessage *dbus_hdmi_handler(E_DBus_Object *obj, DBusMessage *msg)
-{
-       return make_reply_message(msg, hdmi_extcon_ops.status);
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { METHOD_GET_HDMI,       NULL, "i", dbus_hdmi_handler },
-};
-
-static void hdmi_init(void *data)
-{
-       int ret;
-
-       register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-
-       ret = register_edbus_method(DEVICED_PATH_SYSNOTI,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus method(%d)", ret);
-}
-
-static void hdmi_exit(void *data)
-{
-       unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed);
-}
-
-static struct extcon_ops hdmi_extcon_ops = {
-       .name   = EXTCON_CABLE_HDMI,
-       .init   = hdmi_init,
-       .exit   = hdmi_exit,
-       .update = hdmi_update,
-};
-
-EXTCON_OPS_REGISTER(hdmi_extcon_ops)
diff --git a/src/power/power-handler.c b/src/power/power-handler.c
deleted file mode 100644 (file)
index b2679d5..0000000
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 <unistd.h>
-#include <time.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <vconf.h>
-#include <assert.h>
-#include <limits.h>
-#include <time.h>
-#include <vconf.h>
-#include <fcntl.h>
-#include <sys/reboot.h>
-#include <sys/time.h>
-#include <mntent.h>
-#include <sys/mount.h>
-#include <device-node.h>
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "dd-deviced.h"
-#include "core/log.h"
-#include "core/launch.h"
-#include "core/device-notifier.h"
-#include "core/device-idler.h"
-#include "core/common.h"
-#include "core/devices.h"
-#include "core/launch.h"
-#include "display/poll.h"
-#include "display/setting.h"
-#include "core/edbus-handler.h"
-#include "display/core.h"
-#include "power-handler.h"
-#include "apps/apps.h"
-#include "shared/deviced-systemd.h"
-#include "boot.h"
-
-#define POWEROFF_DURATION              2
-#define MAX_RETRY                      2
-
-#define SIGNAL_POWEROFF_STATE  "ChangeState"
-
-#define UMOUNT_RW_PATH "/opt/usr"
-
-static struct timeval tv_start_poweroff;
-
-static const struct device_ops *telephony = NULL;
-
-static void telephony_init(void)
-{
-       FIND_DEVICE_VOID(telephony, "telephony");
-       _I("telephony (%d)", telephony);
-}
-
-static void telephony_start(void)
-{
-       telephony_init();
-       device_start(telephony);
-}
-
-static void telephony_stop(void)
-{
-       device_stop(telephony);
-}
-
-static int telephony_exit(void *data)
-{
-       int ret;
-
-       ret = device_exit(telephony, data);
-       return ret;
-}
-
-static int app_privileged(pid_t pid)
-{
-       char attr[64];
-       int ret;
-       size_t len;
-
-       ret = get_privilege(pid, attr, sizeof(attr));
-       if (ret < 0) {
-               _E("Failed to get privilege of PID(%d)", pid);
-               return 0;
-       }
-
-       len = strlen(attr);
-
-       if (!strncmp("System::Privileged", attr, len + 1))
-               return 1;
-
-       if (strstr(attr, "User::Pkg::") == attr)
-               return 1;
-
-       return 0;
-}
-
-static void poweroff_stop_systemd_service(void)
-{
-       _D("systemd service stop");
-       umount2("/sys/fs/cgroup", MNT_FORCE |MNT_DETACH);
-}
-
-static int stop_systemd_journald(void)
-{
-       int ret;
-
-       ret = deviced_systemd_stop_unit("systemd-journald.socket");
-       if (ret < 0) {
-               _E("failed to stop 'systemd-journald.socket'");
-               return ret;
-       }
-
-       ret |= deviced_systemd_stop_unit("systemd-journald.service");
-       if (ret < 0) {
-               _E("failed to stop 'systemd-journald.service'");
-               return ret;
-       }
-
-       return 0;
-}
-
-/* umount usr data partition */
-static void unmount_rw_partition()
-{
-       int retry = 0, r;
-       struct timespec time = {0,};
-       sync();
-
-       if (!mount_check(UMOUNT_RW_PATH))
-               return;
-       while (1) {
-               switch (retry++) {
-               case 0:
-                       /* Second, kill app with SIGTERM */
-                       _I("Kill app with SIGTERM");
-                       terminate_process(UMOUNT_RW_PATH, false);
-                       time.tv_nsec = 700 * NANO_SECOND_MULTIPLIER;
-                       nanosleep(&time, NULL);
-                       break;
-               case 1:
-                       /* Last time, kill app with SIGKILL */
-                       _I("Kill app with SIGKILL");
-                       terminate_process(UMOUNT_RW_PATH, true);
-                       time.tv_nsec = 300 * NANO_SECOND_MULTIPLIER;
-                       nanosleep(&time, NULL);
-                       sleep(1);
-                       break;
-               default:
-                       r = umount2(UMOUNT_RW_PATH, 0);
-                       if (r != 0)
-                               _I("Failed to unmount %s(%d)", UMOUNT_RW_PATH, r);
-                       else
-                               _I("%s unmounted successfully", UMOUNT_RW_PATH);
-                       return;
-               }
-
-               r = umount2(UMOUNT_RW_PATH, 0);
-               if (r == 0) {
-                       _I("%s unmounted successfully", UMOUNT_RW_PATH);
-                       return;
-               }
-       }
-}
-
-static void powerdown(void)
-{
-       static int wait = 0;
-       static int power_off = 0;
-       struct timeval now;
-       int poweroff_duration = POWEROFF_DURATION;
-       int check_duration = 0;
-       char *buf;
-
-       if (power_off == 1) {
-               _E("during power off");
-               return;
-       }
-
-       stop_systemd_journald();
-
-       /* if this fails, that's OK */
-       power_off = 1;
-       telephony_stop();
-       sync();
-
-       buf = getenv("PWROFF_DUR");
-       if (buf != NULL && strlen(buf) < 1024)
-               poweroff_duration = atoi(buf);
-       if (poweroff_duration < 0 || poweroff_duration > 60)
-               poweroff_duration = POWEROFF_DURATION;
-       gettimeofday(&now, NULL);
-       check_duration = now.tv_sec - tv_start_poweroff.tv_sec;
-       while (check_duration < poweroff_duration) {
-               if (wait == 0) {
-                       _I("wait poweroff %d %d", check_duration, poweroff_duration);
-                       wait = 1;
-               }
-               usleep(100000);
-               gettimeofday(&now, NULL);
-               check_duration = now.tv_sec - tv_start_poweroff.tv_sec;
-               if (check_duration < 0)
-                       break;
-       }
-
-       poweroff_stop_systemd_service();
-
-#ifndef EMULATOR
-       unmount_rw_partition();
-#endif
-}
-
-static void powerdown_ap(void *data)
-{
-       _I("Power off");
-       powerdown();
-       reboot(RB_POWER_OFF);
-}
-
-static void restart_ap(void *data)
-{
-       _I("Restart");
-       powerdown();
-       reboot(RB_AUTOBOOT);
-}
-
-static void system_shutdown_send_system_event(void)
-{
-       bundle *b;
-       const char *str = EVT_VAL_SYSTEM_SHUTDOWN_TRUE;
-
-       b = bundle_create();
-       bundle_add_str(b, EVT_KEY_SYSTEM_SHUTDOWN, str);
-       eventsystem_send_system_event(SYS_EVENT_SYSTEM_SHUTDOWN, b);
-       bundle_free(b);
-}
-
-static void poweroff_start_animation(void)
-{
-       int ret;
-
-       ret = deviced_systemd_start_unit("shutdown-animation.service");
-       if (ret < 0)
-               _E("Failed to start shutdown animation");
-
-       gettimeofday(&tv_start_poweroff, NULL);
-}
-
-static int poweroff(void)
-{
-       int ret;
-       static const struct device_ops *display_device_ops = NULL;
-
-       poweroff_start_animation();
-       telephony_start();
-
-       FIND_DEVICE_INT(display_device_ops, "display");
-
-       pm_change_internal(getpid(), LCD_NORMAL);
-       display_device_ops->exit(NULL);
-       sync();
-
-       ret = telephony_exit(POWER_POWEROFF);
-
-       if (ret < 0) {
-               powerdown_ap(NULL);
-               return 0;
-       }
-       return ret;
-}
-
-static int pwroff_popup(void)
-{
-       return launch_system_app(APP_POWERKEY,
-                       2, APP_KEY_TYPE, APP_POWERKEY);
-}
-
-static int power_reboot(void)
-{
-       int ret;
-       const struct device_ops *display_device_ops = NULL;
-
-       poweroff_start_animation();
-       telephony_start();
-
-       FIND_DEVICE_INT(display_device_ops, "display");
-
-       pm_change_internal(getpid(), LCD_NORMAL);
-       display_device_ops->exit(NULL);
-       sync();
-
-       ret = telephony_exit(POWER_REBOOT);
-       if (ret < 0) {
-               restart_ap(NULL);
-               return 0;
-       }
-       return ret;
-}
-
-static int booting_done(void *data)
-{
-       static int done = 0;
-
-       if (data == NULL)
-               goto out;
-
-       done = *(int*)data;
-       telephony_init();
-out:
-       return done;
-}
-
-static void poweroff_send_broadcast(int status)
-{
-       static int old = 0;
-       char *arr[1];
-       char str_status[32];
-
-       if (old == status)
-               return;
-
-       _D("broadcast poweroff %d", status);
-
-       old = status;
-       snprintf(str_status, sizeof(str_status), "%d", status);
-       arr[0] = str_status;
-
-       /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangeState signal for POWER_OFF_DIRECT and POWER_OFF_RESTART */
-       broadcast_edbus_signal(DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF,
-                       SIGNAL_POWEROFF_STATE, "i", arr);
-}
-
-static void poweroff_idler_cb(void *data)
-{
-       enum poweroff_type val = (long)data;
-
-       telephony_start();
-
-       pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0);
-
-       if (val == POWER_OFF_DIRECT || val == POWER_OFF_RESTART) {
-       /* Need to notify to deviced-vibrator. deviced-vibrator receives ChangeState signal for POWER_OFF_DIRECT and POWER_OFF_RESTART */
-               poweroff_send_broadcast(val);
-               system_shutdown_send_system_event();
-               device_notify(DEVICE_NOTIFIER_POWEROFF, &val);
-       }
-
-       /* TODO for notify. will be removed asap. */
-       vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
-
-       switch (val) {
-       case POWER_OFF_DIRECT:
-               poweroff();
-               break;
-       case POWER_OFF_POPUP:
-               pwroff_popup();
-               break;
-       case POWER_OFF_RESTART:
-               power_reboot();
-               break;
-       default:
-               return;
-       }
-
-       if (update_pm_setting)
-               update_pm_setting(SETTING_POWEROFF, val);
-}
-
-static int power_execute_pid(void *data, pid_t pid)
-{
-       int ret;
-       long val;
-       char *str = (char *)data;
-
-       if (!data) {
-               _E("Invalid parameter : data(NULL)");
-               return -EINVAL;
-       }
-
-       if (strncmp(POWER_POWEROFF, str, POWER_POWEROFF_LEN) == 0)
-               val = POWER_OFF_DIRECT;
-       else if (strncmp(PWROFF_POPUP, str, PWROFF_POPUP_LEN) == 0)
-               val = POWER_OFF_POPUP;
-       else if (strncmp(POWER_REBOOT, str, POWER_REBOOT_LEN) == 0) {
-               if (!app_privileged(pid)) {
-                       _E("PID(%d) does not have the permission for reboot", pid);
-                       return -EPERM;
-               }
-               val = POWER_OFF_RESTART;
-       } else {
-               _E("Invalid parameter : data(%s)", str);
-               return -EINVAL;
-       }
-
-       ret = add_idle_request(poweroff_idler_cb, (void *)val);
-       if (ret < 0) {
-               _E("fail to add poweroff idle request : %d", ret);
-               return ret;
-       }
-
-       return 0;
-}
-
-static int power_execute(void *data)
-{
-       return power_execute_pid(data, getpid());
-}
-
-static DBusMessage *dbus_power_handler(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusError err;
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       pid_t pid;
-       int ret;
-       int argc;
-       char *type_str;
-
-       dbus_error_init(&err);
-
-       if (!dbus_message_get_args(msg, &err,
-                   DBUS_TYPE_STRING, &type_str,
-                   DBUS_TYPE_INT32, &argc, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (argc < 0) {
-               _E("message is invalid!");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-       if (kill(pid, 0) == -1) {
-               _E("%d process does not exist, dbus ignored!", pid);
-               ret = -ESRCH;
-               goto out;
-       }
-
-       _I("PID(%d) requests %s", pid, type_str);
-       ret = power_execute_pid(type_str, pid);
-
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-
-       return reply;
-}
-
-static DBusMessage *request_reboot(E_DBus_Object *obj, DBusMessage *msg)
-{
-       DBusMessageIter iter;
-       DBusMessage *reply;
-       char *str;
-       int ret;
-       pid_t pid;
-
-       if (!dbus_message_get_args(msg, NULL,
-                   DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) {
-               _E("there is no message");
-               ret = -EINVAL;
-               goto out;
-       }
-
-       pid = get_edbus_sender_pid(msg);
-
-       _I("PID(%d) requests reboot with command : %s", pid, str);
-       ret = power_execute_pid(POWER_REBOOT, pid);
-
-out:
-       reply = dbus_message_new_method_return(msg);
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
-       return reply;
-}
-
-static const struct edbus_method edbus_methods[] = {
-       { POWER_REBOOT, "si", "i", dbus_power_handler },
-       /* Public API device_power_reboot() calls this dbus method. */
-       { "Reboot",      "s", "i", request_reboot },
-       /* Add methods here */
-};
-
-static void power_init(void *data)
-{
-       int ret;
-
-       /* init dbus interface */
-       ret = register_edbus_method(DEVICED_PATH_POWER,
-                       edbus_methods, ARRAY_SIZE(edbus_methods));
-       if (ret < 0)
-               _E("fail to init edbus method(%d)", ret);
-
-       add_booting_done_handler(NULL);
-
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-}
-
-static const struct device_ops power_device_ops = {
-       .name     = POWER_OPS_NAME,
-       .init     = power_init,
-       .execute  = power_execute,
-};
-
-DEVICE_OPS_REGISTER(&power_device_ops)
diff --git a/src/power/power-handler.h b/src/power/power-handler.h
deleted file mode 100644 (file)
index b7d7c28..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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.
- */
-
-#ifndef __POWER_HANDLE_H__
-#define __POWER_HANDLE_H__
-
-#define POWER_OPS_NAME      "power"
-
-#define POWER_POWEROFF      "poweroff"
-#define POWER_POWEROFF_LEN  8
-#define POWER_REBOOT        "reboot"
-#define POWER_REBOOT_LEN    6
-#define PWROFF_POPUP        "pwroff-popup"
-#define PWROFF_POPUP_LEN    12
-
-enum poweroff_type {
-       POWER_OFF_NONE = 0,
-       POWER_OFF_POPUP,
-       POWER_OFF_DIRECT,
-       POWER_OFF_RESTART,
-};
-
-#endif /* __POWER_HANDLE_H__ */
index deabf95..62bff11 100644 (file)
@@ -45,8 +45,8 @@
 /*
  * Device daemon
  */
-#define DEVICED_BUS_NAME                    "org.tizen.system.deviced"
-#define DEVICED_OBJECT_PATH                 "/Org/Tizen/System/DeviceD"
+#define DEVICED_BUS_NAME                    "org.tizen.system.pass"
+#define DEVICED_OBJECT_PATH                 "/Org/Tizen/System/Pass"
 #define DEVICED_INTERFACE_NAME              DEVICED_BUS_NAME
 /* Core service: get/set device status operations about device */
 #define DEVICED_PATH_CORE                   DEVICED_OBJECT_PATH"/Core"