Remove and redefine custom_brightness setter and update function.
These functions are added to below display-backlight.
void display_backlight_set_custom_brightness(int brightness)
-> This function set custom_brightness value.
int display_backlight_update_by_custom_brightness(void)
-> If the conditions are met, this function updates brightness with custom_brightness value.
Change-Id: I4c3662fbdfff4a4b17224ac3af74c4cac1503303
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
static int last_timeout = 0;
struct timeval now_tv;
bool custom_status;
+ int brightness;
if (status != DEVICE_OPS_STATUS_START) {
_E("Display is not started.");
case S_LCDDIM:
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_old_state() == S_NORMAL) && custom_status)
- backlight_ops->save_custom_brightness();
+ if ((get_pm_old_state() == S_NORMAL) && custom_status) {
+ backlight_ops->get_brightness(&brightness);
+ display_backlight_set_custom_brightness(brightness);
+ }
/* lcd dim state : dim the brightness */
display_backlight_set_brightness_by_dim_brightness();
#define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state"
static struct _backlight_ops backlight_ops;
-static int custom_brightness;
static int force_brightness;
static int dpms_running_state = DPMS_SETTING_DONE;
static bool display_dev_available = false;
}
}
-static int save_custom_brightness(void)
-{
- int ret, brightness;
-
- ret = backlight_ops.get_brightness(&brightness);
-
- custom_brightness = brightness;
-
- return ret;
-}
-
-static int custom_backlight_update(void)
-{
- int ret = 0;
-
- if (custom_brightness < PM_MIN_BRIGHTNESS ||
- custom_brightness > PM_MAX_BRIGHTNESS)
- return -EINVAL;
-
- if (display_dimstay_check())
- ret = display_backlight_set_brightness_by_dim_brightness();
- else {
- _I("custom brightness restored! %d", custom_brightness);
- ret = backlight_ops.set_brightness(custom_brightness);
- }
-
- return ret;
-}
-
static int set_force_brightness(int level)
{
if (level < 0 || level > PM_MAX_BRIGHTNESS)
static struct _backlight_ops backlight_ops = {
.get_lcd_power = dpms_get_cached_state,
.get_lcd_power_node = get_lcd_power_node,
- .save_custom_brightness = save_custom_brightness,
- .custom_update = custom_backlight_update,
.set_force_brightness = set_force_brightness,
.set_brightness = set_brightness,
.get_brightness = get_brightness,
display_backlight_get_custom_status(&custom_status);
if ((get_pm_cur_state() == S_LCDDIM) && custom_status)
- backlight_ops->custom_update();
+ display_backlight_update_by_custom_brightness();
}
static void pwroff_popup(void)
static int last_timeout = 0;
struct timeval now_tv;
bool custom_status;
+ int brightness;
if (status != DEVICE_OPS_STATUS_START) {
_E("Display is not started.");
case S_LCDDIM:
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_old_state() == S_NORMAL) && custom_status)
- backlight_ops->save_custom_brightness();
+ if ((get_pm_old_state() == S_NORMAL) && custom_status) {
+ backlight_ops->get_brightness(&brightness);
+ display_backlight_set_custom_brightness(brightness);
+ }
/* lcd dim state : dim the brightness */
display_backlight_set_brightness_by_dim_brightness();
#define UNKNOWN_STR "unknown"
static struct _backlight_ops backlight_ops;
-static int custom_brightness;
static int force_brightness;
static int dpms_running_state = DPMS_SETTING_DONE;
static bool display_dev_available = false;
}
}
-static int save_custom_brightness(void)
-{
- int ret, brightness;
-
- ret = backlight_ops.get_brightness(&brightness);
-
- custom_brightness = brightness;
-
- return ret;
-}
-
-static int custom_backlight_update(void)
-{
- int ret = 0;
-
- if (custom_brightness < PM_MIN_BRIGHTNESS ||
- custom_brightness > PM_MAX_BRIGHTNESS)
- return -EINVAL;
-
- if (display_dimstay_check())
- ret = display_backlight_set_brightness_by_dim_brightness();
- else {
- _I("custom brightness restored! %d", custom_brightness);
- ret = backlight_ops.set_brightness(custom_brightness);
- }
-
- return ret;
-}
-
static int set_force_brightness(int level)
{
if (level < 0 || level > PM_MAX_BRIGHTNESS)
static struct _backlight_ops backlight_ops = {
.get_lcd_power = dpms_get_cached_state,
.get_lcd_power_node = get_lcd_power_node,
- .save_custom_brightness = save_custom_brightness,
- .custom_update = custom_backlight_update,
.set_force_brightness = set_force_brightness,
.set_brightness = set_brightness,
.get_brightness = get_brightness,
display_backlight_get_custom_status(&custom_status);
if ((get_pm_cur_state() == S_LCDDIM) && custom_status)
- backlight_ops->custom_update();
+ display_backlight_update_by_custom_brightness();
}
static void longkey_pressed(void)
static int last_timeout = 0;
struct timeval now_tv;
bool custom_status;
+ int brightness;
if (status != DEVICE_OPS_STATUS_START) {
_E("Display is not started.");
case S_LCDDIM:
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_old_state() == S_NORMAL) && custom_status)
- backlight_ops->save_custom_brightness();
+ if ((get_pm_old_state() == S_NORMAL) && custom_status) {
+ backlight_ops->get_brightness(&brightness);
+ display_backlight_set_custom_brightness(brightness);
+ }
/* lcd dim state : dim the brightness */
display_backlight_set_brightness_by_dim_brightness();
#define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state"
static struct _backlight_ops backlight_ops;
-static int custom_brightness;
static int force_brightness;
static int dpms_running_state = DPMS_SETTING_DONE;
static bool display_dev_available = false;
}
}
-static int save_custom_brightness(void)
-{
- int ret, brightness;
-
- ret = backlight_ops.get_brightness(&brightness);
-
- custom_brightness = brightness;
-
- return ret;
-}
-
-static int custom_backlight_update(void)
-{
- int ret = 0;
-
- if (custom_brightness < PM_MIN_BRIGHTNESS ||
- custom_brightness > PM_MAX_BRIGHTNESS)
- return -EINVAL;
-
- if (display_dimstay_check())
- ret = display_backlight_set_brightness_by_dim_brightness();
- else {
- _I("custom brightness restored! %d", custom_brightness);
- ret = backlight_ops.set_brightness(custom_brightness);
- }
-
- return ret;
-}
-
static int set_force_brightness(int level)
{
if (level < 0 || level > PM_MAX_BRIGHTNESS)
static struct _backlight_ops backlight_ops = {
.get_lcd_power = dpms_get_cached_state,
.get_lcd_power_node = get_lcd_power_node,
- .save_custom_brightness = save_custom_brightness,
- .custom_update = custom_backlight_update,
.set_force_brightness = set_force_brightness,
.set_brightness = set_brightness,
.get_brightness = get_brightness,
display_backlight_get_custom_status(&custom_status);
if ((get_pm_cur_state() == S_LCDDIM) && custom_status)
- backlight_ops->custom_update();
+ display_backlight_update_by_custom_brightness();
}
static void pwroff_popup(void)
static int last_timeout = 0;
struct timeval now_tv;
bool custom_status;
+ int brightness;
if (status != DEVICE_OPS_STATUS_START) {
_E("Display is not started.");
case S_LCDDIM:
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_old_state() == S_NORMAL) && custom_status)
- backlight_ops->save_custom_brightness();
+ if ((get_pm_old_state() == S_NORMAL) && custom_status) {
+ backlight_ops->get_brightness(&brightness);
+ display_backlight_set_custom_brightness(brightness);
+ }
/* lcd dim state : dim the brightness */
display_backlight_set_brightness_by_dim_brightness();
static struct _backlight_ops backlight_ops;
static struct battery_plugin *battery_plgn;
-static int custom_brightness;
static int force_brightness;
static int dpms_running_state = DPMS_SETTING_DONE;
static bool display_dev_available = false;
}
}
-static int save_custom_brightness(void)
-{
- int ret, brightness;
-
- ret = backlight_ops.get_brightness(&brightness);
-
- custom_brightness = brightness;
-
- return ret;
-}
-
-static int custom_backlight_update(void)
-{
- int ret = 0;
-
- if (custom_brightness < PM_MIN_BRIGHTNESS ||
- custom_brightness > PM_MAX_BRIGHTNESS)
- return -EINVAL;
-
- if (display_dimstay_check())
- ret = display_backlight_set_brightness_by_dim_brightness();
- else {
- _I("custom brightness restored! %d", custom_brightness);
- ret = backlight_ops.set_brightness(custom_brightness);
- }
-
- return ret;
-}
-
static int set_force_brightness(int level)
{
if (level < 0 || level > PM_MAX_BRIGHTNESS)
static struct _backlight_ops backlight_ops = {
.get_lcd_power = dpms_get_cached_state,
.get_lcd_power_node = get_lcd_power_node,
- .save_custom_brightness = save_custom_brightness,
- .custom_update = custom_backlight_update,
.set_force_brightness = set_force_brightness,
.set_brightness = set_brightness,
.get_brightness = get_brightness,
display_backlight_get_custom_status(&custom_status);
if ((get_pm_cur_state() == S_LCDDIM) && custom_status)
- backlight_ops->custom_update();
+ display_backlight_update_by_custom_brightness();
}
static void longkey_pressed(void)
struct _backlight_ops {
int (*get_lcd_power)(void);
int (*get_lcd_power_node)(void);
- int (*save_custom_brightness)(void);
- int (*custom_update)(void);
int (*set_force_brightness)(int level);
int (*set_brightness)(int val);
int (*get_brightness)(int *val);
static struct _backlight_ops *backlight_ops;
static int default_brightness;
+static int custom_brightness;
static bool g_custom_status;
/* FIXME: This function is for temporary use, should be fixed after plugin refactoring */
return ret;
}
+/* FIXME: This custom_brightness policy can be changed, after plugin refactoring */
+void display_backlight_set_custom_brightness(int brightness)
+{
+ custom_brightness = brightness;
+}
+
+/* FIXME: display_dimstay_check function should be changed to plugin api call */
+int display_backlight_update_by_custom_brightness(void)
+{
+ int ret = 0;
+
+ if (custom_brightness < PM_MIN_BRIGHTNESS || custom_brightness > PM_MAX_BRIGHTNESS)
+ return -EINVAL;
+
+ if (display_dimstay_check()) {
+ ret = display_backlight_set_brightness_by_dim_brightness();
+ } else {
+ _I("Custom brightness restored! %d", custom_brightness);
+ ret = backlight_ops->set_brightness(custom_brightness);
+ }
+
+ return ret;
+}
+
/* FIXME: This custom_status policy can be changed, after plugin refactoting*/
void display_backlight_set_custom_status(bool on)
{
int display_backlight_set_brightness_by_dim_brightness(void);
void display_backlight_set_custom_status(bool on);
void display_backlight_get_custom_status(bool *on);
+void display_backlight_set_custom_brightness(int brightness);
+int display_backlight_update_by_custom_brightness(void);
#endif /* __DISPLAY_BACKLIGHT_H__ */
\ No newline at end of file