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);
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.");
#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"
#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;
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;
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;
.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;
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);
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.");
#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"
#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;
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;
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;
.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;
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);
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.");
#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"
#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;
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;
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;
.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;
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);
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.");
#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"
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;
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;
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,
.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;
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 */
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,
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 },
{ "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 */
};
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.");