It replaces get_pm_cur_state() of the display core.
Change-Id: I7fa227f816b343226f5a7584952862a4ebdd8459
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
static void ambient_start_clock(void)
{
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON) ||
- (get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) ||
+ int ret;
+ enum deviced_display_state current;
+
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
+ if ((current == DEVICED_DISPLAY_STATE_ON) ||
+ (current == DEVICED_DISPLAY_STATE_DIM) ||
(ambient_state == false))
return;
static void ambient_end_clock(pid_t pid)
{
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON) ||
- (get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) ||
+ int ret;
+ enum deviced_display_state current;
+
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
+ if ((current == DEVICED_DISPLAY_STATE_ON) ||
+ (current == DEVICED_DISPLAY_STATE_DIM) ||
(ambient_state == false))
return;
#include "core.h"
#include "device-interface.h"
#include "display.h"
+#include "display-state-transition.h"
#include "display-backlight.h"
#include "display-panel.h"
#include "display-plugin.h"
ret = display_backlight_set_brightness(PM_DIM_BRIGHTNESS);
#ifdef ENABLE_PM_LOG
+ enum deviced_display_state current;
+
+ if (display_state_get_current(¤t) < 0)
+ return ret;
+
if (!ret)
- pm_history_save(PM_LOG_LCD_DIM, get_pm_cur_state());
+ pm_history_save(PM_LOG_LCD_DIM, current);
else
- pm_history_save(PM_LOG_LCD_DIM_FAIL, get_pm_cur_state());
+ pm_history_save(PM_LOG_LCD_DIM_FAIL, current);
#endif
return ret;
}
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
{
+ enum deviced_display_state current;
int brt = -1, ret, result;
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON) {
+ if (display_state_get_current(¤t) < 0) {
+ result = 0;
+ goto out;
+ }
+
+ if (current == DEVICED_DISPLAY_STATE_ON) {
ret = display_backlight_get_brightness(&brt);
if (ret < 0)
result = 0;
else
result = brt;
- } else if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) {
+ } else if (current == DEVICED_DISPLAY_STATE_DIM) {
ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_DIM_BRIGHTNESS, &brt);
if (ret < 0) {
_E("Failed to get vconf value for lcd dim brightness: %d", vconf_get_ext_errno());
_I("get brightness %d, %d", brt, result);
+out:
return g_variant_new("(i)", result);
}
_E("Failed to set vconf value for lcd brightness: %d", vconf_get_ext_errno());
}
} else if (state == DISPLAY_STATE_SCREEN_DIM) {
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) {
+ enum deviced_display_state current;
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ goto error;
+
+ if (current == DEVICED_DISPLAY_STATE_DIM) {
ret = display_backlight_set_brightness(brt);
if (ret < 0)
goto error;
{
unsigned int custom_normal_timeout = 0;
unsigned int custom_dim_timeout = 0;
+ int ret;
+ enum deviced_display_state current;
if (on == 0 && dim == 0) {
_I("LCD timeout changed: default setting");
display_state_transition_set_custom_timeout(DEVICED_DISPLAY_STATE_ON, SEC_TO_MSEC(on));
display_state_transition_set_custom_timeout(DEVICED_DISPLAY_STATE_DIM, SEC_TO_MSEC(dim));
}
+
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return ret;
+
/* Apply new backlight time */
display_state_transition_update_display_state_timeout_by_priority();
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ if (current == DEVICED_DISPLAY_STATE_ON)
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
if (custom_change_name) {
free(custom_change_name);
const gchar *unique_name,
gpointer data)
{
+ enum deviced_display_state current;
+ int ret;
+
if (!sender)
return;
display_state_transition_set_custom_timeout(DEVICED_DISPLAY_STATE_ON, 0);
display_state_transition_set_custom_timeout(DEVICED_DISPLAY_STATE_DIM, 0);
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
display_state_transition_update_display_state_timeout_by_priority();
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ if (current == DEVICED_DISPLAY_STATE_ON)
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
}
static GVariant *dbus_setlcdtimeout(GDBusConnection *conn,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
{
int dimstay, ret = 0;
+ enum deviced_display_state current;
pid_t pid;
g_variant_get(param, "(i)", &dimstay);
clear_pm_status_flag(DIM_FLAG);
}
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ goto out;
+
+ if (current == DEVICED_DISPLAY_STATE_ON)
display_backlight_update_by_default_brightness();
out:
static void free_lock(struct display_lock *dl)
{
enum deviced_display_state state;
+ enum deviced_display_state current;
+ int ret;
if (!dl)
return;
dl = NULL;
/* Trigger state transition */
- if (state == get_pm_cur_state() && // if the unlocked state is equal to the current display state
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
+ if (state == current && // if the unlocked state is equal to the current display state
!display_lock_is_state_locked(state) && // if the released lock is the last lock
display_state_transition_is_there_state_transition_timer() == false) // if there is no running transition timer
display_state_transition_reset_state_transition_timeout(0);
char pname[PATH_MAX];
pid_t pid = data->pid;
enum deviced_display_state state;
+ enum deviced_display_state current;
int ret;
bool value = true;
unsigned int flags;
const char *lock_type = NULL;
const char *state_name = NULL;
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
state = GET_COND_STATE(data->cond);
if (state == DEVICED_DISPLAY_STATE_START)
return;
flags = GET_COND_FLAG(data->cond);
display_misc_get_process_name(pid, pname);
- if ((state == DEVICED_DISPLAY_STATE_OFF) && (get_pm_cur_state() == DEVICED_DISPLAY_STATE_SLEEP) &&
+ if ((state == DEVICED_DISPLAY_STATE_OFF) && (current == DEVICED_DISPLAY_STATE_SLEEP) &&
(pm_get_power_lock() == POWER_UNLOCK))
display_state_transition_do_proc_change_state(data->cond, DEVICED_EVENT_DISPLAY_LOCK);
unsigned int flags;
int timeout = 0;
bool timeout_enable = false;
+ int ret;
+ enum deviced_display_state current;
if (IS_COND_REQUEST_LOCK(data->cond))
proc_condition_lock(data);
if (!timeout_enable)
return 0;
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return ret;
+
flags = GET_COND_FLAG(data->cond);
if (flags == 0) {
/* guard time for suspend */
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_OFF) {
+ if (current == DEVICED_DISPLAY_STATE_OFF) {
display_plugin_state_get_timeout(DEVICED_DISPLAY_STATE_OFF, &timeout);
display_state_transition_reset_state_transition_timeout(timeout);
}
} else {
if (flags & PM_FLAG_RESET_TIMER) {
- display_plugin_state_get_timeout(get_pm_cur_state(), &timeout);
+ display_plugin_state_get_timeout(current, &timeout);
display_state_transition_reset_state_transition_timeout(timeout);
}
}
if (!display_state_transition_is_there_state_transition_timer())
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT);
+ display_state_transition_do_state_transition(current, EVENT_TIMEOUT);
return 0;
}
const char *dim_state_name;
const char *off_state_name;
const char *current_state_name;
+ enum deviced_display_state current;
display_plugin_state_get_timeout(DEVICED_DISPLAY_STATE_ON, &normal_state_timeout);
display_plugin_state_get_timeout(DEVICED_DISPLAY_STATE_DIM, &dim_state_timeout);
if (ret < 0)
_E("Write() failed: %d", errno);
- display_plugin_state_get_name(get_pm_cur_state(), ¤t_state_name);
- snprintf(buf, sizeof(buf), "Current State: %s\n", current_state_name);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
+ ret = display_state_get_current(¤t);
+ if (ret == 0) {
+ display_plugin_state_get_name(current, ¤t_state_name);
+ snprintf(buf, sizeof(buf), "Current State: %s\n", current_state_name);
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Write() failed: %d", errno);
+ }
snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
ret = write(fd, buf, strlen(buf));
*/
#include <sys/time.h>
#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-display.h>
#include <system/syscommon-plugin-deviced-power-interface.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
/* 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)
{
+
dpms_set_state(dpms_on);
#ifdef ENABLE_PM_LOG
+ enum deviced_display_state current;
+
+ if (display_state_get_current(¤t) < 0)
+ return 0;
+
if (dpms_on == DPMS_ON)
- pm_history_save(PM_LOG_LCD_ON_COMPLETE, get_pm_cur_state());
+ pm_history_save(PM_LOG_LCD_ON_COMPLETE, current);
else if (dpms_on == DPMS_OFF || dpms_on == DPMS_FORCE_OFF)
- pm_history_save(PM_LOG_LCD_OFF_COMPLETE, get_pm_cur_state());
+ pm_history_save(PM_LOG_LCD_OFF_COMPLETE, current);
else
pm_history_save(PM_LOG_LCD_CONTROL_FAIL, dpms_on);
#endif
ret = display_panel_set_dpms_state(DPMS_ON, flags);
#ifdef ENABLE_PM_LOG
- pm_history_save(PM_LOG_LCD_ON, get_pm_cur_state());
+ enum deviced_display_state current;
+
+ if (display_state_get_current(¤t) < 0)
+ return 0;
+
+ pm_history_save(PM_LOG_LCD_ON, current);
#endif
return ret;
}
ret = display_panel_set_dpms_state(DPMS_OFF, flags);
#ifdef ENABLE_PM_LOG
- pm_history_save(PM_LOG_LCD_OFF, get_pm_cur_state());
+ enum deviced_display_state current;
+
+ if (display_state_get_current(¤t) < 0)
+ return ret;
+
+ pm_history_save(PM_LOG_LCD_OFF, current);
#endif
return ret;
}
#include <libsyscommon/common.h>
#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-display.h>
#include <system/syscommon-plugin-deviced-power-interface.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
#include "shared/log.h"
}
/**
- * FIXME: All those getter/setter for current/previous will be changed to resource-manager.
+ * DO NOT USE the below functions anymore. They are legacy.
* - get_pm_cur_state()
* - set_pm_cur_state()
* - get_pm_old_state()
* - set_pm_old_state()
+ *
+ * Use below intead.
+ * - display_state_get_current()
+ * - display_state_set_current()
+ * - display_state_get_previous()
+ *
+ * FIXME:
+ * For the plugin side, corresponding resource-driver attributes will be provided.
+ * It can be made by accessing those attributes via resource-manager API.
*/
inline int get_pm_cur_state(void)
{
previous = state;
}
+int display_state_set_current(enum deviced_display_state state)
+{
+ if (!is_display_state_valid(state))
+ return -EINVAL;
+
+ current = state;
+
+ return 0;
+}
+
+int display_state_get_current(enum deviced_display_state *state)
+{
+ if (!state)
+ return -EINVAL;
+
+ *state = current;
+
+ return 0;
+}
+
+int display_state_get_previous(enum deviced_display_state *state)
+{
+ if (!state)
+ return -EINVAL;
+
+ *state = previous;
+
+ return 0;
+}
+
static bool is_device_event_type_valid(int event_type)
{
return (event_type >= EVENT_TIMEOUT && event_type < EVENT_END);
#define __DISPLAY_STATE_TRANSITION_H__
#include <unistd.h>
+#include <system/syscommon-plugin-deviced-display.h>
#include "core.h"
#define LOCK_SCREEN_INPUT_TIMEOUT 10000
+int display_state_set_current(enum deviced_display_state state);
+int display_state_get_current(enum deviced_display_state *state);
+int display_state_get_previous(enum deviced_display_state *state);
+
int display_state_transition_get_next_transition_display_state(enum deviced_display_state from_state, enum deviced_display_state *to_state, int evt_type);
int display_state_transition_set_transition_table_display_state(enum deviced_display_state display_state, enum deviced_display_state set_state, int evt_type);
bool display_state_transition_is_there_state_transition_timer(void);
void display_set_power_save_mode_flag(int onoff)
{
+ int ret;
+ enum deviced_display_state current;
+
if (display_plugin_set_power_save_mode_flag(onoff) == 0)
return;
else
clear_pm_status_flag(PWRSV_FLAG);
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return;
+
+ if (current == DEVICED_DISPLAY_STATE_ON)
display_backlight_update_by_default_brightness();
}
static int power_resume_from_echomem_callback(void *data)
{
+ int ret;
+ enum deviced_display_state current;
+
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return ret;
+
display_plugin_set_system_wakeup_flag(true);
if (check_wakeup_src() == EVENT_DEVICE)
/* system waked up by devices */
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_DEVICE);
+ display_state_transition_do_state_transition(current, EVENT_DEVICE);
else
/* system waked up by user input */
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
return 0;
}
int timeout = 0;
bool timeout_enable = false;
int lcdoff_timeout = 0;
+ int ret;
+ enum deviced_display_state current;
if (!display_panel_init_dpms())
return G_SOURCE_CONTINUE;
- switch (get_pm_cur_state()) {
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return G_SOURCE_REMOVE;
+
+ switch (current) {
case DEVICED_DISPLAY_STATE_ON:
case DEVICED_DISPLAY_STATE_DIM:
display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
int timeout = 0;
int ret = 0;
unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
+ enum deviced_display_state current;
if (!display_plugin_device_ops || !display_plugin_device_ops->init)
return;
set_pm_cur_state(DEVICED_DISPLAY_STATE_OFF);
else
set_pm_cur_state(DEVICED_DISPLAY_STATE_ON);
- ret = vconf_set_int(VCONFKEY_PM_STATE, get_pm_cur_state());
- if (ret < 0)
- _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
+
+ ret = display_state_get_current(¤t);
+ if (ret == 0) {
+ ret = vconf_set_int(VCONFKEY_PM_STATE, current);
+ if (ret < 0)
+ _E("Failed to set vconf value for pm cur state: %d", vconf_get_ext_errno());
+ }
display_set_display_ops_status(DEVICE_OPS_STATUS_START);
if (timeout_enable) {
/* Set current state to DEVICED_DISPLAY_STATE_ON */
set_pm_cur_state(DEVICED_DISPLAY_STATE_ON);
- set_setting_pmstate(get_pm_cur_state());
+ set_setting_pmstate(DEVICED_DISPLAY_STATE_ON);
/* timeout is not needed */
display_state_transition_reset_state_transition_timeout(TIMEOUT_NONE);
#include <system/syscommon-plugin-deviced-display.h>
#include "shared/common.h"
+#include "display-state-transition.h"
#include "display-backlight.h"
static int get_max_brightness(int resource_id,
*(int *) data = brightness;
return 0;
-
}
static const struct syscommon_resman_resource_attribute display_attrs[] = {
int display_setting_update_pm_setting(int key_idx, int val)
{
int ret;
+ enum deviced_display_state current;
if (display_plugin_is_there_update_pm_setting())
return display_plugin_update_pm_setting(key_idx, val);
+ ret = display_state_get_current(¤t);
+ if (ret < 0)
+ return ret;
+
switch (key_idx) {
case SETTING_TO_NORMAL:
display_state_transition_update_display_state_timeout_by_priority();
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
break;
case SETTING_LOW_BATT:
if (display_misc_is_low_battery_state(val)) {
touchled_control_backlight(TOUCHLED_DIRECT_OFF);
/* LCD on if lock screen show before waiting time */
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON) &&
+ if ((current == DEVICED_DISPLAY_STATE_ON) &&
val == VCONFKEY_IDLE_LOCK &&
display_panel_get_dpms_cached_state() != DPMS_ON &&
display_plugin_is_lcd_on_blocked() == LCDON_BLOCK_NONE)
display_panel_lcd_on_procedure(LCD_NORMAL, LCD_ON_BY_EVENT);
display_state_transition_update_display_state_timeout_by_priority();
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ if (current == DEVICED_DISPLAY_STATE_ON)
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
break;
case SETTING_LOCK_SCREEN_BG:
set_lock_screen_bg_state(val);
display_state_transition_update_display_state_timeout_by_priority();
- if (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON)
- display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_INPUT);
+ if (current == DEVICED_DISPLAY_STATE_ON)
+ display_state_transition_do_state_transition(current, EVENT_INPUT);
break;
case SETTING_POWER_CUSTOM_BRIGHTNESS:
if (val == VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON)