4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 * @brief Power manager main loop.
24 * This file includes Main loop, the FSM, signal processing.
35 #include <sys/types.h>
40 #include <vconf-keys.h>
42 #include <libsyscommon/list.h>
43 #include <device/display-internal.h>
44 #include <hal/device/hal-device-power.h>
46 #include "ambient-mode.h"
50 #include "lock-detector.h"
51 #include "display-ops.h"
52 #include "shared/devices.h"
53 #include "shared/device-notifier.h"
54 #include "core/udev.h"
55 #include "shared/common.h"
56 #include "shared/apps.h"
57 #include "extcon/extcon.h"
58 #include "battery/power-supply.h"
59 #include "power/power.h"
60 #include "power/power-off.h"
61 #include "power/power-suspend.h"
62 #include "power/power-boot.h"
63 #include "power/power-doze.h"
64 #include "device-interface.h"
65 #include "display-plugin.h"
66 #include "display-signal.h"
67 #include "display-lock.h"
68 #include "display-backlight.h"
69 #include "display-misc.h"
70 #include "display-panel.h"
71 #include "display-config.h"
72 #include "display-state-transition.h"
73 #include "shared/plugin.h"
74 #include "led/touch-key.h"
77 * @addtogroup POWER_MANAGER
81 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000
83 #define GESTURE_STR "gesture"
84 #define POWER_KEY_STR "powerkey"
85 #define TOUCH_STR "touch"
86 #define EVENT_STR "event"
87 #define TIMEOUT_STR "timeout"
88 #define PROXI_STR "proximity"
89 #define PALM_STR "palm"
90 #define UNKNOWN_STR "unknown"
92 extern void init_save_userlock(void);
94 static struct display_plugin *disp_plgn;
95 static struct display_backlight_ops *backlight_ops;
96 static struct battery_plugin *battery_plgn;
97 static int (*fp_get_charging_status) (int *val);
98 static void (*power_saving_func) (int onoff);
99 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
101 static int system_wakeup_flag = false;
102 static char *custom_change_name;
103 static guint lock_timeout_id;
104 static struct timeval lcdon_tv;
106 * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial
107 * state because it should be sent from previous state at booting time.
109 static bool lcdon_broadcast = true;
111 static bool touch_blocked = false;
113 /* default transition, action fuctions */
114 static int default_trans(int evt);
115 static int default_action(int timeout);
117 static int default_proc_change_state(unsigned int cond, pid_t pid);
118 static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
120 static struct state states[S_END] = {
121 { S_START, "S_START", NULL, NULL, NULL, NULL },
122 { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
123 { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
124 { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
125 { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
126 { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
127 { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
130 #define TIMEOUT_NONE (-1)
132 #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
134 #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
135 #define LONG_PRESS_INTERVAL 2 /* 2 seconds */
136 #define SAMPLING_INTERVAL 1 /* 1 sec */
137 #define BRIGHTNESS_CHANGE_STEP 10
138 #define LCD_ALWAYS_ON 0
139 #define ACCEL_SENSOR_ON 1
140 #define CONTINUOUS_SAMPLING 1
141 #define LCDOFF_TIMEOUT 300 /* milli second */
143 #define DIFF_TIMEVAL_MS(a, b) \
144 (((a.tv_sec * 1000000 + a.tv_usec) - \
145 (b.tv_sec * 1000000 + b.tv_usec)) \
148 static struct display_config display_conf = {
149 .lock_wait_time = LOCK_SCREEN_WATING_TIME,
150 .longpress_interval = LONG_PRESS_INTERVAL,
151 .lightsensor_interval = SAMPLING_INTERVAL,
152 .lcdoff_timeout = LCDOFF_TIMEOUT,
153 .pm_default_brightness = 80,
154 .brightness_change_step = BRIGHTNESS_CHANGE_STEP,
155 .lcd_always_on = LCD_ALWAYS_ON,
157 .framerate_app = {0, 0, 0, 0},
158 .control_display = 0,
159 .powerkey_doublepress = 0,
160 .accel_sensor_on = ACCEL_SENSOR_ON,
161 .continuous_sampling = CONTINUOUS_SAMPLING,
162 .timeout_enable = true,
163 .input_support = true,
164 .lockcheck_timeout = 600,
165 .display_init_direction = DISPLAY_INIT_DIRECTION_HORIZONTAL,
166 .aod_enter_level = 40,
168 .touch_wakeup = false,
169 .display_on_usb_conn_changed = true,
170 .display_dpms_type = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
173 struct display_function_info display_info = {
174 .update_auto_brightness = NULL,
175 .set_autobrightness_min = NULL,
176 .reset_autobrightness_min = NULL,
177 .face_detection = NULL,
180 inline const struct display_config* get_var_display_config()
182 return &display_conf;
185 inline struct state* state_st(enum state_t state)
187 return &states[state];
190 static const char* __device_flags_to_string(enum device_flags flags)
192 if (flags & LCD_ON_BY_GESTURE)
194 else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
195 return POWER_KEY_STR;
196 else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
198 else if (flags & LCD_ON_BY_TOUCH)
200 else if (flags & LCD_OFF_BY_TIMEOUT)
206 bool touch_event_blocked(void)
208 return touch_blocked;
211 void lcd_on_procedure(int state, enum device_flags flag)
213 unsigned long flags = NORMAL_MODE;
214 display_plugin_get_device_flags(&flags);
218 * Display on procedure
220 * step 2. broadcast lcd on signal with cause
221 * step 3. set brightness
222 * step 4. set pmstate of vconf
223 * step 5. display on operate
225 * - b. TSP(touch screen) and touchkey enable
226 * step 6. broadcast lcd on complete signal
227 * step 7. key backlight enable
231 _I("[lcdstep] 0x%lx", flags);
233 /* send LCDOn dbus signal */
234 if (!lcdon_broadcast)
235 broadcast_lcd_on(SIGNAL_PRE, flags);
237 /* Update brightness level */
238 if (state == LCD_DIM)
239 display_backlight_set_brightness_by_dim_brightness();
240 else if (state == LCD_NORMAL)
241 display_backlight_update_by_default_brightness();
243 if (state == LCD_NORMAL)
244 set_setting_pmstate(S_NORMAL);
245 else if (state == LCD_DIM)
246 set_setting_pmstate(S_LCDDIM);
248 display_start_dependent_device(flags);
250 if (!lcdon_broadcast) {
251 broadcast_lcd_on(SIGNAL_POST, flags);
252 lcdon_broadcast = true;
255 touchled_control_backlight(TOUCHLED_DIRECT_ON);
257 touch_blocked = false;
260 inline void lcd_off_procedure(enum device_flags flag)
262 unsigned long flags = NORMAL_MODE;
263 display_plugin_get_device_flags(&flags);
267 * Display off procedure
268 * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM)
269 * step 1. broadcast lcd off signal with cause
270 * step 2. set pmstate of vconf
271 * step 3. display off operate
273 * - b. TSP(touch screen) and touchkey disable
274 * step 4. broadcast lcd off complete siganl
275 * step 5. enter doze mode if it is enabled
277 _I("[lcdstep] 0x%lx", flags);
281 device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
283 if (lcdon_broadcast) {
284 broadcast_lcd_off(SIGNAL_PRE, flags);
285 lcdon_broadcast = false;
290 touch_blocked = true;
292 set_setting_pmstate(S_LCDOFF);
294 touchled_control_backlight(TOUCHLED_DIRECT_OFF);
296 display_stop_dependent_device(flags);
298 broadcast_lcd_off(SIGNAL_POST, flags);
299 device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
304 static void update_display_locktime(int time)
306 display_state_transition_set_lock_screen_timeout(time);
307 display_state_transition_update_display_state_timeout_by_priority();
310 void lcd_on_direct(enum device_flags flags)
312 enum hal_device_power_transition_reason reason;
314 if (flags & LCD_ON_BY_POWER_KEY)
315 reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY;
316 else if (flags & LCD_ON_BY_TOUCH)
317 reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN;
319 reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
321 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL);
322 set_pm_cur_state(S_NORMAL);
324 _D("lcd is on directly");
325 gettimeofday(&lcdon_tv, NULL);
326 lcd_on_procedure(LCD_NORMAL, flags);
328 update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
331 static inline bool check_lcd_is_on(void)
333 if (display_panel_get_dpms_cached_state() != DPMS_ON)
339 static gboolean timer_refresh_cb(gpointer data)
343 /* state transition */
344 set_pm_old_state(get_pm_cur_state());
345 set_pm_cur_state(S_NORMAL);
346 st = &states[get_pm_cur_state()];
349 st->action(st->timeout);
354 int custom_lcdon(int timeout)
361 if (check_lcd_is_on() == false)
362 lcd_on_direct(LCD_ON_BY_GESTURE);
364 _I("Custom lcd on timeout(%d ms).", timeout);
365 if (set_custom_lcdon_timeout(timeout) == true)
366 display_state_transition_update_display_state_timeout_by_priority();
368 /* state transition */
369 set_pm_old_state(get_pm_cur_state());
370 set_pm_cur_state(S_NORMAL);
371 st = &states[get_pm_cur_state()];
375 st->action(st->timeout);
377 g_idle_add(timer_refresh_cb, NULL);
382 int custom_lcdoff(enum device_flags flag)
386 check_processes(S_NORMAL);
387 check_processes(S_LCDDIM);
389 /* check holdkey block flag in lock node */
390 if (check_lock_condition(S_NORMAL) || check_lock_condition(S_LCDDIM)) {
392 * When another proccess is normal lock, device is received call then,
393 * call app can be changed to lcd state by proximity.
394 * If proximity is near then normal lock will be unlocked.
396 if (flag & LCD_OFF_BY_PROXIMITY) {
397 _I("custom lcd off by proximity, delete normal lock");
398 delete_condition(S_NORMAL);
400 _I("skip custom lcd off");
405 _I("custom lcd off by flag(%d)", flag);
406 if (display_panel_get_dpms_cached_state() == DPMS_ON)
407 lcd_off_procedure(flag);
409 if (set_custom_lcdon_timeout(0) == true)
410 display_state_transition_update_display_state_timeout_by_priority();
412 /* state transition */
413 set_pm_old_state(get_pm_cur_state());
414 set_pm_cur_state(S_LCDOFF);
415 st = &states[get_pm_cur_state()];
419 st->action(st->timeout);
424 int display_on_by_reason(const char *reason, int timeout)
430 str_len = strlen(reason);
432 if (!strncmp(reason, GESTURE_STR, str_len))
433 flag = LCD_ON_BY_GESTURE;
434 else if (!strncmp(reason, EVENT_STR, str_len))
435 flag = LCD_ON_BY_EVENT;
437 _E("Reason is unknown(%s)", reason);
442 _E("Cannot setting timeout %d", timeout);
446 if (check_lcd_is_on() == false)
449 _I("platform lcd on by %s (%d ms)", reason, timeout);
450 if (set_custom_lcdon_timeout(timeout) == true)
451 display_state_transition_update_display_state_timeout_by_priority();
453 /* state transition */
454 set_pm_old_state(get_pm_cur_state());
455 set_pm_cur_state(S_NORMAL);
456 st = &states[get_pm_cur_state()];
460 st->action(st->timeout);
465 int display_off_by_reason(const char *reason)
471 str_len = strlen(reason);
473 if (!strncmp(reason, GESTURE_STR, str_len)) {
474 check_processes(S_NORMAL);
475 check_processes(S_LCDDIM);
477 /* check holdkey block flag in lock node */
478 if (check_lock_condition(S_NORMAL) || check_lock_condition(S_LCDDIM)) {
479 _I("skip platform lcd off by gesture");
482 flag = LCD_OFF_BY_GESTURE;
483 } else if (!strncmp(reason, PALM_STR, str_len)) {
484 delete_condition(S_NORMAL);
485 delete_condition(S_LCDDIM);
487 flag = LCD_OFF_BY_PALM;
489 _E("Reason is unknown(%s)", reason);
493 _I("platform lcd off by %s", reason);
494 if (display_panel_get_dpms_cached_state() == DPMS_ON)
495 lcd_off_procedure(flag);
497 /* state transition */
498 set_pm_old_state(get_pm_cur_state());
499 set_pm_cur_state(S_LCDOFF);
500 st = &states[get_pm_cur_state()];
504 st->action(st->timeout);
509 static void default_proc_change_state_action(enum state_t next, int timeout)
513 set_pm_old_state(get_pm_cur_state());
514 set_pm_cur_state(next);
516 st = &states[get_pm_cur_state()];
518 if (st && st->action) {
520 st->action(st->timeout);
526 static int default_proc_change_state(unsigned int cond, pid_t pid)
530 next = GET_COND_STATE(cond);
531 _I("Change process(%d) state to %s.", pid, states[next].name);
535 if (check_lcd_is_on() == false)
536 lcd_on_direct(LCD_ON_BY_EVENT);
537 update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
538 default_proc_change_state_action(next, -1);
541 default_proc_change_state_action(next, -1);
544 if (display_panel_get_dpms_cached_state() == DPMS_ON)
545 lcd_off_procedure(LCD_OFF_BY_EVENT);
546 if (set_custom_lcdon_timeout(0))
547 display_state_transition_update_display_state_timeout_by_priority();
548 default_proc_change_state_action(next, -1);
551 _I("Dangerous requests.");
552 /* at first LCD_OFF and then goto sleep */
553 /* state transition */
554 default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
555 delete_condition(S_NORMAL);
556 delete_condition(S_LCDDIM);
557 delete_condition(S_LCDOFF);
558 if (lcdon_broadcast) {
559 _I("broadcast lcd off signal at non-lcd device");
560 broadcast_lcd_off(SIGNAL_PRE, 0);
561 broadcast_lcd_off(SIGNAL_POST, 0);
563 default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
573 static void proc_condition_lock(PMMsg *data)
576 char pname[PATH_MAX];
577 pid_t pid = data->pid;
579 int holdkey_block, ret;
582 const char *lock_type = NULL;
584 state = GET_COND_STATE(data->cond);
585 if (state == S_START)
588 flags = GET_COND_FLAG(data->cond);
589 display_misc_get_process_name(pid, pname);
591 if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
592 (pm_get_power_lock() == POWER_UNLOCK))
593 proc_change_state(data->cond, INTERNAL_LOCK_PM);
595 holdkey_block = GET_COND_FLAG(data->cond) & PM_FLAG_BLOCK_HOLDKEY;
596 tmp = display_lock_add_pmlock_node(state, pid, holdkey_block, data->timeout);
598 _E("Failed to acquire lock, state: %d, pid: %d.", state, pid);
602 if (state == S_LCDOFF)
603 set_process_active(true, pid);
605 _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
607 if (pid < INTERNAL_LOCK_BASE) {
609 if (state == S_LCDOFF)
610 lock_type = PM_LCDOFF_STR;
611 else if (state == S_LCDDIM)
612 lock_type = PM_LCDDIM_STR;
613 else if (state == S_NORMAL)
614 lock_type = PM_LCDON_STR;
617 /* power lock signal */
618 ret = gdbus_signal_emit(NULL,
619 DEVICED_PATH_DISPLAY,
620 DEVICED_INTERFACE_DISPLAY,
622 g_variant_new("(sii)", lock_type, pid, (int)data->timeout));
624 _E("Failed to send dbus signal PowerLock.");
628 _SD("be requested LOCK info pname(%s), holdkeyblock(%d) flags(%d)",
629 pname, holdkey_block, flags);
630 set_lock_time(pid, pname, state);
632 device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
635 static void proc_condition_unlock(PMMsg *data)
637 pid_t pid = data->pid;
640 char pname[PATH_MAX];
644 const char *lock_type = NULL;
646 state = GET_COND_STATE(data->cond);
650 flags = GET_COND_FLAG(data->cond);
651 display_misc_get_process_name(pid, pname);
653 tmp = find_node(state, pid);
654 del_node(state, tmp);
656 if (state == S_LCDOFF)
657 set_process_active(false, pid);
659 _I("[%s] unlocked by %5d", states[state].name, pid);
661 if (pid < INTERNAL_LOCK_BASE) {
663 if (state == S_LCDOFF)
664 lock_type = PM_LCDOFF_STR;
665 else if (state == S_LCDDIM)
666 lock_type = PM_LCDDIM_STR;
667 else if (state == S_NORMAL)
668 lock_type = PM_LCDON_STR;
671 /* power unlock signal */
672 ret = gdbus_signal_emit(NULL,
673 DEVICED_PATH_DISPLAY,
674 DEVICED_INTERFACE_DISPLAY,
676 g_variant_new("(sii)", lock_type, pid, (int)data->timeout));
678 _E("Failed to send dbus signal PowerUnlock.");
682 _SD("be requested UNLOCK info pname(%s) flag(%d)", pname, flags);
683 set_unlock_time(pid, state);
685 device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
688 static int proc_condition(PMMsg *data)
692 if (IS_COND_REQUEST_LOCK(data->cond))
693 proc_condition_lock(data);
695 if (IS_COND_REQUEST_UNLOCK(data->cond))
696 proc_condition_unlock(data);
698 if (!display_conf.timeout_enable)
701 flags = GET_COND_FLAG(data->cond);
703 /* guard time for suspend */
704 if (get_pm_cur_state() == S_LCDOFF)
705 display_state_transition_reset_state_transition_timeout(states[S_LCDOFF].timeout);
707 if (flags & PM_FLAG_RESET_TIMER)
708 display_state_transition_reset_state_transition_timeout(states[get_pm_cur_state()].timeout);
711 if (!display_state_transition_is_there_state_transition_timer())
712 states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
717 /* SIGHUP signal handler
718 * For debug... print info to syslog
720 static void sig_hup(int signo)
722 _I("received sig hub %d", signo);
728 * default transition function
731 * 3. call enter action function
733 static int default_trans(int evt)
735 struct state *st = &states[get_pm_cur_state()];
736 enum state_t next_state;
739 display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
741 /* check conditions */
742 ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
744 /* There is a condition. */
745 _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
746 states[next_state].name);
750 /* state transition */
751 set_pm_old_state(get_pm_cur_state());
752 set_pm_cur_state(next_state);
753 st = &states[get_pm_cur_state()];
757 if (get_pm_cur_state() == S_LCDOFF)
758 display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
760 if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF))
761 if (set_custom_lcdon_timeout(0) == true)
762 display_state_transition_update_display_state_timeout_by_priority();
764 if (display_state_transition_is_possible_to_go_lcdoff()) {
765 /* enter next state directly */
766 states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
768 if ((get_pm_cur_state() == S_SLEEP)
769 && (is_emulator() == true || timeout_sleep_support == false))
772 st->action(st->timeout);
779 static gboolean lcd_on_expired(void *data)
786 /* check state of lock */
787 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
788 if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK)
789 return G_SOURCE_REMOVE;
791 _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno());
793 /* lock screen is not launched yet, but lcd is on */
794 if (check_lcd_is_on() == false)
795 lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
797 return G_SOURCE_REMOVE;
800 static inline void stop_lock_timer(void)
802 if (lock_timeout_id) {
803 g_source_remove(lock_timeout_id);
808 static void check_lock_screen(void)
814 /* check state of lock */
815 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
816 if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK)
819 /* Use time to check lock is done. */
820 lock_timeout_id = g_timeout_add(display_conf.lock_wait_time,
821 lcd_on_expired, NULL);
824 /* default enter action function */
825 static int default_action(int timeout)
827 int wakeup_count = -1, pm_cur_state;
830 static time_t last_update_time = 0;
831 static int last_timeout = 0;
832 struct timeval now_tv;
835 bool lcd_paneloff_mode = false;
837 if (status != DEVICE_OPS_STATUS_START) {
838 _E("Display is not started.");
842 if (get_pm_cur_state() != S_SLEEP) {
843 if ((get_pm_cur_state() == S_NORMAL) &&
844 lcdon_tv.tv_sec != 0) {
845 gettimeofday(&now_tv, NULL);
846 timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
849 /* set timer with current state timeout */
850 display_state_transition_reset_state_transition_timeout(timeout);
852 if (get_pm_cur_state() == S_NORMAL) {
853 time(&last_update_time);
854 last_timeout = timeout;
856 _I("Timout set: %s state %d ms",
857 states[get_pm_cur_state()].name, timeout);
861 if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
862 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
863 power_get_wakeup_reason(), NULL);
864 set_setting_pmstate(get_pm_cur_state());
865 pm_cur_state = get_pm_cur_state();
866 device_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
869 if ((get_pm_old_state() == S_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
871 diff = difftime(now, last_update_time);
872 _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
873 states[get_pm_cur_state()].name, last_timeout, diff);
876 switch (get_pm_cur_state()) {
879 * normal state : backlight on and restore
880 * the previous brightness
882 if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
884 else if (get_pm_old_state() == S_LCDDIM)
885 display_backlight_update_by_default_brightness();
887 if (check_lcd_is_on() == false)
888 lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
892 display_backlight_get_custom_status(&custom_status);
893 if ((get_pm_old_state() == S_NORMAL) && custom_status) {
894 display_backlight_get_brightness(&brightness);
895 display_backlight_set_custom_brightness(brightness);
897 /* lcd dim state : dim the brightness */
898 display_backlight_set_brightness_by_dim_brightness();
900 if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
901 lcd_on_procedure(LCD_DIM, NORMAL_MODE);
905 if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
907 /* lcd off state : turn off the backlight */
908 if (display_panel_get_dpms_cached_state() == DPMS_ON)
909 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
912 display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
913 if (display_panel_get_dpms_cached_state() == DPMS_ON
914 || lcd_paneloff_mode)
915 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
919 if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF))
922 if (display_panel_get_dpms_cached_state() == DPMS_ON)
923 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
925 if (!pm_get_power_lock_support()) {
926 /* sleep state : set system mode to SUSPEND */
927 if (get_wakeup_count(&wakeup_count) < 0)
928 _E("Wakeup count read error.");
930 if (wakeup_count < 0) {
931 _I("Wakup Event. Can not enter suspend mode.");
935 if (set_wakeup_count(wakeup_count) < 0) {
936 _E("Wakeup count write error.");
947 pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
949 power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
953 if (!pm_get_power_lock_support()) {
955 states[get_pm_cur_state()].trans(EVENT_DEVICE);
960 static void default_saving_mode(int onoff)
963 set_pm_status_flag(PWRSV_FLAG);
965 clear_pm_status_flag(PWRSV_FLAG);
967 if (get_pm_cur_state() == S_NORMAL)
968 display_backlight_update_by_default_brightness();
971 int poll_callback(int condition, PMMsg *data)
973 static time_t last_t;
976 if (status != DEVICE_OPS_STATUS_START) {
977 _E("Display logic is not started.");
981 if (condition == INPUT_POLL_EVENT) {
982 if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
983 _I("Input event signal at Display Off");
985 if ((last_t != now) ||
986 (get_pm_cur_state() == S_LCDOFF) ||
987 (get_pm_cur_state() == S_SLEEP)) {
988 states[get_pm_cur_state()].trans(EVENT_INPUT);
993 if (condition == PM_CONTROL_EVENT) {
994 proc_condition(data);
996 if (IS_COND_REQUEST_CHANGE(data->cond))
997 proc_change_state(data->cond, data->pid);
1003 static int update_setting(int key_idx, int val)
1008 case SETTING_TO_NORMAL:
1009 display_state_transition_update_display_state_timeout_by_priority();
1010 states[get_pm_cur_state()].trans(EVENT_INPUT);
1012 case SETTING_LOW_BATT:
1013 if (display_misc_is_low_battery_state(val)) {
1014 if (!(get_pm_status_flag() & CHRGR_FLAG))
1015 power_saving_func(true);
1016 set_pm_status_flag(LOWBT_FLAG);
1018 if (get_pm_status_flag() & PWRSV_FLAG)
1019 power_saving_func(false);
1020 clear_pm_status_flag(LOWBT_FLAG);
1021 clear_pm_status_flag(BRTCH_FLAG);
1022 ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false);
1024 _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno());
1027 case SETTING_CHARGING:
1029 if (get_pm_status_flag() & LOWBT_FLAG) {
1030 power_saving_func(false);
1031 clear_pm_status_flag(LOWBT_FLAG);
1033 set_pm_status_flag(CHRGR_FLAG);
1036 ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
1039 bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
1040 _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
1042 if (display_misc_is_low_battery_state(bat_state)) {
1043 power_saving_func(true);
1044 set_pm_status_flag(LOWBT_FLAG);
1046 clear_pm_status_flag(CHRGR_FLAG);
1049 case SETTING_BRT_LEVEL:
1050 if (get_pm_status_flag() & PWRSV_FLAG) {
1051 set_pm_status_flag(BRTCH_FLAG);
1052 ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true);
1054 _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno());
1055 _I("Brightness changed in low battery,"
1056 "escape dim state.");
1058 display_backlight_set_default_brightness(val);
1060 case SETTING_LOCK_SCREEN:
1061 set_lock_screen_state(val);
1062 if (val == VCONFKEY_IDLE_UNLOCK)
1063 touchled_control_backlight(TOUCHLED_DIRECT_OFF);
1065 /* LCD on if lock screen show before waiting time */
1066 if ((get_pm_cur_state() == S_NORMAL) &&
1067 val == VCONFKEY_IDLE_LOCK &&
1068 display_panel_get_dpms_cached_state() != DPMS_ON &&
1069 is_lcdon_blocked() == LCDON_BLOCK_NONE)
1070 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1072 display_state_transition_update_display_state_timeout_by_priority();
1073 if (get_pm_cur_state() == S_NORMAL)
1074 states[get_pm_cur_state()].trans(EVENT_INPUT);
1076 case SETTING_LOCK_SCREEN_BG:
1077 set_lock_screen_bg_state(val);
1078 display_state_transition_update_display_state_timeout_by_priority();
1079 if (get_pm_cur_state() == S_NORMAL)
1080 states[get_pm_cur_state()].trans(EVENT_INPUT);
1082 case SETTING_POWER_CUSTOM_BRIGHTNESS:
1083 if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON)
1084 display_backlight_set_custom_status(true);
1086 display_backlight_set_custom_status(false);
1095 static void check_seed_status(void)
1102 int lock_screen_timeout = 0;
1104 /* Charging check */
1105 if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
1106 set_pm_status_flag(CHRGR_FLAG);
1108 ret = get_setting_brightness(&tmp);
1109 if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
1110 _I("Failed to read vconf value for brightness.");
1111 brt = display_conf.pm_default_brightness;
1112 if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) {
1113 ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
1115 _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno());
1119 _I("Set brightness(%d) from setting app.", tmp);
1120 display_backlight_set_default_brightness(tmp);
1121 display_backlight_set_brightness(tmp);
1123 ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
1125 bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
1126 _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
1128 if (display_misc_is_low_battery_state(bat_state)) {
1129 if (!(get_pm_status_flag() & CHRGR_FLAG)) {
1130 power_saving_func(true);
1131 set_pm_status_flag(LOWBT_FLAG);
1135 /* lock screen check */
1136 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
1139 _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno());
1141 set_lock_screen_state(lock_state);
1142 display_state_transition_get_lock_screen_timeout(&lock_screen_timeout);
1143 if (lock_state == VCONFKEY_IDLE_LOCK) {
1144 states[S_NORMAL].timeout = lock_screen_timeout;
1145 _I("LCD NORMAL timeout(%d ms) is set"
1146 " for lock screen.", lock_screen_timeout);
1152 static void init_lcd_operation(void)
1154 const struct device_ops *ops = NULL;
1156 ops = find_device("display");
1157 if (!check_default(ops))
1158 display_register_dependent_device(ops);
1160 ops = find_device("touchkey");
1161 if (!check_default(ops))
1162 display_register_dependent_device(ops);
1164 ops = find_device("touchscreen");
1165 if (!check_default(ops))
1166 display_register_dependent_device(ops);
1169 static void exit_lcd_operation(void)
1171 display_unregister_dependent_device();
1183 static const char *errMSG[INIT_END] = {
1184 [INIT_SETTING] = "setting init error",
1185 [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error",
1186 [INIT_POLL] = "input devices poll init error",
1187 [INIT_FIFO] = "FIFO poll init error",
1188 [INIT_DBUS] = "d-bus init error",
1191 int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name)
1193 unsigned int custom_normal_timeout = 0;
1194 unsigned int custom_dim_timeout = 0;
1196 if (on == 0 && dim == 0) {
1197 _I("LCD timeout changed: default setting");
1198 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1199 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1200 } else if (on < 0 || dim < 0) {
1201 _E("Failed to set value(on=%d dim=%d).", on, dim);
1204 _I("LCD timeout changed: on=%ds dim=%ds", on, dim);
1205 display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on));
1206 display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim));
1208 /* Apply new backlight time */
1209 display_state_transition_update_display_state_timeout_by_priority();
1210 if (get_pm_cur_state() == S_NORMAL)
1211 states[get_pm_cur_state()].trans(EVENT_INPUT);
1213 if (holdkey_block) {
1214 display_lock_set_custom_holdkey_block(true);
1215 _I("Hold key disabled.");
1217 display_lock_set_custom_holdkey_block(false);
1218 _I("Hold key enabled.");
1221 if (custom_change_name) {
1222 free(custom_change_name);
1223 custom_change_name = 0;
1226 display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout);
1227 display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout);
1228 if (custom_normal_timeout == 0 &&
1229 custom_dim_timeout == 0 &&
1233 custom_change_name = strndup(name, strlen(name));
1234 if (!custom_change_name) {
1235 _E("Failed to malloc.");
1236 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1237 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1238 display_lock_set_custom_holdkey_block(false);
1245 void reset_lcd_timeout(GDBusConnection *conn,
1246 const gchar *sender,
1247 const gchar *unique_name,
1253 if (!custom_change_name)
1256 if (strcmp(sender, custom_change_name))
1259 _I("reset lcd timeout: Set default timeout. sender=%s", sender);
1261 free(custom_change_name);
1262 custom_change_name = 0;
1263 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1264 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1265 display_lock_set_custom_holdkey_block(false);
1267 display_state_transition_update_display_state_timeout_by_priority();
1268 if (get_pm_cur_state() == S_NORMAL)
1269 states[get_pm_cur_state()].trans(EVENT_INPUT);
1272 static int delayed_init_done(void *data)
1274 static bool done = false;
1283 _I("Booting done, release booting lock.");
1284 if (disp_plgn->pm_unlock_internal) {
1285 disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN);
1286 disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
1292 static gboolean delayed_dpms_init_done(gpointer data)
1296 if (!display_panel_init_dpms())
1297 return G_SOURCE_CONTINUE;
1299 switch (get_pm_cur_state()) {
1302 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1303 if (display_conf.timeout_enable) {
1304 timeout = states[S_NORMAL].timeout;
1305 /* check minimun lcd on time */
1306 if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
1307 timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
1308 display_state_transition_reset_state_transition_timeout(timeout);
1312 lcd_off_procedure(LCD_OFF_BY_EVENT);
1313 timeout = display_conf.lcdoff_timeout;
1314 display_state_transition_reset_state_transition_timeout(timeout);
1320 return G_SOURCE_REMOVE;
1323 static void add_timer_for_dpms_init(void)
1325 guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL);
1327 _E("Failed to add display_panel_init_dpms timeout.");
1330 static void init_display_states(void *data)
1332 struct display_plugin *dp = (struct display_plugin *) data;
1333 for(int i = 0; i < S_END; i++)
1334 dp->display_states[i] = &states[i];
1337 * Power manager Main
1340 static int display_probe(void *data)
1343 struct display_plugin *dp = (struct display_plugin *) data;
1346 dp->config = &display_conf;
1347 init_display_states(dp);
1348 setup_display_plugin_backlight_ops(dp);
1349 dp->set_dim_state = NULL;
1350 dp->get_device_flags = NULL;
1351 setup_display_plugin_backlight_ops(dp);
1353 /* check display feature */
1354 if (!is_feature_display_supported())
1358 * load display service
1359 * if there is no display shared library,
1360 * deviced does not provide any method and function of display.
1362 ret = display_service_load();
1366 /* display_plugin instance initialization */
1367 init_pm_internal(data);
1368 disp_plgn->device_flags_to_string = __device_flags_to_string;
1370 if (battery_plgn->handle) {
1371 fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
1372 if (!fp_get_charging_status)
1373 _E("Failed to obtain address of get_charging_status");
1375 _I("There is no battery module.");
1380 static int input_init_handler(void)
1382 if (!display_conf.input_support)
1383 remove_device_by_devname("input");
1388 static int power_resume_from_echomem_callback(void *data)
1390 system_wakeup_flag = true;
1391 if (check_wakeup_src() == EVENT_DEVICE)
1392 /* system waked up by devices */
1393 states[get_pm_cur_state()].trans(EVENT_DEVICE);
1395 /* system waked up by user input */
1396 states[get_pm_cur_state()].trans(EVENT_INPUT);
1401 static int poweroff_triggered_callback(void *udata)
1403 int val = (int)(intptr_t) udata;
1406 case VCONFKEY_SYSMAN_POWER_OFF_NONE:
1407 clear_pm_status_flag(PWROFF_FLAG);
1409 case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
1410 case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
1411 set_pm_status_flag(PWROFF_FLAG);
1418 static void esd_action(void)
1420 const struct device_ops *touchscreen_ops = NULL;
1424 touchscreen_ops = find_device("touchscreen");
1426 if (!check_default(touchscreen_ops))
1427 touchscreen_ops->stop(NORMAL_MODE);
1428 display_panel_set_panel_state_by_off_state(NORMAL_MODE);
1429 display_panel_set_panel_state_by_on_state(NORMAL_MODE);
1430 if (!check_default(touchscreen_ops))
1431 touchscreen_ops->start(NORMAL_MODE);
1434 static void lcd_uevent_changed(struct udev_device *dev)
1436 const char *devpath;
1439 devpath = udev_device_get_devpath(dev);
1443 if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
1444 action = udev_device_get_action(dev);
1445 if (!strcmp(action, UDEV_CHANGE))
1450 static const struct uevent_handler lcd_uevent_ops = {
1451 .subsystem = LCD_EVENT_SUBSYSTEM,
1452 .uevent_func = lcd_uevent_changed,
1456 static void display_init(void *data)
1459 unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
1462 _I("Start power manager.");
1464 signal(SIGHUP, sig_hup);
1466 power_saving_func = default_saving_mode;
1468 /* load configutation */
1469 ret = display_load_config(&display_conf);
1471 _W("Failed to load '%s', use default value: %d",
1472 DISPLAY_CONF_FILE, ret);
1474 register_kernel_uevent_control(&lcd_uevent_ops);
1476 register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
1477 register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
1478 register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
1479 register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
1480 register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
1481 register_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
1483 init_save_userlock();
1485 for (i = INIT_SETTING; i < INIT_END; i++) {
1488 ret = init_setting(update_setting);
1490 case INIT_INTERFACE:
1491 if (display_conf.timeout_enable)
1492 display_initialize_display_state_timeout_from_setting();
1493 ret = init_sysfs(flags);
1497 ret = input_init_handler();
1499 pm_lock_detector_init();
1503 ret = init_pm_dbus();
1507 _E("Failed to init: %s", errMSG[i]);
1512 if (i == INIT_END) {
1513 display_ops_init(NULL);
1514 #ifdef ENABLE_PM_LOG
1517 init_lcd_operation();
1518 check_seed_status();
1520 /* In smd test, TSP should be turned off if display panel is not existed. */
1521 if (display_panel_get_dpms_cached_state() == -ENOENT) {
1522 _I("Display panel is not existed.");
1523 lcd_direct_control(DPMS_OFF, NORMAL_MODE);
1524 exit_lcd_operation();
1527 /* wm_ready needs to be checked
1528 * since display manager can be launched later than deviced.
1529 * In the case, display cannot be turned on at the first booting */
1530 // wm_ready = check_wm_ready();
1531 if (display_panel_init_dpms()) {
1532 if (is_lcdon_blocked() != LCDON_BLOCK_NONE)
1533 lcd_off_procedure(LCD_OFF_BY_EVENT);
1535 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1537 add_timer_for_dpms_init();
1540 if (display_conf.lcd_always_on) {
1541 _I("LCD always on.");
1542 display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT);
1545 if (flags & WITHOUT_STARTNOTI) { /* start without noti */
1546 _I("Start Power managing without noti");
1547 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
1548 HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL);
1550 * Lock lcd off until booting is done.
1551 * deviced guarantees all booting script is executing.
1552 * Last script of booting unlocks this suspend blocking state.
1554 if (disp_plgn->pm_lock_internal)
1555 disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
1556 STAY_CUR_STATE, DELAYED_INIT_WATING_TIME);
1558 /* Initial display state right after the booting done */
1559 if (is_lcdon_blocked())
1560 set_pm_cur_state(S_LCDOFF);
1562 set_pm_cur_state(S_NORMAL);
1563 ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state());
1565 _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
1567 status = DEVICE_OPS_STATUS_START;
1568 if (display_conf.timeout_enable) {
1569 timeout = states[S_NORMAL].timeout;
1570 /* check minimun lcd on time */
1571 if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
1572 timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
1574 if (disp_plgn->pm_lock_internal)
1575 disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL,
1576 STAY_CUR_STATE, timeout);
1581 set_display_init_direction(display_conf.display_init_direction);
1585 static void display_exit(void *data)
1589 status = DEVICE_OPS_STATUS_STOP;
1591 /* Set current state to S_NORMAL */
1592 set_pm_cur_state(S_NORMAL);
1593 set_setting_pmstate(get_pm_cur_state());
1594 /* timeout is not needed */
1595 display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
1597 unregister_kernel_uevent_control(&lcd_uevent_ops);
1599 display_ops_exit(NULL);
1601 for (i = i - 1; i >= INIT_SETTING; i--) {
1606 case INIT_INTERFACE:
1610 unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
1611 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
1612 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
1613 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
1614 unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
1620 exit_lcd_operation();
1621 free_lock_info_list();
1623 /* free display service */
1624 display_service_free();
1626 _I("Stop power manager.");
1629 static int display_start(enum device_flags flags)
1632 if (flags & NORMAL_MODE) {
1633 if (flags & LCD_PANEL_OFF_MODE)
1635 display_panel_set_panel_state_by_standby_state(true);
1638 display_panel_set_panel_state_by_on_state(flags);
1643 /* CORE LOGIC MODE */
1644 if (!(flags & CORE_LOGIC_MODE))
1647 if (status == DEVICE_OPS_STATUS_START)
1650 if (display_probe(NULL) < 0)
1658 static int display_stop(enum device_flags flags)
1661 if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
1662 display_panel_set_panel_state_by_off_state(flags);
1666 /* CORE LOGIC MODE */
1667 if (!(flags & CORE_LOGIC_MODE))
1670 if (status == DEVICE_OPS_STATUS_STOP)
1678 static int display_status(void)
1683 static const struct device_ops display_plugin_device_ops = {
1684 .disable_auto_init = true,
1685 DECLARE_NAME_LEN("display-plugin"),
1686 .probe = display_probe,
1687 .init = display_init,
1688 .exit = display_exit,
1689 .start = display_start,
1690 .stop = display_stop,
1691 .status = display_status,
1694 DEVICE_OPS_REGISTER(&display_plugin_device_ops)
1696 static void __CONSTRUCTOR__ initialize(void)
1698 disp_plgn = get_var_display_plugin();
1700 _E("Failed to get display plugin variable.");
1702 backlight_ops = get_var_backlight_ops();
1704 _E("Failed to get backlight operator variable.");
1706 battery_plgn = get_var_battery_plugin();
1708 _E("Failed to get battery plugin variable.");