From fc615fd163508e350eb589a533b1f5c7f7571500 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Mon, 27 Feb 2023 10:59:44 +0900 Subject: [PATCH] display: Move force_brightness getter and setter from plugin to core display module Remove and redefine force_brightness getter/setter. These functions are added below display-backlight. int display_backlight_set_force_brightness(int brightness) void display_backlight_get_force_brightness(int *brightness) -> With these functions, it is possible to get and set for_brightness value. Change-Id: Ibf93bfd10ac13a462759107598ea95d5c915e610 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/device-interface.c | 15 ++------------- plugins/mobile/display/device-interface.c | 15 ++------------- plugins/tv/display/device-interface.c | 15 ++------------- plugins/wearable/display/device-interface.c | 15 ++------------- plugins/wearable/display/powersaver.c | 2 +- src/display/device-interface.h | 1 - src/display/display-backlight.c | 18 ++++++++++++++++++ src/display/display-backlight.h | 2 ++ 8 files changed, 29 insertions(+), 54 deletions(-) diff --git a/plugins/iot-headed/display/device-interface.c b/plugins/iot-headed/display/device-interface.c index 05bd53b..949ad58 100644 --- a/plugins/iot-headed/display/device-interface.c +++ b/plugins/iot-headed/display/device-interface.c @@ -68,7 +68,6 @@ #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" static struct _backlight_ops backlight_ops; -static int force_brightness; static bool display_dev_available = false; static const struct display_config *display_conf; @@ -162,22 +161,13 @@ static void change_brightness(int start, int end, int step) } } -static int set_force_brightness(int level) -{ - if (level < 0 || level > PM_MAX_BRIGHTNESS) - return -EINVAL; - - force_brightness = level; - - return 0; -} - static int set_brightness(int val) { int max, ret; - int default_brightness = 0; + int default_brightness = 0, force_brightness = 0; display_backlight_get_default_brightness(&default_brightness); + display_backlight_get_force_brightness(&force_brightness); if (!display_dev_available) { _E("There is no display device."); @@ -286,7 +276,6 @@ static void restore_brightness_func(void) static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, - .set_force_brightness = set_force_brightness, .set_brightness = set_brightness, .get_brightness = get_brightness, .restore_brightness_func = restore_brightness_func, diff --git a/plugins/mobile/display/device-interface.c b/plugins/mobile/display/device-interface.c index 3f77a77..e7f64bb 100644 --- a/plugins/mobile/display/device-interface.c +++ b/plugins/mobile/display/device-interface.c @@ -67,7 +67,6 @@ #define UNKNOWN_STR "unknown" static struct _backlight_ops backlight_ops; -static int force_brightness; static bool display_dev_available = false; static const struct display_config *display_conf; @@ -161,22 +160,13 @@ static void change_brightness(int start, int end, int step) } } -static int set_force_brightness(int level) -{ - if (level < 0 || level > PM_MAX_BRIGHTNESS) - return -EINVAL; - - force_brightness = level; - - return 0; -} - static int set_brightness(int val) { int max, ret; - int default_brightness = 0; + int default_brightness = 0, force_brightness = 0; display_backlight_get_default_brightness(&default_brightness); + display_backlight_get_force_brightness(&force_brightness); if (!display_dev_available) { _E("There is no display device."); @@ -285,7 +275,6 @@ static void restore_brightness_func(void) static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, - .set_force_brightness = set_force_brightness, .set_brightness = set_brightness, .get_brightness = get_brightness, .restore_brightness_func = restore_brightness_func, diff --git a/plugins/tv/display/device-interface.c b/plugins/tv/display/device-interface.c index 2a672b6..d16433d 100644 --- a/plugins/tv/display/device-interface.c +++ b/plugins/tv/display/device-interface.c @@ -68,7 +68,6 @@ #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state" static struct _backlight_ops backlight_ops; -static int force_brightness; static bool display_dev_available = false; static const struct display_config *display_conf; @@ -162,22 +161,13 @@ static void change_brightness(int start, int end, int step) } } -static int set_force_brightness(int level) -{ - if (level < 0 || level > PM_MAX_BRIGHTNESS) - return -EINVAL; - - force_brightness = level; - - return 0; -} - static int set_brightness(int val) { int max, ret; - int default_brightness = 0; + int default_brightness = 0, force_brightness = 0; display_backlight_get_default_brightness(&default_brightness); + display_backlight_get_force_brightness(&force_brightness); if (!display_dev_available) { _E("There is no display device."); @@ -286,7 +276,6 @@ static void restore_brightness_func(void) static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, - .set_force_brightness = set_force_brightness, .set_brightness = set_brightness, .get_brightness = get_brightness, .restore_brightness_func = restore_brightness_func, diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 33af6f4..ca09f35 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -74,7 +74,6 @@ static struct _backlight_ops backlight_ops; static struct battery_plugin *battery_plgn; -static int force_brightness; static bool display_dev_available = false; static int aod_max_level = -1; static int aod_normal_level = -1; @@ -171,22 +170,13 @@ static void change_brightness(int start, int end, int step) } } -static int set_force_brightness(int level) -{ - if (level < 0 || level > PM_MAX_BRIGHTNESS) - return -EINVAL; - - force_brightness = level; - - return 0; -} - static int set_brightness(int val) { int max, ret; - int default_brightness = 0; + int default_brightness = 0, force_brightness = 0; display_backlight_get_default_brightness(&default_brightness); + display_backlight_get_force_brightness(&force_brightness); if (!display_dev_available) { _E("There is no display device."); @@ -349,7 +339,6 @@ static void restore_brightness_func(void) static struct _backlight_ops backlight_ops = { .get_lcd_power = dpms_get_cached_state, - .set_force_brightness = set_force_brightness, .set_brightness = set_brightness, .get_brightness = get_brightness, .restore_brightness_func = restore_brightness_func, diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c index e859053..609a54f 100644 --- a/plugins/wearable/display/powersaver.c +++ b/plugins/wearable/display/powersaver.c @@ -45,7 +45,7 @@ static int set_powersaver_mode(int mode) _D("Powersaver mode %d pmqos %d.", mode, pmqos); device_notify(DEVICE_NOTIFIER_ULTRAPOWERSAVING, (void *)&pmqos); - backlight_ops->set_force_brightness(0); + display_backlight_set_force_brightness(0); set_force_lcdtimeout(0); FIND_DISPLAY(hbm_ops, "hbm"); diff --git a/src/display/device-interface.h b/src/display/device-interface.h index f75dd54..7de0e98 100644 --- a/src/display/device-interface.h +++ b/src/display/device-interface.h @@ -62,7 +62,6 @@ int display_service_free(void); struct _backlight_ops { int (*get_lcd_power)(void); - int (*set_force_brightness)(int level); int (*set_brightness)(int val); int (*get_brightness)(int *val); int (*get_brightness_raw)(int *val); diff --git a/src/display/display-backlight.c b/src/display/display-backlight.c index 9b226ec..a8215bc 100644 --- a/src/display/display-backlight.c +++ b/src/display/display-backlight.c @@ -33,6 +33,7 @@ static struct _backlight_ops *backlight_ops; static int default_brightness; static int custom_brightness; static bool g_custom_status; +static int force_brightness; static guint release_timer; /* FIXME: This function is for temporary use, should be fixed after plugin refactoring */ @@ -273,6 +274,23 @@ void display_backlight_unset_blink(void) release_timer = g_timeout_add(DUMP_MODE_WAITING_TIME, release_blink_cb, NULL); } +/* FIXME: This function is only used for wearable plugin */ +int display_backlight_set_force_brightness(int brightness) +{ + if (brightness < PM_DIM_BRIGHTNESS || brightness > PM_MAX_BRIGHTNESS) + return -EINVAL; + + force_brightness = brightness; + + return 0; +} + +/* FIXME: This function is only used for wearable plugin */ +void display_backlight_get_force_brightness(int *brightness) +{ + *brightness = force_brightness; +} + /* FIXME: This code structure should be changed to plugin api call, after plugin refactoting*/ static void __CONSTRUCTOR__ initialize(void) { diff --git a/src/display/display-backlight.h b/src/display/display-backlight.h index f624c27..54fc5d1 100644 --- a/src/display/display-backlight.h +++ b/src/display/display-backlight.h @@ -34,5 +34,7 @@ int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brightness); void display_backlight_set_blink(int timeout); void display_backlight_unset_blink(void); +int display_backlight_set_force_brightness(int brightness); +void display_backlight_get_force_brightness(int *brightness); #endif /* __DISPLAY_BACKLIGHT_H__ */ \ No newline at end of file -- 2.7.4