From: Yunhee Seo Date: Thu, 13 Feb 2025 04:32:43 +0000 (+0900) Subject: device-display: Add hal-api passthrough module X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb160df1f389df25a7192f88a52705bb82ec7bca;p=platform%2Fhal%2Fapi%2Fdevice.git device-display: Add hal-api passthrough module As hal-api module supporting ipc communcation, hal-backend dlopen loading method should be devided. The newly added code is same as the existing hal-api codes. Change-Id: If0577aaeff69a900431920de38e6b80e3eb663de Signed-off-by: Yunhee Seo --- diff --git a/src/hal-api-device-display-passthrough.c b/src/hal-api-device-display-passthrough.c new file mode 100644 index 0000000..acd71bd --- /dev/null +++ b/src/hal-api-device-display-passthrough.c @@ -0,0 +1,438 @@ +/* + * 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 + +#include + +#include "hal-device-display-passthrough.h" +#include "common.h" + +static hal_backend_device_display_funcs *hal_device_display_funcs = NULL; + +int hal_device_display_passthrough_get_backend(void) +{ + int ret; + + if (hal_device_display_funcs) + return 0; + + hal_device_display_funcs = calloc(1, sizeof(hal_backend_device_display_funcs)); + if (!hal_device_display_funcs) + return -ENOMEM; + + ret = hal_common_get_backend(HAL_MODULE_DEVICE_DISPLAY, (void **)&hal_device_display_funcs); + if (ret < 0) { + _E("Failed to get device-display backend"); + free(hal_device_display_funcs); + hal_device_display_funcs = NULL; + return -ENOTSUP; + } + + return 0; +} + +int hal_device_display_passthrough_put_backend(void) +{ + int ret = 0; + + if (!hal_device_display_funcs) + return -ENOTSUP; + + ret = hal_common_put_backend(HAL_MODULE_DEVICE_DISPLAY, (void *)hal_device_display_funcs); + if (ret < 0) { + _E("Failed to put device-display backend"); + return ret; + } + + free(hal_device_display_funcs); + hal_device_display_funcs = NULL; + + return 0; +} + +int hal_device_display_passthrough_get_max_brightness(int *brightness) +{ + int ret = 0; + + if (!brightness) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_max_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->get_max_brightness(brightness); +} + +int hal_device_display_passthrough_get_brightness(int *brightness) +{ + int ret = 0; + + if (!brightness) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->get_brightness(brightness); +} + +int hal_device_display_passthrough_set_brightness(int brightness) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->set_brightness(brightness); +} + +int hal_device_display_passthrough_set_multi_brightness(int brightness, int step, int delay) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_multi_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->set_multi_brightness(brightness, step, delay); +} + +int hal_device_display_passthrough_get_auto_brightness(float lmax, float lmin, float light, int *brightness) +{ + int ret = 0; + + if (!brightness) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_auto_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->get_auto_brightness(lmax, lmin, light, brightness); +} + +int hal_device_display_passthrough_get_state(hal_device_display_state_e *state) +{ + int ret = 0; + + if (!state) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_state) + return -ENOTSUP; + + return hal_device_display_funcs->get_state(state); +} + +int hal_device_display_passthrough_set_state(hal_device_display_state_e state) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_state) + return -ENOTSUP; + + return hal_device_display_funcs->set_state(state); +} + +int hal_device_display_passthrough_get_image_effect(hal_device_display_image_effect_e *effect) +{ + int ret = 0; + + if (!effect) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_image_effect) + return -ENOTSUP; + + return hal_device_display_funcs->get_image_effect(effect); +} + +int hal_device_display_passthrough_set_image_effect(hal_device_display_image_effect_e effect) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_image_effect) + return -ENOTSUP; + + return hal_device_display_funcs->set_image_effect(effect); +} + +int hal_device_display_passthrough_get_panel_mode(hal_device_display_panel_mode_e *mode) +{ + int ret = 0; + + if (!mode) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_panel_mode) + return -ENOTSUP; + + return hal_device_display_funcs->get_panel_mode(mode); +} + +int hal_device_display_passthrough_set_panel_mode(hal_device_display_panel_mode_e mode) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_panel_mode) + return -ENOTSUP; + + return hal_device_display_funcs->set_panel_mode(mode); +} + +int hal_device_display_passthrough_get_aod_mode(hal_device_display_aod_mode_e *mode) +{ + int ret = 0; + + if (!mode) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_aod_mode) + return -ENOTSUP; + + return hal_device_display_funcs->get_aod_mode(mode); +} + +int hal_device_display_passthrough_get_aod_brightness(int *max, int *normal, int *min, int *charging) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_aod_brightness) + return -ENOTSUP; + + return hal_device_display_funcs->get_aod_brightness(max, normal, min, charging); +} + +int hal_device_display_passthrough_get_max_frame_rate(int *rate) +{ + int ret = 0; + + if (!rate) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_max_frame_rate) + return -ENOTSUP; + + return hal_device_display_funcs->get_max_frame_rate(rate); +} + +int hal_device_display_passthrough_get_min_frame_rate(int *rate) +{ + int ret = 0; + + if (!rate) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_min_frame_rate) + return -ENOTSUP; + + return hal_device_display_funcs->get_min_frame_rate(rate); +} + +int hal_device_display_passthrough_get_frame_rate(int *rate) +{ + int ret = 0; + + if (!rate) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_frame_rate) + return -ENOTSUP; + + return hal_device_display_funcs->get_frame_rate(rate); +} + +int hal_device_display_passthrough_set_frame_rate(int rate) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_frame_rate) + return -ENOTSUP; + + return hal_device_display_funcs->set_frame_rate(rate); +} + +int hal_device_display_passthrough_set_white_balance(hal_device_display_white_balance_e white_balance_type, int value) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_white_balance) + return -ENOTSUP; + + return hal_device_display_funcs->set_white_balance(white_balance_type, value); +} + +int hal_device_display_passthrough_get_white_balance(hal_device_display_white_balance_e white_balance_type, int* value) +{ + int ret = 0; + + if (!value) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_white_balance) + return -ENOTSUP; + + return hal_device_display_funcs->get_white_balance(white_balance_type, value); +} + +int hal_device_display_passthrough_get_rotation_angle(int display_index, hal_device_display_rotation_angle_e *angle) +{ + int ret = 0; + + if (!angle) + return -EINVAL; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->get_rotation_angle) + return -ENOTSUP; + + return hal_device_display_funcs->get_rotation_angle(display_index, angle); +} + +int hal_device_display_passthrough_set_rotation_angle(int display_index, + hal_device_display_rotation_angle_e angle, + hal_device_display_rotation_direction_e direction) +{ + int ret = 0; + + if (!hal_device_display_funcs) { + if ((ret = hal_device_display_passthrough_get_backend()) < 0) + return ret; + } + + if (!hal_device_display_funcs || + !hal_device_display_funcs->set_rotation_angle) + return -ENOTSUP; + + return hal_device_display_funcs->set_rotation_angle(display_index, angle, direction); +} diff --git a/src/hal-device-display-passthrough.h b/src/hal-device-display-passthrough.h new file mode 100644 index 0000000..92c1e7b --- /dev/null +++ b/src/hal-device-display-passthrough.h @@ -0,0 +1,56 @@ +/* + * 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_DEVICE_DISPLAY_PASSTHROUGH_H__ +#define __HAL_DEVICE_DISPLAY_PASSTHROUGH_H__ + +#include "hal-device-display-interface.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int hal_device_display_passthrough_get_backend(void); +int hal_device_display_passthrough_put_backend(void); +int hal_device_display_passthrough_get_max_brightness(int *brightness); +int hal_device_display_passthrough_get_brightness(int *brightness); +int hal_device_display_passthrough_set_brightness(int brightness); +int hal_device_display_passthrough_set_multi_brightness(int brightness, int step, int delay); +int hal_device_display_passthrough_get_auto_brightness(float lmax, float lmin, float light, int *brightness); +int hal_device_display_passthrough_get_state(hal_device_display_state_e *state); +int hal_device_display_passthrough_set_state(hal_device_display_state_e state); +int hal_device_display_passthrough_get_image_effect(hal_device_display_image_effect_e *effect); +int hal_device_display_passthrough_set_image_effect(hal_device_display_image_effect_e effect); +int hal_device_display_passthrough_get_panel_mode(hal_device_display_panel_mode_e *mode); +int hal_device_display_passthrough_set_panel_mode(hal_device_display_panel_mode_e mode); +int hal_device_display_passthrough_get_aod_mode(hal_device_display_aod_mode_e *mode); +int hal_device_display_passthrough_get_aod_brightness(int *max, int *normal, int *min, int *charging); +int hal_device_display_passthrough_get_max_frame_rate(int *rate); +int hal_device_display_passthrough_get_min_frame_rate(int *rate); +int hal_device_display_passthrough_get_frame_rate(int *rate); +int hal_device_display_passthrough_set_frame_rate(int rate); +int hal_device_display_passthrough_set_white_balance(hal_device_display_white_balance_e white_balance_type, int value); +int hal_device_display_passthrough_get_white_balance(hal_device_display_white_balance_e white_balance_type, int* value); +int hal_device_display_passthrough_get_rotation_angle(int display_index, hal_device_display_rotation_angle_e *angle); +int hal_device_display_passthrough_set_rotation_angle(int display_index, hal_device_display_rotation_angle_e angle, + hal_device_display_rotation_direction_e direction); + +#ifdef __cplusplus +} +#endif + +#endif // __HAL_DEVICE_DISPLAY_PASSTHROUGH_H__ \ No newline at end of file