display: Move white_balance_ops functions from plugins to core display module 70/288470/1
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 16 Feb 2023 06:16:07 +0000 (15:16 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 17 Feb 2023 03:16:55 +0000 (12:16 +0900)
Remove and redefine functions related to display white balance work.
Because white balancing is common for display.
Thus, these functions are added below display-panel.

int display_panel_set_white_balance(enum hal_display_white_balance white_balance_type, int value)
int display_panel_get_white_balance(enum hal_display_white_balance white_balance_type, int* out_val)
-> With hal_display_white_balance enum type, it is possible to get and set white_balance values.

Change-Id: I10213315d109e47f0e8c3a58382648ccef3ca2d1
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
12 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/device-interface.c
plugins/mobile/display/core.c
plugins/mobile/display/device-interface.c
plugins/tv/display/core.c
plugins/tv/display/device-interface.c
plugins/wearable/display/core.c
plugins/wearable/display/device-interface.c
src/display/device-interface.h
src/display/display-dbus.c
src/display/display-panel.c [new file with mode: 0644]
src/display/display-panel.h [new file with mode: 0644]

index 8e2fd12..0a87e47 100644 (file)
@@ -91,7 +91,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct _backlight_ops *backlight_ops;
-static struct _display_white_balance_ops *display_white_balance_ops;
 static struct battery_plugin *battery_plgn;
 static int (*fp_get_charging_status) (int *val);
 static void (*power_saving_func) (int onoff);
@@ -2352,10 +2351,6 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
 
-       display_white_balance_ops = get_var_display_white_balance_ops();
-       if (!display_white_balance_ops)
-               _E("Failed to get display white balance operator variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
index c6bf212..ecb5eb2 100644 (file)
 #define LCD_PHASED_DELAY               10000   /* microsecond */
 #define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
-#define MAX_WHITE_BALANCE_GAIN                 2047
-#define MAX_WHITE_BALANCE_OFFSET               2047
-#define DEFAULT_WHITE_BALANCE_GAIN             1024
-#define DEFAULT_WHITE_BALANCE_OFFSET           0
-
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
 #define GESTURE_STR                    "gesture"
@@ -74,7 +69,6 @@
 #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state"
 
 static struct _backlight_ops backlight_ops;
-static struct _display_white_balance_ops display_white_balance_ops;
 static bool custom_status;
 static int custom_brightness;
 static int force_brightness;
@@ -89,11 +83,6 @@ inline struct _backlight_ops *get_var_backlight_ops(void)
        return &backlight_ops;
 }
 
-inline struct _display_white_balance_ops *get_var_display_white_balance_ops(void)
-{
-       return &display_white_balance_ops;
-}
-
 bool display_dev_ready(void)
 {
        return display_dev_available;
@@ -750,77 +739,6 @@ static void release_blink(void)
        release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
 }
 
-static int set_white_balance(enum hal_display_white_balance white_balance_type, int value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-               if (value > MAX_WHITE_BALANCE_GAIN)
-                       value = DEFAULT_WHITE_BALANCE_GAIN;
-               break;
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               if (value > MAX_WHITE_BALANCE_OFFSET)
-                       value = DEFAULT_WHITE_BALANCE_OFFSET;
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_set_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Set white balance is not supported.");
-               else
-                       _E("Failed to set white balance value.");
-       }
-
-       return ret;
-}
-
-static int get_white_balance(enum hal_display_white_balance white_balance_type, int* value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_get_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get white balance is not supported.");
-               else
-                       _E("Failed to get white balance value.");
-       }
-
-       return ret;
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -859,11 +777,6 @@ static struct _backlight_ops backlight_ops = {
        .release_blink = release_blink,
 };
 
-static struct _display_white_balance_ops display_white_balance_ops = {
-       .set_white_balance = set_white_balance,
-       .get_white_balance = get_white_balance,
-};
-
 int display_service_load(void)
 {
        int r;
index 9078ff4..7948278 100644 (file)
@@ -92,7 +92,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct _backlight_ops *backlight_ops;
-static struct _display_white_balance_ops *display_white_balance_ops;
 static struct battery_plugin *battery_plgn;
 static int (*fp_get_charging_status) (int *val);
 
@@ -2363,10 +2362,6 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
 
-       display_white_balance_ops = get_var_display_white_balance_ops();
-       if (!display_white_balance_ops)
-               _E("Failed to get display white balance operator variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
index 14c5fd5..cef8002 100644 (file)
 #define LCD_PHASED_DELAY               10000   /* microsecond */
 #define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
-#define MAX_WHITE_BALANCE_GAIN                 2047
-#define MAX_WHITE_BALANCE_OFFSET               2047
-#define DEFAULT_WHITE_BALANCE_GAIN             1024
-#define DEFAULT_WHITE_BALANCE_OFFSET           0
-
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
 #define GESTURE_STR                    "gesture"
@@ -73,7 +68,6 @@
 #define UNKNOWN_STR                    "unknown"
 
 static struct _backlight_ops backlight_ops;
-static struct _display_white_balance_ops display_white_balance_ops;
 static bool custom_status;
 static int custom_brightness;
 static int force_brightness;
@@ -88,11 +82,6 @@ inline struct _backlight_ops *get_var_backlight_ops(void)
        return &backlight_ops;
 }
 
-inline struct _display_white_balance_ops *get_var_display_white_balance_ops(void)
-{
-       return &display_white_balance_ops;
-}
-
 bool display_dev_ready(void)
 {
        return display_dev_available;
@@ -749,77 +738,6 @@ static void release_blink(void)
        release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
 }
 
-static int set_white_balance(enum hal_display_white_balance white_balance_type, int value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-               if (value > MAX_WHITE_BALANCE_GAIN)
-                       value = DEFAULT_WHITE_BALANCE_GAIN;
-               break;
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               if (value > MAX_WHITE_BALANCE_OFFSET)
-                       value = DEFAULT_WHITE_BALANCE_OFFSET;
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_set_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Set white balance is not supported.");
-               else
-                       _E("Failed to set white balance value.");
-       }
-
-       return ret;
-}
-
-static int get_white_balance(enum hal_display_white_balance white_balance_type, int* value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_get_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get white balance is not supported.");
-               else
-                       _E("Failed to get white balance value.");
-       }
-
-       return ret;
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -858,11 +776,6 @@ static struct _backlight_ops backlight_ops = {
        .release_blink = release_blink,
 };
 
-static struct _display_white_balance_ops display_white_balance_ops = {
-       .set_white_balance = set_white_balance,
-       .get_white_balance = get_white_balance,
-};
-
 int display_service_load(void)
 {
        int r;
index 90f4e67..f9655cd 100644 (file)
@@ -90,7 +90,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct _backlight_ops *backlight_ops;
-static struct _display_white_balance_ops *display_white_balance_ops;
 static struct battery_plugin *battery_plgn;
 static int (*fp_get_charging_status) (int *val);
 
@@ -2349,10 +2348,6 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
 
-       display_white_balance_ops = get_var_display_white_balance_ops();
-       if (!display_white_balance_ops)
-               _E("Failed to get display white balance operator variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
index ad11487..8c1cd1c 100644 (file)
 #define LCD_PHASED_DELAY               10000   /* microsecond */
 #define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
-#define MAX_WHITE_BALANCE_GAIN                 2047
-#define MAX_WHITE_BALANCE_OFFSET               2047
-#define DEFAULT_WHITE_BALANCE_GAIN             1024
-#define DEFAULT_WHITE_BALANCE_OFFSET           0
-
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
 #define GESTURE_STR                    "gesture"
@@ -74,7 +69,6 @@
 #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state"
 
 static struct _backlight_ops backlight_ops;
-static struct _display_white_balance_ops display_white_balance_ops;
 static bool custom_status;
 static int custom_brightness;
 static int force_brightness;
@@ -89,11 +83,6 @@ inline struct _backlight_ops *get_var_backlight_ops(void)
        return &backlight_ops;
 }
 
-inline struct _display_white_balance_ops *get_var_display_white_balance_ops(void)
-{
-       return &display_white_balance_ops;
-}
-
 bool display_dev_ready(void)
 {
        return display_dev_available;
@@ -750,77 +739,6 @@ static void release_blink(void)
        release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL);
 }
 
-static int set_white_balance(enum hal_display_white_balance white_balance_type, int value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-               if (value > MAX_WHITE_BALANCE_GAIN)
-                       value = DEFAULT_WHITE_BALANCE_GAIN;
-               break;
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               if (value > MAX_WHITE_BALANCE_OFFSET)
-                       value = DEFAULT_WHITE_BALANCE_OFFSET;
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_set_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Set white balance is not supported.");
-               else
-                       _E("Failed to set white balance value.");
-       }
-
-       return ret;
-}
-
-static int get_white_balance(enum hal_display_white_balance white_balance_type, int* value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_get_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get white balance is not supported.");
-               else
-                       _E("Failed to get white balance value.");
-       }
-
-       return ret;
-}
-
 static void restore_brightness_func(void)
 {
        backlight_ops.set_brightness = set_brightness;
@@ -859,11 +777,6 @@ static struct _backlight_ops backlight_ops = {
        .release_blink = release_blink,
 };
 
-static struct _display_white_balance_ops display_white_balance_ops = {
-       .set_white_balance = set_white_balance,
-       .get_white_balance = get_white_balance,
-};
-
 int display_service_load(void)
 {
        int r;
index 3947491..293206d 100644 (file)
@@ -101,7 +101,6 @@ extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
 static struct _backlight_ops *backlight_ops;
-static struct _display_white_balance_ops *display_white_balance_ops;
 static struct battery_plugin *battery_plgn;
 static int (*fp_get_charging_status) (int *val);
 
@@ -2680,10 +2679,6 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
 
-       display_white_balance_ops = get_var_display_white_balance_ops();
-       if (!display_white_balance_ops)
-               _E("Failed to get display white balance operator variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                 _E("Failed to get battery plugin variable.");
index d9fe84f..9689dd0 100644 (file)
 #define LCD_PHASED_DELAY               10000   /* microsecond */
 #define DUMP_MODE_WAITING_TIME         600000  /* milisecond */
 
-#define MAX_WHITE_BALANCE_GAIN                 2047
-#define MAX_WHITE_BALANCE_OFFSET               2047
-#define DEFAULT_WHITE_BALANCE_GAIN             1024
-#define DEFAULT_WHITE_BALANCE_OFFSET           0
-
 #define DISPLAY_HAL_LIB_PATH "/usr/lib/libdisplay-hal.so"
 
 #define GESTURE_STR                    "gesture"
@@ -79,7 +74,6 @@
 
 
 static struct _backlight_ops backlight_ops;
-static struct _display_white_balance_ops display_white_balance_ops;
 static struct battery_plugin *battery_plgn;
 static bool custom_status;
 static int custom_brightness;
@@ -101,11 +95,6 @@ inline struct _backlight_ops *get_var_backlight_ops(void)
        return &backlight_ops;
 }
 
-inline struct _display_white_balance_ops *get_var_display_white_balance_ops(void)
-{
-       return &display_white_balance_ops;
-}
-
 bool display_dev_ready(void)
 {
        return display_dev_available;
@@ -822,77 +811,6 @@ static void restore_brightness_func(void)
        backlight_ops.transit_brt = change_brightness;
 }
 
-static int set_white_balance(enum hal_display_white_balance white_balance_type, int value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-               if (value > MAX_WHITE_BALANCE_GAIN)
-                       value = DEFAULT_WHITE_BALANCE_GAIN;
-               break;
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               if (value > MAX_WHITE_BALANCE_OFFSET)
-                       value = DEFAULT_WHITE_BALANCE_OFFSET;
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_set_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Set white balance is not supported.");
-               else
-                       _E("Failed to set white balance value.");
-       }
-
-       return ret;
-}
-
-static int get_white_balance(enum hal_display_white_balance white_balance_type, int* value)
-{
-       int ret = 0;
-
-       if (!display_dev_available) {
-               _E("There is no display device.");
-               return -ENOENT;
-       }
-
-       switch (white_balance_type) {
-       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
-       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
-       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
-               break;
-       default:
-               _E("Unknown white balance type");
-               return -EINVAL;
-       }
-
-       ret = hal_device_display_get_white_balance(white_balance_type, value);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get white balance is not supported.");
-               else
-                       _E("Failed to get white balance value.");
-       }
-
-       return ret;
-}
-
 static struct _backlight_ops backlight_ops = {
        .off = backlight_off,
        .dim = backlight_dim,
@@ -926,11 +844,6 @@ static struct _backlight_ops backlight_ops = {
        .get_brightness_raw = get_brightness, /* always fetch brightness from node even LBM mode */
 };
 
-static struct _display_white_balance_ops display_white_balance_ops = {
-       .set_white_balance = set_white_balance,
-       .get_white_balance = get_white_balance,
-};
-
 int display_service_load(void)
 {
        int r;
index 56b41e4..759ff50 100644 (file)
@@ -94,13 +94,6 @@ struct _backlight_ops {
 
 struct _backlight_ops *get_var_backlight_ops(void);
 
-struct _display_white_balance_ops {
-       int (*set_white_balance)(enum hal_display_white_balance white_balance_type, int value);
-       int (*get_white_balance)(enum hal_display_white_balance white_balance_type, int* out_val);
-};
-
-struct _display_white_balance_ops *get_var_display_white_balance_ops(void);
-
 enum dpms_state {
        DPMS_ON,       /* In use */
        DPMS_STANDBY,  /* Blanked, low power */
index c181d0f..5c92a43 100644 (file)
@@ -44,6 +44,7 @@
 #include "display.h"
 #include "shared/plugin.h"
 #include "display-lock.h"
+#include "display-panel.h"
 
 #define AUL_APPSTATUS_PATH             "/Org/Tizen/Aul/AppStatus"
 #define AUL_APPSTATUS_INTERFACE                "org.tizen.aul.AppStatus"
@@ -72,7 +73,6 @@
 
 static struct display_plugin *disp_plgn;
 static struct _backlight_ops *backlight_ops;
-static struct _display_white_balance_ops *display_white_balance_ops;
 static struct display_config *display_conf;
 
 static GVariant *dbus_start(GDBusConnection *conn,
@@ -1210,7 +1210,7 @@ static GVariant *dbus_setwhitebalance(GDBusConnection *conn,
 
        g_variant_get(param, "(ii)", &white_balance_type, &value);
 
-       ret_val = display_white_balance_ops->set_white_balance(white_balance_type, value);
+       ret_val = display_panel_set_white_balance(white_balance_type, value);
        if (ret_val < 0) {
                _E("Failed to set white balance");
                ret = -EPERM;
@@ -1232,7 +1232,7 @@ static GVariant *dbus_getwhitebalance(GDBusConnection *conn,
 
        g_variant_get(param, "(i)", &white_balance_type);
 
-       ret = display_white_balance_ops->get_white_balance(white_balance_type, &ret_val);
+       ret = display_panel_get_white_balance(white_balance_type, &ret_val);
        if (ret < 0) {
                _E("Failed to get white balance");
                ret = -EPERM;
@@ -1474,10 +1474,6 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _E("Failed to get backlight operator variable.");
 
-       display_white_balance_ops = get_var_display_white_balance_ops();
-       if (!display_white_balance_ops)
-               _E("Failed to get display white balance operator variable.");
-
        display_conf = get_var_display_config();
        if (!display_conf)
                _E("Failed to get display configuration variable.");
diff --git a/src/display/display-panel.c b/src/display/display-panel.c
new file mode 100644 (file)
index 0000000..9d65416
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 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 "shared/log.h"
+#include "display-panel.h"
+#include "display.h"
+
+#define MAX_WHITE_BALANCE_GAIN                 2047
+#define MAX_WHITE_BALANCE_OFFSET               2047
+#define DEFAULT_WHITE_BALANCE_GAIN             1024
+#define DEFAULT_WHITE_BALANCE_OFFSET           0
+
+int display_panel_set_white_balance(enum hal_display_white_balance white_balance_type,
+                                       int value)
+{
+       int ret = 0;
+
+       if (!display_is_hal_backend_available()) {
+               _E("There is no display device.");
+               return -ENOENT;
+       }
+
+       switch (white_balance_type) {
+       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
+       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
+       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
+               if (value > MAX_WHITE_BALANCE_GAIN)
+                       value = DEFAULT_WHITE_BALANCE_GAIN;
+               break;
+       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
+       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
+       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
+               if (value > MAX_WHITE_BALANCE_OFFSET)
+                       value = DEFAULT_WHITE_BALANCE_OFFSET;
+               break;
+       default:
+               _E("Unknown white balance type");
+               return -EINVAL;
+       }
+
+       ret = hal_device_display_set_white_balance(white_balance_type, value);
+       if (ret == -ENODEV)
+               _E("Set white balance is not supported.");
+       else if (ret < 0)
+               _E("Failed to set white balance value.");
+
+       return ret;
+}
+
+int display_panel_get_white_balance(enum hal_display_white_balance white_balance_type,
+                                       int* value)
+{
+       int ret = 0;
+
+       if (!display_is_hal_backend_available()) {
+               _E("There is no display device.");
+               return -ENOENT;
+       }
+
+       switch (white_balance_type) {
+       case HAL_DISPLAY_WHITE_BALANCE_R_GAIN:
+       case HAL_DISPLAY_WHITE_BALANCE_G_GAIN:
+       case HAL_DISPLAY_WHITE_BALANCE_B_GAIN:
+       case HAL_DISPLAY_WHITE_BALANCE_R_OFFSET:
+       case HAL_DISPLAY_WHITE_BALANCE_G_OFFSET:
+       case HAL_DISPLAY_WHITE_BALANCE_B_OFFSET:
+               break;
+       default:
+               _E("Unknown white balance type");
+               return -EINVAL;
+       }
+
+       ret = hal_device_display_get_white_balance(white_balance_type, value);
+       if (ret == -ENODEV)
+               _E("Get white balance is not supported.");
+       else if (ret < 0)
+               _E("Failed to get white balance value.");
+
+       return ret;
+}
\ No newline at end of file
diff --git a/src/display/display-panel.h b/src/display/display-panel.h
new file mode 100644 (file)
index 0000000..efe6e45
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 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.
+ */
+
+#ifndef __DISPLAY_PANEL_H__
+#define __DISPLAY_PANEL_H__
+
+#include <hal/device/hal-display.h>
+
+int display_panel_set_white_balance(enum hal_display_white_balance white_balance_type, int value);
+int display_panel_get_white_balance(enum hal_display_white_balance white_balance_type, int* out_val);
+
+#endif /* __DISPLAY_PANEL_H__ */
\ No newline at end of file