device-display: Add hal-backend-service-device-display plugin
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 18 Feb 2025 04:49:00 +0000 (13:49 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 4 Mar 2025 10:00:19 +0000 (19:00 +0900)
Add hal-backend-service-device-display plugin which is HAL IPC stub (server)
for HAL_MODULE_DEVICE_DISPLAY.

Change-Id: I77610cf34e9b2f2c789866c73ef3f7ac77910834
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
CMakeLists.txt
hal-backend-service-plugin/display/CMakeLists.txt [new file with mode: 0644]
hal-backend-service-plugin/display/hal-backend-service-device-display.c [new file with mode: 0644]
packaging/hal-api-device.spec

index c2f536d362eed144c502027eebdf9df58c3c08db..65a8fd6444c124f35657f7e07b67983c72ec9d18 100644 (file)
@@ -107,3 +107,4 @@ ADD_CUSTOM_COMMAND(
 
 ENDIF(UNIX)
 
+ADD_SUBDIRECTORY(hal-backend-service-plugin/display)
diff --git a/hal-backend-service-plugin/display/CMakeLists.txt b/hal-backend-service-plugin/display/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b7f2043
--- /dev/null
@@ -0,0 +1,42 @@
+PROJECT(hal-backend-service-device-display 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_DISPLAY\"")
+ENDIF()
+
+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
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+         SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_CFLAGS} ${EXTRA_CFLAGS}")
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/generated)
+
+SET(SRCS
+       ${PROJECT_SOURCE_DIR}/${LIBRARY_NAME}.c
+       ${CMAKE_SOURCE_DIR}/src/hal-api-device-display.c
+       ${CMAKE_SOURCE_DIR}/src/hal-api-device-display-passthrough.c
+       ${CMAKE_SOURCE_DIR}/src/generated/hal_device_display_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/display/hal-backend-service-device-display.c b/hal-backend-service-plugin/display/hal-backend-service-device-display.c
new file mode 100644 (file)
index 0000000..fa69187
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+ * HAL Backend Service Plugin for HAL_MODULE_DEVICE_DISPLAY
+ *
+ * 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-api-device-display-passthrough.h>
+
+#include "common.h"
+
+extern char *program_invocation_name;
+
+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)
+{
+       char *sender = NULL;
+       rpc_port_stub_hal_device_display_stub_1_device_display_context_get_sender(context, &sender);
+       if (!sender)
+               return;
+
+       free(sender);
+}
+
+static void device_display_ipc_terminate(rpc_port_stub_hal_device_display_stub_1_device_display_context_h context,
+               void *user_data)
+{
+       char *sender = NULL;
+
+       rpc_port_stub_hal_device_display_stub_1_device_display_context_get_sender(context, &sender);
+       if (!sender)
+               return;
+
+       free(sender);
+}
+
+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)
+{
+       int ret = 0;
+
+       _D("Starting by %s\n", program_invocation_name);
+
+       if (!brightness)
+               return -EINVAL;
+
+       ret = hal_device_display_passthrough_get_brightness(brightness);
+       if (ret < 0)
+               return ret;
+
+       _D("Started by %s\n", program_invocation_name);
+
+       return 0;
+}
+
+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);
+       if (ret < 0)
+               return ret;
+       *state = (rpc_port_stub_hal_device_display_stub_1_enums_state_e)state_e;
+
+       return 0;
+}
+
+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);
+       if (ret < 0)
+               return ret;
+       *effect = (rpc_port_stub_hal_device_display_stub_1_enums_image_effect_e)image_effect;
+
+       return 0;
+}
+
+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);
+       if (ret < 0)
+               return ret;
+       *mode = (rpc_port_stub_hal_device_display_stub_1_enums_panel_mode_e)panel_mode;
+
+       return 0;
+}
+
+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);
+       if (ret < 0)
+               return ret;
+       *mode = (rpc_port_stub_hal_device_display_stub_1_enums_aod_mode_e)aod_mode;
+
+       return 0;
+}
+
+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);
+       if (ret < 0)
+               return ret;
+       *angle = (rpc_port_stub_hal_device_display_stub_1_enums_rotation_angle_e)rotation_angle;
+
+       return 0;
+}
+
+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 display backend: %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 rpc_port_stub_hal_device_display_stub_1_device_display_callback_s 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,
+};
index 8eeef17a6b37bebb99a4253252e015e5a1b35569..8c0f6d53fa99cb0d96d8f1d3fa00ee8fbd881459 100644 (file)
@@ -72,6 +72,7 @@ cp %{SOURCE2} %{buildroot}%{_sysconfdir}/hal/
 %manifest %{name}.manifest
 %license LICENSE.Apache-2.0
 %{_libdir}/hal/libhal-api-device.so*
+%{_libdir}/hal/libhal-backend-service-device-display.so
 %{_sysconfdir}/hal/hal-api-device-manifest.xml
 
 %files devel