#include <sys/time.h>
#include <libsyscommon/list.h>
#include <device/display-internal.h>
+#include <hal/device/hal-device-power.h>
#include "ambient-mode.h"
#include "util.h"
#include "core.h"
+#include "poll.h"
#include "lock-detector.h"
#include "display-ops.h"
#include "shared/devices.h"
#include "shared/device-notifier.h"
#include "core/udev.h"
#include "shared/common.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-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-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"
-
/**
* @addtogroup POWER_MANAGER
* @{
#define LOCK_SCREEN_INPUT_TIMEOUT 10000
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
#define ALWAYS_ON_TIMEOUT 360000000
-#define LATE_LCD_TRANSIT 1
#define GESTURE_STR "gesture"
#define POWER_KEY_STR "powerkey"
#define PALM_STR "palm"
#define UNKNOWN_STR "unknown"
-#define PM_WAKEUP 0
-#define PM_SUSPEND 1
-
-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.
{ 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 */
.timeout_enable = true,
.input_support = true,
.lockcheck_timeout = 600,
+ .display_init_direction = DISPLAY_INIT_DIRECTION_HORIZONTAL,
.aod_enter_level = 40,
.aod_tsp = true,
.touch_wakeup = false,
.display_on_usb_conn_changed = true,
+ .display_dpms_type = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
};
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;
}
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)
- return 0;
-
- g_source_remove(transit_timer);
- transit_timer = 0;
-
- return 0;
-}
-
static const char* __device_flags_to_string(enum device_flags flags)
{
if (flags & LCD_ON_BY_GESTURE)
static unsigned long get_lcd_on_flags(void)
{
unsigned long flags = NORMAL_MODE;
+ bool lcd_paneloff_mode = false;
+ display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
if (lcd_paneloff_mode)
flags |= LCD_PANEL_OFF_MODE;
- if (ambient_get_condition() == true) {
- flags |= AMBIENT_MODE;
- flags |= LCD_PHASED_TRANSIT_MODE;
- }
-
return flags;
}
return touch_blocked;
}
-static gboolean late_transit_on(void *data)
-{
- if (!transit_timer)
- return G_SOURCE_REMOVE;
-
- g_source_remove(transit_timer);
- transit_timer = 0;
-
- backlight_ops->transit_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();
flags |= flag;
_I("[lcdstep] 0x%lx", flags);
- if (flags & AMBIENT_MODE) {
- if (ambient_get_state() == false && backlight_ops->get_lcd_power() == DPMS_ON)
- return;
- ambient_set_state(false);
- }
-
/* send LCDOn dbus signal */
if (!lcdon_broadcast)
broadcast_lcd_on(SIGNAL_PRE, flags);
- if (!(flags & LCD_PHASED_TRANSIT_MODE)) {
- /* Update brightness level */
- if (state == LCD_DIM)
- backlight_ops->dim();
- else if (state == LCD_NORMAL)
- backlight_ops->update();
- }
+ /* Update brightness level */
+ if (state == LCD_DIM)
+ display_backlight_set_brightness_by_dim_brightness();
+ else if (state == LCD_NORMAL)
+ display_backlight_update_by_default_brightness();
if (state == LCD_NORMAL)
set_setting_pmstate(S_NORMAL);
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);
- if (flags & LCD_PHASED_TRANSIT_MODE)
- transit_timer = g_timeout_add_seconds(LATE_LCD_TRANSIT,
- late_transit_on, NULL);
lcdon_broadcast = true;
}
static unsigned long get_lcd_off_flags(void)
{
unsigned long flags = NORMAL_MODE;
+ bool stay_touchscreen_off = false;
- if (ambient_get_condition() == true) {
- flags |= AMBIENT_MODE;
- flags |= LCD_PHASED_TRANSIT_MODE;
- }
-
+ display_misc_get_stay_touchscreen_off(&stay_touchscreen_off);
if (stay_touchscreen_off)
flags |= TOUCH_SCREEN_OFF_MODE;
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();
flags |= flag;
if (CHECK_OPS(keyfilter_ops, backlight_enable))
keyfilter_ops->backlight_enable(false);
- if (transit_timer) {
- g_source_remove(transit_timer);
- transit_timer = 0;
- }
-
- if (flags & LCD_PHASED_TRANSIT_MODE)
- backlight_ops->transit_state(DPMS_OFF);
+ display_stop_dependent_device(flags);
- SYS_G_LIST_FOREACH(lcdon_ops, l, ops)
- ops->stop(flags);
-
- if (flags & AMBIENT_MODE) {
- broadcast_lcd_off_late(flags);
- } else {
- broadcast_lcd_off(SIGNAL_POST, flags);
- device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
- }
+ broadcast_lcd_off(SIGNAL_POST, flags);
+ device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
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;
* 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)
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 || timeout_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)
{
{
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;
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. */
void lcd_on_direct(enum device_flags flags)
{
- if (pm_get_power_lock_support()
- && (get_pm_cur_state() == S_SLEEP)) {
- broadcast_pm_wakeup();
- power_acquire_wakelock();
- set_pm_cur_state(S_NORMAL);
- }
+ enum hal_device_power_transition_reason reason;
+
+ 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;
+
+ 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);
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;
}
_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)
}
_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 */
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();
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))
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);
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;
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);
+ display_misc_get_process_name((pid_t)t->pid, pname);
ctime_r(&t->time, time_buf);
time_buf[strlen(time_buf) - 1] = 0;
snprintf(buf, sizeof(buf),
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);
static int default_trans(int evt)
{
struct state *st = &states[get_pm_cur_state()];
- int next_state;
+ 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)) {
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.");
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);
}
if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
- if (pm_get_power_lock_support()) {
- broadcast_pm_wakeup();
- power_acquire_wakelock();
- }
+ 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);
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);
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;
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()) {
#ifdef ENABLE_PM_LOG
pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
#endif
- broadcast_pm_suspend();
- if (pm_get_power_lock_support()) {
- power_enable_autosleep();
-
- if (power_release_wakelock() < 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:
clear_pm_status_flag(PWRSV_FLAG);
if (get_pm_cur_state() == S_NORMAL)
- backlight_ops->update();
+ display_backlight_update_by_default_brightness();
}
int poll_callback(int condition, PMMsg *data)
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);
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);
}
_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);
/* 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();
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:
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);
ops = find_device("display");
if (!check_default(ops))
- SYS_G_LIST_APPEND(lcdon_ops, ops);
+ display_register_dependent_device(ops);
ops = find_device("touchkey");
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);
}
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 {
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.");
}
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;
}
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)
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);
- } 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 gboolean delayed_init_done_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()) {
/* 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;
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_done_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
*
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;
/* check display feature */
if (!is_feature_display_supported())
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) {
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;
+}
+
static void esd_action(void)
{
const struct device_ops *touchscreen_ops = NULL;
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);
}
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);
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();
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();
* 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();
- power_acquire_wakelock();
- }
+ 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.
if (display_conf.input_support)
if (CHECK_OPS(keyfilter_ops, init))
keyfilter_ops->init();
+
+ set_display_init_direction(display_conf.display_init_direction);
}
}
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();
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);
break;
}
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);
return 0;
}
{
/* 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;
}
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,
.status = display_status,
};
-DEVICE_OPS_REGISTER(&display_device_ops)
+DEVICE_OPS_REGISTER(&display_plugin_device_ops)
static void __CONSTRUCTOR__ initialize(void)
{