From: Yunhee Seo Date: Thu, 20 Feb 2025 10:13:03 +0000 (+0900) Subject: hal-backend-service-plugin: device-display: Add plugin library code X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc97fbe6ee9c5e103991e14e46c503512363116c;p=platform%2Fhal%2Fapi%2Fdevice.git hal-backend-service-plugin: device-display: Add plugin library code With this, hal-api-common can open hal-backend-service from the device-display plugin library. Also, to communicate with proxy side(hal-api-device-display module), stub callback should be added and initialized. Thus, below logics are added. - Create hal-backend-service-plugin device-display library. - Handling stub callback by tidl, it uses passthrough internally. - Initialization for IPC communication. Change-Id: I290bcba35aaf0c1638ef0a69ff01019d9a3b2b4f Signed-off-by: Yunhee Seo --- diff --git a/hal-backend-service-plugin/display/CMakeLists.txt b/hal-backend-service-plugin/display/CMakeLists.txt new file mode 100644 index 0000000..3652e2a --- /dev/null +++ b/hal-backend-service-plugin/display/CMakeLists.txt @@ -0,0 +1,43 @@ +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_PLUGIN\"") +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) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) + +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 index 0000000..34cc05e --- /dev/null +++ b/hal-backend-service-plugin/display/hal-backend-service-device-display.c @@ -0,0 +1,273 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#include + +#include +#include + +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, +}; diff --git a/packaging/hal-api-device.spec b/packaging/hal-api-device.spec index e44902d..a25bf5b 100644 --- a/packaging/hal-api-device.spec +++ b/packaging/hal-api-device.spec @@ -51,7 +51,8 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} \ -DMAJORVER=${MAJORVER} \ -DHALTEST=on \ - -DHAL_TRANSPORT=%{hal_transport} + -DHAL_TRANSPORT=%{hal_transport} \ + -DENABLE_DLOG=1 %__make %{?jobs:-j%jobs}