From 0b807395978a911334d6204ba383d5ea5a244f5d Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Thu, 10 Nov 2022 17:12:45 +0900 Subject: [PATCH] display: add getter/setter function for white balance 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 --- plugins/iot-headed/display/core.c | 5 ++ plugins/iot-headed/display/device-interface.c | 87 +++++++++++++++++++++++++++ plugins/mobile/display/core.c | 5 ++ plugins/mobile/display/device-interface.c | 87 +++++++++++++++++++++++++++ plugins/tv/display/core.c | 5 ++ plugins/tv/display/device-interface.c | 87 +++++++++++++++++++++++++++ plugins/wearable/display/core.c | 5 ++ plugins/wearable/display/device-interface.c | 87 +++++++++++++++++++++++++++ src/display/device-interface.h | 7 +++ src/display/display-dbus.c | 53 ++++++++++++++++ 10 files changed, 428 insertions(+) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index b6edf04..6bd21d0 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -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."); diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index bef99b0..f07018d 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -55,6 +55,11 @@ #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; diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 2e2d569..ddb7e58 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -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."); diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 28d4f1c..1c3c8dd 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -56,6 +56,11 @@ #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; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index d8ba642..3dc8fc8 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -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."); diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index d377ac8..a5500ca 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -55,6 +55,11 @@ #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; diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 1506958..56275ad 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -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."); diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 8ff62de..cb77833 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -58,6 +58,11 @@ #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; diff --git a/src/display/device-interface.h b/src/display/device-interface.h index 759ff50..56b41e4 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -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 */ diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 9b73ba9..197260a 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -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."); -- 2.7.4