display_on/off_by_reason() is used by dbus_changestatebyreason call.
1. Set display on/off reason to the flag.
2. Check if it is possible to go to lcd_on/off procedure.
If possible, go to the lcd on/off procedure.
3. After that, update current, before display state and do action about S_NORMAL/S_LCDOFF.
For relocating these, the string of device operation declaration has also been moved to shared/devices.h
There is no reason for the same string to exist in all plugins.
New functions are added below display-panel.
- int display_panel_display_turn_on_by_reason(const char *reason, int timeout);
- int display_panel_display_turn_off_by_reason(const char *reason);
-> These replace display_on/off_by_reason()
Change-Id: Ia22ee6295fa138c3742be62c3bbc2c357716caf5
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-#define GESTURE_STR "gesture"
-#define POWER_KEY_STR "powerkey"
-#define TOUCH_STR "touch"
-#define EVENT_STR "event"
-#define TIMEOUT_STR "timeout"
-#define PROXI_STR "proximity"
-#define PALM_STR "palm"
-#define UNKNOWN_STR "unknown"
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
return UNKNOWN_STR;
}
-int display_on_by_reason(const char *reason, int timeout)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len))
- flag = LCD_ON_BY_GESTURE;
- else if (!strncmp(reason, EVENT_STR, str_len))
- flag = LCD_ON_BY_EVENT;
- else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- if (timeout <= 0) {
- _E("Cannot setting timeout %d", timeout);
- return -EINVAL;
- }
-
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- display_panel_lcd_on_direct(flag);
-
- _I("platform lcd on by %s (%d ms)", reason, timeout);
- if (set_custom_lcdon_timeout(timeout) == true)
- display_state_transition_update_display_state_timeout_by_priority();
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_NORMAL);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
-int display_off_by_reason(const char *reason)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len)) {
- if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) {
- _I("skip platform lcd off by gesture");
- return -ECANCELED;
- }
- flag = LCD_OFF_BY_GESTURE;
- } else if (!strncmp(reason, PALM_STR, str_len)) {
- display_lock_release_lock_all(S_NORMAL);
- display_lock_release_lock_all(S_LCDDIM);
-
- flag = LCD_OFF_BY_PALM;
- } else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- _I("platform lcd off by %s", reason);
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(flag);
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_LCDOFF);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
static void default_proc_change_state_action(enum state_t next, int timeout)
{
struct state *st;
dp->lcd_off_procedure = NULL;
dp->custom_lcd_on = NULL;
dp->custom_lcd_off = NULL;
+ dp->display_on_by_reason = NULL;
+ dp->display_off_by_reason = NULL;
setup_display_plugin_backlight_ops(dp);
/* check display feature */
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-#define GESTURE_STR "gesture"
-#define POWER_KEY_STR "powerkey"
-#define TOUCH_STR "touch"
-#define EVENT_STR "event"
-#define TIMEOUT_STR "timeout"
-#define PROXI_STR "proximity"
-#define PALM_STR "palm"
-#define UNKNOWN_STR "unknown"
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
return UNKNOWN_STR;
}
-int display_on_by_reason(const char *reason, int timeout)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len))
- flag = LCD_ON_BY_GESTURE;
- else if (!strncmp(reason, EVENT_STR, str_len))
- flag = LCD_ON_BY_EVENT;
- else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- if (timeout <= 0) {
- _E("Cannot setting timeout %d", timeout);
- return -EINVAL;
- }
-
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- display_panel_lcd_on_direct(flag);
-
- _I("platform lcd on by %s (%d ms)", reason, timeout);
- if (set_custom_lcdon_timeout(timeout) == true)
- display_state_transition_update_display_state_timeout_by_priority();
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_NORMAL);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
-int display_off_by_reason(const char *reason)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len)) {
- if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) {
- _I("skip platform lcd off by gesture");
- return -ECANCELED;
- }
- flag = LCD_OFF_BY_GESTURE;
- } else if (!strncmp(reason, PALM_STR, str_len)) {
- display_lock_release_lock_all(S_NORMAL);
- display_lock_release_lock_all(S_LCDDIM);
-
- flag = LCD_OFF_BY_PALM;
- } else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- _I("platform lcd off by %s", reason);
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(flag);
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_LCDOFF);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
static void default_proc_change_state_action(enum state_t next, int timeout)
{
struct state *st;
dp->lcd_off_procedure = NULL;
dp->custom_lcd_on = NULL;
dp->custom_lcd_off = NULL;
+ dp->display_on_by_reason = NULL;
+ dp->display_off_by_reason = NULL;
setup_display_plugin_backlight_ops(dp);
/**
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
-#define GESTURE_STR "gesture"
-#define POWER_KEY_STR "powerkey"
-#define TOUCH_STR "touch"
-#define EVENT_STR "event"
-#define TIMEOUT_STR "timeout"
-#define PROXI_STR "proximity"
-#define PALM_STR "palm"
-#define UNKNOWN_STR "unknown"
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
return UNKNOWN_STR;
}
-int display_on_by_reason(const char *reason, int timeout)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len))
- flag = LCD_ON_BY_GESTURE;
- else if (!strncmp(reason, EVENT_STR, str_len))
- flag = LCD_ON_BY_EVENT;
- else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- if (timeout <= 0) {
- _E("Cannot setting timeout %d", timeout);
- return -EINVAL;
- }
-
- if (display_panel_get_dpms_cached_state() != DPMS_ON)
- display_panel_lcd_on_direct(flag);
-
- _I("platform lcd on by %s (%d ms)", reason, timeout);
- if (set_custom_lcdon_timeout(timeout) == true)
- display_state_transition_update_display_state_timeout_by_priority();
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_NORMAL);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
-int display_off_by_reason(const char *reason)
-{
- struct state *st;
- int flag;
- int str_len;
-
- str_len = strlen(reason);
-
- if (!strncmp(reason, GESTURE_STR, str_len)) {
- if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) {
- _I("skip platform lcd off by gesture");
- return -ECANCELED;
- }
- flag = LCD_OFF_BY_GESTURE;
- } else if (!strncmp(reason, PALM_STR, str_len)) {
- display_lock_release_lock_all(S_NORMAL);
- display_lock_release_lock_all(S_LCDDIM);
-
- flag = LCD_OFF_BY_PALM;
- } else {
- _E("Reason is unknown(%s)", reason);
- return -EINVAL;
- }
-
- _I("platform lcd off by %s", reason);
- if (display_panel_get_dpms_cached_state() == DPMS_ON)
- display_panel_lcd_off_procedure(flag);
-
- /* state transition */
- set_pm_old_state(get_pm_cur_state());
- set_pm_cur_state(S_LCDOFF);
- st = &states[get_pm_cur_state()];
-
- display_state_transition_do_state_action(st->timeout);
-
- return 0;
-}
-
static void default_proc_change_state_action(enum state_t next, int timeout)
{
struct state *st;
dp->lcd_off_procedure = NULL;
dp->custom_lcd_on = NULL;
dp->custom_lcd_off = NULL;
+ dp->display_on_by_reason = NULL;
+ dp->display_off_by_reason = NULL;
setup_display_plugin_backlight_ops(dp);
/**
#define LOCK_SCREEN_CONTROL_TIMEOUT 5000
#define LATE_LCD_TRANSIT 1
-#define GESTURE_STR "gesture"
-#define POWER_KEY_STR "powerkey"
-#define BACK_KEY_STR "backkey"
-#define TOUCH_STR "touch"
-#define EVENT_STR "event"
-#define BEZEL_STR "bezel"
-#define TIMEOUT_STR "timeout"
-#define PROXI_STR "proximity"
-#define PALM_STR "palm"
-#define DISPLAY_DETACH_STR "display_detach"
-#define UNKNOWN_STR "unknown"
-
extern void init_save_userlock(void);
static struct display_plugin *disp_plgn;
dp->lcd_off_procedure = lcd_off_procedure;
dp->custom_lcd_on = custom_lcdon;
dp->custom_lcd_off = custom_lcdoff;
+ dp->display_on_by_reason = display_on_by_reason;
+ dp->display_off_by_reason = display_off_by_reason;
setup_display_plugin_backlight_ops(dp);
/**
/* core.c */
int delete_condition(enum state_t state);
int custom_lcdoff(enum device_flags flag);
-int display_on_by_reason(const char *reason, int timeout);
-int display_off_by_reason(const char *reason);
int set_lcd_timeout(int on, int dim, const char *name);
void broadcast_lcd_off_late(enum device_flags flags);
return 0;
}
+/** FIXME: handling method should be considered later,
+ * because the handling is too similar for the same lcd on/off procedure, display state transition.
+*/
+int display_panel_display_turn_on_by_reason(const char *reason, int timeout)
+{
+ int flag;
+ int str_len;
+
+ if (dipslay_plugin_display_on_by_reason(reason, timeout) == 0)
+ return 0;
+
+ if (!reason)
+ return -EINVAL;
+
+ str_len = strlen(reason);
+
+ if (!strncmp(reason, GESTURE_STR, str_len)) {
+ flag = LCD_ON_BY_GESTURE;
+ } else if (!strncmp(reason, EVENT_STR, str_len)) {
+ flag = LCD_ON_BY_EVENT;
+ } else {
+ _E("Reason is unknown(%s)", reason);
+ return -EINVAL;
+ }
+
+ if (timeout <= 0) {
+ _E("Cannot setting timeout %d", timeout);
+ return -EINVAL;
+ }
+
+ if (display_panel_get_dpms_cached_state() != DPMS_ON)
+ display_panel_lcd_on_direct(flag);
+
+ _I("platform lcd on by %s (%d ms)", reason, timeout);
+ if (set_custom_lcdon_timeout(timeout) == true)
+ display_state_transition_update_display_state_timeout_by_priority();
+
+ display_state_updated_to_next_and_do_action(S_NORMAL);
+
+ return 0;
+}
+
+int display_panel_display_turn_off_by_reason(const char *reason)
+{
+ int flag;
+ int str_len;
+
+ if (display_plugin_display_off_by_reason(reason) == 0)
+ return 0;
+
+ if (!reason)
+ return -EINVAL;
+
+ str_len = strlen(reason);
+
+ if (!strncmp(reason, GESTURE_STR, str_len)) {
+ if (display_lock_is_state_locked(S_NORMAL) || display_lock_is_state_locked(S_LCDDIM)) {
+ _I("skip platform lcd off by gesture");
+ return -ECANCELED;
+ }
+ flag = LCD_OFF_BY_GESTURE;
+ } else if (!strncmp(reason, PALM_STR, str_len)) {
+ display_lock_release_lock_all(S_NORMAL);
+ display_lock_release_lock_all(S_LCDDIM);
+
+ flag = LCD_OFF_BY_PALM;
+ } else {
+ _E("Reason is unknown(%s)", reason);
+ return -EINVAL;
+ }
+
+ _I("platform lcd off by %s", reason);
+ if (display_panel_get_dpms_cached_state() == DPMS_ON)
+ display_panel_lcd_off_procedure(flag);
+
+ display_state_updated_to_next_and_do_action(S_LCDOFF);
+
+ return 0;
+}
+
bool display_panel_is_lcd_on_state_broadcasted(void)
{
return lcd_on_broadcasted;
void display_panel_lcd_on_direct(enum device_flags flags);
int display_panel_custom_lcd_on(int timeout);
int display_panel_custom_lcd_off(enum device_flags flag);
+int display_panel_display_turn_on_by_reason(const char *reason, int timeout);
+int display_panel_display_turn_off_by_reason(const char *reason);
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);
return -EOPNOTSUPP;
}
+int dipslay_plugin_display_on_by_reason(const char *reason, int timeout)
+{
+ if (g_display_plugin.display_on_by_reason) {
+ g_display_plugin.display_on_by_reason(reason, timeout);
+ return 0;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+int display_plugin_display_off_by_reason(const char *reason)
+{
+ if (g_display_plugin.display_off_by_reason) {
+ g_display_plugin.display_off_by_reason(reason);
+ return 0;
+ }
+
+ return -EOPNOTSUPP;
+}
+
int display_plugin_backlight_get_lcd_power(void)
{
if (g_display_plugin.backlight && g_display_plugin.backlight->get_lcd_power)
void (*lcd_off_procedure) (enum device_flags flag);
int (*custom_lcd_on) (int timeout);
int (*custom_lcd_off) (enum device_flags flag);
+ int (*display_on_by_reason) (const char *reason, int timeout);
+ int (*display_off_by_reason) (const char *reason);
struct display_config *config;
struct display_backlight_ops *backlight;
int display_plugin_lcd_off_procedure(enum device_flags flag);
int display_plugin_custom_lcd_on(int timeout);
int display_plugin_custom_lcd_off(enum device_flags flag);
+int dipslay_plugin_display_on_by_reason(const char *reason, int timeout);
+int display_plugin_display_off_by_reason(const char *reason);
int display_plugin_backlight_get_lcd_power(void);
int display_plugin_backlight_set_brightness(int brightness);
if (next_state == DISPLAY_STATE_NORMAL) {
state = "S_LCDON";
- ret = display_on_by_reason(reason, timeout);
+ ret = display_panel_display_turn_on_by_reason(reason, timeout);
} else if (next_state == DISPLAY_STATE_SCREEN_OFF) {
state = "S_LCDOFF";
- ret = display_off_by_reason(reason);
+ ret = display_panel_display_turn_off_by_reason(reason);
} else if (next_state == DISPLAY_STATE_SCREEN_DIM) {
state = "S_LCDDIM";
ret = -EINVAL;
#define DEVICE_PRIORITY_NORMAL 0
#define DEVICE_PRIORITY_HIGH 1
+#define GESTURE_STR "gesture"
+#define POWER_KEY_STR "powerkey"
+#define BACK_KEY_STR "backkey"
+#define TOUCH_STR "touch"
+#define EVENT_STR "event"
+#define BEZEL_STR "bezel"
+#define TIMEOUT_STR "timeout"
+#define PROXI_STR "proximity"
+#define PALM_STR "palm"
+#define DISPLAY_DETACH_STR "display_detach"
+#define UNKNOWN_STR "unknown"
+
enum device_flags {
NORMAL_MODE = 0x00000001,
AMBIENT_MODE = 0x00000002,