For relocating default_action(), there are some changes.
1. Add device_ops_status getter/setter temporarily.
2. Add lcd on time update and calculation functions.
3. Remove state action functions from the display-plugin.
-> Since default_action() has relocated, these functions no longer need to exist.
New functions in the display
- void display_set_display_ops_status(enum device_ops_status dev_ops_status);
- int display_get_display_ops_status(enum device_ops_status *dev_ops_status);
-> device_ops_status is set during the display init, probe, exit...
New functions in the display-panel
- void display_panel_update_lcd_on_timeval(void);
- int display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(int *diff_time);
-> These functions update lcd_on time and caculate the time difference
between lcd_on_direct and do_state_action.
New function in the display-state-transition
- int display_state_transition_do_state_action(int timeout);
-> This function is usually called after the display state changed.
It handles the rest of the work for changed display state.
Change-Id: If6ccd5f5cbcae21ed87db473596bdc3c71ddb86f
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
static int system_wakeup_flag = false;
static char *custom_change_name;
-static struct timeval lcdon_tv;
-
-/* default transition, action fuctions */
-static int default_action(int timeout);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL },
- { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL },
- { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL },
+ { S_NORMAL, "S_NORMAL", NULL, NULL, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", NULL, NULL, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", NULL, NULL, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL },
+ { S_SLEEP, "S_SLEEP", NULL, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
#define CONTINUOUS_SAMPLING 1
#define LCDOFF_TIMEOUT 300 /* milli second */
-#define DIFF_TIMEVAL_MS(a, b) \
- (((a.tv_sec * 1000000 + a.tv_usec) - \
- (b.tv_sec * 1000000 + b.tv_usec)) \
- / 1000)
-
static struct display_config display_conf = {
.lock_wait_time = LOCK_SCREEN_WATING_TIME,
.longpress_interval = LONG_PRESS_INTERVAL,
set_pm_cur_state(S_NORMAL);
_D("lcd is on directly");
- gettimeofday(&lcdon_tv, NULL);
+ display_panel_update_lcd_on_timeval();
display_panel_lcd_on_procedure(LCD_NORMAL, flags);
update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
}
-static inline bool check_lcd_is_on(void)
-{
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- return false;
-
- return true;
-}
-
static gboolean timer_refresh_cb(gpointer data)
{
struct state *st;
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
if (timeout <= 0)
return -EINVAL;
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_GESTURE);
_I("Custom lcd on timeout(%d ms).", timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
g_idle_add(timer_refresh_cb, NULL);
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
return -EINVAL;
}
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(flag);
_I("platform lcd on by %s (%d ms)", reason, timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
st = &states[get_pm_cur_state()];
- if (st && st->action) {
- if (timeout < 0)
- st->action(st->timeout);
- else
- st->action(timeout);
- }
+ if (timeout < 0)
+ display_state_transition_do_state_action(st->timeout);
+ else
+ display_state_transition_do_state_action(timeout);
+
}
static int default_proc_change_state(unsigned int cond, pid_t pid)
switch (next) {
case S_NORMAL:
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_EVENT);
update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
default_proc_change_state_action(next, -1);
pm_save_logdump();
}
-/* default enter action function */
-static int default_action(int timeout)
-{
- int wakeup_count = -1, pm_cur_state;
- time_t now;
- double diff;
- 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.");
- return -EINVAL;
- }
-
- if (get_pm_cur_state() != S_SLEEP) {
- if ((get_pm_cur_state() == S_NORMAL) &&
- lcdon_tv.tv_sec != 0) {
- gettimeofday(&now_tv, NULL);
- timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
- lcdon_tv.tv_sec = 0;
- }
- /* set timer with current state timeout */
- display_state_transition_reset_state_transition_timeout(timeout);
-
- if (get_pm_cur_state() == S_NORMAL) {
- time(&last_update_time);
- last_timeout = timeout;
- } else {
- _I("Timout set: %s state %d ms",
- states[get_pm_cur_state()].name, timeout);
- }
- }
-
- if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
- 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_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
- time(&now);
- diff = difftime(now, last_update_time);
- _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
- states[get_pm_cur_state()].name, last_timeout, diff);
- }
-
- switch (get_pm_cur_state()) {
- case S_NORMAL:
- /*
- * normal state : backlight on and restore
- * the previous brightness
- */
- if (get_pm_old_state() == S_LCDDIM)
- display_backlight_update_by_default_brightness();
-
- if (check_lcd_is_on() == false)
- display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
- break;
-
- case S_LCDDIM:
- 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 */
- display_backlight_set_brightness_by_dim_brightness();
-
- if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
- display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE);
- break;
-
- case S_LCDOFF:
- if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
- /* lcd off state : turn off the backlight */
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- }
-
- display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
- if (display_panel_get_dpms_cached_state() == DPMS_ON
- || lcd_paneloff_mode)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- break;
-
- case S_SLEEP:
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-
- if (!pm_get_power_lock_support()) {
- /* sleep state : set system mode to SUSPEND */
- if (get_wakeup_count(&wakeup_count) < 0)
- _E("Wakeup count read error.");
-
- if (wakeup_count < 0) {
- _I("Wakup Event. Can not enter suspend mode.");
- goto go_lcd_off;
- }
-
- if (set_wakeup_count(wakeup_count) < 0) {
- _E("Wakeup count write error.");
- goto go_lcd_off;
- }
- }
- goto go_suspend;
- }
-
- return 0;
-
-go_suspend:
-#ifdef ENABLE_PM_LOG
- pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
-#endif
- power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
- return 0;
-
-go_lcd_off:
- if (!pm_get_power_lock_support()) {
- /* Resume !! */
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE);
- }
- return 0;
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
static time_t last_t;
time_t now;
+ display_get_display_ops_status(&status);
if (status != DEVICE_OPS_STATUS_START) {
_E("Display logic is not started.");
return -ECANCELED;
if (ret < 0)
_E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
- status = DEVICE_OPS_STATUS_START;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_START);
if (display_conf.timeout_enable) {
timeout = states[S_NORMAL].timeout;
/* check minimun lcd on time */
{
int i = INIT_END;
- status = DEVICE_OPS_STATUS_STOP;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_STOP);
/* Set current state to S_NORMAL */
set_pm_cur_state(S_NORMAL);
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_START)
return -EALREADY;
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_STOP)
return -EALREADY;
static int system_wakeup_flag = false;
static char *custom_change_name;
-static struct timeval lcdon_tv;
-
-/* default transition, action fuctions */
-static int default_action(int timeout);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL },
- { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL },
- { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL },
+ { S_NORMAL, "S_NORMAL", NULL, NULL, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", NULL, NULL, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", NULL, NULL, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL },
+ { S_SLEEP, "S_SLEEP", NULL, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
#define CONTINUOUS_SAMPLING 1
#define LCDOFF_TIMEOUT 300 /* milli second */
-#define DIFF_TIMEVAL_MS(a, b) \
- (((a.tv_sec * 1000000 + a.tv_usec) - \
- (b.tv_sec * 1000000 + b.tv_usec)) \
- / 1000)
-
static struct display_config display_conf = {
.lock_wait_time = LOCK_SCREEN_WATING_TIME,
.longpress_interval = LONG_PRESS_INTERVAL,
set_pm_cur_state(S_NORMAL);
_D("lcd is on directly");
- gettimeofday(&lcdon_tv, NULL);
+ display_panel_update_lcd_on_timeval();
display_panel_lcd_on_procedure(LCD_NORMAL, flags);
update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
}
-static inline bool check_lcd_is_on(void)
-{
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- return false;
-
- return true;
-}
-
static gboolean timer_refresh_cb(gpointer data)
{
struct state *st;
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
if (timeout <= 0)
return -EINVAL;
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_GESTURE);
_I("Custom lcd on timeout(%d ms).", timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
g_idle_add(timer_refresh_cb, NULL);
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
return -EINVAL;
}
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(flag);
_I("platform lcd on by %s (%d ms)", reason, timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
st = &states[get_pm_cur_state()];
- if (st && st->action) {
- if (timeout < 0)
- st->action(st->timeout);
- else
- st->action(timeout);
- }
+ if (timeout < 0)
+ display_state_transition_do_state_action(st->timeout);
+ else
+ display_state_transition_do_state_action(timeout);
}
static int default_proc_change_state(unsigned int cond, pid_t pid)
switch (next) {
case S_NORMAL:
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_EVENT);
update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
default_proc_change_state_action(next, -1);
pm_save_logdump();
}
-/* default enter action function */
-static int default_action(int timeout)
-{
- int wakeup_count = -1, pm_cur_state;
- time_t now;
- double diff;
- 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.");
- return -EINVAL;
- }
-
- if (get_pm_cur_state() != S_SLEEP) {
- if ((get_pm_cur_state() == S_NORMAL) &&
- lcdon_tv.tv_sec != 0) {
- gettimeofday(&now_tv, NULL);
- timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
- lcdon_tv.tv_sec = 0;
- }
- /* set timer with current state timeout */
- display_state_transition_reset_state_transition_timeout(timeout);
-
- if (get_pm_cur_state() == S_NORMAL) {
- time(&last_update_time);
- last_timeout = timeout;
- } else {
- _I("Timout set: %s state %d ms",
- states[get_pm_cur_state()].name, timeout);
- }
- }
-
- if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
- 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_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
- time(&now);
- diff = difftime(now, last_update_time);
- _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
- states[get_pm_cur_state()].name, last_timeout, diff);
- }
-
- switch (get_pm_cur_state()) {
- case S_NORMAL:
- /*
- * normal state : backlight on and restore
- * the previous brightness
- */
- if (get_pm_old_state() == S_LCDDIM)
- display_backlight_update_by_default_brightness();
-
- if (check_lcd_is_on() == false)
- display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
- break;
-
- case S_LCDDIM:
- 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 */
- display_backlight_set_brightness_by_dim_brightness();
-
- if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
- display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE);
- break;
-
- case S_LCDOFF:
- if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
- /* lcd off state : turn off the backlight */
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- }
-
- display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
- if (display_panel_get_dpms_cached_state() == DPMS_ON
- || lcd_paneloff_mode)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- break;
-
- case S_SLEEP:
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-
- if (!pm_get_power_lock_support()) {
- /* sleep state : set system mode to SUSPEND */
- if (get_wakeup_count(&wakeup_count) < 0)
- _E("Wakeup count read error.");
-
- if (wakeup_count < 0) {
- _I("Wakup Event. Can not enter suspend mode.");
- goto go_lcd_off;
- }
-
- if (set_wakeup_count(wakeup_count) < 0) {
- _E("Wakeup count write error.");
- goto go_lcd_off;
- }
- }
- goto go_suspend;
- }
-
- return 0;
-
-go_suspend:
-#ifdef ENABLE_PM_LOG
- pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
-#endif
- power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
- return 0;
-
-go_lcd_off:
- if (!pm_get_power_lock_support()) {
- /* Resume !! */
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE);
- }
- return 0;
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
static time_t last_t;
time_t now;
+ display_get_display_ops_status(&status);
if (status != DEVICE_OPS_STATUS_START) {
_E("Display logic is not started.");
return -ECANCELED;
if (ret < 0)
_E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
- status = DEVICE_OPS_STATUS_START;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_START);
if (display_conf.timeout_enable) {
timeout = states[S_NORMAL].timeout;
/* check minimun lcd on time */
{
int i = INIT_END;
- status = DEVICE_OPS_STATUS_STOP;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_STOP);
/* Set current state to S_NORMAL */
set_pm_cur_state(S_NORMAL);
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_START)
return -EALREADY;
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_STOP)
return -EALREADY;
static int system_wakeup_flag = false;
static char *custom_change_name;
-static struct timeval lcdon_tv;
-
-/* default transition, action fuctions */
-static int default_action(int timeout);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
static struct state states[S_END] = {
{ S_START, "S_START", NULL, NULL, NULL, NULL },
- { S_NORMAL, "S_NORMAL", NULL, default_action, NULL, NULL },
- { S_LCDDIM, "S_LCDDIM", NULL, default_action, NULL, NULL },
- { S_LCDOFF, "S_LCDOFF", NULL, default_action, NULL, NULL },
+ { S_NORMAL, "S_NORMAL", NULL, NULL, NULL, NULL },
+ { S_LCDDIM, "S_LCDDIM", NULL, NULL, NULL, NULL },
+ { S_LCDOFF, "S_LCDOFF", NULL, NULL, NULL, NULL },
{ S_STANDBY, "S_STANDBY", NULL, NULL, NULL, NULL },
- { S_SLEEP, "S_SLEEP", NULL, default_action, NULL, NULL },
+ { S_SLEEP, "S_SLEEP", NULL, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
#define CONTINUOUS_SAMPLING 1
#define LCDOFF_TIMEOUT 300 /* milli second */
-#define DIFF_TIMEVAL_MS(a, b) \
- (((a.tv_sec * 1000000 + a.tv_usec) - \
- (b.tv_sec * 1000000 + b.tv_usec)) \
- / 1000)
-
static struct display_config display_conf = {
.lock_wait_time = LOCK_SCREEN_WATING_TIME,
.longpress_interval = LONG_PRESS_INTERVAL,
set_pm_cur_state(S_NORMAL);
_D("lcd is on directly");
- gettimeofday(&lcdon_tv, NULL);
+ display_panel_update_lcd_on_timeval();
display_panel_lcd_on_procedure(LCD_NORMAL, flags);
update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
}
-static inline bool check_lcd_is_on(void)
-{
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- return false;
-
- return true;
-}
-
static gboolean timer_refresh_cb(gpointer data)
{
struct state *st;
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
if (timeout <= 0)
return -EINVAL;
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_GESTURE);
_I("Custom lcd on timeout(%d ms).", timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
g_idle_add(timer_refresh_cb, NULL);
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
return -EINVAL;
}
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(flag);
_I("platform lcd on by %s (%d ms)", reason, timeout);
set_pm_cur_state(S_NORMAL);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
set_pm_cur_state(S_LCDOFF);
st = &states[get_pm_cur_state()];
- /* enter action */
- if (st->action)
- st->action(st->timeout);
+ display_state_transition_do_state_action(st->timeout);
return 0;
}
st = &states[get_pm_cur_state()];
- if (st && st->action) {
- if (timeout < 0)
- st->action(st->timeout);
- else
- st->action(timeout);
- }
+ if (timeout < 0)
+ display_state_transition_do_state_action(st->timeout);
+ else
+ display_state_transition_do_state_action(timeout);
}
static int default_proc_change_state(unsigned int cond, pid_t pid)
switch (next) {
case S_NORMAL:
- if (check_lcd_is_on() == false)
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
lcd_on_direct(LCD_ON_BY_EVENT);
update_display_locktime(LOCK_SCREEN_CONTROL_TIMEOUT);
default_proc_change_state_action(next, -1);
pm_save_logdump();
}
-/* default enter action function */
-static int default_action(int timeout)
-{
- int wakeup_count = -1, pm_cur_state;
- time_t now;
- double diff;
- 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.");
- return -EINVAL;
- }
-
- if (get_pm_cur_state() != S_SLEEP) {
- if ((get_pm_cur_state() == S_NORMAL) &&
- lcdon_tv.tv_sec != 0) {
- gettimeofday(&now_tv, NULL);
- timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
- lcdon_tv.tv_sec = 0;
- }
- /* set timer with current state timeout */
- display_state_transition_reset_state_transition_timeout(timeout);
-
- if (get_pm_cur_state() == S_NORMAL) {
- time(&last_update_time);
- last_timeout = timeout;
- } else {
- _I("Timout set: %s state %d ms",
- states[get_pm_cur_state()].name, timeout);
- }
- }
-
- if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
- 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_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
- time(&now);
- diff = difftime(now, last_update_time);
- _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
- states[get_pm_cur_state()].name, last_timeout, diff);
- }
-
- switch (get_pm_cur_state()) {
- case S_NORMAL:
- /*
- * normal state : backlight on and restore
- * the previous brightness
- */
- if (get_pm_old_state() == S_LCDDIM)
- display_backlight_update_by_default_brightness();
-
- if (check_lcd_is_on() == false)
- display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
- break;
-
- case S_LCDDIM:
- 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 */
- display_backlight_set_brightness_by_dim_brightness();
-
- if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
- display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE);
- break;
-
- case S_LCDOFF:
- if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
- /* lcd off state : turn off the backlight */
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- }
-
- display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
- if (display_panel_get_dpms_cached_state() == DPMS_ON
- || lcd_paneloff_mode)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
- break;
-
- case S_SLEEP:
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
-
- if (!pm_get_power_lock_support()) {
- /* sleep state : set system mode to SUSPEND */
- if (get_wakeup_count(&wakeup_count) < 0)
- _E("Wakeup count read error.");
-
- if (wakeup_count < 0) {
- _I("Wakup Event. Can not enter suspend mode.");
- goto go_lcd_off;
- }
-
- if (set_wakeup_count(wakeup_count) < 0) {
- _E("Wakeup count write error.");
- goto go_lcd_off;
- }
- }
- goto go_suspend;
- }
-
- return 0;
-
-go_suspend:
-#ifdef ENABLE_PM_LOG
- pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
-#endif
- power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
- return 0;
-
-go_lcd_off:
- if (!pm_get_power_lock_support()) {
- /* Resume !! */
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE);
- }
- return 0;
-}
-
static void default_saving_mode(int onoff)
{
if (onoff)
static time_t last_t;
time_t now;
+ display_get_display_ops_status(&status);
if (status != DEVICE_OPS_STATUS_START) {
_E("Display logic is not started.");
return -ECANCELED;
if (ret < 0)
_E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
- status = DEVICE_OPS_STATUS_START;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_START);
if (display_conf.timeout_enable) {
timeout = states[S_NORMAL].timeout;
/* check minimun lcd on time */
{
int i = INIT_END;
- status = DEVICE_OPS_STATUS_STOP;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_STOP);
/* Set current state to S_NORMAL */
set_pm_cur_state(S_NORMAL);
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_START)
return -EALREADY;
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_STOP)
return -EALREADY;
static int system_wakeup_flag = false;
static char *custom_change_name;
static guint transit_timer;
-static struct timeval lcdon_tv;
/*
* The two variables(lcdon_broadcast, pmstate_suspend) must be set initial
* state because it should be sent from previous state at booting time.
#define CONTINUOUS_SAMPLING 1
#define LCDOFF_TIMEOUT 300 /* milli second */
-#define DIFF_TIMEVAL_MS(a, b) \
- (((a.tv_sec * 1000000 + a.tv_usec) - \
- (b.tv_sec * 1000000 + b.tv_usec)) \
- / 1000)
-
#define FORCE_RELEASE_LOCK_INTERVAL 5 /* seconds */
static struct display_config display_conf = {
set_pm_cur_state(S_NORMAL);
_D("lcd is on directly");
- gettimeofday(&lcdon_tv, NULL);
+ display_panel_update_lcd_on_timeval();
lcd_on_procedure(LCD_NORMAL, flags);
update_display_locktime(LOCK_SCREEN_INPUT_TIMEOUT);
double diff;
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;
+ int diff_time = 0;
+ display_get_display_ops_status(&status);
if (status != DEVICE_OPS_STATUS_START) {
_E("Display is not started.");
return -EINVAL;
}
if (get_pm_cur_state() != S_SLEEP) {
- if ((get_pm_cur_state() == S_NORMAL) &&
- lcdon_tv.tv_sec != 0) {
- gettimeofday(&now_tv, NULL);
- timeout -= DIFF_TIMEVAL_MS(now_tv, lcdon_tv);
- lcdon_tv.tv_sec = 0;
+ if ((get_pm_cur_state() == S_NORMAL)) {
+ if (display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(&diff_time) == 0) {
+ timeout -= diff_time;
+ }
}
/* set timer with current state timeout */
display_state_transition_reset_state_transition_timeout(timeout);
static time_t last_t;
time_t now;
+ display_get_display_ops_status(&status);
if (status != DEVICE_OPS_STATUS_START) {
_E("Display logic is not started.");
return -ECANCELED;
if (ret < 0)
_E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
- status = DEVICE_OPS_STATUS_START;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_START);
if (display_conf.timeout_enable) {
timeout = states[S_NORMAL].timeout;
/* check minimun lcd on time */
{
int i = INIT_END;
- status = DEVICE_OPS_STATUS_STOP;
+ display_set_display_ops_status(DEVICE_OPS_STATUS_STOP);
/* Set current state to S_NORMAL */
set_pm_cur_state(S_NORMAL);
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_START)
return -EALREADY;
if (!(flags & CORE_LOGIC_MODE))
return 0;
+ display_get_display_ops_status(&status);
if (status == DEVICE_OPS_STATUS_STOP)
return -EALREADY;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <sys/time.h>
#include "shared/log.h"
#include "power/power-suspend.h"
#define LCD_PHASED_MIN_BRIGHTNESS 1
#define LCD_PHASED_CHANGE_STEP 5
+#define DIFF_TIMEVAL_MS(a, b) \
+ (((a.tv_sec * 1000000 + a.tv_usec) - \
+ (b.tv_sec * 1000000 + b.tv_usec)) \
+ / 1000)
+
static int dpms_running_state = DPMS_SETTING_DONE;
static bool lcd_paneloff_mode = false;
static bool lcd_on_broadcasted = true;
+static struct timeval lcd_on_timeval;
/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */
int display_panel_set_dpms_state(int dpms_on, enum device_flags flags)
return lcd_on_broadcasted;
}
+/* FIXME: lcd on time calculation should be discussed, because it is only for lcd_on_direct routine */
+void display_panel_update_lcd_on_timeval(void)
+{
+ gettimeofday(&lcd_on_timeval, NULL);
+}
+
+int display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(int *diff_time)
+{
+ struct timeval now_timeval;
+
+ if (!diff_time)
+ return -EINVAL;
+
+ if (lcd_on_timeval.tv_sec != 0) {
+ gettimeofday(&now_timeval, NULL);
+ *diff_time = DIFF_TIMEVAL_MS(now_timeval, lcd_on_timeval);
+ return 0;
+ }
+
+ return -1;
+}
+
/* FIXME: This function is deprecated, should be fixed after plugin refactoring */
void display_panel_set_dpms_running_state(int val)
{
void display_panel_lcd_on_procedure(int state, enum device_flags flag);
void display_panel_lcd_off_procedure(enum device_flags flag);
bool display_panel_is_lcd_on_state_broadcasted(void);
+void display_panel_update_lcd_on_timeval(void);
+int display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(int *diff_time);
/* Deprecated functions */
int display_panel_set_image_effect(enum display_image_effect effect);
int display_panel_get_image_effect(enum display_image_effect *effect);
return false;
}
-int display_plugin_state_do_default_action(enum state_t state, int timeout)
-{
- if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->action)
- return g_display_plugin.display_states[state]->action(timeout);
-
- return -EOPNOTSUPP;
-}
-
-/* FIXME: default_action/default_trans naming should be changed after state transition functions are relocated */
-bool display_plugin_state_is_there_default_action(enum state_t state)
-{
- if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->action)
- return true;
-
- return false;
-}
-
int display_plugin_state_get_name(enum state_t state, const char **state_name)
{
if (!state_name)
/* FIXME: function names will be redefined */
int display_plugin_state_do_default_trans(enum state_t state, int evt);
bool display_plugin_state_is_there_default_trans(enum state_t state);
-int display_plugin_state_do_default_action(enum state_t state, int timeout);
-bool display_plugin_state_is_there_default_action(enum state_t state);
int display_plugin_state_get_name(enum state_t state, const char **state_name);
int display_plugin_state_set_timeout(enum state_t state, int state_timeout);
int display_plugin_state_get_timeout(enum state_t state, int *state_timeout);
* @brief This file has functions related to display state transition
*/
+#include "shared/log.h"
#include "core/udev.h"
#include "device-interface.h"
#include "display-state-transition.h"
#include "display-lock.h"
#include "display-plugin.h"
#include "extcon/extcon.h"
+#include "power/power.h"
#include "power/power-suspend.h"
-#include "shared/log.h"
#define ALWAYS_ON_TIMEOUT 360000000
set_pm_cur_state(next_state);
/* enter action */
- if (display_plugin_state_is_there_default_action(get_pm_cur_state())) {
+ if (display_state_transition_is_display_state_support_transition(get_pm_cur_state())) {
if (get_pm_cur_state() == S_LCDOFF)
display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
return 0;
display_plugin_state_get_timeout(get_pm_cur_state(), &timeout);
- display_plugin_state_do_default_action(get_pm_cur_state(), timeout);
+ display_state_transition_do_state_action(timeout);
+ }
+ }
+ return 0;
+}
+
+/* FIXME: diff time calculation, set_wakeup_count should be discussed again later */
+int display_state_transition_do_state_action(int timeout)
+{
+ int wakeup_count = -1, pm_cur_state;
+ time_t now;
+ double diff = 0;
+ static time_t last_update_time = 0;
+ static int last_timeout = 0;
+ bool custom_status;
+ int brightness;
+ bool lcd_paneloff_mode = false;
+ const char* state_name;
+ enum device_ops_status display_ops_status;
+ int diff_time = 0;
+
+ if (!display_state_transition_is_display_state_support_transition(get_pm_cur_state()))
+ return -EPERM;
+
+ display_get_display_ops_status(&display_ops_status);
+ if (display_ops_status != DEVICE_OPS_STATUS_START) {
+ _E("Display is not started.");
+ return -EINVAL;
+ }
+
+ if (get_pm_cur_state() != S_SLEEP) {
+ if ((get_pm_cur_state() == S_NORMAL)) {
+ if (display_panel_calculate_diff_time_between_lcd_on_direct_and_state_action(&diff_time) == 0) {
+ timeout -= diff_time;
+ }
+ }
+
+ /* set timer with current state timeout */
+ display_state_transition_reset_state_transition_timeout(timeout);
+
+ if (get_pm_cur_state() == S_NORMAL) {
+ time(&last_update_time);
+ last_timeout = timeout;
+ } else {
+ display_plugin_state_get_name(get_pm_cur_state(), &state_name);
+ _I("Timout set: %s state %d ms", state_name, timeout);
+ }
+ }
+
+ if ((get_pm_cur_state() != get_pm_old_state()) && (get_pm_cur_state() != S_SLEEP)) {
+ 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_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
+ time(&now);
+ diff = difftime(now, last_update_time);
+ display_plugin_state_get_name(get_pm_cur_state(), &state_name);
+ _I("S_NORMAL is changed to %s (timeout=%d ms diff=%.0f s).",
+ state_name, last_timeout, diff);
+ }
+
+ switch (get_pm_cur_state()) {
+ case S_NORMAL:
+ /*
+ * normal state : backlight on and restore
+ * the previous brightness
+ */
+ if (get_pm_old_state() == S_LCDDIM)
+ display_backlight_update_by_default_brightness();
+
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
+ display_panel_lcd_on_procedure(LCD_NORMAL, NORMAL_MODE);
+ break;
+
+ case S_LCDDIM:
+ 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 */
+ display_backlight_set_brightness_by_dim_brightness();
+
+ if ((get_pm_old_state() == S_LCDOFF) || (get_pm_old_state() == S_SLEEP))
+ display_panel_lcd_on_procedure(LCD_DIM, NORMAL_MODE);
+ break;
+
+ case S_LCDOFF:
+ if ((get_pm_old_state() != S_SLEEP) && (get_pm_old_state() != S_LCDOFF)) {
+ /* lcd off state : turn off the backlight */
+ if (display_panel_get_dpms_cached_state() == DPMS_ON)
+ display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
}
+
+ display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
+ if (display_panel_get_dpms_cached_state() == DPMS_ON
+ || lcd_paneloff_mode)
+ display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
+ break;
+
+ case S_SLEEP:
+ if (display_panel_get_dpms_cached_state() == DPMS_ON)
+ display_panel_lcd_off_procedure(LCD_OFF_BY_TIMEOUT);
+
+ if (!pm_get_power_lock_support()) {
+ /* sleep state : set system mode to SUSPEND */
+ if (get_wakeup_count(&wakeup_count) < 0)
+ _E("Wakeup count read error.");
+
+ if (wakeup_count < 0) {
+ _I("Wakup Event. Can not enter suspend mode.");
+ goto go_lcd_off;
+ }
+
+ if (set_wakeup_count(wakeup_count) < 0) {
+ _E("Wakeup count write error.");
+ goto go_lcd_off;
+ }
+ }
+ goto go_suspend;
+ }
+
+ return 0;
+
+go_suspend:
+#ifdef ENABLE_PM_LOG
+ pm_history_save(PM_LOG_SLEEP, get_pm_cur_state());
+#endif
+ power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT);
+ return 0;
+
+go_lcd_off:
+ if (!pm_get_power_lock_support()) {
+ /* Resume !! */
+ display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE);
}
return 0;
}
\ No newline at end of file
bool display_state_transition_is_possible_to_go_lcdoff(void);
int display_state_transition_do_state_transition(enum state_t state, int evt_type);
bool display_state_transition_is_display_state_support_transition(enum state_t state);
+int display_state_transition_do_state_action(int timeout);
#endif /* __DISPLAY_STATE_TRANSITION_H__ */
\ No newline at end of file
static enum display_init_direction_e g_display_init_direction;
static bool g_display_hal_backend_available;
static GList *display_dependent_device_ops;
+static enum device_ops_status display_ops_status = DEVICE_OPS_STATUS_UNINIT;
inline int get_pm_cur_state(void)
{
return 0;
}
+/** FIXME: display_ops_status getter/setter will be removed after plugin-core separation
+ This work should be proceeded in the display core
+*/
+void display_set_display_ops_status(enum device_ops_status dev_ops_status)
+{
+ display_ops_status = dev_ops_status;
+}
+
+int display_get_display_ops_status(enum device_ops_status *dev_ops_status)
+{
+ if (!dev_ops_status)
+ return -EINVAL;
+
+ *dev_ops_status = display_ops_status;
+ return 0;
+}
+
static int display_probe(void *data)
{
display_plugin_device_ops = find_device("display-plugin");
void display_unregister_dependent_device(void);
bool display_dimstay_check(void);
int display_initialize_display_state_timeout_from_setting(void);
+void display_set_display_ops_status(enum device_ops_status dev_ops_status);
+int display_get_display_ops_status(enum device_ops_status *dev_ops_status);
#endif //__DISPLAY_H__