device-bezel: Add hal-backend-service-device-bezel plugin 64/321564/7
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 25 Mar 2025 06:55:41 +0000 (15:55 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 7 Apr 2025 04:04:12 +0000 (13:04 +0900)
Added hal-backend-service-device-bezel plugin that is HAL IPC stub
(server) for HAL_MODULE_DEVICE_BEZEL.

Change-Id: I72efa2e88240d7d17749fc7f3476e1ee4a7799e1
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
hal-backend-service-plugin/bezel/CMakeLists.txt [new file with mode: 0644]
hal-backend-service-plugin/bezel/hal-backend-service-device-bezel.c [new file with mode: 0644]
packaging/hal-api-device-manifest.xml
packaging/hal-api-device.spec

index d309daef8739d34ed831447e6160deb193836a49..7f25346f9ec856f67726a552abcf66c397c46b84 100644 (file)
@@ -109,3 +109,4 @@ ENDIF(UNIX)
 ADD_SUBDIRECTORY(hal-backend-service-plugin/display)
 ADD_SUBDIRECTORY(hal-backend-service-plugin/led)
 ADD_SUBDIRECTORY(hal-backend-service-plugin/battery)
+ADD_SUBDIRECTORY(hal-backend-service-plugin/bezel)
diff --git a/hal-backend-service-plugin/bezel/CMakeLists.txt b/hal-backend-service-plugin/bezel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8b6f9cb
--- /dev/null
@@ -0,0 +1,37 @@
+PROJECT(hal-backend-service-device-bezel C)
+
+SET(LIBRARY_NAME "${PROJECT_NAME}")
+SET(CMAKE_VERBOSE_MAKEFILE ON)
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+IF(ENABLE_DLOG STREQUAL on)
+    ADD_DEFINITIONS("-DFEATURE_DLOG")
+       ADD_DEFINITIONS("-DLOG_TAG=\"HAL_BACKEND_SERVICE_DEVICE_BEZEL\"")
+ENDIF()
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/generated)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       dlog
+       hal-api-common
+       glib-2.0
+       capi-appfw-app-common
+       capi-appfw-app-manager
+       capi-appfw-package-manager
+       rpc-port
+)
+
+SET(SRCS
+       ${CMAKE_CURRENT_SOURCE_DIR}/hal-backend-service-device-bezel.c
+       ${CMAKE_SOURCE_DIR}/src/hal-api-device-bezel.c
+       ${CMAKE_SOURCE_DIR}/src/hal-api-device-bezel-passthrough.c
+       ${CMAKE_SOURCE_DIR}/src/generated/hal_device_bezel_stub_1.c)
+
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${pkgs_LDFLAGS} -ldl)
+
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR}/hal COMPONENT RuntimeLibraries)
diff --git a/hal-backend-service-plugin/bezel/hal-backend-service-device-bezel.c b/hal-backend-service-plugin/bezel/hal-backend-service-device-bezel.c
new file mode 100644 (file)
index 0000000..6f54e3e
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * HAL Backend Service Plugin for HAL_MODULE_DEVICE_BEZEL
+ *
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+#include <hal_device_bezel_stub_1.h>
+#include <hal-api-device-bezel-passthrough.h>
+
+#include <hal/hal-common.h>
+#include <common.h>
+
+static void device_bezel_ipc_create(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+               void *user_data)
+{
+       char *sender = NULL;
+       rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_sender(context, &sender);
+       if (!sender)
+               return;
+
+       free(sender);
+}
+
+static void device_bezel_ipc_terminate(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+               void *user_data)
+{
+       char *sender = NULL;
+
+       rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_sender(context, &sender);
+       if (!sender)
+               return;
+
+       free(sender);
+}
+
+static int device_bezel_ipc_get_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_state_e *state, void *user_data)
+{
+       if (!state)
+               return -EINVAL;
+
+       return hal_device_bezel_passthrough_get_state((hal_device_bezel_state_e *) state);
+}
+
+static int device_bezel_ipc_set_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state, void *user_data)
+{
+
+       return hal_device_bezel_passthrough_set_state((hal_device_bezel_state_e) state);
+}
+
+static int device_bezel_ipc_get_sw_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_state_e *state, void *user_data)
+{
+       if (!state)
+               return -EINVAL;
+
+       return hal_device_bezel_passthrough_get_sw_state((hal_device_bezel_state_e *) state);
+}
+
+static int device_bezel_ipc_set_sw_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state, void *user_data)
+{
+       return hal_device_bezel_passthrough_set_sw_state((hal_device_bezel_state_e) state);
+}
+
+static int device_bezel_ipc_get_vib_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e *state, void *user_data)
+{
+       if (!state)
+               return -EINVAL;
+
+       return hal_device_bezel_passthrough_get_vib_state((hal_device_bezel_vib_state_e *) state);
+}
+
+static int device_bezel_ipc_set_vib_state(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context,
+       rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e state, void *user_data)
+{
+       return hal_device_bezel_passthrough_set_vib_state((hal_device_bezel_vib_state_e) state);
+}
+
+static int device_bezel_init (void *data)
+{
+       int ret = 0;
+
+       ret = hal_device_bezel_passthrough_get_backend();
+       if (ret < 0) {
+               _E("Failed to get passthrough bezel backend: %d", ret);
+               return ret;
+       }
+
+       rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s callback = {
+               .create = device_bezel_ipc_create,
+               .terminate = device_bezel_ipc_terminate,
+               .get_state = device_bezel_ipc_get_state,
+               .set_state = device_bezel_ipc_set_state,
+               .get_sw_state = device_bezel_ipc_get_sw_state,
+               .set_sw_state = device_bezel_ipc_set_sw_state,
+               .get_vib_state = device_bezel_ipc_get_vib_state,
+               .set_vib_state = device_bezel_ipc_set_vib_state,
+       };
+
+       ret = rpc_port_stub_hal_device_bezel_stub_1_device_bezel_register(&callback, NULL);
+       if (ret < 0)
+               _E("Failed to register rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s ret(%d)", ret);
+
+       return 0;
+}
+
+static int device_bezel_exit (void *data)
+{
+       int ret = 0;
+
+       rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+
+       ret = hal_device_bezel_passthrough_put_backend();
+       if (ret < 0)
+               _E("Failed to hal_device_bezel_put_backend_passthrough ret(%d)", ret);
+
+       return 0;
+}
+
+hal_backend_service hal_backend_service_device_bezel_data = {
+       .module         = HAL_MODULE_DEVICE_BEZEL,
+       .name           = "hal-backend-service-device-bezel",
+       .early_init     = NULL,
+       .init           = device_bezel_init,
+       .exit           = device_bezel_exit,
+       .late_exit      = NULL,
+};
\ No newline at end of file
index 451cabf909e8bc79a82a5de38146bd39563481ea..146a800e31d83e4de62b4a6092776391b6d61315 100644 (file)
@@ -6,7 +6,7 @@
                </hal-module>
                <hal-module>
                        <name>HAL_MODULE_DEVICE_BEZEL</name>
-                       <version>1.0</version>
+                       <version transport="ipc">1.0</version>
                </hal-module>
                <hal-module>
                        <name>HAL_MODULE_DEVICE_DISPLAY</name>
index 0d160ebe14d482ea4b8f405968f0e892a1a36f2c..4150bfc7d0489da9fdd657c46650f18b8e4a4d58 100644 (file)
@@ -79,6 +79,7 @@ cp %{SOURCE2} %{buildroot}%{_sysconfdir}/hal/
 %{_libdir}/hal/libhal-backend-service-device-display.so
 %{_libdir}/hal/libhal-backend-service-device-led.so
 %{_libdir}/hal/libhal-backend-service-device-battery.so
+%{_libdir}/hal/libhal-backend-service-device-bezel.so
 %{_sysconfdir}/hal/hal-api-device-manifest.xml
 
 %files devel