Above two functions are used for display-lock related functions.
default_proc_change_state_action() sets pm_cur_state and occurs state_action.
default_proc_change_state() occurs next state action when the specific condition is met.
These functions are added to display-plugin.
- bool display_plugin_state_is_there_proc_change_state(void);
- int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid);
These functions are added to display-state-transition.
- void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout);
- int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid);
Newly added functions should also be refactored.
Change-Id: I85476642bb4b4c4fc5c607ce6ce0591736d1a014
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
* @{
*/
-#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
static struct display_backlight_ops *backlight_ops;
static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-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, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
-#define TIMEOUT_NONE (-1)
-
#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
return UNKNOWN_STR;
}
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
- struct state *st;
-
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(next);
-
- st = &states[get_pm_cur_state()];
-
- 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)
-{
- enum state_t next;
-
- next = GET_COND_STATE(cond);
- _I("Change process(%d) state to %s.", pid, states[next].name);
-
- switch (next) {
- case S_NORMAL:
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
- display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
- default_proc_change_state_action(next, -1);
- break;
- case S_LCDDIM:
- default_proc_change_state_action(next, -1);
- break;
- case S_LCDOFF:
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
- if (set_custom_lcdon_timeout(0))
- display_state_transition_update_display_state_timeout_by_priority();
- default_proc_change_state_action(next, -1);
- break;
- case S_SLEEP:
- _I("Dangerous requests.");
- /* at first LCD_OFF and then goto sleep */
- /* state transition */
- default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
- display_lock_release_lock_all(S_NORMAL);
- display_lock_release_lock_all(S_LCDDIM);
- display_lock_release_lock_all(S_LCDOFF);
- if (display_panel_is_lcd_on_state_broadcasted()) {
- _I("broadcast lcd off signal at non-lcd device");
- broadcast_lcd_off(SIGNAL_PRE, 0);
- broadcast_lcd_off(SIGNAL_POST, 0);
- }
- default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static void proc_condition_lock(PMMsg *data)
{
char pname[PATH_MAX];
if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
(pm_get_power_lock() == POWER_UNLOCK))
- proc_change_state(data->cond, INTERNAL_LOCK_PM);
+ display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
ret = display_lock_request_lock(state, pid, data->timeout);
if (ret == -EALREADY)
proc_condition(data);
if (IS_COND_REQUEST_CHANGE(data->cond))
- proc_change_state(data->cond, data->pid);
+ display_state_transition_do_proc_change_state(data->cond, data->pid);
}
return 0;
dp->display_off_by_reason = NULL;
dp->default_saving_mode = NULL;
dp->is_lcdon_blocked = is_lcdon_blocked;
+ dp->proc_change_state = NULL;
setup_display_plugin_backlight_ops(dp);
/* check display feature */
* @{
*/
-#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-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, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
-#define TIMEOUT_NONE (-1)
-
#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
return UNKNOWN_STR;
}
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
- struct state *st;
-
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(next);
-
- st = &states[get_pm_cur_state()];
-
- 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)
{
enum state_t next;
if (display_panel_get_dpms_cached_state() != DPMS_ON)
display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_LCDDIM:
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_LCDOFF:
if (display_panel_get_dpms_cached_state() == DPMS_ON) {
}
if (set_custom_lcdon_timeout(0))
display_state_transition_update_display_state_timeout_by_priority();
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_SLEEP:
_I("Dangerous requests.");
/* at first LCD_OFF and then goto sleep */
/* state transition */
- default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+ display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
display_lock_release_lock_all(S_NORMAL);
display_lock_release_lock_all(S_LCDDIM);
display_lock_release_lock_all(S_LCDOFF);
broadcast_lcd_off(SIGNAL_PRE, 0);
broadcast_lcd_off(SIGNAL_POST, 0);
}
- default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+ display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
break;
default:
if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
(pm_get_power_lock() == POWER_UNLOCK))
- proc_change_state(data->cond, INTERNAL_LOCK_PM);
+ display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
ret = display_lock_request_lock(state, pid, data->timeout);
if (ret == -EALREADY)
proc_condition(data);
if (IS_COND_REQUEST_CHANGE(data->cond))
- proc_change_state(data->cond, data->pid);
+ display_state_transition_do_proc_change_state(data->cond, data->pid);
}
return 0;
dp->display_off_by_reason = NULL;
dp->default_saving_mode = NULL;
dp->is_lcdon_blocked = is_lcdon_blocked;
+ dp->proc_change_state = default_proc_change_state;
setup_display_plugin_backlight_ops(dp);
/**
* @{
*/
-#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
-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, NULL, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
-#define TIMEOUT_NONE (-1)
-
#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
return UNKNOWN_STR;
}
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
- struct state *st;
-
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(next);
-
- st = &states[get_pm_cur_state()];
-
- 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)
-{
- enum state_t next;
-
- next = GET_COND_STATE(cond);
- _I("Change process(%d) state to %s.", pid, states[next].name);
-
- switch (next) {
- case S_NORMAL:
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
- display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
- default_proc_change_state_action(next, -1);
- break;
- case S_LCDDIM:
- default_proc_change_state_action(next, -1);
- break;
- case S_LCDOFF:
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
- if (set_custom_lcdon_timeout(0))
- display_state_transition_update_display_state_timeout_by_priority();
- default_proc_change_state_action(next, -1);
- break;
- case S_SLEEP:
- _I("Dangerous requests.");
- /* at first LCD_OFF and then goto sleep */
- /* state transition */
- default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
- display_lock_release_lock_all(S_NORMAL);
- display_lock_release_lock_all(S_LCDDIM);
- display_lock_release_lock_all(S_LCDOFF);
- if (display_panel_is_lcd_on_state_broadcasted()) {
- _I("broadcast lcd off signal at non-lcd device");
- broadcast_lcd_off(SIGNAL_PRE, 0);
- broadcast_lcd_off(SIGNAL_POST, 0);
- }
- default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static void proc_condition_lock(PMMsg *data)
{
char pname[PATH_MAX];
if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
(pm_get_power_lock() == POWER_UNLOCK))
- proc_change_state(data->cond, INTERNAL_LOCK_PM);
+ display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
ret = display_lock_request_lock(state, pid, data->timeout);
if (ret == -EALREADY)
proc_condition(data);
if (IS_COND_REQUEST_CHANGE(data->cond))
- proc_change_state(data->cond, data->pid);
+ display_state_transition_do_proc_change_state(data->cond, data->pid);
}
return 0;
dp->display_off_by_reason = NULL;
dp->default_saving_mode = NULL;
dp->is_lcdon_blocked = is_lcdon_blocked;
+ dp->proc_change_state = NULL;
setup_display_plugin_backlight_ops(dp);
/**
* @{
*/
-#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
#define LATE_LCD_TRANSIT 1
extern void init_save_userlock(void);
static int default_trans(int evt);
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", default_trans, default_action, NULL, NULL },
{ S_POWEROFF, "S_POWEROFF", NULL, NULL, NULL, NULL },
};
-#define TIMEOUT_NONE (-1)
-
#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
#define LOCK_SCREEN_WATING_TIME 300 /* 0.3 second */
return 0;
}
-static void default_proc_change_state_action(enum state_t next, int timeout)
-{
- struct state *st;
-
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(next);
-
- st = &states[get_pm_cur_state()];
-
- if (st && st->action) {
- if (timeout < 0)
- st->action(st->timeout);
- else
- st->action(timeout);
- }
-}
-
static int default_proc_change_state(unsigned int cond, pid_t pid)
{
enum state_t next;
if (check_lcd_is_on() == false)
display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_LCDDIM:
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_LCDOFF:
if (display_panel_get_dpms_cached_state() == DPMS_ON)
lcd_off_procedure(LCD_OFF_BY_EVENT);
if (set_custom_lcdon_timeout(0))
display_state_transition_update_display_state_timeout_by_priority();
- default_proc_change_state_action(next, -1);
+ display_state_transition_do_proc_change_state_action(next, -1);
break;
case S_SLEEP:
_I("Dangerous requests.");
/* at first LCD_OFF and then goto sleep */
/* state transition */
- default_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+ display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
display_lock_release_lock_all(S_NORMAL);
display_lock_release_lock_all(S_LCDDIM);
display_lock_release_lock_all(S_LCDOFF);
broadcast_lcd_off(SIGNAL_PRE, 0);
broadcast_lcd_off(SIGNAL_POST, 0);
}
- default_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+ display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
break;
default:
if ((state == S_LCDOFF) && (get_pm_cur_state() == S_SLEEP) &&
(pm_get_power_lock() == POWER_UNLOCK))
- proc_change_state(data->cond, INTERNAL_LOCK_PM);
+ display_state_transition_do_proc_change_state(data->cond, INTERNAL_LOCK_PM);
ret = display_lock_request_lock(state, pid, data->timeout);
if (ret == -EALREADY)
proc_condition(data);
if (IS_COND_REQUEST_CHANGE(data->cond))
- proc_change_state(data->cond, data->pid);
+ display_state_transition_do_proc_change_state(data->cond, data->pid);
}
return 0;
dp->display_off_by_reason = display_off_by_reason;
dp->default_saving_mode = default_saving_mode;
dp->is_lcdon_blocked = is_lcdon_blocked;
+ dp->proc_change_state = default_proc_change_state;
setup_display_plugin_backlight_ops(dp);
/**
#define CLOCK_START "clockstart"
#define CLOCK_END "clockend"
#define CLOCK_CHANGED "clockchanged"
-#define TIMEOUT_NONE (-1)
#define AMBIENT_CLOCK_WAITING_TIME 5000 /* ms */
static struct display_plugin *disp_plgn;
#define MASK_OFF 0x4 /* 100 */
#define DEFAULT_NORMAL_TIMEOUT 30
+#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
+#define TIMEOUT_NONE (-1)
#define DIM_MASK 0x000f0000
#define MASK32 0xffffffff
return -EOPNOTSUPP;
}
+bool display_plugin_state_is_there_proc_change_state(void)
+{
+ return (g_display_plugin.proc_change_state != NULL);
+}
+
+int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid)
+{
+ if (!g_display_plugin.proc_change_state)
+ return -EOPNOTSUPP;
+
+ return g_display_plugin.proc_change_state(cond, pid);
+}
+
int display_plugin_config_get_timeout_enable(bool *timeout_enable)
{
if (!timeout_enable)
int (*display_off_by_reason) (const char *reason);
void (*default_saving_mode) (int onoff);
int (*is_lcdon_blocked) (void);
+ int (*proc_change_state) (unsigned int cond, pid_t pid);
struct display_config *config;
struct display_backlight_ops *backlight;
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);
int display_plugin_state_get_state_by_state_index(int state_index, enum state_t *state);
+/* FIXME: This function used in the display lock related functions */
+bool display_plugin_state_is_there_proc_change_state(void);
+int display_plugin_state_proc_change_state(unsigned int cond, pid_t pid);
/* FIXME: display config getter/setter is also temporary in this file */
int display_plugin_config_get_timeout_enable(bool *timeout_enable);
#include "display-state-transition.h"
#include "display-lock.h"
#include "display-plugin.h"
+#include "display-signal.h"
#include "extcon/extcon.h"
#include "power/power.h"
#include "power/power-suspend.h"
}
return 0;
}
+
+/* FIXME: this function is temporary, it will be refactored */
+void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout)
+{
+ int state_timeout = 0;
+
+ set_pm_old_state(get_pm_cur_state());
+ set_pm_cur_state(next);
+
+ display_plugin_state_get_timeout(get_pm_cur_state(), &state_timeout);
+
+ if (timeout < 0)
+ display_state_transition_do_state_action(state_timeout);
+ else
+ display_state_transition_do_state_action(timeout);
+
+}
+
+/* FIXME: this function is temporary, it will be refactored */
+int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid)
+{
+ enum state_t next;
+ const char *state_name = NULL;
+
+ if (display_plugin_state_is_there_proc_change_state())
+ return display_plugin_state_proc_change_state(cond, pid);
+
+ next = GET_COND_STATE(cond);
+ display_plugin_state_get_name(next, &state_name);
+ _I("Change process(%d) state to %s.", pid, state_name);
+
+ switch (next) {
+ case S_NORMAL:
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
+ display_panel_lcd_on_direct(LCD_ON_BY_EVENT);
+ display_state_transition_update_lock_screen_timeout(LOCK_SCREEN_CONTROL_TIMEOUT);
+ display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+ break;
+ case S_LCDDIM:
+ display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+ break;
+ case S_LCDOFF:
+ if (display_panel_get_dpms_cached_state() == DPMS_ON)
+ display_panel_lcd_off_procedure(LCD_OFF_BY_EVENT);
+ if (set_custom_lcdon_timeout(0))
+ display_state_transition_update_display_state_timeout_by_priority();
+ display_state_transition_do_proc_change_state_action(next, TIMEOUT_NONE);
+ break;
+ case S_SLEEP:
+ _I("Dangerous requests.");
+ /* at first LCD_OFF and then goto sleep */
+ /* state transition */
+ display_state_transition_do_proc_change_state_action(S_LCDOFF, TIMEOUT_NONE);
+ display_lock_release_lock_all(S_NORMAL);
+ display_lock_release_lock_all(S_LCDDIM);
+ display_lock_release_lock_all(S_LCDOFF);
+ if (display_panel_is_lcd_on_state_broadcasted()) {
+ _I("broadcast lcd off signal at non-lcd device");
+ broadcast_lcd_off(SIGNAL_PRE, 0);
+ broadcast_lcd_off(SIGNAL_POST, 0);
+ }
+ display_state_transition_do_proc_change_state_action(S_SLEEP, TIMEOUT_NONE);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
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);
+void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout);
+int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid);
#endif /* __DISPLAY_STATE_TRANSITION_H__ */
\ No newline at end of file