--- /dev/null
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdbool.h>
+#include <assert.h>
+#include <glib.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-api-device-bezel-ipc.h"
+#include "src/generated/hal_device_bezel_proxy_1.h"
+
+#include "common.h"
+
+static bool g_hal_backend_service_connected = false;
+static rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h g_hal_device_bezel_ipc_h = NULL;
+
+static void hal_device_bezel_ipc_connected_cb(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h,
+ void *user_data)
+{
+ g_hal_backend_service_connected = true;
+
+ _I("device-bezel: Connected to hal-backend-service");
+}
+
+static void hal_device_bezel_ipc_disconnected_cb(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h,
+ void *user_data)
+{
+ int ret = 0;
+
+ g_hal_backend_service_connected = false;
+ ret = hal_device_bezel_ipc_put_backend();
+ if (ret < 0)
+ _W("device-bezel: Cannot put ipc backend");
+}
+
+static void hal_device_bezel_ipc_rejected_cb(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h,
+ void *user_data)
+{
+ int ret = 0;
+
+ g_hal_backend_service_connected = false;
+ ret = hal_device_bezel_ipc_put_backend();
+ if (ret < 0)
+ _W("device-bezel: Cannot put ipc backend");
+}
+
+int hal_device_bezel_ipc_get_backend(void)
+{
+ int ret = 0;
+ const char *stub_proc_name = NULL;
+
+ if (g_hal_device_bezel_ipc_h)
+ return 0;
+
+ ret = hal_common_get_stub_proc_name(HAL_MODULE_DEVICE_BEZEL, &stub_proc_name);
+ if (ret != 0) {
+ _E("Failed to get stub proc name for device-bezel: ret(%d)", ret);
+ return ret;
+ }
+
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s callback = {
+ .connected = hal_device_bezel_ipc_connected_cb,
+ .disconnected = hal_device_bezel_ipc_disconnected_cb,
+ .rejected = hal_device_bezel_ipc_rejected_cb
+ };
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_create(stub_proc_name,
+ &callback, NULL, &g_hal_device_bezel_ipc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create bezel ipc handle(%d)", ret);
+ goto ipc_init_fail;
+ }
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connect_sync(g_hal_device_bezel_ipc_h);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to connect bezel ipc handle(%d)", ret);
+ goto ipc_init_fail;
+ }
+
+ return 0;
+
+ipc_init_fail:
+ g_hal_backend_service_connected = false;
+ if (g_hal_device_bezel_ipc_h)
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(g_hal_device_bezel_ipc_h);
+ g_hal_device_bezel_ipc_h = NULL;
+ return ret;
+}
+
+int hal_device_bezel_ipc_put_backend(void)
+{
+ int ret = 0;
+
+ if (!g_hal_device_bezel_ipc_h)
+ return 0;
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnect(g_hal_device_bezel_ipc_h);
+ if (ret != RPC_PORT_ERROR_NONE)
+ _W("Cannot disconnect bezel ipc proxy handle(%d)", ret);
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(g_hal_device_bezel_ipc_h);
+ if (ret != RPC_PORT_ERROR_NONE)
+ _W("Cannot destroy bezel ipc proxy handle(%d)", ret);
+
+ g_hal_device_bezel_ipc_h = NULL;
+ return ret;
+}
+
+int hal_device_bezel_ipc_get_state(hal_device_bezel_state_e *state)
+{
+ if (!state)
+ return -EINVAL;
+
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *) state);
+
+}
+
+int hal_device_bezel_ipc_set_state(hal_device_bezel_state_e state)
+{
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e) state);
+}
+
+int hal_device_bezel_ipc_get_sw_state(hal_device_bezel_state_e *state)
+{
+ if (!state)
+ return -EINVAL;
+
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_sw_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *) state);
+}
+
+int hal_device_bezel_ipc_set_sw_state(hal_device_bezel_state_e state)
+{
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_sw_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e) state);
+}
+
+int hal_device_bezel_ipc_get_vib_state(hal_device_bezel_vib_state_e *state)
+{
+ if (!state)
+ return -EINVAL;
+
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_vib_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e *) state);
+}
+
+int hal_device_bezel_ipc_set_vib_state(hal_device_bezel_vib_state_e state)
+{
+ if (!g_hal_backend_service_connected) {
+ if (hal_device_bezel_ipc_get_backend() != RPC_PORT_ERROR_NONE) {
+ return -ENOTSUP;
+ }
+ }
+
+ return rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_vib_state(
+ g_hal_device_bezel_ipc_h,
+ (rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e) state);
+}
--- /dev/null
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __HAL_API_DEVICE_BEZEL_IPC_H__
+#define __HAL_API_DEVICE_BEZEL_IPC_H__
+
+#include "hal-device-bezel-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_bezel_ipc_get_backend(void);
+int hal_device_bezel_ipc_put_backend(void);
+int hal_device_bezel_ipc_get_state(hal_device_bezel_state_e *state);
+int hal_device_bezel_ipc_set_state(hal_device_bezel_state_e state);
+int hal_device_bezel_ipc_get_sw_state(hal_device_bezel_state_e *state);
+int hal_device_bezel_ipc_set_sw_state(hal_device_bezel_state_e state);
+int hal_device_bezel_ipc_get_vib_state(hal_device_bezel_vib_state_e *state);
+int hal_device_bezel_ipc_set_vib_state(hal_device_bezel_vib_state_e state);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_API_DEVICE_BEZEL_IPC_H__ */