From 32b355358b5fd45e71c2c3efddf9335b5afafc46 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 9 Aug 2023 17:45:23 +0900 Subject: [PATCH 01/16] resource-manager: Add convenient macro SYSCOMMON_RESOURCE_ID() The resource-manage APIs are working on top of the resource_id. Thus an API user must get resource_id in advance to access resource instance. Currently resource-manager provides syscommon_resman_get_resource_id() for this purpose, however, it gets resource_id via parameter. Therefore, it cannot pass resource_id directly to a function parameter. On the other hand, the convenient macro returns resource_id on success, -1 on failure. As it returns reosurce_id, it can be used as an inline parameter. Change-Id: I45426096144c2a47de2554cbf2856b9f78d5b51d Signed-off-by: Youngjae Cho --- include/libsyscommon/resource-manager.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/libsyscommon/resource-manager.h b/include/libsyscommon/resource-manager.h index ddf70b4..c7bb435 100644 --- a/include/libsyscommon/resource-manager.h +++ b/include/libsyscommon/resource-manager.h @@ -191,6 +191,15 @@ int syscommon_resman_monitor_get_resource_attr_json(int resource_id, u_int64_t a int syscommon_resman_get_resource_list_json(char **json_string); int syscommon_resman_get_number_of_resource_instance(int resource_type, int *n_instance); int syscommon_resman_get_resource_id(int resource_type, int *resource_id); +#define SYSCOMMON_RESOURCE_ID(resource_type) ({ \ + int _id; \ + int _ret; \ + if (syscommon_resman_get_resource_id(resource_type, &_id) >= 0) \ + _ret = _id; \ + else \ + _ret = -1; \ + _ret; \ + }) int syscommon_resman_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32_t *data); int syscommon_resman_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int64_t *data); -- 2.7.4 From be844883631f2049238eb81e834cc2241c8d12b1 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 9 Aug 2023 20:27:27 +0900 Subject: [PATCH 02/16] plugin-api: deviced: Add display state It replaces existing enum state_t of the deviced. - S_START => DEVICED_DISPLAY_STATE_START - S_NORMAL => DEVICED_DISPLAY_STATE_ON - S_LCDON => DEVICED_DISPLAY_STATE_ON - S_LCDDIM => DEVICED_DISPLAY_STATE_DIM - S_LCDOFF => DEVICED_DISPLAY_STATE_OFF - S_STANDBY => removed - S_SLEEP => DEVICED_DISPLAY_STATE_SLEEP* - S_SUSPEND => removed - S_POWEROFF => removed [*] Technically, the DEVICED_DISPLAY_STATE_SLEEP cannot be a state of display. It should be a state of power, not display. However, current code indiscriminately uses S_SLEEP state as one of the display state. This will be fixed to make power module exclusively handle sleep, and the enum itself will be removed accordingly. The other removed enums are not being used. Change-Id: I1f22379e730311c211b36cd516a020eadd730938 Signed-off-by: Youngjae Cho --- .../deviced/include/syscommon-plugin-deviced-display-interface.h | 9 +++++++++ 1 file changed, 9 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 f47845e..9569061 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 @@ -31,6 +31,15 @@ extern "C" { #define DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS (1ULL << 0) +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, +}; + #ifdef __cplusplus } #endif -- 2.7.4 From 5b2a3e4aa2db1a7f7b47180575a8a495d213e135 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 10 Aug 2023 13:17:15 +0900 Subject: [PATCH 03/16] plugin-api: deviced: Add display state get attribute - DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE : Reprenest the current display state. Only gettable. Change-Id: I170f62ce68ae31c60775d1253d9e83b6f0e706ce 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 9569061..1082c40 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 #define DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS (1ULL << 0) +#define DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE (1ULL << 1) enum deviced_display_state { DEVICED_DISPLAY_STATE_START, -- 2.7.4 From 1e7168ca61d776669b678d24e2db797d841f4799 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 16 Aug 2023 11:18:29 +0900 Subject: [PATCH 04/16] plugin-api: deviced: Add display state set attribute - DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE : Attribute for setting display state. It requires two parameter, each type of enum deviced_display_state and enum deviced_event. The first one designates state to be changed and the latter one specifies reason why the state change has been triggered. When it comes to the state setter, it is necessary to reset screen timeout of the changed state. Therefore the below values have been added. - DEVICED_EVENT_DISPLAY_SCREEN_TIMEOUT : Event for screen timeout expiration - DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE : Magic number for setting infinite screen timeout Change-Id: I616a5ecd009dfb8c5aa4710ed68f2b09f5fe2981 Signed-off-by: Youngjae Cho --- .../deviced/include/syscommon-plugin-deviced-common-interface.h | 1 + .../deviced/include/syscommon-plugin-deviced-display-interface.h | 3 +++ 2 files changed, 4 insertions(+) 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 2ffd792..5300c78 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 @@ -51,6 +51,7 @@ enum deviced_event { DEVICED_EVENT_DISPLAY, DEVICED_EVENT_DISPLAY_AMBIENT, DEVICED_EVENT_DISPLAY_LOCK, + DEVICED_EVENT_DISPLAY_SCREEN_TIMEOUT, /* battery */ DEVICED_EVENT_BATTERY, 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 1082c40..eec2f42 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 @@ -31,6 +31,7 @@ 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) enum deviced_display_state { DEVICED_DISPLAY_STATE_START, @@ -41,6 +42,8 @@ enum deviced_display_state { DEVICED_DISPLAY_STATE_END, }; +#define DEVICED_DISPLAY_SCREEN_TIMEOUT_INFINITE ((~0) >> 1) + #ifdef __cplusplus } #endif -- 2.7.4 From 821aa6d7ca85421f555300e241d8827e48baa511 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 14:11:24 +0900 Subject: [PATCH 05/16] libsyscommon: Add common log.h to print log via dlog All system service uses the dlog to print the logging. So that add the common log.h file using dlog. Change-Id: Id3f594bb5607db807f8608670f9e60839146d917 Signed-off-by: Chanwoo Choi --- include/libsyscommon/log.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/libsyscommon/log.h diff --git a/include/libsyscommon/log.h b/include/libsyscommon/log.h new file mode 100644 index 0000000..0d7db18 --- /dev/null +++ b/include/libsyscommon/log.h @@ -0,0 +1,41 @@ +/* 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 __LOG_H__ +#define __LOG_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 /* __LOG_H__ */ -- 2.7.4 From e12e21c2063a34145053bea676db57dd06021779 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 17 Aug 2023 14:30:43 +0900 Subject: [PATCH 06/16] plugin-api: deviced: Add enum deviced_notifier Change-Id: If2b3960557996dd483d0a77f4db643a77914bd3f Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-common-interface.h | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) 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 5300c78..6b1175f 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 @@ -88,6 +88,60 @@ enum deviced_event { DEVICED_EVENT_MISC_TIME, }; +enum deviced_notifier { + DEVICED_NOTIFIER_MIN, + DEVICED_NOTIFIER_DAEMON_RESTARTED = DEVICED_NOTIFIER_MIN, + DEVICED_NOTIFIER_DELAYED_INIT, + DEVICED_NOTIFIER_LCD, + DEVICED_NOTIFIER_LCD_OFF, + DEVICED_NOTIFIER_LCD_OFF_COMPLETE, + DEVICED_NOTIFIER_LCD_AUTOBRT_SENSING, + DEVICED_NOTIFIER_LOWBAT, + DEVICED_NOTIFIER_FULLBAT, + DEVICED_NOTIFIER_POWER_SUPPLY, + DEVICED_NOTIFIER_BATTERY_HEALTH, + DEVICED_NOTIFIER_BATTERY_PRESENT, + DEVICED_NOTIFIER_BATTERY_OVP, + DEVICED_NOTIFIER_BATTERY_CHARGING, + DEVICED_NOTIFIER_BATTERY_CHARGER_CONNECTED, + DEVICED_NOTIFIER_BATTERY_CHARGER_DISCONNECTED, + DEVICED_NOTIFIER_DISPLAY_AMBIENT_CONDITION, + DEVICED_NOTIFIER_DISPLAY_AMBIENT_STATE, + DEVICED_NOTIFIER_DISPLAY_LOCK, + DEVICED_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, + DEVICED_NOTIFIER_POWEROFF_TRIGGERED, + DEVICED_NOTIFIER_POWEROFF, + DEVICED_NOTIFIER_APPLICATION_BACKGROUND, + DEVICED_NOTIFIER_APPLICATION_FOREGROUND, + DEVICED_NOTIFIER_APPLICATION_TERMINATED, + DEVICED_NOTIFIER_USB_DEBUG_MODE, + DEVICED_NOTIFIER_USB_TETHERING_MODE, + DEVICED_NOTIFIER_EVENT_HANDLER, + DEVICED_NOTIFIER_CPU_BOOST_LOWBAT, + DEVICED_NOTIFIER_CPU_BOOST_POWEROFF, + /* Experimental for Specific device - contact to deviced owner */ + DEVICED_NOTIFIER_PMQOS, + DEVICED_NOTIFIER_PMQOS_ULTRAPOWERSAVING, + DEVICED_NOTIFIER_PMQOS_POWERSAVING, + DEVICED_NOTIFIER_COOL_DOWN, + DEVICED_NOTIFIER_VITAL_STATE, + DEVICED_NOTIFIER_LONGKEY_RESTORE, + DEVICED_NOTIFIER_UPSM, + DEVICED_NOTIFIER_UPSM_OFF, + DEVICED_NOTIFIER_BEZEL_WAKEUP, + DEVICED_NOTIFIER_DISPLAY_BRIGHTNESS, + DEVICED_NOTIFIER_ULTRAPOWERSAVING, + DEVICED_NOTIFIER_KEY_PRESS, + DEVICED_NOTIFIER_KEY_RELEASE, + DEVICED_NOTIFIER_EVENT_ACQUIRE_WAKELOCK, + DEVICED_NOTIFIER_EVENT_RELEASE_WAKELOCK, + + /* Purpose of calling methods of different modules + * Use prefix DEVICED_NOTIFIER_REQUEST */ + DEVICED_NOTIFIER_REQUEST_TRANSITION_STATE, + DEVICED_NOTIFIER_MAX, +}; + #ifdef __cplusplus } #endif -- 2.7.4 From 8b99b480c3bf4e5f89eb92d66777c2c8ec2e2115 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 14:44:43 +0900 Subject: [PATCH 07/16] plugin-api: deviced: power: Add new DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK attribute provides the setter function to acquire the wakelock in order to prevent the suspending. - attr id : DEVICED_POWER_ATTR_TUPLE2_SET_WAKELOCK - setter : O - getter : X - 1st param : Event ID - 2nd param : Timeout to release the wakelock count Change-Id: If0daee6ffc53838313a661feedd5b2fae45af136 Signed-off-by: Chanwoo Choi --- .../deviced/include/syscommon-plugin-deviced-power-interface.h | 1 + 1 file changed, 1 insertion(+) 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 010639b..4f05328 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 @@ -32,6 +32,7 @@ extern "C" { #define DEVICED_POWER_ATTR_SET_UINT64_4_CURRENT_STATE (1ULL << 0) #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) enum { DEVICED_POWER_STATE_MIN_INDEX, -- 2.7.4 From d4defbfc9564f7d51dde26a22e8d7e132a26b795 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 18:06:41 +0900 Subject: [PATCH 08/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 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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