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 <hal/device/hal-device-power.h>
45 #include "ambient-mode.h"
49 #include "lock-detector.h"
50 #include "display-ops.h"
51 #include "shared/devices.h"
52 #include "shared/device-notifier.h"
53 #include "core/udev.h"
54 #include "shared/common.h"
55 #include "shared/apps.h"
56 #include "extcon/extcon.h"
57 #include "battery/power-supply.h"
58 #include "power/power.h"
59 #include "power/power-off.h"
60 #include "power/power-suspend.h"
61 #include "power/power-boot.h"
62 #include "power/power-doze.h"
63 #include "device-interface.h"
64 #include "display-plugin.h"
65 #include "proximity.h"
66 #include "display-info.h"
67 #include "display-signal.h"
68 #include "display-lock.h"
69 #include "display-backlight.h"
70 #include "display-misc.h"
71 #include "display-panel.h"
72 #include "display-config.h"
73 #include "display-state-transition.h"
74 #include "shared/plugin.h"
75 #include "led/touch-key.h"
78 * @addtogroup POWER_MANAGER
82 #define LOCK_SCREEN_CONTROL_TIMEOUT 5000
84 #define GESTURE_STR "gesture"
85 #define POWER_KEY_STR "powerkey"
86 #define TOUCH_STR "touch"
87 #define EVENT_STR "event"
88 #define TIMEOUT_STR "timeout"
89 #define PROXI_STR "proximity"
90 #define PALM_STR "palm"
91 #define UNKNOWN_STR "unknown"
93 extern void init_save_userlock(void);
95 static struct display_plugin *disp_plgn;
96 static struct display_backlight_ops *backlight_ops;
97 static struct battery_plugin *battery_plgn;
98 static int (*fp_get_charging_status) (int *val);
100 static void (*power_saving_func) (int onoff);
101 static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
103 static int system_wakeup_flag = false;
104 static char *custom_change_name;
105 static guint lock_timeout_id;
106 static struct timeval lcdon_tv;
108 * The two variables(lcdon_broadcast, pmstate_suspend) must be set initial
109 * state because it should be sent from previous state at booting time.
111 static bool lcdon_broadcast = true;
113 static bool touch_blocked = false;
115 /* default transition, action fuctions */
116 static int default_trans(int evt);
117 static int default_action(int timeout);
119 static int default_proc_change_state(unsigned int cond, pid_t pid);
120 static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
122 static struct state states[S_END] = {
123 { S_START, "S_START", NULL, NULL, NULL, NULL },
124 { S_NORMAL, "S_NORMAL", default_trans, default_action, NULL, NULL },
125 { S_LCDDIM, "S_LCDDIM", default_trans, default_action, NULL, NULL },
126 { S_LCDOFF, "S_LCDOFF", default_trans, default_action, NULL, NULL },
127 { S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
128 { S_SLEEP, "S_SLEEP", default_trans, default_action, NULL, NULL },
129 { S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
132 #define TIMEOUT_NONE (-1)
134 #define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
136 #define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
137 #define LONG_PRESS_INTERVAL 400 /* 0.4 seconds */
138 #define SAMPLING_INTERVAL 1 /* 1 sec */
139 #define BRIGHTNESS_CHANGE_STEP 10
140 #define LCD_ALWAYS_ON 0
141 #define ACCEL_SENSOR_ON 1
142 #define CONTINUOUS_SAMPLING 1
143 #define LCDOFF_TIMEOUT 300 /* milli second */
145 #define DIFF_TIMEVAL_MS(a, b) \
146 (((a.tv_sec * 1000000 + a.tv_usec) - \
147 (b.tv_sec * 1000000 + b.tv_usec)) \
150 static struct display_config display_conf = {
151 .lock_wait_time = LOCK_SCREEN_WATING_TIME,
152 .longpress_interval = LONG_PRESS_INTERVAL,
153 .lightsensor_interval = SAMPLING_INTERVAL,
154 .lcdoff_timeout = LCDOFF_TIMEOUT,
155 .pm_default_brightness = 80,
156 .brightness_change_step = BRIGHTNESS_CHANGE_STEP,
157 .lcd_always_on = LCD_ALWAYS_ON,
159 .framerate_app = {0, 0, 0, 0},
160 .control_display = 0,
161 .powerkey_doublepress = 0,
162 .accel_sensor_on = ACCEL_SENSOR_ON,
163 .continuous_sampling = CONTINUOUS_SAMPLING,
164 .timeout_enable = true,
165 .input_support = true,
166 .lockcheck_timeout = 600,
167 .display_init_direction = DISPLAY_INIT_DIRECTION_HORIZONTAL,
168 .aod_enter_level = 40,
170 .touch_wakeup = false,
171 .display_on_usb_conn_changed = true,
172 .display_dpms_type = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
175 struct display_function_info display_info = {
176 .update_auto_brightness = NULL,
177 .set_autobrightness_min = NULL,
178 .reset_autobrightness_min = NULL,
179 .face_detection = NULL,
182 inline const struct display_config* get_var_display_config()
184 return &display_conf;
187 inline struct state* state_st(enum state_t state)
189 return &states[state];
192 static const char* __device_flags_to_string(enum device_flags flags)
195 if (flags & (LCD_ON_BY_GESTURE | LCD_OFF_BY_GESTURE))
197 else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
198 return POWER_KEY_STR;
199 else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
201 else if (flags & LCD_ON_BY_TOUCH)
203 else if (flags & LCD_OFF_BY_TIMEOUT)
205 else if (flags & LCD_OFF_BY_PROXIMITY)
207 else if (flags & LCD_OFF_BY_PALM)
213 bool touch_event_blocked(void)
215 return touch_blocked;
218 void lcd_on_procedure(int state, enum device_flags flag)
220 unsigned long flags = NORMAL_MODE;
221 display_plugin_get_device_flags(&flags);
225 * Display on procedure
227 * step 2. broadcast lcd on signal with cause
228 * step 3. set brightness
229 * step 4. set pmstate of vconf
230 * step 5. display on operate
232 * - b. TSP(touch screen) and touchkey enable
233 * step 6. broadcast lcd on complete signal
234 * step 7. key backlight enable
238 _I("[lcdstep] 0x%lx", flags);
240 /* send LCDOn dbus signal */
241 if (!lcdon_broadcast)
242 broadcast_lcd_on(SIGNAL_PRE, flags);
244 /* Update brightness level */
245 if (state == LCD_DIM)
246 display_backlight_set_brightness_by_dim_brightness();
247 else if (state == LCD_NORMAL)
248 display_backlight_update_by_default_brightness();
250 if (state == LCD_NORMAL)
251 set_setting_pmstate(S_NORMAL);
252 else if (state == LCD_DIM)
253 set_setting_pmstate(S_LCDDIM);
255 display_start_dependent_device(flags);
257 if (!lcdon_broadcast) {
258 broadcast_lcd_on(SIGNAL_POST, flags);
259 lcdon_broadcast = true;
262 touchled_control_backlight(TOUCHLED_DIRECT_ON);
264 touch_blocked = false;
267 inline void lcd_off_procedure(enum device_flags flag)
269 unsigned long flags = NORMAL_MODE;
270 display_plugin_get_device_flags(&flags);
274 * Display off procedure
275 * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM)
276 * step 1. broadcast lcd off signal with cause
277 * step 2. set pmstate of vconf
278 * step 3. display off operate
280 * - b. TSP(touch screen) and touchkey disable
281 * step 4. broadcast lcd off complete siganl
282 * step 5. enter doze mode if it is enabled
284 _I("[lcdstep] 0x%lx", flags);
288 device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
290 if (lcdon_broadcast) {
291 broadcast_lcd_off(SIGNAL_PRE, flags);
292 lcdon_broadcast = false;
297 touch_blocked = true;
299 set_setting_pmstate(S_LCDOFF);
301 touchled_control_backlight(TOUCHLED_DIRECT_OFF);
303 display_stop_dependent_device(flags);
305 broadcast_lcd_off(SIGNAL_POST, flags);
306 device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
311 static void update_display_locktime(int time)
313 display_state_transition_set_lock_screen_timeout(time);
314 display_state_transition_update_display_state_timeout_by_priority();
317 void lcd_on_direct(enum device_flags flags)
319 enum hal_device_power_transition_reason reason;
321 if (flags & LCD_ON_BY_POWER_KEY)
322 reason = HAL_DEVICE_POWER_TRANSITION_REASON_POWER_KEY;
323 else if (flags & LCD_ON_BY_TOUCH)
324 reason = HAL_DEVICE_POWER_TRANSITION_REASON_TOUCH_SCREEN;
326 reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
328 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL);
329 set_pm_cur_state(S_NORMAL);
331 _D("lcd is on directly");
332 gettimeofday(&lcdon_tv, NULL);
333 lcd_on_procedure(LCD_NORMAL, flags);
335 update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
338 static inline bool check_lcd_is_on(void)
340 if (display_panel_get_dpms_cached_state() != DPMS_ON)
346 static gboolean timer_refresh_cb(gpointer data)
350 /* state transition */
351 set_pm_old_state(get_pm_cur_state());
352 set_pm_cur_state(S_NORMAL);
353 st = &states[get_pm_cur_state()];
356 st->action(st->timeout);
361 int custom_lcdon(int timeout)
368 if (check_lcd_is_on() == false)
369 lcd_on_direct(LCD_ON_BY_GESTURE);
371 _I("Custom lcd on timeout(%d ms).", timeout);
372 if (set_custom_lcdon_timeout(timeout) == true)
373 display_state_transition_update_display_state_timeout_by_priority();
375 /* state transition */
376 set_pm_old_state(get_pm_cur_state());
377 set_pm_cur_state(S_NORMAL);
378 st = &states[get_pm_cur_state()];
382 st->action(st->timeout);
384 g_idle_add(timer_refresh_cb, NULL);
389 int custom_lcdoff(enum device_flags flag)
393 check_processes(S_NORMAL);
394 check_processes(S_LCDDIM);
396 /* check holdkey block flag in lock node */
397 if (check_lock_condition(S_NORMAL) || check_lock_condition(S_LCDDIM)) {
399 * When another proccess is normal lock, device is received call then,
400 * call app can be changed to lcd state by proximity.
401 * If proximity is near then normal lock will be unlocked.
403 if (flag & LCD_OFF_BY_PROXIMITY) {
404 _I("custom lcd off by proximity, delete normal lock");
405 delete_condition(S_NORMAL);
407 _I("skip custom lcd off");
412 _I("custom lcd off by flag(%d)", flag);
413 if (display_panel_get_dpms_cached_state() == DPMS_ON)
414 lcd_off_procedure(flag);
416 if (set_custom_lcdon_timeout(0) == true)
417 display_state_transition_update_display_state_timeout_by_priority();
419 /* state transition */
420 set_pm_old_state(get_pm_cur_state());
421 set_pm_cur_state(S_LCDOFF);
422 st = &states[get_pm_cur_state()];
426 st->action(st->timeout);
431 int display_on_by_reason(const char *reason, int timeout)
437 str_len = strlen(reason);
439 if (!strncmp(reason, GESTURE_STR, str_len))
440 flag = LCD_ON_BY_GESTURE;
441 else if (!strncmp(reason, EVENT_STR, str_len))
442 flag = LCD_ON_BY_EVENT;
444 _E("Reason is unknown(%s)", reason);
449 _E("Cannot setting timeout %d", timeout);
453 if (check_lcd_is_on() == false)
456 _I("platform lcd on by %s (%d ms)", reason, timeout);
457 if (set_custom_lcdon_timeout(timeout) == true)
458 display_state_transition_update_display_state_timeout_by_priority();
460 /* state transition */
461 set_pm_old_state(get_pm_cur_state());
462 set_pm_cur_state(S_NORMAL);
463 st = &states[get_pm_cur_state()];
467 st->action(st->timeout);
472 int display_off_by_reason(const char *reason)
478 str_len = strlen(reason);
480 if (!strncmp(reason, GESTURE_STR, str_len)) {
481 check_processes(S_NORMAL);
482 check_processes(S_LCDDIM);
484 /* check holdkey block flag in lock node */
485 if (check_lock_condition(S_NORMAL) || check_lock_condition(S_LCDDIM)) {
486 _I("skip platform lcd off by gesture");
489 flag = LCD_OFF_BY_GESTURE;
490 } else if (!strncmp(reason, PALM_STR, str_len)) {
491 delete_condition(S_NORMAL);
492 delete_condition(S_LCDDIM);
494 flag = LCD_OFF_BY_PALM;
496 _E("Reason is unknown(%s)", reason);
500 _I("platform lcd off by %s", reason);
501 if (display_panel_get_dpms_cached_state() == DPMS_ON)
502 lcd_off_procedure(flag);
504 /* state transition */
505 set_pm_old_state(get_pm_cur_state());
506 set_pm_cur_state(S_LCDOFF);
507 st = &states[get_pm_cur_state()];
511 st->action(st->timeout);
516 static void default_proc_change_state_action(enum state_t next, int timeout)
520 set_pm_old_state(get_pm_cur_state());
521 set_pm_cur_state(next);
523 st = &states[get_pm_cur_state()];
525 if (st && st->action) {
527 st->action(st->timeout);
533 static int default_proc_change_state(unsigned int cond, pid_t pid)
537 next = GET_COND_STATE(cond);
538 _I("Change process(%d) state to %s.", pid, states[next].name);
542 if (check_lcd_is_on() == false)
543 lcd_on_direct(LCD_ON_BY_EVENT);
544 update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
545 default_proc_change_state_action(next, -1);
548 default_proc_change_state_action(next, -1);
551 if (display_panel_get_dpms_cached_state() == DPMS_ON) {
552 if (get_proximity_state() == SENSOR_PROXIMITY_NEAR)
553 lcd_off_procedure(LCD_OFF_BY_PROXIMITY);
555 lcd_off_procedure(LCD_OFF_BY_EVENT);
557 if (set_custom_lcdon_timeout(0))
558 display_state_transition_update_display_state_timeout_by_priority();
559 default_proc_change_state_action(next, -1);
562 _I("Dangerous requests.");
563 /* at first LCD_OFF and then goto sleep */
564 /* state transition */
565 default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
566 delete_condition(S_NORMAL);
567 delete_condition(S_LCDDIM);
568 delete_condition(S_LCDOFF);
569 if (lcdon_broadcast) {
570 _I("broadcast lcd off signal at non-lcd device");
571 broadcast_lcd_off(SIGNAL_PRE, 0);
572 broadcast_lcd_off(SIGNAL_POST, 0);
574 default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
584 static void proc_condition_lock(PMMsg *data)
587 char pname[PATH_MAX];
588 pid_t pid = data->pid;
590 int holdkey_block, ret;
593 const char *lock_type = NULL;
595 state = GET_COND_STATE(data->cond);
596 if (state == S_START)
599 flags = GET_COND_FLAG(data->cond);
600 display_misc_get_process_name(pid, pname);
602 if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
603 (pm_get_power_lock() == POWER_UNLOCK))
604 proc_change_state(data->cond, INTERNAL_LOCK_PM);
606 holdkey_block = GET_COND_FLAG(data->cond) & PM_FLAG_BLOCK_HOLDKEY;
607 tmp = display_lock_add_pmlock_node(state, pid, holdkey_block, data->timeout);
609 _E("Failed to acquire lock, state: %d, pid: %d.", state, pid);
613 if (state == S_LCDOFF)
614 set_process_active(true, pid);
616 _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
618 if (pid < INTERNAL_LOCK_BASE) {
620 if (state == S_LCDOFF)
621 lock_type = PM_LCDOFF_STR;
622 else if (state == S_LCDDIM)
623 lock_type = PM_LCDDIM_STR;
624 else if (state == S_NORMAL)
625 lock_type = PM_LCDON_STR;
628 /* power lock signal */
629 ret = gdbus_signal_emit(NULL,
630 DEVICED_PATH_DISPLAY,
631 DEVICED_INTERFACE_DISPLAY,
633 g_variant_new("(sii)", lock_type, pid, (int)data->timeout));
635 _E("Failed to send dbus signal PowerLock.");
638 _SD("be requested LOCK info pname(%s), holdkeyblock(%d) flags(%d)",
639 pname, holdkey_block, flags);
640 set_lock_time(pid, pname, state);
642 device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
645 static void proc_condition_unlock(PMMsg *data)
647 pid_t pid = data->pid;
650 char pname[PATH_MAX];
654 const char *lock_type = NULL;
656 state = GET_COND_STATE(data->cond);
660 flags = GET_COND_FLAG(data->cond);
661 display_misc_get_process_name(pid, pname);
663 tmp = find_node(state, pid);
664 del_node(state, tmp);
666 if (state == S_LCDOFF)
667 set_process_active(false, pid);
669 _I("[%s] unlocked by %5d", states[state].name, pid);
671 if (pid < INTERNAL_LOCK_BASE) {
673 if (state == S_LCDOFF)
674 lock_type = PM_LCDOFF_STR;
675 else if (state == S_LCDDIM)
676 lock_type = PM_LCDDIM_STR;
677 else if (state == S_NORMAL)
678 lock_type = PM_LCDON_STR;
681 /* power unlock signal */
682 ret = gdbus_signal_emit(NULL,
683 DEVICED_PATH_DISPLAY,
684 DEVICED_INTERFACE_DISPLAY,
686 g_variant_new("(sii)", lock_type, pid, (int)data->timeout));
688 _E("Failed to send dbus signal PowerUnlock.");
692 _SD("be requested UNLOCK info pname(%s) flag(%d)", pname, flags);
693 set_unlock_time(pid, state);
695 device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
698 static int proc_condition(PMMsg *data)
702 if (IS_COND_REQUEST_LOCK(data->cond))
703 proc_condition_lock(data);
705 if (IS_COND_REQUEST_UNLOCK(data->cond))
706 proc_condition_unlock(data);
708 if (!display_conf.timeout_enable)
711 flags = GET_COND_FLAG(data->cond);
713 /* guard time for suspend */
714 if (get_pm_cur_state() == S_LCDOFF)
715 display_state_transition_reset_state_transition_timeout(states[S_LCDOFF].timeout);
717 if (flags & PM_FLAG_RESET_TIMER)
718 display_state_transition_reset_state_transition_timeout(states[get_pm_cur_state()].timeout);
721 if (!display_state_transition_is_there_state_transition_timer())
722 states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
727 /* SIGHUP signal handler
728 * For debug... print info to syslog
730 static void sig_hup(int signo)
732 _I("received sig hub %d", signo);
738 * default transition function
741 * 3. call enter action function
743 static int default_trans(int evt)
745 struct state *st = &states[get_pm_cur_state()];
746 enum state_t next_state;
749 display_state_transition_get_next_transition_display_state(get_pm_cur_state(), &next_state, evt);
751 /* check conditions */
752 ret = display_state_transition_check_state_transition_condition(get_pm_cur_state(), next_state);
754 /* There is a condition. */
755 _I("%s locked. Trans to %s failed.", states[get_pm_cur_state()].name,
756 states[next_state].name);
760 /* state transition */
761 set_pm_old_state(get_pm_cur_state());
762 set_pm_cur_state(next_state);
763 st = &states[get_pm_cur_state()];
767 if (get_pm_cur_state() == S_LCDOFF)
768 display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
770 if ((get_pm_cur_state() == S_NORMAL) || (get_pm_cur_state() == S_LCDOFF))
771 if (set_custom_lcdon_timeout(0) == true)
772 display_state_transition_update_display_state_timeout_by_priority();
774 if (display_state_transition_is_possible_to_go_lcdoff()) {
775 /* enter next state directly */
776 states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
778 if ((get_pm_cur_state() == S_SLEEP)
779 && (is_emulator() == true || timeout_sleep_support == false))
782 st->action(st->timeout);
789 static gboolean lcd_on_expired(void *data)
796 /* check state of lock */
797 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
798 if (ret > 0 && lock_state == VCONFKEY_IDLE_LOCK)
799 return G_SOURCE_REMOVE;
801 _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno());
803 /* lock screen is not launched yet, but lcd is on */
804 if (check_lcd_is_on() == false)
805 lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
807 return G_SOURCE_REMOVE;
810 static inline void stop_lock_timer(void)
812 if (lock_timeout_id) {
813 g_source_remove(lock_timeout_id);
818 static void check_lock_screen(void)
824 /* check state of lock */
825 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
826 if (ret < 0 || lock_state == VCONFKEY_IDLE_LOCK)
829 /* Use time to check lock is done. */
830 lock_timeout_id = g_timeout_add(display_conf.lock_wait_time,
831 lcd_on_expired, NULL);
834 /* default enter action function */
835 static int default_action(int timeout)
837 int wakeup_count = -1, pm_cur_state;
840 static time_t last_update_time = 0;
841 static int last_timeout = 0;
842 struct timeval now_tv;
845 bool lcd_paneloff_mode = false;
847 if (status != DEVICE_OPS_STATUS_START) {
848 _E("Display is not started.");
852 if (get_pm_cur_state() != S_SLEEP) {
853 if ((get_pm_cur_state() == S_NORMAL) &&
854 lcdon_tv.tv_sec != 0) {
855 gettimeofday(&now_tv, NULL);
856 timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
859 /* set timer with current state timeout */
860 display_state_transition_reset_state_transition_timeout(timeout);
862 if (get_pm_cur_state() == S_NORMAL) {
863 time(&last_update_time);
864 last_timeout = timeout;
866 _I("Timout set: %s state %d ms",
867 states[get_pm_cur_state()].name, timeout);
871 if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
872 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
873 power_get_wakeup_reason(), NULL);
874 set_setting_pmstate(get_pm_cur_state());
875 pm_cur_state = get_pm_cur_state();
876 device_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
879 if ((get_pm_old_state() == S_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
881 diff = difftime(now, last_update_time);
882 _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
883 states[get_pm_cur_state()].name, last_timeout, diff);
886 switch (get_pm_cur_state()) {
889 * normal state : backlight on and restore
890 * the previous brightness
892 if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
894 else if (get_pm_old_state() == S_LCDDIM)
895 display_backlight_update_by_default_brightness();
897 if (check_lcd_is_on() == false)
898 lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
902 display_backlight_get_custom_status(&custom_status);
903 if ((get_pm_old_state() == S_NORMAL) && custom_status) {
904 display_backlight_get_brightness(&brightness);
905 display_backlight_set_custom_brightness(brightness);
907 /* lcd dim state : dim the brightness */
908 display_backlight_set_brightness_by_dim_brightness();
910 if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
911 lcd_on_procedure(LCD_DIM, NORMAL_MODE);
915 if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
917 /* lcd off state : turn off the backlight */
918 if (display_panel_get_dpms_cached_state() == DPMS_ON)
919 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
922 display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
923 if (display_panel_get_dpms_cached_state() == DPMS_ON
924 || lcd_paneloff_mode)
925 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
929 if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF))
932 if (display_panel_get_dpms_cached_state() == DPMS_ON)
933 lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
935 if (!pm_get_power_lock_support()) {
936 /* sleep state : set system mode to SUSPEND */
937 if (get_wakeup_count(&wakeup_count) < 0)
938 _E("Wakeup count read error.");
940 if (wakeup_count < 0) {
941 _I("Wakup Event. Can not enter suspend mode.");
945 if (set_wakeup_count(wakeup_count) < 0) {
946 _E("Wakeup count write error.");
957 pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
959 power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
963 if (!pm_get_power_lock_support()) {
965 states[get_pm_cur_state()].trans(EVENT_DEVICE);
970 static void default_saving_mode(int onoff)
973 set_pm_status_flag(PWRSV_FLAG);
975 clear_pm_status_flag(PWRSV_FLAG);
977 if (get_pm_cur_state() == S_NORMAL)
978 display_backlight_update_by_default_brightness();
981 int poll_callback(int condition, PMMsg *data)
983 static time_t last_t;
986 if (status != DEVICE_OPS_STATUS_START) {
987 _E("Display logic is not started.");
991 if (condition == INPUT_POLL_EVENT) {
992 if ((get_pm_cur_state() == S_LCDOFF) || (get_pm_cur_state() == S_SLEEP))
993 _I("Input event signal at Display Off");
995 if ((last_t != now) ||
996 (get_pm_cur_state() == S_LCDOFF) ||
997 (get_pm_cur_state() == S_SLEEP)) {
998 states[get_pm_cur_state()].trans(EVENT_INPUT);
1003 if (condition == PM_CONTROL_EVENT) {
1004 proc_condition(data);
1006 if (IS_COND_REQUEST_CHANGE(data->cond))
1007 proc_change_state(data->cond, data->pid);
1013 static int update_setting(int key_idx, int val)
1018 case SETTING_TO_NORMAL:
1019 display_state_transition_update_display_state_timeout_by_priority();
1020 states[get_pm_cur_state()].trans(EVENT_INPUT);
1022 case SETTING_LOW_BATT:
1023 if (display_misc_is_low_battery_state(val)) {
1024 if (!(get_pm_status_flag() & CHRGR_FLAG))
1025 power_saving_func(true);
1026 set_pm_status_flag(LOWBT_FLAG);
1028 if (get_pm_status_flag() & PWRSV_FLAG)
1029 power_saving_func(false);
1030 clear_pm_status_flag(LOWBT_FLAG);
1031 clear_pm_status_flag(BRTCH_FLAG);
1032 ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, false);
1034 _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno());
1037 case SETTING_CHARGING:
1039 if (get_pm_status_flag() & LOWBT_FLAG) {
1040 power_saving_func(false);
1041 clear_pm_status_flag(LOWBT_FLAG);
1043 set_pm_status_flag(CHRGR_FLAG);
1046 ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
1049 bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
1050 _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
1052 if (display_misc_is_low_battery_state(bat_state)) {
1053 power_saving_func(true);
1054 set_pm_status_flag(LOWBT_FLAG);
1056 clear_pm_status_flag(CHRGR_FLAG);
1059 case SETTING_BRT_LEVEL:
1060 if (get_pm_status_flag() & PWRSV_FLAG) {
1061 set_pm_status_flag(BRTCH_FLAG);
1062 ret = vconf_set_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, true);
1064 _E("Failed to set vconf value for brightness changed in lpm: %d", vconf_get_ext_errno());
1065 _I("Brightness changed in low battery,"
1066 "escape dim state.");
1068 display_backlight_set_default_brightness(val);
1070 case SETTING_LOCK_SCREEN:
1071 set_lock_screen_state(val);
1072 if (val == VCONFKEY_IDLE_UNLOCK)
1073 touchled_control_backlight(TOUCHLED_DIRECT_OFF);
1075 /* LCD on if lock screen show before waiting time */
1076 if ((get_pm_cur_state() == S_NORMAL) &&
1077 val == VCONFKEY_IDLE_LOCK &&
1078 display_panel_get_dpms_cached_state() != DPMS_ON &&
1079 is_lcdon_blocked() == LCDON_BLOCK_NONE)
1080 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1082 display_state_transition_update_display_state_timeout_by_priority();
1083 if (get_pm_cur_state() == S_NORMAL)
1084 states[get_pm_cur_state()].trans(EVENT_INPUT);
1086 case SETTING_LOCK_SCREEN_BG:
1087 set_lock_screen_bg_state(val);
1088 display_state_transition_update_display_state_timeout_by_priority();
1089 if (get_pm_cur_state() == S_NORMAL)
1090 states[get_pm_cur_state()].trans(EVENT_INPUT);
1092 case SETTING_POWER_CUSTOM_BRIGHTNESS:
1093 if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON)
1094 display_backlight_set_custom_status(true);
1096 display_backlight_set_custom_status(false);
1105 static void check_seed_status(void)
1112 int lock_screen_timeout = 0;
1114 /* Charging check */
1115 if (fp_get_charging_status && (fp_get_charging_status(&tmp) == 0) && (tmp > 0))
1116 set_pm_status_flag(CHRGR_FLAG);
1118 ret = get_setting_brightness(&tmp);
1119 if (ret != 0 || (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS)) {
1120 _I("Failed to read vconf value for brightness.");
1121 brt = display_conf.pm_default_brightness;
1122 if (tmp < PM_MIN_BRIGHTNESS || tmp > PM_MAX_BRIGHTNESS) {
1123 ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
1125 _E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno());
1129 _I("Set brightness(%d) from setting app.", tmp);
1130 display_backlight_set_default_brightness(tmp);
1131 display_backlight_set_brightness(tmp);
1133 ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
1135 bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
1136 _E("Failed to get vconf value for battery status low: %d", vconf_get_ext_errno());
1138 if (display_misc_is_low_battery_state(bat_state)) {
1139 if (!(get_pm_status_flag() & CHRGR_FLAG)) {
1140 power_saving_func(true);
1141 set_pm_status_flag(LOWBT_FLAG);
1145 /* lock screen check */
1146 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
1149 _E("Failed to get vconf value for idle lock state: %d", vconf_get_ext_errno());
1151 set_lock_screen_state(lock_state);
1152 display_state_transition_get_lock_screen_timeout(&lock_screen_timeout);
1153 if (lock_state == VCONFKEY_IDLE_LOCK) {
1154 states[S_NORMAL].timeout = lock_screen_timeout;
1155 _I("LCD NORMAL timeout(%d ms) is set"
1156 " for lock screen.", lock_screen_timeout);
1162 static void init_lcd_operation(void)
1164 const struct device_ops *ops = NULL;
1166 ops = find_device("display");
1167 if (!check_default(ops))
1168 display_register_dependent_device(ops);
1170 ops = find_device("touchkey");
1171 if (!check_default(ops))
1172 display_register_dependent_device(ops);
1174 ops = find_device("touchscreen");
1175 if (!check_default(ops))
1176 display_register_dependent_device(ops);
1179 static void exit_lcd_operation(void)
1181 display_unregister_dependent_device();
1193 static const char *errMSG[INIT_END] = {
1194 [INIT_SETTING] = "setting init error",
1195 [INIT_INTERFACE] = "lowlevel interface(sysfs or others) init error",
1196 [INIT_POLL] = "input devices poll init error",
1197 [INIT_FIFO] = "FIFO poll init error",
1198 [INIT_DBUS] = "d-bus init error",
1201 int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name)
1203 unsigned int custom_normal_timeout = 0;
1204 unsigned int custom_dim_timeout = 0;
1206 if (on == 0 && dim == 0) {
1207 _I("LCD timeout changed: default setting");
1208 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1209 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1210 } else if (on < 0 || dim < 0) {
1211 _E("Failed to set value(on=%d dim=%d).", on, dim);
1214 _I("LCD timeout changed: on=%ds dim=%ds", on, dim);
1215 display_state_transition_set_custom_timeout(S_NORMAL, SEC_TO_MSEC(on));
1216 display_state_transition_set_custom_timeout(S_LCDDIM, SEC_TO_MSEC(dim));
1218 /* Apply new backlight time */
1219 display_state_transition_update_display_state_timeout_by_priority();
1220 if (get_pm_cur_state() == S_NORMAL)
1221 states[get_pm_cur_state()].trans(EVENT_INPUT);
1223 if (holdkey_block) {
1224 display_lock_set_custom_holdkey_block(true);
1225 _I("Hold key disabled.");
1227 display_lock_set_custom_holdkey_block(false);
1228 _I("Hold key enabled.");
1231 if (custom_change_name) {
1232 free(custom_change_name);
1233 custom_change_name = 0;
1236 display_state_transition_get_custom_timeout(S_NORMAL, &custom_normal_timeout);
1237 display_state_transition_get_custom_timeout(S_LCDDIM, &custom_dim_timeout);
1238 if (custom_normal_timeout == 0 &&
1239 custom_dim_timeout == 0 &&
1243 custom_change_name = strndup(name, strlen(name));
1244 if (!custom_change_name) {
1245 _E("Failed to malloc.");
1246 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1247 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1248 display_lock_set_custom_holdkey_block(false);
1255 void reset_lcd_timeout(GDBusConnection *conn,
1256 const gchar *sender,
1257 const gchar *unique_name,
1263 if (!custom_change_name)
1266 if (strcmp(sender, custom_change_name))
1269 _I("reset lcd timeout: Set default timeout. sender=%s", sender);
1271 free(custom_change_name);
1272 custom_change_name = 0;
1273 display_state_transition_set_custom_timeout(S_NORMAL, 0);
1274 display_state_transition_set_custom_timeout(S_LCDDIM, 0);
1275 display_lock_set_custom_holdkey_block(false);
1277 display_state_transition_update_display_state_timeout_by_priority();
1278 if (get_pm_cur_state() == S_NORMAL)
1279 states[get_pm_cur_state()].trans(EVENT_INPUT);
1282 static int delayed_init_done(void *data)
1284 static bool done = false;
1293 _I("Booting done, release booting lock.");
1294 if (disp_plgn->pm_unlock_internal) {
1295 disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN);
1296 disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
1302 static gboolean delayed_dpms_init_done(gpointer data)
1306 if (!display_panel_init_dpms())
1307 return G_SOURCE_CONTINUE;
1309 switch (get_pm_cur_state()) {
1312 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1313 if (display_conf.timeout_enable) {
1314 timeout = states[S_NORMAL].timeout;
1315 /* check minimun lcd on time */
1316 if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
1317 timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
1318 display_state_transition_reset_state_transition_timeout(timeout);
1322 lcd_off_procedure(LCD_OFF_BY_EVENT);
1323 timeout = display_conf.lcdoff_timeout;
1324 display_state_transition_reset_state_transition_timeout(timeout);
1330 return G_SOURCE_REMOVE;
1333 static void add_timer_for_dpms_init(void)
1335 guint id = g_timeout_add(500/* milliseconds */, delayed_dpms_init_done, NULL);
1337 _E("Failed to add display_panel_init_dpms timeout.");
1340 static void init_display_states(void *data)
1342 struct display_plugin *dp = (struct display_plugin *) data;
1343 for(int i = 0; i < S_END; i++)
1344 dp->display_states[i] = &states[i];
1347 * Power manager Main
1350 static int display_probe(void *data)
1353 struct display_plugin *dp = (struct display_plugin *) data;
1356 dp->config = &display_conf;
1357 init_display_states(dp);
1358 setup_display_plugin_backlight_ops(dp);
1359 dp->set_dim_state = NULL;
1360 dp->get_device_flags = NULL;
1361 setup_display_plugin_backlight_ops(dp);
1364 * load display service
1365 * if there is no display shared library,
1366 * deviced does not provide any method and function of display.
1368 ret = display_service_load();
1372 /* display_plugin instance initialization */
1373 init_pm_internal(data);
1374 disp_plgn->device_flags_to_string = __device_flags_to_string;
1376 if (battery_plgn->handle) {
1377 fp_get_charging_status = dlsym(battery_plgn->handle, "get_charging_status");
1378 if (!fp_get_charging_status)
1379 _E("Failed to obtain address of get_charging_status");
1381 _I("There is no battery module.");
1386 static int input_init_handler(void)
1388 if (!display_conf.input_support)
1389 remove_device_by_devname("input");
1394 static int power_resume_from_echomem_callback(void *data)
1396 system_wakeup_flag = true;
1397 if (check_wakeup_src() == EVENT_DEVICE)
1398 /* system waked up by devices */
1399 states[get_pm_cur_state()].trans(EVENT_DEVICE);
1401 /* system waked up by user input */
1402 states[get_pm_cur_state()].trans(EVENT_INPUT);
1407 static int poweroff_triggered_callback(void *udata)
1409 int val = (int)(intptr_t) udata;
1412 case VCONFKEY_SYSMAN_POWER_OFF_NONE:
1413 clear_pm_status_flag(PWROFF_FLAG);
1415 case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
1416 case VCONFKEY_SYSMAN_POWER_OFF_RESTART:
1417 set_pm_status_flag(PWROFF_FLAG);
1424 static void esd_action(void)
1426 const struct device_ops *touchscreen_ops = NULL;
1430 touchscreen_ops = find_device("touchscreen");
1432 if (!check_default(touchscreen_ops))
1433 touchscreen_ops->stop(NORMAL_MODE);
1434 display_panel_set_panel_state_by_off_state(NORMAL_MODE);
1435 display_panel_set_panel_state_by_on_state(NORMAL_MODE);
1436 if (!check_default(touchscreen_ops))
1437 touchscreen_ops->start(NORMAL_MODE);
1440 static void lcd_uevent_changed(struct udev_device *dev)
1442 const char *devpath;
1445 devpath = udev_device_get_devpath(dev);
1449 if (!fnmatch(LCD_ESD_PATH, devpath, 0)) {
1450 action = udev_device_get_action(dev);
1451 if (!strcmp(action, UDEV_CHANGE))
1456 static const struct uevent_handler lcd_uevent_ops = {
1457 .subsystem = LCD_EVENT_SUBSYSTEM,
1458 .uevent_func = lcd_uevent_changed,
1462 static void display_init(void *data)
1465 unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
1468 _I("Start power manager.");
1470 signal(SIGHUP, sig_hup);
1472 power_saving_func = default_saving_mode;
1474 /* load configutation */
1475 ret = display_load_config(&display_conf);
1477 _W("Failed to load '%s', use default value: %d",
1478 DISPLAY_CONF_FILE, ret);
1480 register_kernel_uevent_control(&lcd_uevent_ops);
1482 register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
1483 register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
1484 register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
1485 register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
1486 register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
1487 register_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
1489 init_save_userlock();
1491 for (i = INIT_SETTING; i < INIT_END; i++) {
1494 ret = init_setting(update_setting);
1496 case INIT_INTERFACE:
1497 if (display_conf.timeout_enable)
1498 display_initialize_display_state_timeout_from_setting();
1499 ret = init_sysfs(flags);
1503 ret = input_init_handler();
1505 pm_lock_detector_init();
1509 ret = init_pm_dbus();
1513 _E("Failed to init: %s", errMSG[i]);
1518 if (i == INIT_END) {
1519 display_ops_init(NULL);
1520 #ifdef ENABLE_PM_LOG
1523 init_lcd_operation();
1524 check_seed_status();
1526 /* In smd test, TSP should be turned off if display panel is not existed. */
1527 if (display_panel_get_dpms_cached_state() == -ENOENT) {
1528 _I("Display panel is not existed.");
1529 lcd_direct_control(DPMS_OFF, NORMAL_MODE);
1530 exit_lcd_operation();
1533 /* wm_ready needs to be checked
1534 * since display manager can be launched later than deviced.
1535 * In the case, display cannot be turned on at the first booting */
1536 // wm_ready = check_wm_ready();
1537 if (display_panel_init_dpms()) {
1538 if (is_lcdon_blocked() != LCDON_BLOCK_NONE)
1539 lcd_off_procedure(LCD_OFF_BY_EVENT);
1541 lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
1543 add_timer_for_dpms_init();
1546 if (display_conf.lcd_always_on) {
1547 _I("LCD always on.");
1548 display_state_transition_set_transition_table_display_state(S_NORMAL, S_NORMAL, EVENT_TIMEOUT);
1551 if (flags & WITHOUT_STARTNOTI) { /* start without noti */
1552 _I("Start Power managing without noti");
1553 power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
1554 HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL);
1556 * Lock lcd off until booting is done.
1557 * deviced guarantees all booting script is executing.
1558 * Last script of booting unlocks this suspend blocking state.
1560 if (disp_plgn->pm_lock_internal)
1561 disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
1562 STAY_CUR_STATE, DELAYED_INIT_WATING_TIME);
1564 /* Initial display state right after the booting done */
1565 if (is_lcdon_blocked())
1566 set_pm_cur_state(S_LCDOFF);
1568 set_pm_cur_state(S_NORMAL);
1569 ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state());
1571 _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
1573 status = DEVICE_OPS_STATUS_START;
1574 if (display_conf.timeout_enable) {
1575 timeout = states[S_NORMAL].timeout;
1576 /* check minimun lcd on time */
1577 if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT))
1578 timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT);
1580 if (disp_plgn->pm_lock_internal)
1581 disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL,
1582 STAY_CUR_STATE, timeout);
1587 set_display_init_direction(display_conf.display_init_direction);
1591 static void display_exit(void *data)
1595 status = DEVICE_OPS_STATUS_STOP;
1597 /* Set current state to S_NORMAL */
1598 set_pm_cur_state(S_NORMAL);
1599 set_setting_pmstate(get_pm_cur_state());
1600 /* timeout is not needed */
1601 display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
1603 unregister_kernel_uevent_control(&lcd_uevent_ops);
1605 display_ops_exit(NULL);
1607 for (i = i - 1; i >= INIT_SETTING; i--) {
1612 case INIT_INTERFACE:
1616 unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
1617 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
1618 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
1619 unregister_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
1620 unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
1626 exit_lcd_operation();
1627 free_lock_info_list();
1629 /* free display service */
1630 display_service_free();
1632 _I("Stop power manager.");
1635 static int display_start(enum device_flags flags)
1637 const struct display_ops *enhance_ops = NULL;
1641 if (flags & NORMAL_MODE) {
1642 if (flags & LCD_PANEL_OFF_MODE)
1644 display_panel_set_panel_state_by_standby_state(true);
1647 display_panel_set_panel_state_by_on_state(flags);
1648 FIND_DISPLAY(enhance_ops, "enhance");
1649 if (enhance_ops && enhance_ops->func)
1650 enhance_ops->func(RESTORE_ENHANCE_OUTDOOR, &on);
1654 /* CORE LOGIC MODE */
1655 if (!(flags & CORE_LOGIC_MODE))
1658 if (status == DEVICE_OPS_STATUS_START)
1661 if (display_probe(NULL) < 0)
1669 static int display_stop(enum device_flags flags)
1672 if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
1673 display_panel_set_panel_state_by_off_state(flags);
1677 /* CORE LOGIC MODE */
1678 if (!(flags & CORE_LOGIC_MODE))
1681 if (status == DEVICE_OPS_STATUS_STOP)
1689 static int display_status(void)
1694 static const struct device_ops display_plugin_device_ops = {
1695 .disable_auto_init = true,
1696 DECLARE_NAME_LEN("display-plugin"),
1697 .probe = display_probe,
1698 .init = display_init,
1699 .exit = display_exit,
1700 .start = display_start,
1701 .stop = display_stop,
1702 .status = display_status,
1705 DEVICE_OPS_REGISTER(&display_plugin_device_ops)
1707 static void __CONSTRUCTOR__ initialize(void)
1709 disp_plgn = get_var_display_plugin();
1711 _E("Failed to get display plugin variable.");
1713 backlight_ops = get_var_backlight_ops();
1715 _E("Failed to get backlight operator variable.");
1717 battery_plgn = get_var_battery_plugin();
1719 _E("Failed to get battery plugin variable.");