From: Youngjae Cho Date: Tue, 22 Aug 2023 04:21:22 +0000 (+0900) Subject: power: Add attribute for pm_history_save() X-Git-Tag: accepted/tizen/unified/20230823.021355~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa0138c423c78ac6972648a878cb04117de0d05c;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: Add attribute for pm_history_save() New attribute: - id: DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG - type: DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG - setter: O - getter: X - 1st param: enum syscommon_deviced_power_log_type - 2nd param: secondary information of type integer Additionally, replaced enum pm_log_type to syscommon_deviced_power_log_type of the libsyscommon. Change-Id: Ifacf09c2f95b8fcc84399f79483634e1d5c1b467 Signed-off-by: Youngjae Cho --- diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 14a7e924..36b809c7 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -685,9 +685,13 @@ static int check_key(struct input_event *pinput) } #ifdef ENABLE_PM_LOG if (pinput->value == KEY_PRESSED) - pm_history_save(PM_LOG_KEY_PRESS, pinput->code); + syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER), + DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_PRESS, pinput->code); else if (pinput->value == KEY_RELEASED) - pm_history_save(PM_LOG_KEY_RELEASE, pinput->code); + syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER), + DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_RELEASE, pinput->code); #endif return ignore; } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index a4e79ae7..6b3cf2fb 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -676,9 +676,9 @@ static int check_key(struct input_event *pinput) } #ifdef ENABLE_PM_LOG if (pinput->value == KEY_PRESSED) - pm_history_save(PM_LOG_KEY_PRESS, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_PRESS, pinput->code); else if (pinput->value == KEY_RELEASED) - pm_history_save(PM_LOG_KEY_RELEASE, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_RELEASE, pinput->code); #endif return ignore; } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index f9aed5f3..0160ab44 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -644,9 +644,9 @@ static int check_key(struct input_event *pinput) } #ifdef ENABLE_PM_LOG if (pinput->value == KEY_PRESSED) - pm_history_save(PM_LOG_KEY_PRESS, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_PRESS, pinput->code); else if (pinput->value == KEY_RELEASED) - pm_history_save(PM_LOG_KEY_RELEASE, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_RELEASE, pinput->code); #endif return ignore; } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index fc5e4f8a..b83d3993 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -781,7 +781,7 @@ static int default_action(int timeout) go_suspend: #ifdef ENABLE_PM_LOG - pm_history_save(PM_LOG_SLEEP, get_pm_cur_state()); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_SLEEP, get_pm_cur_state()); #endif power_request_change_state(DEVICED_POWER_STATE_SLEEP, HAL_DEVICE_POWER_TRANSITION_REASON_DISPLAY_OFF_TIMEOUT); return 0; diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 8700061a..294e80c8 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -585,9 +585,9 @@ static int check_key(struct input_event *pinput) } #ifdef ENABLE_PM_LOG if (pinput->value == KEY_PRESSED) - pm_history_save(PM_LOG_KEY_PRESS, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_PRESS, pinput->code); else if (pinput->value == KEY_RELEASED) - pm_history_save(PM_LOG_KEY_RELEASE, pinput->code); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_RELEASE, pinput->code); #endif return ignore; } diff --git a/src/display/display-backlight.c b/src/display/display-backlight.c index d35f2a2e..a74707fc 100644 --- a/src/display/display-backlight.c +++ b/src/display/display-backlight.c @@ -319,9 +319,9 @@ int display_backlight_set_brightness_by_dim_brightness(void) return ret; if (!ret) - pm_history_save(PM_LOG_LCD_DIM, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_DIM, current); else - pm_history_save(PM_LOG_LCD_DIM_FAIL, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_DIM_FAIL, current); #endif return ret; } diff --git a/src/display/display-panel.c b/src/display/display-panel.c index f8bcbf9f..a0513abc 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -66,11 +66,11 @@ int display_panel_set_dpms_state(int dpms_on, enum device_flags flags) return 0; if (dpms_on == SYSCOMMON_DEVICED_DPMS_ON) - pm_history_save(PM_LOG_LCD_ON_COMPLETE, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_ON_COMPLETE, current); else if (dpms_on == SYSCOMMON_DEVICED_DPMS_OFF || dpms_on == SYSCOMMON_DEVICED_DPMS_FORCE_OFF) - pm_history_save(PM_LOG_LCD_OFF_COMPLETE, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_OFF_COMPLETE, current); else - pm_history_save(PM_LOG_LCD_CONTROL_FAIL, dpms_on); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_CONTROL_FAIL, dpms_on); #endif return 0; @@ -161,7 +161,7 @@ int display_panel_set_panel_state_by_on_state(enum device_flags flags) if (display_state_get_current(¤t) < 0) return 0; - pm_history_save(PM_LOG_LCD_ON, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_ON, current); #endif return ret; } @@ -198,7 +198,7 @@ int display_panel_set_panel_state_by_off_state(enum device_flags flags) if (display_state_get_current(¤t) < 0) return ret; - pm_history_save(PM_LOG_LCD_OFF, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_OFF, current); #endif return ret; } diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 85c38fdf..37810a0a 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -805,7 +805,7 @@ static int display_state_transition_do_state_action(int timeout) go_suspend: #ifdef ENABLE_PM_LOG - pm_history_save(PM_LOG_SLEEP, current); + pm_history_save(SYSCOMMON_DEVICED_POWER_LOG_TYPE_SLEEP, current); #endif syscommon_resman_set_resource_attr_uint64_4(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER), DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE, diff --git a/src/power/power-suspend.c b/src/power/power-suspend.c index 63eaf2ec..e95370e8 100644 --- a/src/power/power-suspend.c +++ b/src/power/power-suspend.c @@ -56,7 +56,7 @@ static enum hal_device_power_transition_reason wakeup_reason = HAL_DEVICE_POWER_ typedef struct _pm_history { time_t time; - enum pm_log_type log_type; + enum syscommon_deviced_power_log_type log_type; int keycode; } pm_history; @@ -64,7 +64,7 @@ static int max_history_count = MAX_LOG_COUNT; static pm_history pm_history_log[MAX_LOG_COUNT] = {{0, }, }; static int history_count = 0; -static const char history_string[PM_LOG_MAX][15] = { +static const char history_string[SYSCOMMON_DEVICED_POWER_LOG_TYPE_MAX][15] = { "PRESS", "LONG PRESS", "RELEASE", "LCD ON", "LCD ON COMPL", "LCD ON FAIL", "LCD DIM", "LCD DIM FAIL", "LCD OFF", "LCD OFF COMPL", "LCD OFF FAIL", "LCD FAIL", "SLEEP"}; @@ -123,7 +123,7 @@ void pm_history_init() max_history_count = MAX_LOG_COUNT; } -void pm_history_save(enum pm_log_type log_type, int code) +void pm_history_save(enum syscommon_deviced_power_log_type log_type, int code) { time_t now; @@ -156,7 +156,7 @@ void pm_history_print(int fd, int count) if (pm_history_log[index].time == 0) continue; - if (pm_history_log[index].log_type >= PM_LOG_MAX) + if (pm_history_log[index].log_type >= SYSCOMMON_DEVICED_POWER_LOG_TYPE_MAX) continue; ctime_r(&pm_history_log[index].time, time_buf); time_buf[strlen(time_buf) - 1] = 0; diff --git a/src/power/power-suspend.h b/src/power/power-suspend.h index 0590e400..0bcbdc3e 100644 --- a/src/power/power-suspend.h +++ b/src/power/power-suspend.h @@ -38,30 +38,11 @@ enum mainlock_state { POWER_LOCK, }; -enum pm_log_type { - PM_LOG_MIN = 0, - PM_LOG_KEY_PRESS = PM_LOG_MIN, /* key log */ - PM_LOG_KEY_LONG_PRESS, - PM_LOG_KEY_RELEASE, - PM_LOG_LCD_ON, /* lcd log */ - PM_LOG_LCD_ON_COMPLETE, - PM_LOG_LCD_ON_FAIL, - PM_LOG_LCD_DIM, - PM_LOG_LCD_DIM_FAIL, - PM_LOG_LCD_OFF, - PM_LOG_LCD_OFF_COMPLETE, - PM_LOG_LCD_OFF_FAIL, - PM_LOG_LCD_CONTROL_FAIL, - PM_LOG_SLEEP, - PM_LOG_MAX -}; - - extern bool timeout_sleep_support; #ifdef ENABLE_PM_LOG void pm_history_init(void); -void pm_history_save(enum pm_log_type log_type, int code); +void pm_history_save(enum syscommon_deviced_power_log_type log_type, int code); void pm_history_print(int fd, int count); #endif bool vital_mode(void); diff --git a/src/power/resource-power.c b/src/power/resource-power.c index fe65cff5..dda111a0 100644 --- a/src/power/resource-power.c +++ b/src/power/resource-power.c @@ -61,6 +61,32 @@ static int set_current_state(int resource_id, const struct syscommon_resman_reso return 0; } +static int set_tuple2_power_attr_data(int resource_id, + const struct syscommon_resman_resource_attribute *attr, + const void *data1, const void *data2, int count1, int count2) +{ + if (!data1 || !data2) + return -EINVAL; + + switch (attr->id) { + case DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG: + { + enum syscommon_deviced_power_log_type type = *(enum syscommon_deviced_power_log_type *) data1; + int code = *(int *) data2; + + pm_history_save(type, code); + + return 0; + } + break; + default: + return -EINVAL; + } + + return 0; +} + + static int get_power_attr_data(int resource_id, const struct syscommon_resman_resource_attribute *attr, void *data) { @@ -213,6 +239,15 @@ static const struct syscommon_resman_resource_attribute power_attrs[] = { .get = get_power_attr_data, .is_supported = syscommon_resman_resource_attr_supported_always, }, + }, { + .name = "DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG", + .id = DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG, + .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64, + .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC, + .ops = { + .set_2_tuple = set_tuple2_power_attr_data, + .is_supported = syscommon_resman_resource_attr_supported_always, + }, } };