From d4defbfc9564f7d51dde26a22e8d7e132a26b795 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 18:06:41 +0900 Subject: [PATCH 01/16] dbus-iface-system: Add event dbus interface of deviced Add new deviced dbus interface to broadcast the event id. [Detailed description of newly added dbus information] - DEVICED_PATH_EVENT "/Org/Tizen/System/DeviceD/Event" - DEVICED_INTERFACE_EVENT "org.tizen.system.deviced.Event" - DEVICED_SIGNAL_EVENT_ID "Id" Change-Id: I5a444639b64bb47ee10f32a092b9879850c26000 Signed-off-by: Chanwoo Choi --- include/libsyscommon/dbus-iface-system.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/libsyscommon/dbus-iface-system.h b/include/libsyscommon/dbus-iface-system.h index f14227d..52338d3 100644 --- a/include/libsyscommon/dbus-iface-system.h +++ b/include/libsyscommon/dbus-iface-system.h @@ -161,6 +161,11 @@ extern "C" { #define DEVICED_PATH_INPUT DEVICED_OBJECT_PATH"/Input" #define DEVICED_INTERFACE_INPUT DEVICED_INTERFACE_NAME".input" +/* Event service: To broadcast event values */ +#define DEVICED_PATH_EVENT DEVICED_OBJECT_PATH"/Event" +#define DEVICED_INTERFACE_EVENT DEVICED_INTERFACE_NAME".Event" +#define DEVICED_SIGNAL_EVENT_ID "Id" + /******************************************************************************* * * Storage daemon (storaged) -- 2.7.4 From 9ebe7bc5c583fe49a8d56af241ef6044c63dd286 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 17 Aug 2023 20:30:14 +0900 Subject: [PATCH 02/16] libsyscommon: Add CRITICAL_LOG() It requires macro definition ENABLE_DLOG and CRITICAL_LOG_ON. Change-Id: Ic25393d9c96cd24047cff33cdaf72a25cf627706 Signed-off-by: Youngjae Cho --- include/libsyscommon/log.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/libsyscommon/log.h b/include/libsyscommon/log.h index 0d7db18..59fdb08 100644 --- a/include/libsyscommon/log.h +++ b/include/libsyscommon/log.h @@ -31,11 +31,27 @@ #define _I(fmt, args...) SLOGI(fmt, ##args) #define _W(fmt, args...) SLOGW(fmt, ##args) #define _E(fmt, args...) SLOGE(fmt, ##args) -#else + +#ifdef CRITICAL_LOG_ON +#define CRITICAL_LOG(fmt, arg...) \ + do { CRITICAL_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, fmt, ##arg); } while (0) +#define CRITICAL_LOG_E(fmt, arg...) \ + do { CRITICAL_LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, fmt, ##arg); } while (0) +#else /* CRITICAL_LOG_ON */ +#define CRITICAL_LOG(fmt, arg...) _I(fmt, ##arg) +#define CRITICAL_LOG_E(fmt, arg...) _E(fmt, ##arg) +#endif /* CRITICAL_LOG_ON */ + +#else /* ENABLE_DLOG */ + #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 CRITICAL_LOG(fmt, arg...) _I(fmt, ##arg) +#define CRITICAL_LOG_E(fmt, arg...) _E(fmt, ##arg) + +#endif /* ENABLE_DLOG */ #endif /* __LOG_H__ */ -- 2.7.4 From 913842514c326300feb34b50eba6e8e56e3b9719 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 19:44:15 +0900 Subject: [PATCH 03/16] plugin-api: deviced: power: Add syscommon_plugin_deviced_power_convert_to_power_state() syscommon_plugin_deviced_power_convert_to_power_state() plugin api converts the power action string to DEVICED_POWER_STATE_* enumeration. Change-Id: I14fb07cfa64527fceba58116977b32986c14edda Signed-off-by: Chanwoo Choi --- .../syscommon-plugin-deviced-power-interface.h | 20 ++++++++++++++++++++ 1 file changed, 20 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 4f05328..95394c1 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 @@ -73,6 +73,26 @@ enum { #define DEVICED_POWER_STATE_INDEX(state) (__builtin_ctzll(state)) +static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(const char *str) +{ + if (MATCH(str, "start")) + return DEVICED_POWER_STATE_START; + else if (MATCH(str, "sleep")) + return DEVICED_POWER_STATE_SLEEP; + else if (MATCH(str, "normal")) + return DEVICED_POWER_STATE_NORMAL; + else if (MATCH(str, "poweroff")) + return DEVICED_POWER_STATE_POWEROFF; + else if (MATCH(str, "reboot")) + return DEVICED_POWER_STATE_REBOOT; + else if (MATCH(str, "exit")) + return DEVICED_POWER_STATE_EXIT; + else if (MATCH(str, "current")) + return DEVICED_POWER_STATE_ALL; + + return DEVICED_POWER_STATE_UNDEFINED; +} + #ifdef __cplusplus } #endif -- 2.7.4 From 0ae8aa2f87c16319ceaa7efaa005fa14ac1001d8 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 19:51:40 +0900 Subject: [PATCH 04/16] plugin-api: deviced: power: Add struct syscommon_plugin_deviced_power_trans_info Add struct syscommon_plugin_deviced_power_trans_info which contains the power transition information. [Detailed description] struct syscommon_plugin_deviced_power_trans_info - curr : Current power state - next : Next power state for transition - reason : Transition reason when changing the state from curr to next - void *data : Passed data of transition information Change-Id: I69450db85c4303f77f7675270a4a1890e0f98bbe Signed-off-by: Chanwoo Choi --- .../deviced/include/syscommon-plugin-deviced-power-interface.h | 7 +++++++ 1 file changed, 7 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 95394c1..71f0b89 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 @@ -73,6 +73,13 @@ enum { #define DEVICED_POWER_STATE_INDEX(state) (__builtin_ctzll(state)) +struct syscommon_plugin_deviced_power_trans_info { + u_int64_t curr; + u_int64_t next; + int reason; + const void *data; +}; + static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(const char *str) { if (MATCH(str, "start")) -- 2.7.4 From 01b6308b10000b0f28bddc6100d5addc2d0e001e Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 17 Aug 2023 21:12:59 +0900 Subject: [PATCH 05/16] plugin-api: deviced: Add display DPMS attribute and enum New attribute: - id: DEVICED_DISPLAY_ATTR_INT_DPMS_STATE - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: O - getter: O It sets/gets DPMS value type of enum deviced_dpms_state. New attribute: - id: DEVICED_DISPLAY_ATTR_TUPLE2_SET_DISPLAY_DIRECT - type: SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64 - setter: O - getter: X - 1st param: enum deviced_dpms_state - 2nd param: enum deviced_event It bypasses display state transition routine. Instead it sets DPMS directly. Change-Id: I077c4066288f8e0f8856e4f78bbc6e7e1283f3e6 Signed-off-by: Youngjae Cho --- .../include/syscommon-plugin-deviced-display-interface.h | 11 +++++++++++ 1 file changed, 11 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 eec2f42..7f1ae86 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 @@ -32,6 +32,8 @@ extern "C" { #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) enum deviced_display_state { DEVICED_DISPLAY_STATE_START, @@ -42,6 +44,15 @@ enum deviced_display_state { DEVICED_DISPLAY_STATE_END, }; +enum deviced_dpms_state { + DEVICED_DPMS_ON, /* In use */ + DEVICED_DPMS_STANDBY, /* Blanked, low power */ + DEVICED_DPMS_SUSPEND, /* Blanked, lower power */ + DEVICED_DPMS_OFF, /* Shut off, awaiting activity */ + DEVICED_DPMS_FORCE_OFF,/* Force Shut off */ + DEVICED_DPMS_DETACH, /* Display detached */ +}; + #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) #ifdef __cplusplus -- 2.7.4 From 78f8cede59a6c0375eca9bddf047b92fa373e3ee Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 18 Aug 2023 15:44:17 +0900 Subject: [PATCH 06/16] plugin-api: deviced: Add struct deviced_display_config Add display configuration structure that can be accessed by both display core and plugin. And the below enums also be added - enum deviced_dpms_type : Type that DPMS is working on top of. - enum deviced_display_orientation : Direction that display hardware is attached to. Change-Id: I2c36f4d38ce654d80843ff21cbf1f702c3c034c9 Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-display-interface.h | 37 ++++++++++++++++++++++ 1 file changed, 37 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 7f1ae86..0f9a961 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 @@ -29,6 +29,8 @@ extern "C" { #endif +#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) @@ -53,6 +55,41 @@ enum deviced_dpms_state { DEVICED_DPMS_DETACH, /* Display detached */ }; +enum deviced_dpms_type { + DEVICED_DPMS_TYPE_WINDOW_MANAGER, + DEVICED_DPMS_TYPE_NONE, +}; + +enum deviced_display_orientation { + DEVICED_DISPLAY_ORIENTATION_HORIZONTAL, + DEVICED_DISPLAY_ORIENTATION_VERTICAL, +}; + +struct deviced_display_config { + double lock_wait_time; + double longpress_interval; + double lightsensor_interval; + int lcdoff_timeout; + const int pm_default_brightness; + int brightness_change_step; + int lcd_always_on; + int dimming; + int framerate_app[4]; + int control_display; + int powerkey_doublepress; + int alpm_on; + int accel_sensor_on; + int continuous_sampling; + enum deviced_display_orientation display_init_direction; + int aod_enter_level; + bool aod_tsp; + bool timeout_enable; + bool input_support; + bool touch_wakeup; + bool display_on_usb_conn_changed; + enum deviced_dpms_type display_dpms_type; +}; + #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) #ifdef __cplusplus -- 2.7.4 From 066aa13d02610fd33cc7d2557007b1a875e46f58 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 18 Aug 2023 19:06:47 +0900 Subject: [PATCH 07/16] plugin-api: deviced: Add prefix 'syscommon' to enum and struct Change-Id: Ie08a5397ef8829ef27eb3a8010d599941352e591 Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-display-interface.h | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) 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 0f9a961..383e361 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 @@ -37,35 +37,35 @@ extern "C" { #define DEVICED_DISPLAY_ATTR_INT_DPMS_STATE (1ULL << 3) #define DEVICED_DISPLAY_ATTR_TUPLE2_SET_DISPLAY_DIRECT (1ULL << 4) -enum deviced_display_state { - DEVICED_DISPLAY_STATE_START, - DEVICED_DISPLAY_STATE_ON, - DEVICED_DISPLAY_STATE_DIM, - DEVICED_DISPLAY_STATE_OFF, - DEVICED_DISPLAY_STATE_SLEEP, - DEVICED_DISPLAY_STATE_END, +enum syscommon_deviced_display_state { + SYSCOMMON_DEVICED_DISPLAY_STATE_START, + SYSCOMMON_DEVICED_DISPLAY_STATE_ON, + SYSCOMMON_DEVICED_DISPLAY_STATE_DIM, + SYSCOMMON_DEVICED_DISPLAY_STATE_OFF, + SYSCOMMON_DEVICED_DISPLAY_STATE_SLEEP, + SYSCOMMON_DEVICED_DISPLAY_STATE_END, }; -enum deviced_dpms_state { - DEVICED_DPMS_ON, /* In use */ - DEVICED_DPMS_STANDBY, /* Blanked, low power */ - DEVICED_DPMS_SUSPEND, /* Blanked, lower power */ - DEVICED_DPMS_OFF, /* Shut off, awaiting activity */ - DEVICED_DPMS_FORCE_OFF,/* Force Shut off */ - DEVICED_DPMS_DETACH, /* Display detached */ +enum syscommon_deviced_dpms_state { + SYSCOMMON_DEVICED_DPMS_ON, /* In use */ + SYSCOMMON_DEVICED_DPMS_STANDBY, /* Blanked, low power */ + SYSCOMMON_DEVICED_DPMS_SUSPEND, /* Blanked, lower power */ + SYSCOMMON_DEVICED_DPMS_OFF, /* Shut off, awaiting activity */ + SYSCOMMON_DEVICED_DPMS_FORCE_OFF,/* Force Shut off */ + SYSCOMMON_DEVICED_DPMS_DETACH, /* Display detached */ }; -enum deviced_dpms_type { - DEVICED_DPMS_TYPE_WINDOW_MANAGER, - DEVICED_DPMS_TYPE_NONE, +enum syscommon_deviced_dpms_type { + SYSCOMMON_DEVICED_DPMS_TYPE_WINDOW_MANAGER, + SYSCOMMON_DEVICED_DPMS_TYPE_NONE, }; -enum deviced_display_orientation { - DEVICED_DISPLAY_ORIENTATION_HORIZONTAL, - DEVICED_DISPLAY_ORIENTATION_VERTICAL, +enum syscommon_deviced_display_orientation { + SYSCOMMON_DEVICED_DISPLAY_ORIENTATION_HORIZONTAL, + SYSCOMMON_DEVICED_DISPLAY_ORIENTATION_VERTICAL, }; -struct deviced_display_config { +struct syscommon_deviced_display_config { double lock_wait_time; double longpress_interval; double lightsensor_interval; @@ -80,14 +80,14 @@ struct deviced_display_config { int alpm_on; int accel_sensor_on; int continuous_sampling; - enum deviced_display_orientation display_init_direction; + enum syscommon_deviced_display_orientation display_init_direction; int aod_enter_level; bool aod_tsp; bool timeout_enable; bool input_support; bool touch_wakeup; bool display_on_usb_conn_changed; - enum deviced_dpms_type display_dpms_type; + enum syscommon_deviced_dpms_type display_dpms_type; }; #define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) -- 2.7.4 From 349a1db584b3c6f9211797c1ce74a6b9659a78ee Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Fri, 18 Aug 2023 19:45:23 +0900 Subject: [PATCH 08/16] plugin-api: deviced: Add struct syscommon_deviced_display_state_info Change-Id: I4b9c8e605fa8c111d95fe9dbb09710d6ba2d33e9 Signed-off-by: Youngjae Cho --- .../include/syscommon-plugin-deviced-display-interface.h | 11 +++++++++++ 1 file changed, 11 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 383e361..be00316 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 @@ -30,6 +30,7 @@ extern "C" { #endif #include +#include #define DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS (1ULL << 0) #define DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE (1ULL << 1) @@ -46,6 +47,16 @@ enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_END, }; +struct syscommon_deviced_display_state_info { + enum syscommon_deviced_display_state state; /**< state number */ + const char *name; /**< state name (string) */ + int (*trans) (int evt); /**< transition function pointer */ + int (*action) (int timeout); /**< enter action */ + int (*check) (int curr, int next); /**< transition check function */ + GSourceFunc timeout_cb; + int timeout; +}; + enum syscommon_deviced_dpms_state { SYSCOMMON_DEVICED_DPMS_ON, /* In use */ SYSCOMMON_DEVICED_DPMS_STANDBY, /* Blanked, low power */ -- 2.7.4 From 1a234517f7e127c1de68aca1b96464532063ee74 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 14:31:55 +0900 Subject: [PATCH 09/16] plugin-api: common: Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin module Add SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT for input plugin module. [Detailed description] 1. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin module - module : SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT - library_name : "/usr/lib/system/plugin/libplugin-backend-deviced-input.so" - library_name_64bit : "/usr/lib64/system/plugin/libplugin-backend-deviced-input.so" - symbol_name : "system_plugin_backend_deviced_input_data" 2. Newly added SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT plugin api - int syscommon_plugin_deviced_input_get_backend(void) : Load Deviced input plugin-backend from above library_name/library_name_64bit path - int syscommon_plugin_deviced_input_put_backend(void); : Unload Deviced input plugin-backend - void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, unsigned short keycode, unsigned int keyvalue); : Callback function to handle the key event when input key event happen Change-Id: I0194c88da69abff226c92846637c0e000d58e019 Signed-off-by: Chanwoo Choi --- .../common/include/syscommon-plugin-common.h | 1 + .../common/src/syscommon-plugin-api-list.h | 18 ++++ src/plugin-api/deviced/CMakeLists.txt | 1 + .../syscommon-plugin-deviced-input-interface.h | 47 +++++++++++ .../include/syscommon-plugin-deviced-input.h | 57 +++++++++++++ .../deviced/src/syscommon-plugin-deviced-input.c | 96 ++++++++++++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h create mode 100644 src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h create mode 100644 src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c diff --git a/src/plugin-api/common/include/syscommon-plugin-common.h b/src/plugin-api/common/include/syscommon-plugin-common.h index c644453..8caccbb 100644 --- a/src/plugin-api/common/include/syscommon-plugin-common.h +++ b/src/plugin-api/common/include/syscommon-plugin-common.h @@ -35,6 +35,7 @@ enum syscommon_plugin_module { SYSCOMMON_PLUGIN_MODULE_UNKNOWN = 0, SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK, SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY, + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, 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 66a6c01..7d61902 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -48,6 +48,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_INPUT] = { + [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[] = { @@ -75,6 +81,18 @@ static struct __plugin_module_info g_plugin_module_info[] = { .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY]), .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY], }, + [SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT] = { + .group = PLUGIN_GROUP_DEVICED, + .module = SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + .license = PLUGIN_LICENSE_APACHE_2_0, + .module_name = "SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT", + .backend_module_name = "deviced-input", + .library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-input.so", + .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-input.so", + .symbol_name = "system_plugin_backend_deviced_input_data", + .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], + }, }; #endif /* __PLUGIN_API_LIST_H__ */ diff --git a/src/plugin-api/deviced/CMakeLists.txt b/src/plugin-api/deviced/CMakeLists.txt index a82642b..644c594 100644 --- a/src/plugin-api/deviced/CMakeLists.txt +++ b/src/plugin-api/deviced/CMakeLists.txt @@ -41,6 +41,7 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") # to PKG_MODULES. SET(SRCS src/syscommon-plugin-deviced-display.c src/syscommon-plugin-deviced-battery.c + src/syscommon-plugin-deviced-input.c ../common/src/syscommon-plugin-api-common.c ../common/src/syscommon-plugin-api-conf.c) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h new file mode 100644 index 0000000..b777152 --- /dev/null +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input-interface.h @@ -0,0 +1,47 @@ +/** + * 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_DEVICED_INPUT_INTERFACE_H__ +#define __SYSCOMMON_PLUGIN_DEVICED_INPUT_INTERFACE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SYSCOMMON_DEVICED_INPUT_KEY_RELEASED 0 +#define SYSCOMMON_DEVICED_INPUT_KEY_PRESSED 1 +#define SYSCOMMON_DEVICED_INPUT_KEY_BEING_PRESSED 2 + +typedef struct _syscommon_plugin_backend_deviced_input_funcs { + void (*input_event_cb)(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue); +} syscommon_plugin_backend_deviced_input_funcs; + +#ifdef __cplusplus +} +#endif + +#endif //__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/syscommon-plugin-deviced-input.h new file mode 100644 index 0000000..9dda045 --- /dev/null +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-input.h @@ -0,0 +1,57 @@ +/** + * 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_DEVICED_INPUT_H__ +#define __SYSCOMMON_PLUGIN_DEVICED_INPUT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the backend data of deviced-input module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_input_get_backend(void); + +/** + * @brief Put the backend data of deviced-input module + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_input_put_backend(void); + +/** + * @brief Input event callback function + */ +void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue); + + +#ifdef __cplusplus +} +#endif + +#endif //__SYSCOMMON_PLUGIN_DEVICED_INPUT_H__ diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c new file mode 100644 index 0000000..350e574 --- /dev/null +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-input.c @@ -0,0 +1,96 @@ +/** + * 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 "syscommon-plugin-common.h" + +#include "common.h" +#include "syscommon-plugin-deviced-input.h" +#include "syscommon-plugin-deviced-input-interface.h" + +#ifndef EXPORT +#define EXPORT __attribute__((visibility("default"))) +#endif + +static syscommon_plugin_backend_deviced_input_funcs *g_input_funcs = NULL; + +EXPORT +int syscommon_plugin_deviced_input_get_backend(void) +{ + int ret = 0; + + if (g_input_funcs) + return 0; + + ret = syscommon_plugin_common_get_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + (void **)&g_input_funcs); + if (ret < 0) { + _E("Failed to get deviced_input backend: %d", ret); + return ret; + } + + _I("Success to get deviced_input backend: %d", ret); + + return 0; +} + +EXPORT +int syscommon_plugin_deviced_input_put_backend(void) +{ + int ret = 0; + + if (!g_input_funcs) + return 0; + + ret = syscommon_plugin_common_put_backend( + SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT, + (void *)g_input_funcs); + if (ret < 0) { + _E("Failed to put deviced_input backend: %d", ret); + return ret; + } + g_input_funcs = NULL; + + _I("Success to put deviced_input backend: %d", ret); + + return 0; +} + +EXPORT +void syscommon_plugin_deviced_input_event_cb(struct timeval time, unsigned short type, + unsigned short keycode, unsigned int keyvalue) +{ + if (!g_input_funcs) { + _E("Failed to get device_input backend : -ENOTSUP\n"); + return; + } + + if (!g_input_funcs->input_event_cb) { + _E("Failed to execute (*input_event_cb) : -ENOTSUP\n"); + return; + } + + g_input_funcs->input_event_cb(time, type, keycode, keyvalue); +} -- 2.7.4 From 9f7152a174524a8af193a2897a61b9fe60078a83 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 18 Aug 2023 21:17:33 +0900 Subject: [PATCH 10/16] plugin-api: common: Fix wrong symbol name of SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY Change-Id: I810cd3cbbf6f78f3bd4d20c925912d90140c127e Signed-off-by: Chanwoo Choi --- src/plugin-api/common/src/syscommon-plugin-api-list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7d61902..cf92695 100644 --- a/src/plugin-api/common/src/syscommon-plugin-api-list.h +++ b/src/plugin-api/common/src/syscommon-plugin-api-list.h @@ -77,7 +77,7 @@ static struct __plugin_module_info g_plugin_module_info[] = { .backend_module_name = "deviced-battery", .library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-battery.so", .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-battery.so", - .symbol_name = "system_plugin_backend_deviced_battery", + .symbol_name = "system_plugin_backend_deviced_battery_data", .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY]), .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY], }, -- 2.7.4 From a23a71c4208a11c7239d43cefca9365c3531afa6 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 15:49:29 +0900 Subject: [PATCH 11/16] plugin-api: deviced: Add attribute for custom brightness New attribute: - id: DEVICED_DISPLAY_ATTR_INT_CUSTOM_BRIGHTNESS - type: SYSCOMMON_RESMAN_DATA_TYPE_INT - setter: O - getter: O It gets whether custom brightness is set or not. And it enables the custom brightness when it sets attrbute by a value other than 0. Change-Id: I6ba2c27f82d76933633e3322248d99fd2bc6df35 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 be00316..6f1dfac 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 @@ -37,6 +37,7 @@ extern "C" { #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) enum syscommon_deviced_display_state { SYSCOMMON_DEVICED_DISPLAY_STATE_START, -- 2.7.4 From 719d8031b7fc53d089557783270eaa6c9663b765 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 17:28:47 +0900 Subject: [PATCH 12/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 13/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 14/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 15/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 16/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