From 719d8031b7fc53d089557783270eaa6c9663b765 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 17:28:47 +0900 Subject: [PATCH 01/16] plugin-api: deviced: Replace macro MATCH() with strncmp() The macro MATCH() has come from the deviced, and has been working well as it is, currently, always built with that macro definition within the deviced. Fix it not to be associated with the deviced so that it is able to be built alone. Change-Id: I21fe6f33f14ad6037592af12c6e1404f8ef128d1 Signed-off-by: Youngjae Cho --- .../include/syscommon-plugin-deviced-power-interface.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h index 71f0b89..c28b7e8 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h @@ -25,6 +25,8 @@ #ifndef __SYSCOMMON_PLUGIN_DEVICED_POWER_INTERFACE_H__ #define __SYSCOMMON_PLUGIN_DEVICED_POWER_INTERFACE_H__ +#include + #ifdef __cplusplus extern "C" { #endif @@ -82,19 +84,19 @@ struct syscommon_plugin_deviced_power_trans_info { static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(const char *str) { - if (MATCH(str, "start")) + if (strncmp(str, "start", sizeof("start")) == 0) return DEVICED_POWER_STATE_START; - else if (MATCH(str, "sleep")) + else if (strncmp(str, "sleep", sizeof("sleep")) == 0) return DEVICED_POWER_STATE_SLEEP; - else if (MATCH(str, "normal")) + else if (strncmp(str, "normal", sizeof("normal")) == 0) return DEVICED_POWER_STATE_NORMAL; - else if (MATCH(str, "poweroff")) + else if (strncmp(str, "poweroff", sizeof("poweroff")) == 0) return DEVICED_POWER_STATE_POWEROFF; - else if (MATCH(str, "reboot")) + else if (strncmp(str, "reboot", sizeof("reboot")) == 0) return DEVICED_POWER_STATE_REBOOT; - else if (MATCH(str, "exit")) + else if (strncmp(str, "exit", sizeof("exit")) == 0) return DEVICED_POWER_STATE_EXIT; - else if (MATCH(str, "current")) + else if (strncmp(str, "current", sizeof("current")) == 0) return DEVICED_POWER_STATE_ALL; return DEVICED_POWER_STATE_UNDEFINED; -- 2.7.4 From 48b58c77b08bec534fe22d4f66992d110aa8e332 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 17:08:38 +0900 Subject: [PATCH 02/16] plugin-api: deviced: Add power attribute and enum for vital mode New attribute: - id: DEVICED_POWER_ATTR_INT_GET_VITAL_MODE - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: X - getter: O Change-Id: I8b1819d0171b0406b1eaf2b92d9e044e55408df2 Signed-off-by: Youngjae Cho --- .../include/syscommon-plugin-deviced-power-interface.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h index c28b7e8..40b7065 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h @@ -35,6 +35,7 @@ extern "C" { #define DEVICED_POWER_ATTR_UINT64_CURRENT_STATE (1ULL << 1) #define DEVICED_POWER_ATTR_INT_WAKEUP_REASON (1ULL << 2) #define DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK (1ULL << 3) +#define DEVICED_POWER_ATTR_INT_GET_VITAL_MODE (1ULL << 4) enum { DEVICED_POWER_STATE_MIN_INDEX, @@ -102,6 +103,16 @@ static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(co return DEVICED_POWER_STATE_UNDEFINED; } +/* + * Vital state enumeration + */ +enum syscommon_deviced_vital_state { + SYSCOMMON_DEVICED_VITAL_SLEEP, /* suspend state */ + SYSCOMMON_DEVICED_VITAL_WAKEUP, /* resume state */ + SYSCOMMON_DEVICED_VITAL_DISPLAY_WAKEUP, + SYSCOMMON_DEVICED_VITAL_EXIT, +}; + #ifdef __cplusplus } #endif -- 2.7.4 From e45b4c9d5237fe2ca4a58f0a9c10bca253185e6f Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 21 Aug 2023 18:03:45 +0900 Subject: [PATCH 03/16] resource-manager: Add new getter with user data Until now, getter function has only passed the data to get the data without any other arguments. But, it has the constraint which is not able to pass the user data and then get the data. So thet add new following getter funciton with passed user data: - int syscommon_resman_get_resource_attr_uint64_with_1_user_data( int resource_id, u_int64_t attr_id, u_int64_t *user_data1, u_int64_t *data); : This function is able to pass the one user data in order to get data from resource attirbute. : SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA data type should be used for this new getter function. - int syscommon_resman_get_resource_attr_uint64_with_2_user_data( int resource_id, u_int64_t attr_id, u_int64_t *user_data1, u_int64_t *user_data2, u_int64_t *data); : This function is able to pass the two user data in order to get data from resource attirbute. : SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA data type should be used for this new getter function. Change-Id: Ic406fe4bad5e952472769f4ec634544a4d45d0a8 Signed-off-by: Chanwoo Choi --- include/libsyscommon/resource-manager.h | 11 ++++ include/libsyscommon/resource-type.h | 4 ++ src/resource-manager/resource-manager.c | 100 ++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/include/libsyscommon/resource-manager.h b/include/libsyscommon/resource-manager.h index c7bb435..838895d 100644 --- a/include/libsyscommon/resource-manager.h +++ b/include/libsyscommon/resource-manager.h @@ -67,6 +67,13 @@ struct syscommon_resman_resource_attribute_ops { int (*get)(int resource_id, const struct syscommon_resman_resource_attribute *attr, void *data); + int (*get_with_1_user_data)(int resource_id, + const struct syscommon_resman_resource_attribute *attr, + void *user_data1, int user_count1, void *data); + int (*get_with_2_user_data)(int resource_id, + const struct syscommon_resman_resource_attribute *attr, + void *user_data1, void *user_data2, + int user_count1, int user_count2, void *data); /* * If .is_supported ops is not implemented, use .get ops in order to * check whether the resource attribute is supported or not. @@ -205,6 +212,10 @@ int syscommon_resman_get_resource_attr_int(int resource_id, u_int64_t attr_id, i int syscommon_resman_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data); int syscommon_resman_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t *data); int syscommon_resman_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t *data); +int syscommon_resman_get_resource_attr_uint64_with_1_user_data(int resource_id, u_int64_t attr_id, + u_int64_t *user_data1, u_int64_t *data); +int syscommon_resman_get_resource_attr_uint64_with_2_user_data(int resource_id, u_int64_t attr_id, + u_int64_t *user_data1, u_int64_t *user_data2, u_int64_t *data); int syscommon_resman_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data); int syscommon_resman_get_resource_attr_string(int resource_id, u_int64_t attr_id, char *data); int syscommon_resman_get_resource_attr_array(int resource_id, u_int64_t attr_id, struct syscommon_resman_array_value **data); diff --git a/include/libsyscommon/resource-type.h b/include/libsyscommon/resource-type.h index abb460a..b2f98ba 100644 --- a/include/libsyscommon/resource-type.h +++ b/include/libsyscommon/resource-type.h @@ -39,6 +39,10 @@ enum syscommon_resman_data_type { SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64_UINT64, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64_UINT64_UINT64, + + SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA, + SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA, + SYSCOMMON_RESMAN_DATA_TYPE_NUM }; diff --git a/src/resource-manager/resource-manager.c b/src/resource-manager/resource-manager.c index 95d5bd3..62dddca 100644 --- a/src/resource-manager/resource-manager.c +++ b/src/resource-manager/resource-manager.c @@ -477,6 +477,70 @@ update_resource_attr(struct syscommon_resman_resource *resource, u_int64_t attr_ } static int +update_resource_attr_with_1_user_data(struct syscommon_resman_resource *resource, u_int64_t attr_id, + u_int64_t *user_data1, int user_count1) +{ + int attr_index; + const struct syscommon_resman_resource_attribute *attr = NULL; + struct syscommon_resman_resource_attribute_value *attr_value = NULL; + int ret; + + if (!resource || attr_id == 0) + return -EINVAL; + + attr_index = RESOURCE_ATTR_INDEX(attr_id); + if (attr_index >= resource->num_attrs) + return -EINVAL; + + attr = &resource->attrs[attr_index]; + + if (!attr->ops.get) + return -EINVAL; + + attr_value = &resource->attrs_value[attr_index]; + + ret = attr->ops.get_with_1_user_data(resource->id, attr, + user_data1, user_count1, attr_value->data); + if (ret < 0) + return ret; + + return 0; +} + +static int +update_resource_attr_with_2_user_data(struct syscommon_resman_resource *resource, u_int64_t attr_id, + u_int64_t *user_data1, u_int64_t *user_data2, + int user_count1, int user_count2) +{ + int attr_index; + const struct syscommon_resman_resource_attribute *attr = NULL; + struct syscommon_resman_resource_attribute_value *attr_value = NULL; + int ret; + + if (!resource || attr_id == 0) + return -EINVAL; + + attr_index = RESOURCE_ATTR_INDEX(attr_id); + if (attr_index >= resource->num_attrs) + return -EINVAL; + + attr = &resource->attrs[attr_index]; + + if (!attr->ops.get) + return -EINVAL; + + attr_value = &resource->attrs_value[attr_index]; + + ret = attr->ops.get_with_2_user_data(resource->id, attr, + user_data1, user_data2, + user_count1, user_count2, attr_value->data); + if (ret < 0) + return ret; + + return 0; +} + +static int monitor_update_resource_attr(struct syscommon_resman_resource *resource, u_int64_t attr_id) { int attr_index; @@ -1042,6 +1106,8 @@ get_resource_attr_value_data(struct syscommon_resman_resource *resource, u_int64 *(u_int32_t *) data = *((u_int32_t *)attr_value->data); break; case SYSCOMMON_RESMAN_DATA_TYPE_UINT64: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA: *(u_int64_t *) data = *((u_int64_t *)attr_value->data); break; case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE: @@ -1130,6 +1196,38 @@ syscommon_resman_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_ } int +syscommon_resman_get_resource_attr_uint64_with_1_user_data(int resource_id, u_int64_t attr_id, u_int64_t *user_data1, u_int64_t *data) +{ + struct syscommon_resman_resource *resource = find_resource(resource_id); + int ret; + + if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) + return -EINVAL; + + ret = update_resource_attr_with_1_user_data(resource, attr_id, user_data1, 1); + if (ret < 0) + return ret; + + return get_resource_attr_value_data(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA, data); +} + +int +syscommon_resman_get_resource_attr_uint64_with_2_user_data(int resource_id, u_int64_t attr_id, u_int64_t *user_data1, u_int64_t *user_data2, u_int64_t *data) +{ + struct syscommon_resman_resource *resource = find_resource(resource_id); + int ret; + + if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) + return -EINVAL; + + ret = update_resource_attr_with_2_user_data(resource, attr_id, user_data1, user_data2, 1, 1); + if (ret < 0) + return ret; + + return get_resource_attr_value_data(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA, data); +} + +int syscommon_resman_get_resource_attr_double(int resource_id, u_int64_t attr_id, double *data) { struct syscommon_resman_resource *resource = find_resource(resource_id); @@ -1656,6 +1754,8 @@ set_resource_attr_interest(struct syscommon_resman_resource *resource, u_int64_t attr_value->data = calloc(1, sizeof(u_int32_t)); break; case SYSCOMMON_RESMAN_DATA_TYPE_UINT64: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA: attr_value->data = calloc(1, sizeof(u_int64_t)); break; case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE: -- 2.7.4 From c5505e9edea2724f7991c5b6aec0a73da4798762 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 21 Aug 2023 18:26:29 +0900 Subject: [PATCH 04/16] resource-manager: Gather the related funciton of set_resource_attr_uint64 Gather the related funciton of set_resource_attr_uint64 in order to improve the readability as following: int syscommon_resman_set_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t data); int syscommon_resman_set_resource_attr_uint64_2(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2); int syscommon_resman_set_resource_attr_uint64_3(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2, u_int64_t data3); int syscommon_resman_set_resource_attr_uint64_4(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2, u_int64_t data3, u_int64_t data4); Change-Id: I45e2a8736af3e1f2a397298629c50fe78acd2e1a Signed-off-by: Chanwoo Choi --- include/libsyscommon/resource-manager.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/libsyscommon/resource-manager.h b/include/libsyscommon/resource-manager.h index 838895d..17d9d72 100644 --- a/include/libsyscommon/resource-manager.h +++ b/include/libsyscommon/resource-manager.h @@ -234,17 +234,16 @@ int syscommon_resman_set_resource_attr_int(int resource_id, u_int64_t attr_id, i int syscommon_resman_set_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t data); int syscommon_resman_set_resource_attr_uint(int resource_id, u_int64_t attr_id, u_int32_t data); int syscommon_resman_set_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_int64_t data); -int syscommon_resman_set_resource_attr_double(int resource_id, u_int64_t attr_id, double data); -int syscommon_resman_set_resource_attr_string(int resource_id, u_int64_t attr_id, char data); -int syscommon_resman_set_resource_attr_array(int resource_id, u_int64_t attr_id, void *data, int count); -int syscommon_resman_set_resource_attr_ptr(int resource_id, u_int64_t attr_id, void *data); - int syscommon_resman_set_resource_attr_uint64_2(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2); int syscommon_resman_set_resource_attr_uint64_3(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2, u_int64_t data3); int syscommon_resman_set_resource_attr_uint64_4(int resource_id, u_int64_t attr_id, u_int64_t data1, u_int64_t data2, u_int64_t data3, u_int64_t data4); +int syscommon_resman_set_resource_attr_double(int resource_id, u_int64_t attr_id, double data); +int syscommon_resman_set_resource_attr_string(int resource_id, u_int64_t attr_id, char data); +int syscommon_resman_set_resource_attr_array(int resource_id, u_int64_t attr_id, void *data, int count); +int syscommon_resman_set_resource_attr_ptr(int resource_id, u_int64_t attr_id, void *data); int syscommon_resman_set_resource_attr_interest(int resource_id, u_int64_t interest_mask); int syscommon_resman_unset_resource_attr_interest(int resource_id, u_int64_t interest_mask); -- 2.7.4 From 4f7cb8159fb52f2410d37b3d6f77e65966609149 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 20:51:53 +0900 Subject: [PATCH 05/16] plugin-api: deviced: Add attribute for display actor capability New attribute: - id: DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY - type: SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA - setter: X - getter: O - 1st param: syscommon_deviced_display_actor_id - 2nd param: syscommon_deviced_display_capability It finds whether an actor id has an capability. New attribute: - id: DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY - type: SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64_UINT64 - setter: O - getter: X - 1st param: syscommon_deviced_display_actor_id - 2nd param: syscommon_deviced_display_capability - 3rd param: 0: reset, 1: set It sets/resets capability of an actor id. Change-Id: Ib63c31f10c5180b48cd677be1d6e3e11538580aa Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-display-interface.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h index 6f1dfac..b53329a 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h @@ -38,6 +38,8 @@ extern "C" { #define DEVICED_DISPLAY_ATTR_INT_DPMS_STATE (1ULL << 3) #define DEVICED_DISPLAY_ATTR_TUPLE2_SET_DISPLAY_DIRECT (1ULL << 4) #define DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS (1ULL << 5) +#define DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY (1ULL << 6) +#define DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY (1ULL << 7) enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_START, @@ -102,6 +104,25 @@ struct syscommon_deviced_display_config { enum syscommon_deviced_dpms_type display_dpms_type; }; +enum syscommon_deviced_display_actor_id { + SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY = 1, + SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY, + SYSCOMMON_DEVICED_DISPLAY_ACTOR_API, + SYSCOMMON_DEVICED_DISPLAY_ACTOR_GESTURE, +}; + +struct syscommon_deviced_display_actor_ops { + enum syscommon_deviced_display_actor_id id; + unsigned int caps; +}; + +enum syscommon_deviced_display_capability { + SYSCOMMON_DEVICED_DISPLAY_CAPA_BRIGHTNESS = 1 << 0, + SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON = 1 << 1, + SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF = 1 << 2, + SYSCOMMON_DEVICED_DISPLAY_CAPA_POWEROFF = 1 << 3, +}; + #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) #ifdef __cplusplus -- 2.7.4 From 22bffed7e40d74f652a9ea71c2402e218d77ab48 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 22 Aug 2023 11:15:23 +0900 Subject: [PATCH 06/16] plugin-api: deviced: Add attribute for touch event blocked New attribute: - id: DEVICED_DISPLAY_ATTR_INT_GET_TOUCH_EVENT_BLOCKED - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: X - getter: O Change-Id: Idf5030debd46da3ed88851e61198ddd52cbd3e85 Signed-off-by: Youngjae Cho --- .../deviced/include/syscommon-plugin-deviced-display-interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h index b53329a..38c0790 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h @@ -40,6 +40,7 @@ extern "C" { #define DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS (1ULL << 5) #define DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY (1ULL << 6) #define DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY (1ULL << 7) +#define DEVICED_DISPLAY_ATTR_INT_GET_TOUCH_EVENT_BLOCKED (1ULL << 8) enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_START, -- 2.7.4 From b8a646486515a3249f5853414a283672e2152aac Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 22 Aug 2023 11:32:05 +0900 Subject: [PATCH 07/16] plugin-api: deviced: Add attribute for release all display lock Change-Id: I988fdb0a18073a88f3a63b399f58105959c53ceb Signed-off-by: Youngjae Cho --- .../deviced/include/syscommon-plugin-deviced-display-interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h index 38c0790..7f09817 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h @@ -41,6 +41,7 @@ extern "C" { #define DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY (1ULL << 6) #define DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY (1ULL << 7) #define DEVICED_DISPLAY_ATTR_INT_GET_TOUCH_EVENT_BLOCKED (1ULL << 8) +#define DEVICED_DISPLAY_ATTR_INT_SET_RELEASE_LOCK_ALL (1ULL << 9) enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_START, -- 2.7.4 From b3d9cba49b6a51b045b93c5ee04391ba92e64e92 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 22 Aug 2023 11:57:32 +0900 Subject: [PATCH 08/16] plugin-api: deviced: Add deviced_event DEVICED_EVENT_INPUT_BACKKEY Change-Id: If05c2d43ec9230cc085465aee42dda8ab8e1b63a Signed-off-by: Youngjae Cho --- .../deviced/include/syscommon-plugin-deviced-common-interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h index 6b1175f..4e18d39 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h @@ -70,6 +70,7 @@ enum deviced_event { /* input */ DEVICED_EVENT_INPUT, DEVICED_EVENT_INPUT_POWERKEY, + DEVICED_EVENT_INPUT_BACKKEY, DEVICED_EVENT_INPUT_BEZEL, /* power */ -- 2.7.4 From 29fa9ba9511b85edb48b5be5b3ab20a8c70ce27a Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 22 Aug 2023 16:42:02 +0900 Subject: [PATCH 09/16] plugin-api: deviced: Add attribute for power history log 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 In addition, added enum syscommon_deviced_power_log_type for the power history log. Change-Id: Ibdebeac6fa97bfd6705c251b694314dad11a98e6 Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-power-interface.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h index 40b7065..b7eb153 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h @@ -36,6 +36,7 @@ extern "C" { #define DEVICED_POWER_ATTR_INT_WAKEUP_REASON (1ULL << 2) #define DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK (1ULL << 3) #define DEVICED_POWER_ATTR_INT_GET_VITAL_MODE (1ULL << 4) +#define DEVICED_POWER_ATTR_TUPLE2_SET_HISTORY_LOG (1ULL << 5) enum { DEVICED_POWER_STATE_MIN_INDEX, @@ -113,6 +114,24 @@ enum syscommon_deviced_vital_state { SYSCOMMON_DEVICED_VITAL_EXIT, }; +enum syscommon_deviced_power_log_type { + SYSCOMMON_DEVICED_POWER_LOG_TYPE_MIN = 0, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_PRESS = SYSCOMMON_DEVICED_POWER_LOG_TYPE_MIN, /* key log */ + SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_LONG_PRESS, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_KEY_RELEASE, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_ON, /* lcd log */ + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_ON_COMPLETE, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_ON_FAIL, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_DIM, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_DIM_FAIL, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_OFF, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_OFF_COMPLETE, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_OFF_FAIL, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_LCD_CONTROL_FAIL, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_SLEEP, + SYSCOMMON_DEVICED_POWER_LOG_TYPE_MAX +}; + #ifdef __cplusplus } #endif -- 2.7.4 From 7412ea8bcc98594f6424e4e77154c184e3734c7f Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 21 Aug 2023 19:12:32 +0900 Subject: [PATCH 10/16] plugin-api: common: Add SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY plugin module Add SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY for display plugin module. [Detailed description] 1. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY plugin module - module : SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY - library_name : "/usr/lib/system/plugin/libplugin-backend-deviced-display.so" - library_name_64bit : "/usr/lib64/system/plugin/libplugin-backend-deviced-display.so" - symbol_name : "system_plugin_backend_deviced_display_data" 2. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY plugin api - int syscommon_plugin_deviced_display_get_backend(void) : Load deviced display plugin-backend from above library_name/library_name_64bit path - int syscommon_plugin_deviced_display_put_backend(void); : Unload Deviced display plugin-backend Change-Id: I51ea96d56046d09b10d449c1455c97575837fdee Signed-off-by: Chanwoo Choi --- .../common/include/syscommon-plugin-common.h | 1 + .../common/src/syscommon-plugin-api-list.h | 18 +++++++ .../syscommon-plugin-deviced-display-interface.h | 4 ++ .../include/syscommon-plugin-deviced-display.h | 16 ++++++- .../deviced/src/syscommon-plugin-deviced-display.c | 56 ++++++++++++++++++++++ 5 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/plugin-api/common/include/syscommon-plugin-common.h b/src/plugin-api/common/include/syscommon-plugin-common.h index 8caccbb..13b35d7 100644 --- a/src/plugin-api/common/include/syscommon-plugin-common.h +++ b/src/plugin-api/common/include/syscommon-plugin-common.h @@ -36,6 +36,7 @@ enum syscommon_plugin_module { SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK, SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY, SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY, SYSCOMMON_PLUGIN_MODULE_END, }; diff --git a/src/plugin-api/common/src/syscommon-plugin-api-list.h b/src/plugin-api/common/src/syscommon-plugin-api-list.h index cf92695..29562d1 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -54,6 +54,12 @@ static struct plugin_abi_version_match abi_version_match_data[SYSCOMMON_PLUGIN_M .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, }, }, + [SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY] = { + [0] = { + .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + }, + }, }; static struct __plugin_module_info g_plugin_module_info[] = { @@ -93,6 +99,18 @@ static struct __plugin_module_info g_plugin_module_info[] = { .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT]), .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT], }, + [SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY] = { + .group = PLUGIN_GROUP_DEVICED, + .module = SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY, + .license = PLUGIN_LICENSE_APACHE_2_0, + .module_name = "SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY", + .backend_module_name = "deviced-display", + .library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-display.so", + .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-display.so", + .symbol_name = "system_plugin_backend_deviced_display_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY]), + .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY], + }, }; #endif /* __PLUGIN_API_LIST_H__ */ diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h index 7f09817..aec7526 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h @@ -127,6 +127,10 @@ enum syscommon_deviced_display_capability { #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) +typedef struct _syscommon_plugin_backend_deviced_display_funcs { + /* NONE */ +} syscommon_plugin_backend_deviced_display_funcs; + #ifdef __cplusplus } #endif diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h index bd6c437..1e7a034 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h @@ -29,8 +29,20 @@ extern "C" { #endif -#include -#include +#include "syscommon-plugin-deviced-common-interface.h" +#include "syscommon-plugin-deviced-display-interface.h" + +/** + * @brief Get the backend data of deviced-display module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_display_get_backend(void); + +/** + * @brief Put the backend data of deviced-display module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_display_put_backend(void); #ifdef __cplusplus } diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c index f07bd13..ba04d4e 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c @@ -21,3 +21,59 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include + +#include "syscommon-plugin-common.h" + +#include "common.h" +#include "syscommon-plugin-deviced-display.h" +#include "syscommon-plugin-deviced-display-interface.h" + +#ifndef EXPORT +#define EXPORT __attribute__((visibility("default"))) +#endif + +static syscommon_plugin_backend_deviced_display_funcs *g_display_funcs = NULL; + +EXPORT +int syscommon_plugin_deviced_display_get_backend(void) +{ + int ret = 0; + + if (g_display_funcs) + return 0; + + ret = syscommon_plugin_common_get_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY, + (void **)&g_display_funcs); + if (ret < 0) { + _E("Failed to get deviced_display backend: %d", ret); + return ret; + } + + _I("Success to get deviced_display backend: %d", ret); + + return 0; +} + +EXPORT +int syscommon_plugin_deviced_display_put_backend(void) +{ + int ret = 0; + + if (!g_display_funcs) + return 0; + + ret = syscommon_plugin_common_put_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY, + (void *)g_display_funcs); + if (ret < 0) { + _E("Failed to put deviced_display backend: %d", ret); + return ret; + } + g_display_funcs = NULL; + + _I("Success to put deviced_display backend: %d", ret); + + return 0; +} -- 2.7.4 From 17afc1b405334efcd8099b681c058fc9fea175a1 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 22 Aug 2023 19:43:10 +0900 Subject: [PATCH 11/16] plugin-api: Change the header including style and remove duplicate common.h In order to specify the path of header file, change the header including style as following and the remove the duplicated common.h including log macro. - Before header including style #include "syscommon-plugin-common.h" #include "syscommon-plugin-common-interface.h" - After header including style #include #include Change-Id: I723114be26e7891661dcc7ac02fd7d1ceb8dc0a1 Signed-off-by: Chanwoo Choi --- src/plugin-api/common/CMakeLists.txt | 2 +- .../syscommon-plugin-common-interface.h | 0 .../include/{ => system}/syscommon-plugin-common.h | 0 src/plugin-api/common/src/common.h | 2 +- .../common/src/syscommon-plugin-api-conf.c | 4 +-- .../common/src/syscommon-plugin-api-conf.h | 2 +- .../common/src/syscommon-plugin-api-list.h | 2 +- src/plugin-api/deviced/CMakeLists.txt | 2 +- .../syscommon-plugin-deviced-battery-interface.h | 0 .../syscommon-plugin-deviced-battery.h | 0 .../syscommon-plugin-deviced-common-interface.h | 0 .../syscommon-plugin-deviced-display-interface.h | 0 .../syscommon-plugin-deviced-display.h | 4 +-- .../syscommon-plugin-deviced-input-interface.h | 0 .../{ => system}/syscommon-plugin-deviced-input.h | 0 .../syscommon-plugin-deviced-power-interface.h | 0 .../{ => system}/syscommon-plugin-deviced-power.h | 0 src/plugin-api/deviced/src/common.h | 42 ---------------------- .../deviced/src/syscommon-plugin-deviced-battery.c | 8 ++--- .../deviced/src/syscommon-plugin-deviced-display.c | 8 ++--- .../deviced/src/syscommon-plugin-deviced-input.c | 8 ++--- src/plugin-api/resourced/CMakeLists.txt | 2 +- ...scommon-plugin-resourced-memory-lmk-interface.h | 0 .../syscommon-plugin-resourced-memory-lmk.h | 0 src/plugin-api/resourced/src/common.h | 42 ---------------------- .../src/syscommon-plugin-resourced-memory-lmk.c | 8 ++--- 26 files changed, 26 insertions(+), 110 deletions(-) rename src/plugin-api/common/include/{ => system}/syscommon-plugin-common-interface.h (100%) rename src/plugin-api/common/include/{ => system}/syscommon-plugin-common.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-battery-interface.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-battery.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-common-interface.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-display-interface.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-display.h (93%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-input-interface.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-input.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-power-interface.h (100%) rename src/plugin-api/deviced/include/{ => system}/syscommon-plugin-deviced-power.h (100%) delete mode 100644 src/plugin-api/deviced/src/common.h rename src/plugin-api/resourced/include/{ => system}/syscommon-plugin-resourced-memory-lmk-interface.h (100%) rename src/plugin-api/resourced/include/{ => system}/syscommon-plugin-resourced-memory-lmk.h (100%) delete mode 100644 src/plugin-api/resourced/src/common.h diff --git a/src/plugin-api/common/CMakeLists.txt b/src/plugin-api/common/CMakeLists.txt index 666d51f..d6eea2b 100644 --- a/src/plugin-api/common/CMakeLists.txt +++ b/src/plugin-api/common/CMakeLists.txt @@ -47,7 +47,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_LDFLAGS} SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/system/ DESTINATION ${INCLUDEDIR} FILES_MATCHING PATTERN "*.h") diff --git a/src/plugin-api/common/include/syscommon-plugin-common-interface.h b/src/plugin-api/common/include/system/syscommon-plugin-common-interface.h similarity index 100% rename from src/plugin-api/common/include/syscommon-plugin-common-interface.h rename to src/plugin-api/common/include/system/syscommon-plugin-common-interface.h diff --git a/src/plugin-api/common/include/syscommon-plugin-common.h b/src/plugin-api/common/include/system/syscommon-plugin-common.h similarity index 100% rename from src/plugin-api/common/include/syscommon-plugin-common.h rename to src/plugin-api/common/include/system/syscommon-plugin-common.h diff --git a/src/plugin-api/common/src/common.h b/src/plugin-api/common/src/common.h index a89fe09..44e99fd 100644 --- a/src/plugin-api/common/src/common.h +++ b/src/plugin-api/common/src/common.h @@ -27,7 +27,7 @@ #include -#include "syscommon-plugin-common.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/plugin-api/common/src/syscommon-plugin-api-conf.c b/src/plugin-api/common/src/syscommon-plugin-api-conf.c index 19daa1a..0525b0a 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-conf.c +++ b/src/plugin-api/common/src/syscommon-plugin-api-conf.c @@ -27,8 +27,8 @@ #include #include -#include "syscommon-plugin-common.h" -#include "syscommon-plugin-common-interface.h" +#include +#include #include "common.h" #include "syscommon-plugin-api-conf.h" diff --git a/src/plugin-api/common/src/syscommon-plugin-api-conf.h b/src/plugin-api/common/src/syscommon-plugin-api-conf.h index 20e8b32..17dbbe8 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-conf.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-conf.h @@ -28,7 +28,7 @@ #include #include -#include "syscommon-plugin-common-interface.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/plugin-api/common/src/syscommon-plugin-api-list.h b/src/plugin-api/common/src/syscommon-plugin-api-list.h index 29562d1..9271370 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -25,7 +25,7 @@ #ifndef __SYSCOMMON_PLUGIN_API_LIST_H__ #define __SYSCOMMON_PLUGIN_API_LIST_H__ -#include "syscommon-plugin-common.h" +#include #include "common.h" diff --git a/src/plugin-api/deviced/CMakeLists.txt b/src/plugin-api/deviced/CMakeLists.txt index 644c594..c51dce5 100644 --- a/src/plugin-api/deviced/CMakeLists.txt +++ b/src/plugin-api/deviced/CMakeLists.txt @@ -53,7 +53,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${PLUGIN_API_DEVICED_VE SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PLUGIN_API_DEVICED_MAJORVER}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/system/ DESTINATION ${INCLUDEDIR} FILES_MATCHING PATTERN "*.h" ) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-battery-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery-interface.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-battery-interface.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery-interface.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-battery.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-battery.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-common-interface.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-common-interface.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-common-interface.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-display-interface.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h similarity index 93% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h index 1e7a034..d284e62 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-display.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h @@ -29,8 +29,8 @@ extern "C" { #endif -#include "syscommon-plugin-deviced-common-interface.h" -#include "syscommon-plugin-deviced-display-interface.h" +#include +#include /** * @brief Get the backend data of deviced-display module diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-input-interface.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-input-interface.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-input.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-input.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-power-interface.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-power-interface.h diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-power.h similarity index 100% rename from src/plugin-api/deviced/include/syscommon-plugin-deviced-power.h rename to src/plugin-api/deviced/include/system/syscommon-plugin-deviced-power.h diff --git a/src/plugin-api/deviced/src/common.h b/src/plugin-api/deviced/src/common.h deleted file mode 100644 index 236c616..0000000 --- a/src/plugin-api/deviced/src/common.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2023 Samsung Electronics Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#ifdef ENABLE_DLOG -#include - -#define _D(fmt, args...) SLOGD(fmt, ##args) -#define _I(fmt, args...) SLOGI(fmt, ##args) -#define _W(fmt, args...) SLOGW(fmt, ##args) -#define _E(fmt, args...) SLOGE(fmt, ##args) -#else -#define _D(fmt, args...) do { } while(0) -#define _I(fmt, args...) do { } while(0) -#define _W(fmt, args...) do { } while(0) -#define _E(fmt, args...) do { } while(0) -#endif - -#endif /* __COMMON_H__ */ diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-battery.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-battery.c index f242f2d..bf459ae 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-battery.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-battery.c @@ -23,11 +23,11 @@ */ #include -#include "syscommon-plugin-common.h" +#include -#include "common.h" -#include "syscommon-plugin-deviced-battery.h" -#include "syscommon-plugin-deviced-battery-interface.h" +#include +#include +#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c index ba04d4e..8819c47 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c @@ -23,11 +23,11 @@ */ #include -#include "syscommon-plugin-common.h" +#include -#include "common.h" -#include "syscommon-plugin-deviced-display.h" -#include "syscommon-plugin-deviced-display-interface.h" +#include +#include +#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c index 350e574..2e74d8c 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c @@ -23,11 +23,11 @@ */ #include -#include "syscommon-plugin-common.h" +#include -#include "common.h" -#include "syscommon-plugin-deviced-input.h" -#include "syscommon-plugin-deviced-input-interface.h" +#include +#include +#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) diff --git a/src/plugin-api/resourced/CMakeLists.txt b/src/plugin-api/resourced/CMakeLists.txt index 9060f8e..d595753 100644 --- a/src/plugin-api/resourced/CMakeLists.txt +++ b/src/plugin-api/resourced/CMakeLists.txt @@ -52,7 +52,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${PLUGIN_API_RESOURCED_ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PLUGIN_API_RESOURCED_MAJORVER}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/system/ DESTINATION ${INCLUDEDIR} FILES_MATCHING PATTERN "*.h" ) diff --git a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h similarity index 100% rename from src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h rename to src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h diff --git a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h similarity index 100% rename from src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h rename to src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h diff --git a/src/plugin-api/resourced/src/common.h b/src/plugin-api/resourced/src/common.h deleted file mode 100644 index 236c616..0000000 --- a/src/plugin-api/resourced/src/common.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2023 Samsung Electronics Co., Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#ifdef ENABLE_DLOG -#include - -#define _D(fmt, args...) SLOGD(fmt, ##args) -#define _I(fmt, args...) SLOGI(fmt, ##args) -#define _W(fmt, args...) SLOGW(fmt, ##args) -#define _E(fmt, args...) SLOGE(fmt, ##args) -#else -#define _D(fmt, args...) do { } while(0) -#define _I(fmt, args...) do { } while(0) -#define _W(fmt, args...) do { } while(0) -#define _E(fmt, args...) do { } while(0) -#endif - -#endif /* __COMMON_H__ */ diff --git a/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c b/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c index 431625a..0d97201 100644 --- a/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c @@ -25,11 +25,11 @@ #include #include -#include "syscommon-plugin-common.h" +#include -#include "common.h" -#include "syscommon-plugin-resourced-memory-lmk.h" -#include "syscommon-plugin-resourced-memory-lmk-interface.h" +#include +#include +#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) -- 2.7.4 From 3fa3646359a9c612519fade29176da073b10663c Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 22 Aug 2023 19:55:51 +0900 Subject: [PATCH 12/16] plugin-api: common: Remove log macro from common.h to use libsyscommon/log.h Change-Id: I4de1c0b035397d4c58a702665696bd64233d4885 Signed-off-by: Chanwoo Choi --- src/plugin-api/common/src/common.h | 14 -------------- src/plugin-api/common/src/syscommon-plugin-api-common.c | 2 ++ src/plugin-api/common/src/syscommon-plugin-api-conf.c | 2 ++ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/plugin-api/common/src/common.h b/src/plugin-api/common/src/common.h index 44e99fd..d33b4ae 100644 --- a/src/plugin-api/common/src/common.h +++ b/src/plugin-api/common/src/common.h @@ -33,20 +33,6 @@ extern "C" { #endif -#ifdef ENABLE_DLOG -#include - -#define _D(fmt, args...) SLOGD(fmt, ##args) -#define _I(fmt, args...) SLOGI(fmt, ##args) -#define _W(fmt, args...) SLOGW(fmt, ##args) -#define _E(fmt, args...) SLOGE(fmt, ##args) -#else -#define _D(fmt, args...) do { } while(0) -#define _I(fmt, args...) do { } while(0) -#define _W(fmt, args...) do { } while(0) -#define _E(fmt, args...) do { } while(0) -#endif - #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) enum plugin_license { diff --git a/src/plugin-api/common/src/syscommon-plugin-api-common.c b/src/plugin-api/common/src/syscommon-plugin-api-common.c index b6fb3db..7ff51d3 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-common.c +++ b/src/plugin-api/common/src/syscommon-plugin-api-common.c @@ -35,6 +35,8 @@ #include +#include + #include "common.h" #include "syscommon-plugin-api-conf.h" diff --git a/src/plugin-api/common/src/syscommon-plugin-api-conf.c b/src/plugin-api/common/src/syscommon-plugin-api-conf.c index 0525b0a..1e25c4a 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-conf.c +++ b/src/plugin-api/common/src/syscommon-plugin-api-conf.c @@ -27,6 +27,8 @@ #include #include +#include + #include #include -- 2.7.4 From 46d0830e85e75e4478278f3a042567c430076a3b Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 23 Aug 2023 15:46:51 +0900 Subject: [PATCH 13/16] plugin-api: deviced: Add attribute for display config New attribute: - id: DEVICED_DISPLAY_ATTR_INT_GET_CONFIG_POWERKEY_DOUBLEPRESS - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: X - getter: O New attribute: - id: DEVICED_DISPLAY_ATTR_INT_GET_CONFIG_LONGPRESS_INTERVAL - type: SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE - setter: X - getter: O New attribute: - id: DEVICED_DISPLAY_ATTR_INT_GET_CONFIG_TOUCH_WAKEUP - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: X - getter: O Change-Id: I841459f76e6a4a75379c53d9875006823917c570 Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-display-interface.h | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h index aec7526..c3fb99d 100644 --- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h @@ -32,16 +32,19 @@ extern "C" { #include #include -#define DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS (1ULL << 0) -#define DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE (1ULL << 1) -#define DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE (1ULL << 2) -#define DEVICED_DISPLAY_ATTR_INT_DPMS_STATE (1ULL << 3) -#define DEVICED_DISPLAY_ATTR_TUPLE2_SET_DISPLAY_DIRECT (1ULL << 4) -#define DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS (1ULL << 5) -#define DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY (1ULL << 6) -#define DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY (1ULL << 7) -#define DEVICED_DISPLAY_ATTR_INT_GET_TOUCH_EVENT_BLOCKED (1ULL << 8) -#define DEVICED_DISPLAY_ATTR_INT_SET_RELEASE_LOCK_ALL (1ULL << 9) +#define DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS (1ULL << 0) +#define DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE (1ULL << 1) +#define DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE (1ULL << 2) +#define DEVICED_DISPLAY_ATTR_INT_DPMS_STATE (1ULL << 3) +#define DEVICED_DISPLAY_ATTR_TUPLE2_SET_DISPLAY_DIRECT (1ULL << 4) +#define DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS (1ULL << 5) +#define DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY (1ULL << 6) +#define DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY (1ULL << 7) +#define DEVICED_DISPLAY_ATTR_INT_GET_TOUCH_EVENT_BLOCKED (1ULL << 8) +#define DEVICED_DISPLAY_ATTR_INT_SET_RELEASE_LOCK_ALL (1ULL << 9) +#define DEVICED_DISPLAY_ATTR_INT_GET_CONFIG_POWERKEY_DOUBLEPRESS (1ULL << 10) +#define DEVICED_DISPLAY_ATTR_DOUBLE_GET_CONFIG_LONGPRESS_INTERVAL (1ULL << 11) +#define DEVICED_DISPLAY_ATTR_INT_GET_CONFIG_TOUCH_WAKEUP (1ULL << 12) enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_START, -- 2.7.4 From 68b8bc2bf8f0afb4f528968775444a7579320122 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 23 Aug 2023 17:09:44 +0900 Subject: [PATCH 14/16] plugin-api: deviced: Add syscommon_plugin_deviced_display_load_config() Add plugin API that loads display configuration that intialized by plugin. Change-Id: Ie4767a61db7dd1a222866a23f71c98b056a58607 Signed-off-by: Youngjae Cho --- .../system/syscommon-plugin-deviced-display-interface.h | 2 +- .../include/system/syscommon-plugin-deviced-display.h | 6 ++++++ .../deviced/src/syscommon-plugin-deviced-display.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h index c3fb99d..3b7ee20 100644 --- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h @@ -131,7 +131,7 @@ enum syscommon_deviced_display_capability { #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) typedef struct _syscommon_plugin_backend_deviced_display_funcs { - /* NONE */ + int (*load_display_config) (struct syscommon_deviced_display_config **); } syscommon_plugin_backend_deviced_display_funcs; #ifdef __cplusplus diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h index d284e62..b49a5bd 100644 --- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h @@ -44,6 +44,12 @@ int syscommon_plugin_deviced_display_get_backend(void); */ int syscommon_plugin_deviced_display_put_backend(void); +/** + * @brief Load the backend config of deviced-displaymodule + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_display_load_config(struct syscommon_deviced_display_config **); + #ifdef __cplusplus } #endif diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c index 8819c47..00caf73 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c @@ -77,3 +77,17 @@ int syscommon_plugin_deviced_display_put_backend(void) return 0; } + +EXPORT +int syscommon_plugin_deviced_display_load_config(struct syscommon_deviced_display_config **data) +{ + int ret = 0; + + if (!g_display_funcs) { + ret = syscommon_plugin_deviced_display_get_backend(); + if (ret < 0) + return ret; + } + + return g_display_funcs->load_display_config(data); +} -- 2.7.4 From e1fa338dee2a4687940c29ed9167258f1f8bdf2d Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 25 Aug 2023 09:57:55 +0900 Subject: [PATCH 15/16] plugin-api: deviced: Add assert() to prevent NULL dereferencing Change-Id: I55a46976ff30100468e249e02a769099da9fa0f3 Signed-off-by: Youngjae Cho --- src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c index 00caf73..57495fb 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c @@ -21,6 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include + #include #include @@ -89,5 +91,7 @@ int syscommon_plugin_deviced_display_load_config(struct syscommon_deviced_displa return ret; } + assert(g_display_funcs); + return g_display_funcs->load_display_config(data); } -- 2.7.4 From fd6bd3f76fe427c90ffa8af087de26713fdc90fb Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Wed, 9 Aug 2023 17:17:47 +0900 Subject: [PATCH 16/16] plugin-api: resourced: Add cpu boosting module Add cpu boosting governor function to be called when CPU PSI is triggered in resourced. The goal of cpu boosting governor is finding out cpu contention reason and making actions to do in cpu boosting controller. A new function called cpu boosting governor is added: - int syscommon_plugin_resourced_cpu_boosting_governor_govern_request (GHashTable *cpu_boosting_info_table, cpu_boosting_level_e cpu_boosting_level, GSList **cpu_boosting_controller_action); * This function receives cpu_boosting_info_table and cpu_boosting_level as inputs and gives cpu_boosting_controller_action as an output. If return value of this function is not 0, then cpu_boosting_controller_action is meaningless. Change-Id: Id6f7854278560fd8816a2e15021cccd7261b7027 Signed-off-by: Unsung Lee --- packaging/libsyscommon.spec | 1 + .../include/system/syscommon-plugin-common.h | 1 + .../common/src/syscommon-plugin-api-list.h | 18 ++++ src/plugin-api/resourced/CMakeLists.txt | 7 +- ...ommon-plugin-resourced-cpu-boosting-interface.h | 62 ++++++++++++ .../syscommon-plugin-resourced-cpu-boosting.h | 67 +++++++++++++ .../src/syscommon-plugin-resourced-cpu-boosting.c | 104 +++++++++++++++++++++ 7 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h create mode 100644 src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h create mode 100644 src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index bb2d003..4d2d613 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -20,6 +20,7 @@ BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(capi-system-resource) Requires: /bin/cp Requires(post): /sbin/ldconfig diff --git a/src/plugin-api/common/include/system/syscommon-plugin-common.h b/src/plugin-api/common/include/system/syscommon-plugin-common.h index 13b35d7..528c339 100644 --- a/src/plugin-api/common/include/system/syscommon-plugin-common.h +++ b/src/plugin-api/common/include/system/syscommon-plugin-common.h @@ -37,6 +37,7 @@ enum syscommon_plugin_module { SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY, SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY, + SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING, SYSCOMMON_PLUGIN_MODULE_END, }; diff --git a/src/plugin-api/common/src/syscommon-plugin-api-list.h b/src/plugin-api/common/src/syscommon-plugin-api-list.h index 9271370..248d699 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -60,6 +60,12 @@ static struct plugin_abi_version_match abi_version_match_data[SYSCOMMON_PLUGIN_M .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, }, }, + [SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING] = { + [0] = { + .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0, + }, + }, }; static struct __plugin_module_info g_plugin_module_info[] = { @@ -111,6 +117,18 @@ static struct __plugin_module_info g_plugin_module_info[] = { .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY]), .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY], }, + [SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING] = { + .group = PLUGIN_GROUP_RESOURCED, + .module = SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING, + .license = PLUGIN_LICENSE_APACHE_2_0, + .module_name = "SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING", + .backend_module_name = "resourced-cpu-boosting", + .library_name = "/usr/lib/system/plugin/libplugin-backend-resourced-cpu-boosting.so", + .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-resourced-cpu-boosting.so", + .symbol_name = "system_plugin_backend_resourced_cpu_boosting_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING]), + .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING], + }, }; #endif /* __PLUGIN_API_LIST_H__ */ diff --git a/src/plugin-api/resourced/CMakeLists.txt b/src/plugin-api/resourced/CMakeLists.txt index d595753..7b9dbe4 100644 --- a/src/plugin-api/resourced/CMakeLists.txt +++ b/src/plugin-api/resourced/CMakeLists.txt @@ -16,12 +16,14 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/include) if (${PLUGIN_API_RESOURCED_ENABLE_DLOG}) SET(PKG_MODULES glib-2.0 - dlog) + dlog + capi-system-resource) ADD_DEFINITIONS("-DENABLE_DLOG") ADD_DEFINITIONS("-DLOG_TAG=\"SYSTEM_PLUGIN_API_RESOURCED\"") else() SET(PKG_MODULES - glib-2.0) + glib-2.0 + capi-system-resource) endif() INCLUDE(FindPkgConfig) @@ -41,6 +43,7 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") # Please remove them from SRCS and add 'syscommon-plugin-api-common' # to PKG_MODULES. SET(SRCS src/syscommon-plugin-resourced-memory-lmk.c + src/syscommon-plugin-resourced-cpu-boosting.c ../common/src/syscommon-plugin-api-common.c ../common/src/syscommon-plugin-api-conf.c) diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h new file mode 100644 index 0000000..5e43274 --- /dev/null +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting-interface.h @@ -0,0 +1,62 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_INTERFACE_H__ +#define __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_INTERFACE_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct syscommon_resourced_cpu_boosting_input { + cpu_boosting_input_t client_input; + int sock; + guint *gsource_id; + bool remove_input; +}; + +struct syscommon_resourced_cpu_boosting_info { + pid_t tid; + cpu_boosting_level_e level; /* current boosting level */ + guint gsource_id; /* timer id */ + int ref_cnt; /* reference count */ + cpu_boosting_flag_e cpu_boosting_flags; +}; + +typedef struct _syscommon_plugin_backend_resourced_cpu_boosting_funcs { + int (*cpu_boosting_governor_govern_request) ( + GHashTable *cpu_boosting_info_table, + cpu_boosting_level_e cpu_boosting_level, + GSList **cpu_boosting_controller_action) +} syscommon_plugin_backend_resourced_cpu_boosting_funcs; + +#ifdef __cplusplus +} +#endif + +#endif /* __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_INTERFACE_H__ */ diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h new file mode 100644 index 0000000..1242b73 --- /dev/null +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-cpu-boosting.h @@ -0,0 +1,67 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_H__ +#define __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_H__ + +#include "syscommon-plugin-resourced-cpu-boosting-interface.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the backend data of resourced-cpu-boosting module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_resourced_cpu_boosting_get_backend(void); + +/** + * @brief Put the backend data of resourced-cpu-boosting module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_resourced_cpu_boosting_put_backend(void); + +/** + * @brief Analyze cpu contention reason and + * make a list to do for cpu boosting controller + * @param[in] cpu_boosting_info_table is a GHashTable containing cpu boosting info + * of the currently boosted thread + * @param[in] cpu_boosting_level is cpu boosting level among CPU_BOOSTING_LEVEL_STRONG, + * CPU_BOOSTING_LEVEL_MEDIUM, and CPU_BOOSTING_LEVEL_WEAK + * @param[out] cpu_boosting_controller_action is a GSList containing actions + * to be taken by cpu boosting controller + * @return @c zero on success, + * otherwise a negative error value + */ +int syscommon_plugin_resourced_cpu_boosting_governor_govern_request( + GHashTable *cpu_boosting_info_table, + cpu_boosting_level_e cpu_boosting_level, + GSList **cpu_boosting_controller_action); + +#ifdef __cplusplus +} +#endif + +#endif /* __SYSCOMMON_PLUGIN_RESOURCED_CPU_BOOSTING_H__ */ diff --git a/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c new file mode 100644 index 0000000..1bd8eea --- /dev/null +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c @@ -0,0 +1,104 @@ +/** + * MIT License + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include + +#include +#include + +#ifndef EXPORT +#define EXPORT __attribute__((visibility("default"))) +#endif + +static syscommon_plugin_backend_resourced_cpu_boosting_funcs *funcs = NULL; + +EXPORT +int syscommon_plugin_resourced_cpu_boosting_get_backend(void) +{ + int ret = 0; + + if (funcs) + return 0; + + ret = syscommon_plugin_common_get_backend( + SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING, + (void **)&funcs); + if (ret < 0) { + _E("Failed to get resourced_cpu_boosting backend: %d", ret); + return ret; + } + + _I("Success to get resourced_cpu_boosting backend: %d", ret); + + return 0; +} + +EXPORT +int syscommon_plugin_resourced_cpu_boosting_put_backend(void) +{ + int ret = 0; + + if (!funcs) + return 0; + + ret = syscommon_plugin_common_put_backend( + SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING, + (void *)funcs); + if (ret < 0) { + _E("Failed to put resourced_cpu_boosting backend: %d", ret); + return ret; + } + funcs = NULL; + + _I("Success to put resourced_cpu_boosting backend: %d", ret); + + return 0; +} + +EXPORT +int syscommon_plugin_resourced_cpu_boosting_governor_govern_request( + GHashTable *cpu_boosting_info_table, + cpu_boosting_level_e cpu_boosting_level, + GSList **cpu_boosting_controller_action) + +{ + int ret = 0; + + if (!funcs) { + ret = syscommon_plugin_resourced_cpu_boosting_get_backend(); + if (ret < 0) + return ret; + } + + assert(funcs); + if (!funcs->cpu_boosting_governor_govern_request) { + _E("No \"cpu_boosting_governor_govern_request\" function"); + return -ENOTSUP; + } + + return funcs->cpu_boosting_governor_govern_request(cpu_boosting_info_table, + cpu_boosting_level, cpu_boosting_controller_action); +} -- 2.7.4