display: plugin: Add display_plugin_get_device_flags()
[platform/core/system/deviced.git] / plugins / wearable / display / core.c
index 2747156..4365feb 100644 (file)
 #include <vconf-keys.h>
 #include <sys/time.h>
 #include <libsyscommon/list.h>
+#include <hal/device/hal-device-power.h>
 
 #include "auto-brightness-sensorhub.h"
 #include "ambient-mode.h"
 #include "util.h"
 #include "core.h"
+#include "poll.h"
 #include "lock-detector.h"
 #include "display-ops.h"
-#include "core/devices.h"
-#include "core/device-notifier.h"
+#include "shared/devices.h"
+#include "shared/device-notifier.h"
 #include "core/udev.h"
 #include "shared/common.h"
-#include "core/launch.h"
-#include "apps/apps.h"
+#include "shared/apps.h"
 #include "extcon/extcon.h"
 #include "battery/power-supply.h"
-#include "power/power-handler.h"
-#include "power/power-control.h"
-#include "power/boot.h"
-#include "power/doze.h"
-#include "display/display-dpms.h"
+#include "power/power.h"
+#include "power/power-off.h"
+#include "power/power-suspend.h"
+#include "power/power-boot.h"
+#include "power/power-doze.h"
+#include "device-interface.h"
+#include "display-plugin.h"
 #include "display-info.h"
 #include "battery-monitor.h"
-#include "display/display-signal.h"
+#include "display-signal.h"
 #include "display-lock.h"
+#include "display-backlight.h"
+#include "display-misc.h"
+#include "display-panel.h"
+#include "display-config.h"
+#include "display-state-transition.h"
 #include "shared/plugin.h"
 
-#define DISPLAY_CONF_FILE    "/etc/deviced/display.conf"
 #define POWERLOCK_CONF_FILE  "/etc/deviced/powerlock.conf"
 
 #ifndef VCONFKEY_HOMESCREEN_TUTORIAL_OOBE_ENABLED
 #define DISPLAY_DETACH_STR  "display_detach"
 #define UNKNOWN_STR         "unknown"
 
-extern void init_pm_internal();
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
-static struct _backlight_ops *backlight_ops;
+static struct display_backlight_ops *backlight_ops;
 static struct battery_plugin *battery_plgn;
 static int (*fp_get_charging_status) (int *val);
 
 static void (*power_saving_func) (int onoff);
 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 
-static guint timeout_src_id;
 static int system_wakeup_flag = false;
 static unsigned int custom_normal_timeout = 0;
 static unsigned int custom_dim_timeout = 0;
-int custom_holdkey_block = false;
 static char *custom_change_name;
-static bool hallic_open = true;
 static guint lock_timeout_id;
 static guint transit_timer;
 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;
-GList *lcdon_ops;
 /*
  * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial
  * state because it should be sent from previous state at booting time.
@@ -150,17 +150,6 @@ static struct state states[S_END] = {
        { 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 */
-};
-
 #define SHIFT_UNLOCK           4
 #define SHIFT_CHANGE_STATE     7
 #define CHANGE_STATE_BIT       0xF00   /* 1111 0000 0000 */
@@ -173,7 +162,7 @@ static int trans_table[S_END][EVENT_END] = {
 
 #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 DELAYED_INIT_WATING_TIME       60000   /* 1 minute */
 
 #define LOCK_SCREEN_WATING_TIME                300     /* 0.3 second */
 #define LONG_PRESS_INTERVAL             500       /* 0.5 seconds */
@@ -219,11 +208,13 @@ static struct display_config display_conf = {
        .timeout_enable         = true,
        .input_support          = true,
        .lockcheck_timeout      = 600,
+       .display_init_direction = DISPLAY_INIT_DIRECTION_HORIZONTAL,
        .pmlock_check = pmlock_check,
        .aod_enter_level        = 40,
        .aod_tsp                = true,
        .touch_wakeup           = false,
-       .sleep_support          = true,
+       .display_on_usb_conn_changed = true,
+       .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
 struct display_function_info display_info = {
@@ -233,7 +224,7 @@ struct display_function_info display_info = {
        .face_detection                 = NULL,
 };
 
-inline struct display_config *get_var_display_config()
+inline const struct display_config *get_var_display_config()
 {
        return &display_conf;
 }
@@ -243,64 +234,6 @@ inline struct state *state_st(enum state_t state)
        return &states[state];
 }
 
-guint get_transition_timer(void)
-{
-       return timeout_src_id;
-}
-
-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, const 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 int display_brightness_changed(void *data)
-{
-       int brt, ret;
-
-       brt = DATA_VALUE_INT(data);
-
-       ret = gdbus_signal_emit(NULL,
-                                                       DEVICED_PATH_DISPLAY,
-                                                       DEVICED_INTERFACE_DISPLAY,
-                                                       "Brightness",
-                                                       g_variant_new("(i)", brt));
-       if (ret < 0)
-               _E("Failed to send dbus signal Brightness.");
-
-       return 0;
-}
-
 static int display_auto_brightness_sensing(void *data)
 {
        if (!transit_timer)
@@ -431,7 +364,7 @@ static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data)
                        *pname ? pname : "Unknown", pid, states[state].name, KILLABLE_DAEMON_LOCK_LIMIT);
                ret = kill(pid, SIGTERM);
                if (ret < 0)
-                       CRITICAL_LOG("Failed to send SIGTERM to process %s(%d), %d.",
+                       CRITICAL_LOG_E("Failed to send SIGTERM to process %s(%d), %d.",
                                *pname ? pname : "Unknown", pid, errno);
 
                node->force_release = true;
@@ -445,7 +378,7 @@ static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data)
 
                        ret = kill(pid, SIGKILL);
                        if (ret < 0)
-                               CRITICAL_LOG("Failed to kill process %s(%d), %d.",
+                               CRITICAL_LOG_E("Failed to kill process %s(%d), %d.",
                                        *pname ? pname : "Unknown", pid, errno);
                }
 
@@ -454,7 +387,7 @@ static gboolean pmlock_terminate_daemon_to_release_lock(gpointer data)
                del_node(state, node);
                set_unlock_time(pid, state);
 
-               if (!timeout_src_id)
+               if (!display_state_transition_is_there_state_transition_timer())
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
        }
 
@@ -513,19 +446,31 @@ static void free_killable_daemon_list(void)
        initialized_killable_daemon_list = false;
 }
 
-static unsigned long get_lcd_on_flags(void)
+static int get_device_flags(unsigned long *device_flags)
 {
-       unsigned long flags = NORMAL_MODE;
+       if (!device_flags)
+               return -EINVAL;
 
-       if (lcd_paneloff_mode)
-               flags |= LCD_PANEL_OFF_MODE;
+       *device_flags = NORMAL_MODE;
+       bool lcd_paneloff_mode = false;
+       bool stay_touchscreen_off = false;
+       display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
+       display_misc_get_stay_touchscreen_off(&stay_touchscreen_off);
+
+       if (lcd_paneloff_mode) {
+               *device_flags |= LCD_PANEL_OFF_MODE;
+       }
+
+       if (stay_touchscreen_off) {
+               *device_flags |= TOUCH_SCREEN_OFF_MODE;
+       }
 
        if (ambient_get_state()) {
-               flags |= AMBIENT_MODE;
-               flags |= LCD_PHASED_TRANSIT_MODE;
+               *device_flags |= AMBIENT_MODE;
+               *device_flags |= LCD_PHASED_TRANSIT_MODE;
        }
 
-       return flags;
+       return 0;
 }
 
 bool touch_event_blocked(void)
@@ -541,15 +486,14 @@ static gboolean late_transit_on(void *data)
        g_source_remove(transit_timer);
        transit_timer = 0;
 
-       backlight_ops->transit_state(DPMS_ON);
+       display_backlight_change_brightness_by_dpms_state(DPMS_ON);
        return G_SOURCE_REMOVE;
 }
 
 void lcd_on_procedure(int state, enum device_flags flag)
 {
-       GList *l = NULL;
-       const struct device_ops *ops = NULL;
-       unsigned long flags = get_lcd_on_flags();
+       unsigned long flags = NORMAL_MODE;
+       display_plugin_get_device_flags(&flags);
        flags |= flag;
        int ret;
 
@@ -577,7 +521,7 @@ void lcd_on_procedure(int state, enum device_flags flag)
        _I("[lcdstep] 0x%lx", flags);
 
        if (flags & AMBIENT_MODE) {
-               if (ambient_get_state() == false && backlight_ops->get_lcd_power() == DPMS_ON)
+               if (ambient_get_state() == false && display_panel_get_dpms_cached_state() == DPMS_ON)
                        return;
                ambient_set_state(false);
        }
@@ -589,9 +533,9 @@ void lcd_on_procedure(int state, enum device_flags flag)
        if (!(flags & LCD_PHASED_TRANSIT_MODE)) {
                /* Update brightness level */
                if (state == LCD_DIM)
-                       backlight_ops->dim();
+                       display_backlight_set_brightness_by_dim_brightness();
                else if (state == LCD_NORMAL)
-                       backlight_ops->update();
+                       display_backlight_update_by_default_brightness();
        }
 
        if (state == LCD_NORMAL)
@@ -599,8 +543,7 @@ void lcd_on_procedure(int state, enum device_flags flag)
        else if (state == LCD_DIM)
                set_setting_pmstate(S_LCDDIM);
 
-       SYS_G_LIST_FOREACH(lcdon_ops, l, ops)
-               ops->start(flags);
+       display_start_dependent_device(flags);
 
        if (!lcdon_broadcast) {
                broadcast_lcd_on(SIGNAL_POST, flags);
@@ -613,26 +556,10 @@ void lcd_on_procedure(int state, enum device_flags flag)
        touch_blocked = false;
 }
 
-static unsigned long get_lcd_off_flags(void)
-{
-       unsigned long flags = NORMAL_MODE;
-
-       if (ambient_get_condition() == true) {
-               flags |= AMBIENT_MODE;
-               flags |= LCD_PHASED_TRANSIT_MODE;
-       }
-
-       if (stay_touchscreen_off)
-               flags |= TOUCH_SCREEN_OFF_MODE;
-
-       return flags;
-}
-
 inline void lcd_off_procedure(enum device_flags flag)
 {
-       GList *l = NULL;
-       const struct device_ops *ops = NULL;
-       unsigned long flags = get_lcd_off_flags();
+       unsigned long flags = NORMAL_MODE;
+       display_plugin_get_device_flags(&flags);
        flags |= flag;
 
        /*
@@ -675,10 +602,9 @@ inline void lcd_off_procedure(enum device_flags flag)
        }
 
        if (flags & LCD_PHASED_TRANSIT_MODE)
-               backlight_ops->transit_state(DPMS_OFF);
+               display_backlight_change_brightness_by_dpms_state(DPMS_OFF);
 
-       SYS_G_LIST_FOREACH(lcdon_ops, l, ops)
-               ops->stop(flags);
+       display_stop_dependent_device(flags);
 
        if (flags & AMBIENT_MODE) {
                broadcast_lcd_off_late(flags);
@@ -690,66 +616,6 @@ inline void lcd_off_procedure(enum device_flags flag)
        enter_doze();
 }
 
-void set_stay_touchscreen_off(int val)
-{
-       _I("Stay touch screen off: %d", val);
-       stay_touchscreen_off = val;
-
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL);
-}
-
-void set_lcd_paneloff_mode(int val)
-{
-       _I("Lcd paneloff mode: %d", val);
-       lcd_paneloff_mode = val;
-
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, 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;
-}
-
-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("Process(%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;
@@ -773,7 +639,7 @@ static void del_state_cond(void *data, enum state_t state)
         *   1. There should be no running state-transition timer
         *   2. Released lock is one of the pm_cur_state's lock
         * This emulates already expired transition timer */
-       if (!timeout_src_id && get_pm_cur_state() == state)
+       if (!display_state_transition_is_there_state_transition_timer() && (get_pm_cur_state() == state))
                states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
 
        if (state == S_LCDOFF)
@@ -798,45 +664,6 @@ static gboolean del_off_cond(void *data)
        return G_SOURCE_REMOVE;
 }
 
-/* timeout handler  */
-gboolean timeout_handler(void *data)
-{
-       _I("Time out state %s", states[get_pm_cur_state()].name);
-
-       if (timeout_src_id) {
-               g_source_remove(timeout_src_id);
-               timeout_src_id = 0;
-       }
-
-       states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
-       return G_SOURCE_REMOVE;
-}
-
-void reset_timeout(int timeout)
-{
-       if (!display_conf.timeout_enable)
-               return;
-
-       if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || display_conf.sleep_support == false))
-               return;
-
-       _I("Reset timeout(%d ms).", timeout);
-       if (timeout_src_id != 0) {
-               g_source_remove(timeout_src_id);
-               timeout_src_id = 0;
-       }
-
-       if (trans_table[get_pm_cur_state()][EVENT_TIMEOUT] == get_pm_cur_state())
-               return;
-
-       if (timeout > 0)
-               timeout_src_id = g_timeout_add(timeout,
-                   timeout_handler, NULL);
-       else if (timeout == 0)
-               states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
-}
-
 /* get configurations from setting */
 static int get_lcd_timeout_from_settings(void)
 {
@@ -873,15 +700,7 @@ 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(%d ms) is set by normal.",
-                   S_COVER_TIMEOUT);
-               return;
-       }
-
-       /* second priority : custom timeout */
+       /* first priority : custom timeout */
        if (custom_normal_timeout > 0) {
                states[S_NORMAL].timeout = custom_normal_timeout;
                states[S_LCDDIM].timeout = custom_dim_timeout;
@@ -890,7 +709,7 @@ static void update_display_time(void)
                return;
        }
 
-       /* third priority : lock state */
+       /* second priority : lock state */
        if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
            !get_lock_screen_bg_state()) {
                /* timeout is different according to key or event. */
@@ -935,20 +754,17 @@ void set_dim_state(bool on)
 
 void lcd_on_direct(enum device_flags flags)
 {
-       int ret;
+       enum hal_device_power_transition_reason reason;
 
-       if (pm_get_power_lock_support()
-           && (get_pm_cur_state() == S_SLEEP)) {
-               broadcast_pm_wakeup();
-               pm_power_lock();
-               set_pm_cur_state(S_NORMAL);
-       }
+       if (flags & LCD_ON_BY_POWER_KEY)
+               reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY;
+       else if (flags & LCD_ON_BY_TOUCH)
+               reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN;
+       else
+               reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
 
-       ret = is_lcdon_blocked();
-       if (ret != LCDON_BLOCK_NONE) {
-               _W("LCDON is blocked, %d", ret);
-               return;
-       }
+       power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL);
+       set_pm_cur_state(S_NORMAL);
 
        _D("lcd is on directly");
        gettimeofday(&lcdon_tv, NULL);
@@ -959,7 +775,7 @@ void lcd_on_direct(enum device_flags flags)
 
 static inline bool check_lcd_is_on(void)
 {
-       if (backlight_ops->get_lcd_power() != DPMS_ON)
+       if (display_panel_get_dpms_cached_state() != DPMS_ON)
                return false;
 
        return true;
@@ -1060,7 +876,7 @@ int custom_lcdoff(enum device_flags flag)
        }
 
        _I("custom lcd off by flag(%d)", flag);
-       if (backlight_ops->get_lcd_power() == DPMS_ON)
+       if (display_panel_get_dpms_cached_state() == DPMS_ON)
                lcd_off_procedure(flag);
 
        if (set_custom_lcdon_timeout(0) == true)
@@ -1153,7 +969,7 @@ int display_off_by_reason(const char *reason)
        }
 
        _I("platform lcd off by %s", reason);
-       if (backlight_ops->get_lcd_power() == DPMS_ON)
+       if (display_panel_get_dpms_cached_state() == DPMS_ON)
                lcd_off_procedure(flag);
 
        /* state transition */
@@ -1203,7 +1019,7 @@ static int default_proc_change_state(unsigned int cond, pid_t pid)
                default_proc_change_state_action(next, -1);
                break;
        case S_LCDOFF:
-               if (backlight_ops->get_lcd_power() == DPMS_ON)
+               if (display_panel_get_dpms_cached_state() == DPMS_ON)
                        lcd_off_procedure(LCD_OFF_BY_EVENT);
                if (set_custom_lcdon_timeout(0))
                        update_display_time();
@@ -1249,7 +1065,7 @@ static void proc_condition_lock(PMMsg *data)
                return;
 
        flags = GET_COND_FLAG(data->cond);
-       get_pname(pid, pname);
+       display_misc_get_process_name(pid, pname);
 
        if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
            (pm_get_power_lock() == POWER_UNLOCK))
@@ -1330,7 +1146,7 @@ static void proc_condition_unlock(PMMsg *data)
                return;
 
        flags = GET_COND_FLAG(data->cond);
-       get_pname(pid, pname);
+       display_misc_get_process_name(pid, pname);
 
        tmp = find_node(state, pid);
        del_node(state, tmp);
@@ -1384,13 +1200,13 @@ static int proc_condition(PMMsg *data)
        if (flags == 0) {
                /* guard time for suspend */
                if (get_pm_cur_state() == S_LCDOFF)
-                       reset_timeout(states[S_LCDOFF].timeout);
+                       display_state_transition_reset_state_transition_timeout(states[S_LCDOFF].timeout);
        } else {
                if (flags & PM_FLAG_RESET_TIMER)
-                       reset_timeout(states[get_pm_cur_state()].timeout);
+                       display_state_transition_reset_state_transition_timeout(states[get_pm_cur_state()].timeout);
        }
 
-       if (!timeout_src_id)
+       if (!display_state_transition_is_there_state_transition_timer())
                states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
 
        return 0;
@@ -1416,118 +1232,6 @@ void update_lcdoff_source(int source)
                _E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno());
 }
 
-void print_info(int fd)
-{
-       int s_index = 0;
-       char buf[PATH_MAX + 255];
-       int i = 1;
-       int ret;
-       char pname[PATH_MAX];
-       PmLockNode *t;
-       GList *elem;
-       char time_buf[30];
-
-       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",
-                (get_trans_condition() & MASK_NORMAL) ? states[S_NORMAL].name : "-",
-                (get_trans_condition() & MASK_DIM) ? states[S_LCDDIM].name : "-",
-                (get_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[get_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++) {
-               SYS_G_LIST_FOREACH(get_cond_head(s_index), elem, t) {
-                       get_pname((pid_t)t->pid, pname);
-                       ctime_r(&t->time, time_buf);
-                       time_buf[strlen(time_buf) - 1] = 0;
-                       snprintf(buf, sizeof(buf),
-                                " %d: [%s] locked by pid %d %s %s\n",
-                                i++, states[s_index].name, t->pid, pname, time_buf);
-                       ret = write(fd, buf, strlen(buf));
-                       if (ret < 0)
-                               _E("Write() failed: %d", errno);
-               }
-       }
-
-       print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
-       pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(const char *path)
-{
-       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);
-       time_buf[strlen(time_buf) - 1] = 0;
-
-       fd = open(path, 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", get_pm_status_flag());
-               ret = write(fd, buf, strlen(buf));
-               if (ret < 0)
-                       _E("write() failed (%d)", errno);
-
-               if (disp_plgn->get_lock_screen_state ) {
-                       snprintf(buf, sizeof(buf), "screen lock status : %d\n",
-                               disp_plgn->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
  */
@@ -1553,7 +1257,7 @@ int check_lcdoff_direct(void)
                return true;
 
        lock = __get_lock_screen_state();
-       if (lock != VCONFKEY_IDLE_LOCK && hallic_open)
+       if (lock != VCONFKEY_IDLE_LOCK)
                return false;
 
        hdmi_state = extcon_get_status(EXTCON_CABLE_HDMI);
@@ -1580,9 +1284,10 @@ int check_lcdoff_direct(void)
 static int default_trans(int evt)
 {
        struct state *st = &states[get_pm_cur_state()];
-       int next_state, ret;
+       int ret;
+       enum state_t next_state;
 
-       next_state = (enum state_t)trans_table[get_pm_cur_state()][evt];
+       display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
 
        /* check conditions */
        if (st->check && !st->check(get_pm_cur_state(), next_state)) {
@@ -1619,7 +1324,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || display_conf.sleep_support == false))
+                       && (is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
@@ -1684,6 +1389,9 @@ static int default_action(int timeout)
        static time_t last_update_time = 0;
        static int last_timeout = 0;
        struct timeval now_tv;
+       bool custom_status;
+       int brightness;
+       bool lcd_paneloff_mode = false;
 
        if (status != DEVICE_OPS_STATUS_START) {
                _E("Display is not started.");
@@ -1706,7 +1414,7 @@ static int default_action(int timeout)
                        lcdon_tv.tv_sec = 0;
                }
                /* set timer with current state timeout */
-               reset_timeout(timeout);
+               display_state_transition_reset_state_transition_timeout(timeout);
 
                if (get_pm_cur_state() == S_NORMAL) {
                        time(&last_update_time);
@@ -1718,10 +1426,8 @@ static int default_action(int timeout)
        }
 
        if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
-               if (pm_get_power_lock_support()) {
-                       broadcast_pm_wakeup();
-                       pm_power_lock();
-               }
+               power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
+                       power_get_wakeup_reason(), NULL);
                set_setting_pmstate(get_pm_cur_state());
                pm_cur_state = get_pm_cur_state();
                device_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
@@ -1746,18 +1452,20 @@ static int default_action(int timeout)
                if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
                        check_lock_screen();
                else if (get_pm_old_state() == S_LCDDIM)
-                       backlight_ops->update();
+                       display_backlight_update_by_default_brightness();
 
                if (check_lcd_is_on() == false)
                        lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
                break;
 
        case S_LCDDIM:
-               if ((get_pm_old_state() == S_NORMAL) &&
-                   backlight_ops->get_custom_status())
-                       backlight_ops->save_custom_brightness();
+               display_backlight_get_custom_status(&custom_status);
+               if ((get_pm_old_state() == S_NORMAL) && custom_status) {
+                       display_backlight_get_brightness(&brightness);
+                       display_backlight_set_custom_brightness(brightness);
+               }
                /* lcd dim state : dim the brightness */
-               backlight_ops->dim();
+               display_backlight_set_brightness_by_dim_brightness();
 
                if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
                        lcd_on_procedure(LCD_DIM, NORMAL_MODE);
@@ -1767,11 +1475,12 @@ static int default_action(int timeout)
                if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
                        stop_lock_timer();
                        /* lcd off state : turn off the backlight */
-                       if (backlight_ops->get_lcd_power() == DPMS_ON)
+                       if (display_panel_get_dpms_cached_state() == DPMS_ON)
                                lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
                }
 
-               if (backlight_ops->get_lcd_power() == DPMS_ON
+               display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
+               if (display_panel_get_dpms_cached_state() == DPMS_ON
                    || lcd_paneloff_mode)
                        lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
                break;
@@ -1780,7 +1489,7 @@ static int default_action(int timeout)
                if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF))
                        stop_lock_timer();
 
-               if (backlight_ops->get_lcd_power() == DPMS_ON)
+               if (display_panel_get_dpms_cached_state() == DPMS_ON)
                        lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
 
                if (!pm_get_power_lock_support()) {
@@ -1807,24 +1516,7 @@ go_suspend:
 #ifdef ENABLE_PM_LOG
        pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
 #endif
-       broadcast_pm_suspend();
-       if (pm_get_power_lock_support()) {
-               pm_enable_autosleep();
-
-               if (pm_power_unlock() < 0)
-                       _E("Power unlock state error.");
-       } else {
-               pm_suspend();
-               _I("system wakeup!!");
-               system_wakeup_flag = true;
-               /* Resume !! */
-               if (check_wakeup_src() == EVENT_DEVICE)
-                       /* system waked up by devices */
-                       states[get_pm_cur_state()].trans(EVENT_DEVICE);
-               else
-                       /* system waked up by user input */
-                       states[get_pm_cur_state()].trans(EVENT_INPUT);
-       }
+       power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
        return 0;
 
 go_lcd_off:
@@ -1885,7 +1577,7 @@ static void default_saving_mode(int onoff)
        }
 }
 
-static int poll_callback(int condition, PMMsg *data)
+int poll_callback(int condition, PMMsg *data)
 {
        static time_t last_t;
        time_t now;
@@ -1926,16 +1618,8 @@ static int update_setting(int key_idx, int val)
                update_display_time();
                states[get_pm_cur_state()].trans(EVENT_INPUT);
                break;
-       case SETTING_HALLIC_OPEN:
-               hallic_open = val;
-               update_display_time();
-               if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDDIM))
-                       states[get_pm_cur_state()].trans(EVENT_INPUT);
-               else if ((get_pm_cur_state() == S_SLEEP) && hallic_open)
-                       proc_change_state(S_LCDOFF, INTERNAL_LOCK_HALLIC);
-               break;
        case SETTING_LOW_BATT:
-               if (low_battery_state(val)) {
+               if (display_misc_is_low_battery_state(val)) {
                        if (!(get_pm_status_flag() & CHRGR_FLAG))
                                power_saving_func(true);
                        set_pm_status_flag(LOWBT_FLAG);
@@ -1964,7 +1648,7 @@ static int update_setting(int key_idx, int val)
                                bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
                                _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
                        }
-                       if (low_battery_state(bat_state)) {
+                       if (display_misc_is_low_battery_state(bat_state)) {
                                power_saving_func(true);
                                set_pm_status_flag(LOWBT_FLAG);
                        }
@@ -1980,7 +1664,7 @@ static int update_setting(int key_idx, int val)
                        _I("Brightness changed in low battery,"
                                "escape dim state.");
                }
-               backlight_ops->set_default_brt(val);
+               display_backlight_set_default_brightness(val);
                break;
        case SETTING_LOCK_SCREEN:
                set_lock_screen_state(val);
@@ -1988,7 +1672,7 @@ static int update_setting(int key_idx, int val)
                /* LCD on if lock screen show before waiting time */
                if ((get_pm_cur_state() == S_NORMAL) &&
                    val == VCONFKEY_IDLE_LOCK &&
-                   backlight_ops->get_lcd_power() != DPMS_ON &&
+                   display_panel_get_dpms_cached_state() != DPMS_ON &&
                        is_lcdon_blocked() == LCDON_BLOCK_NONE)
                        lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
                stop_lock_timer();
@@ -2002,22 +1686,11 @@ static int update_setting(int key_idx, int val)
                if (get_pm_cur_state() == S_NORMAL)
                        states[get_pm_cur_state()].trans(EVENT_INPUT);
                break;
-       case SETTING_POWEROFF:
-               switch (val) {
-               case POWEROFF_TYPE_NONE:
-                       clear_pm_status_flag(PWROFF_FLAG);
-                       break;
-               case POWEROFF_TYPE_DIRECT:
-               case POWEROFF_TYPE_RESTART:
-                       set_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);
+                       display_backlight_set_custom_status(true);
                else
-                       backlight_ops->set_custom_status(false);
+                       display_backlight_set_custom_status(false);
                break;
 
        default:
@@ -2050,15 +1723,15 @@ static void check_seed_status(void)
                tmp = brt;
        }
        _I("Set brightness(%d) from setting app.", tmp);
-       backlight_ops->set_default_brt(tmp);
-       backlight_ops->set_brightness(tmp);
+       display_backlight_set_default_brightness(tmp);
+       display_backlight_set_brightness(tmp);
 
        ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
        if (ret < 0) {
                bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
                _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
        }
-       if (low_battery_state(bat_state)) {
+       if (display_misc_is_low_battery_state(bat_state)) {
                if (!(get_pm_status_flag() & CHRGR_FLAG)) {
                        power_saving_func(true);
                        set_pm_status_flag(LOWBT_FLAG);
@@ -2087,25 +1760,20 @@ static void init_lcd_operation(void)
 
        ops = find_device("display");
        if (!check_default(ops))
-               SYS_G_LIST_APPEND(lcdon_ops, ops);
+               display_register_dependent_device(ops);
 
        ops = find_device("touchscreen");
        if (!check_default(ops))
-               SYS_G_LIST_APPEND(lcdon_ops, ops);
+               display_register_dependent_device(ops);
 
        ops = find_device("bezel");
        if (!check_default(ops))
-               SYS_G_LIST_APPEND(lcdon_ops, ops);
+               display_register_dependent_device(ops);
 }
 
 static void exit_lcd_operation(void)
 {
-       GList *l = NULL;
-       GList *l_next = NULL;
-       const struct device_ops *ops = NULL;
-
-       SYS_G_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops)
-               SYS_G_LIST_REMOVE_LIST(lcdon_ops, l);
+       display_unregister_dependent_device();
 }
 
 enum {
@@ -2144,10 +1812,10 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name)
                states[get_pm_cur_state()].trans(EVENT_INPUT);
 
        if (holdkey_block) {
-               custom_holdkey_block = true;
+               display_lock_set_custom_holdkey_block(true);
                _I("Hold key disabled.");
        } else {
-               custom_holdkey_block = false;
+               display_lock_set_custom_holdkey_block(false);
                _I("Hold key enabled.");
        }
 
@@ -2165,7 +1833,7 @@ int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name)
        if (!custom_change_name) {
                _E("Failed to malloc.");
                custom_normal_timeout = custom_dim_timeout = 0;
-               custom_holdkey_block = false;
+               display_lock_set_custom_holdkey_block(false);
                return -ENOMEM;
        }
 
@@ -2191,14 +1859,14 @@ void reset_lcd_timeout(GDBusConnection *conn,
        free(custom_change_name);
        custom_change_name = 0;
        custom_normal_timeout = custom_dim_timeout = 0;
-       custom_holdkey_block = false;
+       display_lock_set_custom_holdkey_block(false);
 
        update_display_time();
        if (get_pm_cur_state() == S_NORMAL)
                states[get_pm_cur_state()].trans(EVENT_INPUT);
 }
 
-static int booting_done(void *data)
+static int delayed_init_done(void *data)
 {
        static bool done = false;
 
@@ -2218,27 +1886,6 @@ static int booting_done(void *data)
        return done;
 }
 
-static int battery_health_changed(void *data)
-{
-       int health = DATA_VALUE_INT(data);
-
-       _I("battery health change %d", health);
-
-       if (health == HEALTH_GOOD) {
-               clear_pm_status_flag(BATTERY_FLAG);
-               clear_pm_status_flag(DIMSTAY_FLAG);
-               if (backlight_ops->get_lcd_power() == DPMS_ON)
-                       auto_brightness_restore();
-       } else if (health == HEALTH_LOW || health == HEALTH_HIGH || health == HEALTH_OVP) {
-               set_pm_status_flag(BATTERY_FLAG);
-               set_pm_status_flag(DIMSTAY_FLAG);
-               if (backlight_ops->get_lcd_power() == DPMS_ON)
-                       backlight_ops->update();
-       }
-
-       return 0;
-}
-
 static int powerlock_load_config(struct parse_result *result, void *user_data)
 {
        char *name = NULL;
@@ -2259,11 +1906,11 @@ static int powerlock_load_config(struct parse_result *result, void *user_data)
        return 0;
 }
 
-static gboolean delayed_init_dpms(gpointer data)
+static gboolean delayed_dpms_init_done(gpointer data)
 {
        int timeout;
 
-       if (!init_dpms())
+       if (!display_panel_init_dpms())
                return G_SOURCE_CONTINUE;
 
        switch (get_pm_cur_state()) {
@@ -2275,13 +1922,13 @@ static gboolean delayed_init_dpms(gpointer data)
                        /* check minimun lcd on time */
                        if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
                                timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
-                       reset_timeout(timeout);
+                       display_state_transition_reset_state_transition_timeout(timeout);
                }
                break;
        case S_LCDOFF:
                lcd_off_procedure(LCD_OFF_BY_EVENT);
                timeout = display_conf.lcdoff_timeout;
-               reset_timeout(timeout);
+               display_state_transition_reset_state_transition_timeout(timeout);
                break;
        default:
                break;
@@ -2290,13 +1937,19 @@ static gboolean delayed_init_dpms(gpointer data)
        return G_SOURCE_REMOVE;
 }
 
-static void add_timer_for_init_dpms(void)
+static void add_timer_for_dpms_init(void)
 {
-       guint id = g_timeout_add(500/* milliseconds */, delayed_init_dpms, NULL);
+       guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL);
        if (id == 0)
-               _E("Failed to add init_dpms timeout.");
+               _E("Failed to add display_panel_init_dpms timeout.");
 }
 
+static void init_display_states(void *data)
+{
+       struct display_plugin *dp = (struct display_plugin *) data;
+       for(int i = 0; i < S_END; i++)
+               dp->display_states[i] = &states[i];
+}
 /**
  * Power manager Main
  *
@@ -2304,6 +1957,16 @@ static void add_timer_for_init_dpms(void)
 static int display_probe(void *data)
 {
        int ret;
+       struct display_plugin *dp = (struct display_plugin *) data;
+       assert(dp);
+
+       dp->config = &display_conf;
+       init_display_states(dp);
+       setup_display_plugin_backlight_ops(dp);
+       dp->delete_state_cond = del_state_cond;
+       dp->set_dim_state = set_dim_state;
+       dp->get_device_flags = get_device_flags;
+       setup_display_plugin_backlight_ops(dp);
 
        /**
         * load display service
@@ -2315,7 +1978,7 @@ static int display_probe(void *data)
                return ret;
 
        /* display_plugin instance initialization */
-       init_pm_internal();
+       init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
        if (battery_plgn->handle) {
@@ -2331,9 +1994,37 @@ static int display_probe(void *data)
 static int input_init_handler(void)
 {
        if (!display_conf.input_support)
-               return 0;
+               remove_device_by_devname("input");
 
-       g_idle_add(init_input, NULL);
+       return 0;
+}
+
+static int power_resume_from_echomem_callback(void *data)
+{
+       system_wakeup_flag = true;
+       if (check_wakeup_src() == EVENT_DEVICE)
+               /* system waked up by devices */
+               states[get_pm_cur_state()].trans(EVENT_DEVICE);
+       else
+               /* system waked up by user input */
+               states[get_pm_cur_state()].trans(EVENT_INPUT);
+
+       return 0;
+}
+
+static int poweroff_triggered_callback(void *udata)
+{
+       int val = (int)(intptr_t) udata;
+
+       switch (val) {
+       case VCONFKEY_SYSMAN_POWER_OFF_NONE:
+               clear_pm_status_flag(PWROFF_FLAG);
+               break;
+       case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
+       case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
+               set_pm_status_flag(PWROFF_FLAG);
+               break;
+       }
 
        return 0;
 }
@@ -2348,8 +2039,8 @@ static void esd_action(void)
 
        if (!check_default(touchscreen_ops))
                touchscreen_ops->stop(NORMAL_MODE);
-       backlight_ops->off(NORMAL_MODE);
-       backlight_ops->on(NORMAL_MODE);
+       display_panel_set_panel_state_by_off_state(NORMAL_MODE);
+       display_panel_set_panel_state_by_on_state(NORMAL_MODE);
        if (!check_default(touchscreen_ops))
                touchscreen_ops->start(NORMAL_MODE);
 }
@@ -2420,7 +2111,7 @@ static void display_init(void *data)
        power_saving_func = default_saving_mode;
 
        /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
+       ret = display_load_config(&display_conf);
        if (ret < 0)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
@@ -2434,13 +2125,13 @@ static void display_init(void *data)
        register_kernel_uevent_control(&lcd_uevent_ops);
        register_kernel_uevent_control(&sec_dsim_uevent_ops);
 
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
+       register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
        register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
-       register_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, battery_health_changed);
-       register_notifier(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, display_brightness_changed);
        register_notifier(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, display_auto_brightness_sensing);
+       register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
+       register_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
 
        init_save_userlock();
 
@@ -2456,7 +2147,6 @@ static void display_init(void *data)
                        break;
                case INIT_POLL:
                        _I("input init");
-                       pm_callback = poll_callback;
                        ret = input_init_handler();
 
                        pm_lock_detector_init();
@@ -2481,7 +2171,7 @@ static void display_init(void *data)
                check_seed_status();
 
                /* In smd test, TSP should be turned off if display panel is not existed. */
-               if (backlight_ops->get_lcd_power() == -ENOENT) {
+               if (display_panel_get_dpms_cached_state() == -ENOENT) {
                        _I("Display panel is not existed.");
                        lcd_direct_control(DPMS_OFF, NORMAL_MODE);
                        exit_lcd_operation();
@@ -2491,26 +2181,24 @@ static void display_init(void *data)
                 * 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 (init_dpms()) {
+               if (display_panel_init_dpms()) {
                        if (is_lcdon_blocked() != LCDON_BLOCK_NONE)
                                lcd_off_procedure(LCD_OFF_BY_EVENT);
                        else
                                lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
                } else {
-                       add_timer_for_init_dpms();
+                       add_timer_for_dpms_init();
                }
 
                if (display_conf.lcd_always_on) {
                        _I("LCD always on.");
-                       trans_table[S_NORMAL][EVENT_TIMEOUT] = S_NORMAL;
+                       display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT);
                }
 
                if (flags & WITHOUT_STARTNOTI) {        /* start without noti */
                        _I("Start Power managing without noti");
-                       if (pm_get_power_lock_support()) {
-                               broadcast_pm_wakeup();
-                               pm_power_lock();
-                       }
+                       power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
+                               HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL);
                        /*
                         * Lock lcd off until booting is done.
                         * deviced guarantees all booting script is executing.
@@ -2518,7 +2206,7 @@ static void display_init(void *data)
                         */
                        if (disp_plgn->pm_lock_internal)
                                disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
-                                               STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
+                                               STAY_CUR_STATE, DELAYED_INIT_WATING_TIME);
 
                        /* Initial display state right after the booting done */
                        if (is_lcdon_blocked())
@@ -2546,6 +2234,8 @@ static void display_init(void *data)
                if (display_conf.input_support)
                        if (CHECK_OPS(keyfilter_ops, init))
                                keyfilter_ops->init();
+
+               set_display_init_direction(display_conf.display_init_direction);
        }
 }
 
@@ -2559,7 +2249,7 @@ static void display_exit(void *data)
        set_pm_cur_state(S_NORMAL);
        set_setting_pmstate(get_pm_cur_state());
        /* timeout is not needed */
-       reset_timeout(TIMEOUT_NONE);
+       display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
 
        if (CHECK_OPS(keyfilter_ops, exit))
                keyfilter_ops->exit();
@@ -2578,14 +2268,12 @@ static void display_exit(void *data)
                        exit_sysfs();
                        break;
                case INIT_POLL:
-                       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
+                       unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
                        unregister_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
                        unregister_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
                        unregister_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
-                       unregister_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, battery_health_changed);
-                       unregister_notifier(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, display_brightness_changed);
+                       unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
 
-                       exit_input();
                        break;
                }
        }
@@ -2608,10 +2296,10 @@ static int display_start(enum device_flags flags)
        if (flags & NORMAL_MODE) {
                if (flags & LCD_PANEL_OFF_MODE)
                        /* standby on */
-                       backlight_ops->standby(true);
+                       display_panel_set_panel_state_by_standby_state(true);
                else
                        /* normal lcd on */
-                       backlight_ops->on(flags);
+                       display_panel_set_panel_state_by_on_state(flags);
                FIND_DISPLAY(enhance_ops, "enhance");
                if (enhance_ops && enhance_ops->func)
                        enhance_ops->func(RESTORE_ENHANCE_OUTDOOR, &on);
@@ -2637,7 +2325,7 @@ static int display_stop(enum device_flags flags)
 {
        /* NORMAL MODE */
        if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
-               backlight_ops->off(flags);
+               display_panel_set_panel_state_by_off_state(flags);
                return 0;
        }
 
@@ -2658,9 +2346,9 @@ static int display_status(void)
        return status;
 }
 
-static const struct device_ops display_device_ops = {
-       .priority = DEVICE_PRIORITY_HIGH,
-       DECLARE_NAME_LEN("display"),
+static const struct device_ops display_plugin_device_ops = {
+       .disable_auto_init = true,
+       DECLARE_NAME_LEN("display-plugin"),
        .probe    = display_probe,
        .init     = display_init,
        .exit     = display_exit,
@@ -2669,7 +2357,7 @@ static const struct device_ops display_device_ops = {
        .status   = display_status,
 };
 
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {