display: Move custom_brightness setter and update function from plugin to core displa... 91/288791/11
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 23 Feb 2023 06:47:25 +0000 (15:47 +0900)
committeryunhee <yuni.seo@samsung.com>
Mon, 20 Mar 2023 08:01:36 +0000 (17:01 +0900)
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>
15 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/device-interface.c
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/core.c
plugins/mobile/display/device-interface.c
plugins/mobile/display/key-filter.c
plugins/tv/display/core.c
plugins/tv/display/device-interface.c
plugins/tv/display/key-filter.c
plugins/wearable/display/core.c
plugins/wearable/display/device-interface.c
plugins/wearable/display/key-filter.c
src/display/device-interface.h
src/display/display-backlight.c
src/display/display-backlight.h

index de8ccb3..c021a59 100644 (file)
@@ -1377,6 +1377,7 @@ static int default_action(int timeout)
        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.");
@@ -1434,8 +1435,10 @@ static int default_action(int timeout)
 
        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();
 
index e8cf4fe..806512a 100644 (file)
@@ -69,7 +69,6 @@
 #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;
@@ -200,35 +199,6 @@ static void change_brightness(int start, int end, int step)
        }
 }
 
-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)
@@ -432,8 +402,6 @@ static void restore_brightness_func(void)
 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,
index cd22e66..aefad96 100644 (file)
@@ -117,7 +117,7 @@ static inline void restore_custom_brightness(void)
 
        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)
index 25db558..bdf0ee3 100644 (file)
@@ -1387,6 +1387,7 @@ static int default_action(int timeout)
        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.");
@@ -1444,8 +1445,10 @@ static int default_action(int timeout)
 
        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();
 
index d9a2a57..6985f4d 100644 (file)
@@ -68,7 +68,6 @@
 #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;
@@ -199,35 +198,6 @@ static void change_brightness(int start, int end, int step)
        }
 }
 
-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)
@@ -431,8 +401,6 @@ static void restore_brightness_func(void)
 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,
index 128dbd8..efdc77c 100644 (file)
@@ -117,7 +117,7 @@ static inline void restore_custom_brightness(void)
 
        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)
index c63d8ee..5fa0867 100644 (file)
@@ -1377,6 +1377,7 @@ static int default_action(int timeout)
        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.");
@@ -1434,8 +1435,10 @@ static int default_action(int timeout)
 
        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();
 
index 842be00..1fd9534 100644 (file)
@@ -69,7 +69,6 @@
 #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;
@@ -200,35 +199,6 @@ static void change_brightness(int start, int end, int step)
        }
 }
 
-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)
@@ -432,8 +402,6 @@ static void restore_brightness_func(void)
 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,
index 5da93d1..1a7729a 100644 (file)
@@ -117,7 +117,7 @@ static inline void restore_custom_brightness(void)
 
        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)
index 8f0edcb..55067ab 100644 (file)
@@ -1637,6 +1637,7 @@ static int default_action(int timeout)
        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.");
@@ -1705,8 +1706,10 @@ static int default_action(int timeout)
 
        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();
 
index 3647d8b..7acfe2a 100644 (file)
@@ -75,7 +75,6 @@
 
 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;
@@ -211,35 +210,6 @@ static void change_brightness(int start, int end, int step)
        }
 }
 
-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)
@@ -497,8 +467,6 @@ static void restore_brightness_func(void)
 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,
index 4ca88d8..69b0fb3 100644 (file)
@@ -116,7 +116,7 @@ static inline void restore_custom_brightness(void)
 
        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)
index f5010f1..389fab7 100644 (file)
@@ -63,8 +63,6 @@ int display_service_free(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);
index 379c7f5..9271033 100644 (file)
@@ -29,6 +29,7 @@ static const struct display_config *display_conf;
 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 */
@@ -156,6 +157,30 @@ int display_backlight_update_by_default_brightness(void)
        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)
 {
index 61f3095..61e315a 100644 (file)
@@ -28,5 +28,7 @@ int display_backlight_update_by_default_brightness(void);
 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