* limitations under the License.
*/
#include <sys/time.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
#include "shared/log.h"
#include "power/power.h"
(b.tv_sec * 1000000 + b.tv_usec)) \
/ 1000)
+#define POWER_RESOURCE_ID get_power_resource_id()
+
static bool lcd_paneloff_mode = false;
static bool lcd_on_broadcasted = true;
static struct timeval lcd_on_timeval;
+static int get_power_resource_id(void)
+{
+ static int resource_id = -1;
+
+ if (resource_id >= 0)
+ return resource_id;
+
+ int ret = syscommon_resman_get_resource_id(DEVICED_RESOURCE_TYPE_POWER, &resource_id);
+ if (ret < 0)
+ return -1;
+ else
+ return resource_id;
+}
+
/* 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)
{
else
reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
- power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, NULL);
+ syscommon_resman_set_resource_attr_uint64_4(POWER_RESOURCE_ID,
+ DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE,
+ DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, reason, 0);
+
set_pm_cur_state(S_NORMAL);
_D("lcd is on directly");
*/
#include <libsyscommon/common.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
#include "shared/log.h"
#include "core/udev.h"
#include "device-interface.h"
#include "power/power-suspend.h"
#define ALWAYS_ON_TIMEOUT 360000000
+#define POWER_RESOURCE_ID get_power_resource_id()
static guint state_transition_timer_id;
static unsigned int custom_normal_timeout = 0;
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
+static int get_power_resource_id(void)
+{
+ static int resource_id = -1;
+
+ if (resource_id >= 0)
+ return resource_id;
+
+ int ret = syscommon_resman_get_resource_id(DEVICED_RESOURCE_TYPE_POWER, &resource_id);
+ if (ret < 0)
+ return -1;
+ else
+ return resource_id;
+}
+
static bool is_display_state_valid(enum state_t display_state)
{
return (display_state >= S_START && display_state < S_END);
}
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);
+ int wakeup_reason = 0;
+
+ syscommon_resman_get_resource_attr_int(POWER_RESOURCE_ID,
+ DEVICED_POWER_ATTR_INT_WAKEUP_REASON, &wakeup_reason);
+ syscommon_resman_set_resource_attr_uint64_4(POWER_RESOURCE_ID,
+ DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE,
+ DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL, wakeup_reason, 0);
+
set_setting_pmstate(get_pm_cur_state());
pm_cur_state = get_pm_cur_state();
syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
#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);
+ syscommon_resman_set_resource_attr_uint64_4(POWER_RESOURCE_ID,
+ DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE,
+ DEVICED_POWER_STATE_ALL, DEVICED_POWER_STATE_SLEEP,
+ HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT, 0);
+
return 0;
go_lcd_off:
#include <signal.h>
#include <libsyscommon/list.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-power-interface.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
#include <shared/devices.h>
#include "core/udev.h"
#include "lock-detector.h"
#define DELAYED_INIT_WATING_TIME 60000 /* 1 minute */
+#define POWER_RESOURCE_ID get_power_resource_id()
static const struct device_ops *display_plugin_device_ops;
static int pm_cur_state;
extern void init_save_userlock(void);
+static int get_power_resource_id(void)
+{
+ static int resource_id = -1;
+
+ if (resource_id >= 0)
+ return resource_id;
+
+ int ret = syscommon_resman_get_resource_id(DEVICED_RESOURCE_TYPE_POWER, &resource_id);
+ if (ret < 0)
+ return -1;
+ else
+ return resource_id;
+}
+
inline int get_pm_cur_state(void)
{
return pm_cur_state;
if (flags & WITHOUT_STARTNOTI) { /* start without noti */
_I("Start Power managing without noti");
- power_request_change_state_strict(DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
- HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, NULL);
+ syscommon_resman_set_resource_attr_uint64_4(POWER_RESOURCE_ID,
+ DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE,
+ DEVICED_POWER_STATE_SLEEP, DEVICED_POWER_STATE_NORMAL,
+ HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN, 0);
+
/*
* Lock lcd off until booting is done.
* deviced guarantees all booting script is executing.