From: Youngjae Cho Date: Tue, 1 Aug 2023 09:50:19 +0000 (+0900) Subject: display: Apply resource-manager for controlling power X-Git-Tag: accepted/tizen/unified/20230803.174810~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F296598%2F4;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Apply resource-manager for controlling power Previously, controlling power has operated via power functions such as power_request_change_state(), power_request_change_state_strict(). It has changed to work via the libsyscommon resource-manager. Change-Id: I39253c193ccf73e66a6075c4e46e4a1432c501dd Signed-off-by: Youngjae Cho --- diff --git a/src/display/display-panel.c b/src/display/display-panel.c index 583b86e..6d7e5b4 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -16,6 +16,9 @@ * limitations under the License. */ #include +#include +#include +#include #include "shared/log.h" #include "power/power.h" @@ -45,10 +48,26 @@ (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) { @@ -323,7 +342,10 @@ void display_panel_lcd_on_direct(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"); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 260e0ee..4c413d3 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -22,6 +22,9 @@ */ #include +#include +#include +#include #include "shared/log.h" #include "core/udev.h" #include "device-interface.h" @@ -35,6 +38,7 @@ #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; @@ -52,6 +56,20 @@ static int trans_table[S_END][EVENT_END] = { { 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); @@ -473,8 +491,14 @@ int display_state_transition_do_state_action(int timeout) } 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); @@ -555,7 +579,11 @@ go_suspend: #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: diff --git a/src/display/display.c b/src/display/display.c index 223cb8c..e4620e2 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -19,6 +19,9 @@ #include #include +#include +#include +#include #include #include "core/udev.h" @@ -38,6 +41,7 @@ #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; @@ -50,6 +54,20 @@ static enum device_ops_status display_ops_status = DEVICE_OPS_STATUS_UNINIT; 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; @@ -593,8 +611,11 @@ static void display_init(void *data) 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.