summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaeyoung Kim <ty317.kim@samsung.com>2016-02-29 03:56:39 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-02-29 03:56:39 -0800
commita20a327cc3652d5cd81bbd28a8198ac0260337eb (patch)
treeae6b4ffef66e0a64ade050a868e7ee19dff5f3e2
parent8df1dc4a032dd6a3407e8fdb01ca0d936a2cfa3d (diff)
parent34444b69296aa3d112e744473be5dab4c755fabd (diff)
downloaddeviced-a20a327cc3652d5cd81bbd28a8198ac0260337eb.tar.gz
deviced-a20a327cc3652d5cd81bbd28a8198ac0260337eb.tar.bz2
deviced-a20a327cc3652d5cd81bbd28a8198ac0260337eb.zip
Merge "display: change display state from standby to suspend automatically" into tizen
-rw-r--r--src/core/device-notifier.h1
-rw-r--r--src/display/core.c6
-rw-r--r--src/display/poll.h1
-rw-r--r--src/display/state-tv.c56
4 files changed, 59 insertions, 5 deletions
diff --git a/src/core/device-notifier.h b/src/core/device-notifier.h
index 85a4e9a7..da2d6cc3 100644
--- a/src/core/device-notifier.h
+++ b/src/core/device-notifier.h
@@ -33,6 +33,7 @@ enum device_notifier_type {
DEVICE_NOTIFIER_BATTERY_PRESENT,
DEVICE_NOTIFIER_BATTERY_OVP,
DEVICE_NOTIFIER_BATTERY_CHARGING,
+ DEVICE_NOTIFIER_DISPLAY_LOCK,
DEVICE_NOTIFIER_POWER_RESUME,
DEVICE_NOTIFIER_POWEROFF,
DEVICE_NOTIFIER_POWEROFF_HAPTIC,
diff --git a/src/display/core.c b/src/display/core.c
index bff7de37..8b8c2f72 100644
--- a/src/display/core.c
+++ b/src/display/core.c
@@ -126,7 +126,7 @@ static int trans_table[S_END][EVENT_END] = {
{ S_LCDDIM, S_NORMAL }, /* S_NORMAL */
{ S_LCDOFF, S_NORMAL }, /* S_LCDDIM */
{ S_SLEEP, S_NORMAL }, /* S_LCDOFF */
- { S_STANDBY, S_STANDBY }, /* S_STANDBY */
+ { S_SLEEP, S_STANDBY }, /* S_STANDBY */
{ S_LCDOFF, S_NORMAL }, /* S_SLEEP */
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
@@ -921,6 +921,8 @@ static void proc_condition_lock(PMMsg *data)
_SD("[%s] locked by pid %d - process %s holdkeyblock %d\n",
states[state].name, pid, pname, holdkey_block);
set_lock_time(pname, state);
+
+ device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)true);
}
static void proc_condition_unlock(PMMsg *data)
@@ -945,6 +947,8 @@ static void proc_condition_unlock(PMMsg *data)
_SD("[%s] unlocked by pid %d - process %s\n",
states[state].name, pid, pname);
set_unlock_time(pname, state);
+
+ device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)false);
}
static int proc_condition(PMMsg *data)
diff --git a/src/display/poll.h b/src/display/poll.h
index e1a1200a..567e3949 100644
--- a/src/display/poll.h
+++ b/src/display/poll.h
@@ -53,6 +53,7 @@ enum {
INTERNAL_LOCK_TIME,
INTERNAL_LOCK_USB,
INTERNAL_LOCK_POWEROFF,
+ INTERNAL_LOCK_SUSPEND,
INTERNAL_LOCK_COOL_DOWN,
INTERNAL_LOCK_LOWBAT,
};
diff --git a/src/display/state-tv.c b/src/display/state-tv.c
index 4b759f64..263b32ff 100644
--- a/src/display/state-tv.c
+++ b/src/display/state-tv.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
+#include <Ecore.h>
#include "core/common.h"
#include "core/log.h"
#include "core/device-notifier.h"
@@ -37,6 +38,8 @@
#define SIGNAL_POST_WAKEUP "PostWakeUp"
#define SIGNAL_EARLY_WAKEUP "EarlyWakeUp"
+static Ecore_Timer *standby_timer;
+
static int change_state(pid_t pid, int type, enum state_t st)
{
int ret;
@@ -265,9 +268,9 @@ static int standby_check(int curr, int next)
return -EPERM;
/* do not change to next state if who lock the standby mode */
- check_processes(pm_cur_state);
- if (check_lock_state(pm_cur_state)) {
- _I("S_STANDBY Lock state");
+ check_processes(S_LCDOFF);
+ if (check_lock_state(S_LCDOFF)) {
+ _I("S_LCDOFF Lock state");
return 1;
}
@@ -297,6 +300,26 @@ static int standby_post(void *data)
return 0;
}
+static int poweroff_trans(int evt);
+
+static Eina_Bool standby_go_next_state(void *data)
+{
+ int ret;
+
+ if (standby_timer) {
+ ecore_timer_del(standby_timer);
+ standby_timer = NULL;
+ }
+
+ ret = pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND);
+ if (ret < 0) {
+ _E("Failed to change state to S_SUSPEND. Now Power off !!");
+ poweroff_trans(0);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static int standby_action(int timeout)
{
if (pm_cur_state != pm_old_state &&
@@ -305,6 +328,11 @@ static int standby_action(int timeout)
backlight_ops.off(0);
+ standby_timer = ecore_timer_add(0,
+ standby_go_next_state, NULL);
+ if (!standby_timer)
+ _E("Failed to add timer to go to next state of S_STANDBY");
+
return 0;
}
@@ -354,7 +382,7 @@ static int suspend_post(void *data)
/* TODO: count InstandOn */
cond = S_LCDON;
- ret = tv_proc_change_state(cond, getpid());
+ ret = tv_proc_change_state(cond, INTERNAL_LOCK_SUSPEND);
if (ret < 0)
_E("Fail to change state to next_state(%s)", states[cond].name);
@@ -453,6 +481,19 @@ static int poweroff_trans(int evt)
return 0;
}
+static int display_lock_changed(void *data)
+{
+ bool state = (bool)data;
+
+ if (pm_cur_state != S_STANDBY)
+ return 0;
+
+ if (!state)
+ standby_go_next_state(NULL);
+
+ return 0;
+}
+
static void set_tv_operations(enum state_t st,
char *name,
int (*check) (int curr, int next),
@@ -493,4 +534,11 @@ static void __CONSTRUCTOR__ state_tv_init(void)
tv_states[i].action);
change_proc_change_state(tv_proc_change_state);
+
+ register_notifier(DEVICE_NOTIFIER_DISPLAY_LOCK, display_lock_changed);
+}
+
+static void __DESTRUCTOR__ state_tv_deinit(void)
+{
+ unregister_notifier(DEVICE_NOTIFIER_DISPLAY_LOCK, display_lock_changed);
}