--- /dev/null
+/*
+ * hal-backend-service-plugin for hal-api-device.
+ *
+ * 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 <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <libgen.h>
+#include <dlog.h>
+#include <stdlib.h>
+
+#include <hal/hal-common.h>
+
+#include <hal_device_display_stub_1.h>
+#include <hal-device-display-passthrough.h>
+
+static int device_display_early_init (void *data)
+{
+ return 0;
+}
+
+static void device_display_ipc_create(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ void *user_data)
+{
+ return;
+}
+
+static void device_display_ipc_terminate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ void *user_data)
+{
+ return;
+}
+
+static int device_display_ipc_get_max_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *brightness, void *user_data)
+{
+ if (!brightness)
+ return -EINVAL;
+
+ return hal_device_display_passthrough_get_max_brightness(brightness);
+}
+
+static int device_display_ipc_get_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *brightness, void *user_data)
+{
+ if (!brightness)
+ return -EINVAL;
+
+ return hal_device_display_passthrough_get_brightness(brightness);
+}
+
+static int device_display_ipc_set_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int brightness, void *user_data)
+{
+ return hal_device_display_passthrough_set_brightness(brightness);
+}
+
+static int device_display_ipc_set_multi_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int brightness, int step, int delay, void *user_data)
+{
+ return hal_device_display_passthrough_set_multi_brightness(brightness, step, delay);
+}
+
+static int device_display_ipc_get_auto_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ float lmax, float lmin, float light, int *brightness, void *user_data)
+{
+ return hal_device_display_passthrough_get_auto_brightness(lmax, lmin, light, brightness);
+}
+
+static int device_display_ipc_get_state(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_state_e *state, void *user_data)
+{
+ int ret = 0;
+ hal_device_display_state_e state_e;
+
+ ret = hal_device_display_passthrough_get_state(&state_e);
+ *state = (rpc_port_stub_hal_device_display_stub_1_enums_state_e)state_e;
+ return ret;
+}
+
+static int device_display_ipc_set_state(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_state_e state, void *user_data)
+{
+ return hal_device_display_passthrough_set_state((hal_device_display_state_e)state);
+}
+
+static int device_display_ipc_get_image_effect(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_image_effect_e *effect, void *user_data)
+{
+ int ret = 0;
+ hal_device_display_image_effect_e image_effect;
+
+ ret = hal_device_display_passthrough_get_image_effect(&image_effect);
+ *effect = (rpc_port_stub_hal_device_display_stub_1_enums_image_effect_e)image_effect;
+ return ret;
+}
+
+static int device_display_ipc_set_image_effect(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_image_effect_e effect, void *user_data)
+{
+ return hal_device_display_passthrough_set_image_effect(effect);
+}
+
+static int device_display_ipc_get_panel_mode(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_panel_mode_e *mode, void *user_data)
+{
+ int ret = 0;
+ hal_device_display_panel_mode_e panel_mode;
+
+ ret = hal_device_display_passthrough_get_panel_mode(&panel_mode);
+ *mode = (rpc_port_stub_hal_device_display_stub_1_enums_panel_mode_e)panel_mode;
+ return ret;
+}
+
+static int device_display_ipc_set_panel_mode(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_panel_mode_e mode, void *user_data)
+{
+ return hal_device_display_passthrough_set_panel_mode(mode);
+}
+
+static int device_display_ipc_get_aod_mode(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_aod_mode_e *mode, void *user_data)
+{
+ int ret = 0;
+ hal_device_display_aod_mode_e aod_mode;
+
+ ret = hal_device_display_passthrough_get_aod_mode(&aod_mode);
+ *mode = (rpc_port_stub_hal_device_display_stub_1_enums_aod_mode_e)aod_mode;
+ return ret;
+}
+
+static int device_display_ipc_get_aod_brightness(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *max, int *normal, int *min, int *charging, void *user_data)
+{
+ return hal_device_display_passthrough_get_aod_brightness(max, normal, min, charging);
+}
+
+static int device_display_ipc_get_max_frame_rate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *rate, void *user_data)
+{
+ return hal_device_display_passthrough_get_max_frame_rate(rate);
+}
+
+static int device_display_ipc_get_min_frame_rate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *rate, void *user_data)
+{
+ return hal_device_display_passthrough_get_min_frame_rate(rate);
+}
+
+static int device_display_ipc_get_frame_rate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int *rate, void *user_data)
+{
+ return hal_device_display_passthrough_get_frame_rate(rate);
+}
+
+static int device_display_ipc_set_frame_rate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int rate, void *user_data)
+{
+ return hal_device_display_passthrough_set_frame_rate(rate);
+}
+
+static int device_display_ipc_set_white_balance(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_white_balance_e white_balance_type, int value, void *user_data)
+{
+ return hal_device_display_passthrough_set_white_balance((hal_device_display_white_balance_e)white_balance_type, value);
+}
+
+static int device_display_ipc_get_white_balance(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ rpc_port_stub_hal_device_display_stub_1_enums_white_balance_e white_balance_type, int *value, void *user_data)
+{
+ return hal_device_display_passthrough_get_white_balance((hal_device_display_white_balance_e)white_balance_type, value);
+}
+
+static int device_display_ipc_get_rotation_angle(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int display_index, rpc_port_stub_hal_device_display_stub_1_enums_rotation_angle_e *angle, void *user_data)
+{
+ int ret = 0;
+ hal_device_display_rotation_angle_e rotation_angle;
+
+ ret = hal_device_display_passthrough_get_rotation_angle(display_index, &rotation_angle);
+ *angle = (rpc_port_stub_hal_device_display_stub_1_enums_rotation_angle_e)rotation_angle;
+ return ret;
+}
+
+static int device_display_ipc_set_rotation_angle(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+ int display_index, rpc_port_stub_hal_device_display_stub_1_enums_rotation_angle_e angle,
+ rpc_port_stub_hal_device_display_stub_1_enums_rotation_direction_e direction, void *user_data)
+{
+ return hal_device_display_passthrough_set_rotation_angle(display_index, angle, direction);
+}
+
+static int device_display_init (void *data)
+{
+ int ret = 0;
+
+ ret = hal_device_display_passthrough_get_backend();
+ if (ret != 0) {
+ _E("Failed to get passthrough device-display backend, ret(%d)", ret);
+ return ret;
+ }
+
+ rpc_port_stub_hal_device_display_stub_1_device_display_callback_s callback = {
+ .create = device_display_ipc_create,
+ .terminate = device_display_ipc_terminate,
+ .get_max_brightness = device_display_ipc_get_max_brightness,
+ .get_brightness = device_display_ipc_get_brightness,
+ .set_brightness = device_display_ipc_set_brightness,
+ .set_multi_brightness = device_display_ipc_set_multi_brightness,
+ .get_auto_brightness = device_display_ipc_get_auto_brightness,
+ .get_state = device_display_ipc_get_state,
+ .set_state = device_display_ipc_set_state,
+ .get_image_effect = device_display_ipc_get_image_effect,
+ .set_image_effect = device_display_ipc_set_image_effect,
+ .get_panel_mode = device_display_ipc_get_panel_mode,
+ .set_panel_mode = device_display_ipc_set_panel_mode,
+ .get_aod_mode = device_display_ipc_get_aod_mode,
+ .get_aod_brightness = device_display_ipc_get_aod_brightness,
+ .get_max_frame_rate = device_display_ipc_get_max_frame_rate,
+ .get_min_frame_rate = device_display_ipc_get_min_frame_rate,
+ .get_frame_rate = device_display_ipc_get_frame_rate,
+ .set_frame_rate = device_display_ipc_set_frame_rate,
+ .set_white_balance = device_display_ipc_set_white_balance,
+ .get_white_balance = device_display_ipc_get_white_balance,
+ .get_rotation_angle = device_display_ipc_get_rotation_angle,
+ .set_rotation_angle = device_display_ipc_set_rotation_angle,
+ };
+
+ ret = rpc_port_stub_hal_device_display_stub_1_device_display_register(&callback, NULL);
+ if (ret != RPC_PORT_ERROR_NONE)
+ _E("Failed to register device-display stub callback, ret(%d)", ret);
+
+ return 0;
+}
+
+static int device_display_exit (void *data)
+{
+ int ret = 0;
+
+ rpc_port_stub_hal_device_display_stub_1_device_display_unregister();
+
+ ret = hal_device_display_passthrough_put_backend();
+ if (ret != 0)
+ _E("Failed to hal_device_display_put_backend_passthrough ret(%d)", ret);
+
+ return 0;
+}
+
+static int device_display_late_exit (void *data)
+{
+ return 0;
+}
+
+hal_backend_service hal_backend_service_device_display_data = {
+ .module = HAL_MODULE_DEVICE_DISPLAY,
+ .name = "hal-backend-service-device-display",
+ .early_init = device_display_early_init,
+ .init = device_display_init,
+ .exit = device_display_exit,
+ .late_exit = device_display_late_exit,
+};