From 22bffed7e40d74f652a9ea71c2402e218d77ab48 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 22 Aug 2023 11:15:23 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 11/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 From b1e09d725217b32726d19483bcecac2e797c5e2a Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Wed, 30 Aug 2023 17:09:51 +0900 Subject: [PATCH 12/16] plugin-api: resourced: Add is_cpu_contention_alleviated Add is_cpu_contention_alleviated function to check whether cpu contention is alleviated or not. Prototype of new function is like below: - bool syscommon_plugin_resourced_is_cpu_contention_alleviated( guint timer_id, guint latest_timer_id); * After a stall event is monitored, a timer with some interval set. If no more stall events between setting timer and timeout, timer_id is equal to latest_timer_id. Change-Id: I0136f445827ae49d002fd8dcb0919cef0ada40b9 Signed-off-by: Unsung Lee --- ...common-plugin-resourced-cpu-boosting-interface.h | 4 +++- .../syscommon-plugin-resourced-cpu-boosting.h | 9 +++++++++ .../src/syscommon-plugin-resourced-cpu-boosting.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) 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 index 5e43274..73c0c40 100644 --- 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 @@ -52,7 +52,9 @@ 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) + GSList **cpu_boosting_controller_action); + bool (*is_cpu_contention_alleviated) + (guint timer_id, guint latest_timer_id); } syscommon_plugin_backend_resourced_cpu_boosting_funcs; #ifdef __cplusplus 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 index 1242b73..598ccbd 100644 --- 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 @@ -60,6 +60,15 @@ int syscommon_plugin_resourced_cpu_boosting_governor_govern_request( cpu_boosting_level_e cpu_boosting_level, GSList **cpu_boosting_controller_action); +/** + * @brief Check whehter cpu contention is alleviated + * @param[in] timer id when handling cpu boosting level + * @param[in] timer id when monitoring the latest stall event + * @return @c true when cpu contention is alleviated, otherwise false + */ +bool syscommon_plugin_resourced_is_cpu_contention_alleviated( + guint timer_id, guint latest_timer_id); + #ifdef __cplusplus } #endif 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 index 1bd8eea..4d6739b 100644 --- a/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c @@ -102,3 +102,24 @@ int syscommon_plugin_resourced_cpu_boosting_governor_govern_request( return funcs->cpu_boosting_governor_govern_request(cpu_boosting_info_table, cpu_boosting_level, cpu_boosting_controller_action); } + +EXPORT +bool syscommon_plugin_resourced_is_cpu_contention_alleviated( + guint timer_id, guint latest_timer_id) +{ + int ret = 0; + + if (!funcs) { + ret = syscommon_plugin_resourced_cpu_boosting_get_backend(); + if (ret < 0) + return ret; + } + + assert(funcs); + if (!funcs->is_cpu_contention_alleviated) { + _E("No \"is_cpu_contention_alleviated\" function"); + return -ENOTSUP; + } + + return funcs->is_cpu_contention_alleviated(timer_id, latest_timer_id); +} -- 2.7.4 From c07f0071360337731b37a5659b3016bcf519ed2a Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Mon, 4 Sep 2023 15:36:47 +0900 Subject: [PATCH 13/16] plugin-api: resourced: Add is_cpu_busy argument into govenor func Add is_cpu_busy argument into syscommon_plugin_resourced_cpu_boosting_governor_govern_request() function to check whether system cpu is busy or not. If system cpu is not busy, then resourced cpu boosting will ignore stall event immediately. Function called cpu boosting governor is modified: - 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, bool *is_cpu_busy); * output argument called is_cpu_busy is added. Change-Id: I0827f4b5ac5ffec8c64f34c124e89176e24a6c3c Signed-off-by: Unsung Lee --- .../system/syscommon-plugin-resourced-cpu-boosting-interface.h | 2 +- .../include/system/syscommon-plugin-resourced-cpu-boosting.h | 3 ++- .../resourced/src/syscommon-plugin-resourced-cpu-boosting.c | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) 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 index 73c0c40..72fefd0 100644 --- 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 @@ -52,7 +52,7 @@ 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); + GSList **cpu_boosting_controller_action, bool *is_cpu_busy); bool (*is_cpu_contention_alleviated) (guint timer_id, guint latest_timer_id); } syscommon_plugin_backend_resourced_cpu_boosting_funcs; 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 index 598ccbd..e337bd8 100644 --- 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 @@ -52,13 +52,14 @@ int syscommon_plugin_resourced_cpu_boosting_put_backend(void); * 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 + * @param[out] is_cpu_busy is a bool info whehter system cpu is busy or not * @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); + GSList **cpu_boosting_controller_action, bool *is_cpu_busy); /** * @brief Check whehter cpu contention is alleviated 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 index 4d6739b..79bbe5c 100644 --- a/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-cpu-boosting.c @@ -82,7 +82,7 @@ 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) + GSList **cpu_boosting_controller_action, bool *is_cpu_busy) { int ret = 0; @@ -100,7 +100,8 @@ int syscommon_plugin_resourced_cpu_boosting_governor_govern_request( } return funcs->cpu_boosting_governor_govern_request(cpu_boosting_info_table, - cpu_boosting_level, cpu_boosting_controller_action); + cpu_boosting_level, cpu_boosting_controller_action, + is_cpu_busy); } EXPORT -- 2.7.4 From fc317d4802f5a515094fb29d58a0392d198d4497 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 6 Sep 2023 20:16:21 +0900 Subject: [PATCH 14/16] resource-manager: Add missing cases for unset_resource_attr_interest() Change-Id: Ibc6b4d62c3209a8826d349ae3b818c8a9c68e4f9 Signed-off-by: Youngjae Cho --- src/resource-manager/resource-manager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/resource-manager/resource-manager.c b/src/resource-manager/resource-manager.c index 62dddca..3320ee9 100644 --- a/src/resource-manager/resource-manager.c +++ b/src/resource-manager/resource-manager.c @@ -1864,6 +1864,8 @@ unset_resource_attr_interest(struct syscommon_resman_resource *resource, u_int64 case SYSCOMMON_RESMAN_DATA_TYPE_UINT64: case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE: case SYSCOMMON_RESMAN_DATA_TYPE_STRING: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA: + case SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA: free(attr_value->data); attr_value->data = NULL; break; -- 2.7.4 From 617110ad7fb7e15be6e18237ae357854ae7fa298 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Tue, 5 Sep 2023 10:41:26 +0900 Subject: [PATCH 15/16] plugin-api: resourced: Move common struct and enum from *.h to *-interface.h Move common struct and enum, referened by both resourced and resourced backend, from syscommon-plugin-resourced-memory-lmk.h to syscommon-plugin-resourced-memory-lmk-interface.h for consistency. *.h can be referenced only by resourced. On the other hand, *-interface.h can be referenced by both side. Therefore, common struct and enum should be defined in *-interface.h. Change-Id: I0529e21da6688eeebb9a0583521dc69c2e400f2c Signed-off-by: Unsung Lee --- ...scommon-plugin-resourced-memory-lmk-interface.h | 56 +++++++++++++++++++++ .../system/syscommon-plugin-resourced-memory-lmk.h | 58 +--------------------- .../src/syscommon-plugin-resourced-memory-lmk.c | 1 - 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h index a07f0c4..2d3d746 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h @@ -31,6 +31,62 @@ extern "C" { #endif +enum syscommon_resourced_memory_lmk_oom_level { + OOM_LEVEL_BACKGROUND_LEAST_RECENTLY_USED, + OOM_LEVEL_BACKGROUND_MOST_RECENTLY_USED, + OOM_LEVEL_FOREGROUND, + OOM_LEVEL_FOREGROUND_AND_PROC, + OOM_LEVEL_ALL, +}; + +struct task_info { + /* + * Mostly, there are not multiple processes with the same pgid. + * So, for the frequent case, we use pid variable to avoid + * allocating arrays. + */ + pid_t pid; + GArray *pids; + pid_t pgid; + /* oom_score_adj is smae as /proc//oom_score_adj */ + int oom_score_adj; + /* + * oom_score_lru is same as oom_score_adj or adjusted by + * proc_app_info lru_state for apps that are marked as favourite. + * + * oom_score_lru is the main value used in comparison for LMK. + */ + int oom_score_lru; + int size; + /** + * proc_app_info_oom_killed and proc_app_info_flags + * are not used if task is not an app. + * Especially, proc_app_info_oom_killed is NULL when this task + * is not an app. + */ + bool *proc_app_info_oom_killed; + int proc_app_info_flags; + + /** + * TODO: A process can have more than one window, + * and an app can have more than one process. Therefore, + * a task_info can have more than one window. + */ + int window_pid; + int x; + int y; + int z; + int w; + int h; + int layer; + int opaque; + int visibility; + bool is_transformed; + bool alpha; + bool is_focused; + bool is_mapped; +}; + typedef struct _syscommon_plugin_backend_resourced_memory_lmk_funcs { int (*get_kill_candidates)(GArray *candidates, GArray *task_info_app_array, diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h index d3d5b67..b2ac1b0 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h @@ -28,66 +28,12 @@ #include #include +#include "syscommon-plugin-resourced-memory-lmk-interface.h" + #ifdef __cplusplus extern "C" { #endif -enum syscommon_resourced_memory_lmk_oom_level { - OOM_LEVEL_BACKGROUND_LEAST_RECENTLY_USED, - OOM_LEVEL_BACKGROUND_MOST_RECENTLY_USED, - OOM_LEVEL_FOREGROUND, - OOM_LEVEL_FOREGROUND_AND_PROC, - OOM_LEVEL_ALL, -}; - -struct task_info { - /* - * Mostly, there are not multiple processes with the same pgid. - * So, for the frequent case, we use pid variable to avoid - * allocating arrays. - */ - pid_t pid; - GArray *pids; - pid_t pgid; - /* oom_score_adj is smae as /proc//oom_score_adj */ - int oom_score_adj; - /* - * oom_score_lru is same as oom_score_adj or adjusted by - * proc_app_info lru_state for apps that are marked as favourite. - * - * oom_score_lru is the main value used in comparison for LMK. - */ - int oom_score_lru; - int size; - /** - * proc_app_info_oom_killed and proc_app_info_flags - * are not used if task is not an app. - * Especially, proc_app_info_oom_killed is NULL when this task - * is not an app. - */ - bool *proc_app_info_oom_killed; - int proc_app_info_flags; - - /** - * TODO: A process can have more than one window, - * and an app can have more than one process. Therefore, - * a task_info can have more than one window. - */ - int window_pid; - int x; - int y; - int z; - int w; - int h; - int layer; - int opaque; - int visibility; - bool is_transformed; - bool alpha; - bool is_focused; - bool is_mapped; -}; - /** * @brief Get the backend data of resourced-memory-lmk module * @return @c 0 on success, otherwise a negative error value 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 0d97201..6ccb8b2 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 @@ -29,7 +29,6 @@ #include #include -#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) -- 2.7.4 From 418dfa5feca0f07cf72d714711a4d805e29fa532 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Tue, 5 Sep 2023 10:59:14 +0900 Subject: [PATCH 16/16] plugin-api: resourced: Add working set size related info in task_info resourced requires active, inactive, and swap memory size, because working set size-based resourced-lmk-governor should know them to calculate memory efficiency of each app. Normally, this information is located in memory.stat of memcg. In addition, some apps are free from LMK according to working set size. Change-Id: I8d20a3be57391fb4813f42a4704dc91f43ce1101 Signed-off-by: Unsung Lee --- .../system/syscommon-plugin-resourced-memory-lmk-interface.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h index 2d3d746..e14f60a 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h @@ -85,6 +85,13 @@ struct task_info { bool alpha; bool is_focused; bool is_mapped; + + /* These elements are required to calculate working set size of a task */ + unsigned long active_memory_kb; + unsigned long inactive_memory_kb; + unsigned long swap_memory_kb; + + bool is_free_from_kill; }; typedef struct _syscommon_plugin_backend_resourced_memory_lmk_funcs { -- 2.7.4