power: Add attribute for pm_history_save() 42/297642/2
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 22 Aug 2023 04:21:22 +0000 (13:21 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 22 Aug 2023 07:48:54 +0000 (16:48 +0900)
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 <y0.cho@samsung.com>
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/key-filter.c
plugins/tv/display/key-filter.c
plugins/wearable/display/core.c
plugins/wearable/display/key-filter.c
src/display/display-backlight.c
src/display/display-panel.c
src/display/display-state-transition.c
src/power/power-suspend.c
src/power/power-suspend.h
src/power/resource-power.c

index 14a7e9243443a21ab96421e727b6d99fbdeddf21..36b809c79663d12d02f65485fdb43cb5bd4d2488 100644 (file)
@@ -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;
 }
index a4e79ae7b4e4325e59fd08c6ca886e4c43786834..6b3cf2fb2ad1f2a13042d1c07a7e1f381bebdc74 100644 (file)
@@ -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;
 }
index f9aed5f334421905ead964cad2b1498540862e2d..0160ab440790747b114ec02de866ba3df4898396 100644 (file)
@@ -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;
 }
index fc5e4f8ad44be9970eb937a229b6008b858084c0..b83d39931d5d4bf6566917cd92cb9967b41f63c3 100644 (file)
@@ -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;
index 8700061ab1ab606622c9c697102165b40ec81218..294e80c812f6a7353a9575f48378d029416ff582 100644 (file)
@@ -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;
 }
index d35f2a2e1204f933c6d57692cba5134208e23d13..a74707fc6ba76c8d34b34a8a58f417d26b5370eb 100644 (file)
@@ -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;
 }
index f8bcbf9f840b54acbe6861385680094c318602ea..a0513abca5968b8e5c8a63ecbc22b5c686601497 100644 (file)
@@ -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(&current) < 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(&current) < 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;
 }
index 85c38fdfb0050a617fb332eae1812961746da9f5..37810a0a19c1cbf40193ec6c5164487f9de9aece 100644 (file)
@@ -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,
index 63eaf2ec6d1f6a1495c02b0af29a657ab0cc88a5..e95370e8db2c809d592b12961128aaf4ede7e35c 100644 (file)
@@ -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;
index 0590e400b2d399df5e38cf601a78e6e8eb16aefd..0bcbdc3e3d8688c8a4c0db72fd8791c25a63d172 100644 (file)
@@ -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);
index fe65cff5585921ea7c3b5dca0200eed54f48b4c8..dda111a07651f549b5680e93a4339237abb9b241 100644 (file)
@@ -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,
+               },
        }
 };