summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunhee Seo <yuni.seo@samsung.com>2024-04-02 20:23:52 +0900
committerYunhee Seo <yuni.seo@samsung.com>2024-04-04 10:29:46 +0900
commit76e39bd49f09eff0d1708f0dcc447abba298aa74 (patch)
tree5bef37927bf64d499bcc931006491764100b2677
parentc49cb7d57e90d30a0f144ee1c34b67b8a54c73de (diff)
downloaddevice-76e39bd49f09eff0d1708f0dcc447abba298aa74.tar.gz
device-76e39bd49f09eff0d1708f0dcc447abba298aa74.tar.bz2
device-76e39bd49f09eff0d1708f0dcc447abba298aa74.zip
device-display: Apply HAL ABI versioning rule
In HAL-API-[module], source file name should follow hal-api-[module].c format for applying HAL ABI versioning. hal-api-device-display.c -> HAL-INTERFACE Wrapper call according to major version and implemenation of functions declared in hal-device-display.h To apply HAL ABI versioning, the backend function structure memory allocation part was moved to hal-api-device-display. Change-Id: I6c203c078a512e474a8568b1303bcfbf20afe31e Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r--src/hal-api-device-display.c (renamed from src/display.c)270
1 files changed, 81 insertions, 189 deletions
diff --git a/src/display.c b/src/hal-api-device-display.c
index 18881f2..a8969ef 100644
--- a/src/display.c
+++ b/src/hal-api-device-display.c
@@ -20,12 +20,6 @@
#include "common.h"
static hal_backend_device_display_funcs *hal_device_display_funcs = NULL;
-/*
--1 : failed to initialize
-0 : not initialized
-1 : succeeded to initialize
-*/
-static int hal_initialized = 0;
int hal_device_display_get_backend(void)
{
@@ -34,345 +28,250 @@ int hal_device_display_get_backend(void)
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 display backend");
- hal_initialized = -1;
- return -EINVAL;
+ _E("Failed to get device-display backend");
+ free(hal_device_display_funcs);
+ return -ENOTSUP;
}
- hal_initialized = 1;
return 0;
}
int hal_device_display_put_backend(void)
{
+ int ret = 0;
+
if (!hal_device_display_funcs)
- return 0;
+ return -ENOTSUP;
- hal_common_put_backend(HAL_MODULE_DEVICE_DISPLAY, (void *)hal_device_display_funcs);
- hal_device_display_funcs = NULL;
- hal_initialized = 0;
+ 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_get_max_brightness(int *brightness)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!brightness)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_max_brightness)
- return -ENODEV;
+ !hal_device_display_funcs->get_max_brightness)
+ return -ENOTSUP;
return hal_device_display_funcs->get_max_brightness(brightness);
}
int hal_device_display_get_brightness(int *brightness)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!brightness)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_brightness)
- return -ENODEV;
+ !hal_device_display_funcs->get_brightness)
+ return -ENOTSUP;
return hal_device_display_funcs->get_brightness(brightness);
}
int hal_device_display_set_brightness(int brightness)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_brightness)
- return -ENODEV;
+ !hal_device_display_funcs->set_brightness)
+ return -ENOTSUP;
return hal_device_display_funcs->set_brightness(brightness);
}
int hal_device_display_set_multi_brightness(int brightness, int step, int delay)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_multi_brightness)
- return -ENODEV;
+ !hal_device_display_funcs->set_multi_brightness)
+ return -ENOTSUP;
return hal_device_display_funcs->set_multi_brightness(brightness, step, delay);
}
int hal_device_display_get_auto_brightness(float lmax, float lmin, float light, int *brightness)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!brightness)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_auto_brightness)
- return -ENODEV;
+ !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_get_state(hal_device_display_state_e *state)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!state)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_state)
- return -ENODEV;
+ !hal_device_display_funcs->get_state)
+ return -ENOTSUP;
return hal_device_display_funcs->get_state(state);
}
int hal_device_display_set_state(hal_device_display_state_e state)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_state)
- return -ENODEV;
+ !hal_device_display_funcs->set_state)
+ return -ENOTSUP;
return hal_device_display_funcs->set_state(state);
}
int hal_device_display_get_image_effect(hal_device_display_image_effect_e *effect)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!effect)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_image_effect)
- return -ENODEV;
+ !hal_device_display_funcs->get_image_effect)
+ return -ENOTSUP;
return hal_device_display_funcs->get_image_effect(effect);
}
int hal_device_display_set_image_effect(hal_device_display_image_effect_e effect)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_image_effect)
- return -ENODEV;
+ !hal_device_display_funcs->set_image_effect)
+ return -ENOTSUP;
return hal_device_display_funcs->set_image_effect(effect);
}
int hal_device_display_get_panel_mode(hal_device_display_panel_mode_e *mode)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!mode)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_panel_mode)
- return -ENODEV;
+ !hal_device_display_funcs->get_panel_mode)
+ return -ENOTSUP;
return hal_device_display_funcs->get_panel_mode(mode);
}
int hal_device_display_set_panel_mode(hal_device_display_panel_mode_e mode)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_panel_mode)
- return -ENODEV;
+ !hal_device_display_funcs->set_panel_mode)
+ return -ENOTSUP;
return hal_device_display_funcs->set_panel_mode(mode);
}
int hal_device_display_get_aod_mode(hal_device_display_aod_mode_e *mode)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!mode)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_aod_mode)
- return -ENODEV;
+ !hal_device_display_funcs->get_aod_mode)
+ return -ENOTSUP;
return hal_device_display_funcs->get_aod_mode(mode);
}
int hal_device_display_get_aod_brightness(int *max, int *normal, int *min, int *charging)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_aod_brightness)
- return -ENODEV;
+ !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_get_max_frame_rate(int *rate)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!rate)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_max_frame_rate)
- return -ENODEV;
+ !hal_device_display_funcs->get_max_frame_rate)
+ return -ENOTSUP;
return hal_device_display_funcs->get_max_frame_rate(rate);
}
int hal_device_display_get_min_frame_rate(int *rate)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!rate)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_min_frame_rate)
- return -ENODEV;
+ !hal_device_display_funcs->get_min_frame_rate)
+ return -ENOTSUP;
return hal_device_display_funcs->get_min_frame_rate(rate);
}
int hal_device_display_get_frame_rate(int *rate)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!rate)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_frame_rate)
- return -ENODEV;
+ !hal_device_display_funcs->get_frame_rate)
+ return -ENOTSUP;
return hal_device_display_funcs->get_frame_rate(rate);
}
int hal_device_display_set_frame_rate(int rate)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_frame_rate)
- return -ENODEV;
+ !hal_device_display_funcs->set_frame_rate)
+ return -ENOTSUP;
return hal_device_display_funcs->set_frame_rate(rate);
}
int hal_device_display_set_white_balance(hal_device_display_white_balance_e white_balance_type, int value)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
!hal_device_display_funcs->set_white_balance)
- return -ENODEV;
+ return -ENOTSUP;
return hal_device_display_funcs->set_white_balance(white_balance_type, value);
}
int hal_device_display_get_white_balance(hal_device_display_white_balance_e white_balance_type, int* value)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!value)
+ return -EINVAL;
if (!hal_device_display_funcs ||
!hal_device_display_funcs->get_white_balance)
- return -ENODEV;
+ return -ENOTSUP;
return hal_device_display_funcs->get_white_balance(white_balance_type, value);
}
int hal_device_display_get_rotation_angle(int display_index, hal_device_display_rotation_angle_e *angle)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
+ if (!angle)
+ return -EINVAL;
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->get_rotation_angle)
- return -ENODEV;
+ !hal_device_display_funcs->get_rotation_angle)
+ return -ENOTSUP;
return hal_device_display_funcs->get_rotation_angle(display_index, angle);
}
@@ -381,16 +280,9 @@ int hal_device_display_set_rotation_angle(int display_index,
hal_device_display_rotation_angle_e angle,
hal_device_display_rotation_direction_e direction)
{
- int ret;
-
- if (!hal_device_display_funcs && !hal_initialized) {
- if ((ret = hal_device_display_get_backend()) < 0)
- return ret;
- }
-
if (!hal_device_display_funcs ||
- !hal_device_display_funcs->set_rotation_angle)
- return -ENODEV;
+ !hal_device_display_funcs->set_rotation_angle)
+ return -ENOTSUP;
return hal_device_display_funcs->set_rotation_angle(display_index, angle, direction);
}