#include "display-misc.h"
#include "display-panel.h"
#include "display-config.h"
+#include "display-state-transition.h"
#include "shared/plugin.h"
/**
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 guint lock_timeout_id;
static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT;
{ 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 */
return &states[state];
}
-guint get_transition_timer(void)
-{
- return timeout_src_id;
-}
-
static const char* __device_flags_to_string(enum device_flags flags)
{
if (flags & LCD_ON_BY_GESTURE)
* 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)
{
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;
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)) {
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);
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)
/* 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;
_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
*
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())
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 */
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();