display: add getter/setter function for white balance 92/284292/1 accepted/tizen/7.0/unified/20221117.014348
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 10 Nov 2022 08:12:45 +0000 (17:12 +0900)
committeryunhee seo <yuni.seo@samsung.com>
Tue, 15 Nov 2022 04:53:12 +0000 (04:53 +0000)
Add a dbus/plugin getter and setter function of display white balance which controls RGB gain and offset.

White balancing is adjusting standard point of white color, this because the light source is different for each device.
gain value is a value to be multiplied for RGB value calculation.
offset value is a value to be added for RGB value calculation.

white balancing getter/setter dbus methods
1. Set white balance
    path: /Org/Tizen/System/DeviceD/Display
    interface: org.tizen.system.deviced.display
    member: SetWhiteBalance
    parameter: "(ii)", white balance enum type to be set, value to be set
    return: "(i)", 0 on success, negative on error.

2. Get white balance
    path: /Org/Tizen/System/DeviceD/Display
    interface: org.tizen.system.deviced.display
    member: GetWhiteBalance
    parameter: "(i)", white balance enum type to be get
    return: "(i)", value for that white balance type, negative on error.

plugin implementation is referring to this enum type
enum hal_display_white_balance {
HAL_DISPLAY_WHITE_BALANCE_R_GAIN,
HAL_DISPLAY_WHITE_BALANCE_G_GAIN,
HAL_DISPLAY_WHITE_BALANCE_B_GAIN,
HAL_DISPLAY_WHITE_BALANCE_R_OFFSET,
HAL_DISPLAY_WHITE_BALANCE_G_OFFSET,
HAL_DISPLAY_WHITE_BALANCE_B_OFFSET,
};

Change-Id: I972bdb468806b442b221634a166645764c7c2ec9
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
(cherry picked from commit 0b807395978a911334d6204ba383d5ea5a244f5d)

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

index b6edf04eebb96d4438a85327ba58619378aa767b..6bd21d02712a653cc268800159ca83721b98e577 100644 (file)
@@ -92,6 +92,7 @@ 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);
@@ -2350,6 +2351,10 @@ 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 bef99b038b119c366d644e754453add91455b20c..f07018decb8dde237b86c57bccc59a6034446715 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"
@@ -69,6 +74,7 @@
 #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;
@@ -83,6 +89,11 @@ 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;
@@ -739,6 +750,77 @@ 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;
@@ -777,6 +859,11 @@ 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 2e2d569e7630cbdfcfe9dc7a9346bb9462edacad..ddb7e5896ee3fadaa8a145ad6830d8d829b3d5d4 100644 (file)
@@ -93,6 +93,7 @@ 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);
 
@@ -2361,6 +2362,10 @@ 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 28d4f1c6b1feccb95941294f9726c57c146ff79a..1c3c8dd100f6ed3e8c27adada7cdd85f5fe48c17 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"
@@ -68,6 +73,7 @@
 #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;
@@ -82,6 +88,11 @@ 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;
@@ -738,6 +749,77 @@ 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;
@@ -776,6 +858,11 @@ 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 d8ba6420c2358d78c572e4017138ef3d8bf3c00a..3dc8fc8fc20eb734e6cdd3aff62ea2fc37796310 100644 (file)
@@ -91,6 +91,7 @@ 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);
 
@@ -2347,6 +2348,10 @@ 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 d377ac81d99ec4addcd0872d802ac786686fbb7d..a5500ca5eba541a8966a66c977cd2b0695e04012 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"
@@ -69,6 +74,7 @@
 #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;
@@ -83,6 +89,11 @@ 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;
@@ -739,6 +750,77 @@ 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;
@@ -777,6 +859,11 @@ 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 1506958e16fe02c23d8be8690c0e8b0181c1138d..56275ad82aa1a6001ec198dc720a3e935ea83355 100644 (file)
@@ -99,6 +99,7 @@ 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);
 
@@ -2683,6 +2684,10 @@ 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 8ff62de2d0b63626a1a17e9d8fee377997fdee5c..cb77833901e821109503f04c25edb78c916485d7 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,6 +79,7 @@
 
 
 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;
@@ -95,6 +101,11 @@ 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;
@@ -811,6 +822,77 @@ 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,
@@ -844,6 +926,11 @@ 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 759ff50918dbc03fe953a72860507861e7e15414..56b41e40c6be2cc2bc3a3e7e18a62381faf79055 100644 (file)
@@ -94,6 +94,13 @@ 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 9b73ba9b16bd6627e846335508c87b8969600cd0..197260aec02d518dba9069a708156dd03f156f18 100644 (file)
@@ -71,6 +71,7 @@
 
 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,
@@ -1198,6 +1199,52 @@ static GVariant *dbus_getbrightnessinfo(GDBusConnection *conn,
        return g_variant_new("(ii)", default_brightness, current_brightness);
 }
 
+static GVariant *dbus_setwhitebalance(GDBusConnection *conn,
+       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       int white_balance_type, value;
+       int ret = 0, ret_val;
+       pid_t pid;
+
+       g_variant_get(param, "(ii)", &white_balance_type, &value);
+
+       ret_val = display_white_balance_ops->set_white_balance(white_balance_type, value);
+       if (ret_val < 0) {
+               _E("Failed to set white balance");
+               ret = -EPERM;
+       }
+
+       pid = gdbus_connection_get_sender_pid(conn, sender);
+       _I("Set white balance pid=%d white balance type=%d value=%d", pid, white_balance_type, value);
+
+       return g_variant_new("(i)", ret);
+}
+
+static GVariant *dbus_getwhitebalance(GDBusConnection *conn,
+       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       int white_balance_type;
+       int ret = 0, ret_val;
+       pid_t pid;
+
+       g_variant_get(param, "(i)", &white_balance_type);
+
+       ret = display_white_balance_ops->get_white_balance(white_balance_type, &ret_val);
+       if (ret < 0) {
+               _E("Failed to get white balance");
+               ret = -EPERM;
+       }
+       else
+               ret = ret_val;
+
+       pid = gdbus_connection_get_sender_pid(conn, sender);
+       _I("Get white balance pid=%d white balance type=%d", pid, white_balance_type);
+
+       return g_variant_new("(i)", ret);
+}
+
 static const dbus_method_s dbus_methods[] = {
        { "start",           NULL,  NULL, dbus_start },
        { "stop",            NULL,  NULL, dbus_stop },
@@ -1235,6 +1282,8 @@ static const dbus_method_s dbus_methods[] = {
        { "LockTimeoutInput",  "si", "i", dbus_locktimeout_input },
        { "DimStayControl",        "i",  "i", dbus_dimstay_control },
        { "GetBrightnessInfo", NULL, "ii", dbus_getbrightnessinfo},
+       { "SetWhiteBalance", "ii", "i", dbus_setwhitebalance},
+       { "GetWhiteBalance", "i", "i", dbus_getwhitebalance},
        /* Add methods here */
 };
 
@@ -1363,6 +1412,10 @@ 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.");