From 392f6c775277b115dc080ff1a265fc42e2c2e280 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 11 Jul 2023 18:30:52 +0900 Subject: [PATCH] display: Refactor display_plugin_get_device_flags() To make display-plugin independent without any other file dependence, display_plugin_get_device_flags() is refactored. This function is added to display-util - int display_util_get_device_flags(unsigned long *device_flags); -> This function sets display flag value and return. Change-Id: I1ad7f1ebb3838a0bca7aa74623f9e6ee3da4299a Signed-off-by: Yunhee Seo --- src/display/display-panel.c | 5 +++-- src/display/display-plugin.c | 19 +++---------------- src/display/display-util.c | 28 +++++++++++++++++++++++++++- src/display/display-util.h | 1 + 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/display/display-panel.c b/src/display/display-panel.c index fbc615e..ec6706c 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -29,6 +29,7 @@ #include "display-plugin.h" #include "display-signal.h" #include "display-state-transition.h" +#include "display-util.h" #include "led/touch-key.h" #define MAX_WHITE_BALANCE_GAIN 2047 @@ -218,7 +219,7 @@ void display_panel_get_lcd_paneloff_mode(bool *on) void display_panel_lcd_on_procedure(int state, enum device_flags flag) { unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); + display_util_get_device_flags(&flags); flags |= flag; if (display_plugin_lcd_on_procedure(state, flag) == 0) @@ -269,7 +270,7 @@ void display_panel_lcd_on_procedure(int state, enum device_flags flag) void display_panel_lcd_off_procedure(enum device_flags flag) { unsigned long flags = NORMAL_MODE; - display_plugin_get_device_flags(&flags); + display_util_get_device_flags(&flags); flags |= flag; if (display_plugin_lcd_off_procedure(flag) == 0) diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 1e8171a..1328593 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -17,7 +17,6 @@ */ #include -#include "display-misc.h" #include "display-plugin.h" #include "shared/log-macro.h" @@ -382,20 +381,8 @@ int display_plugin_get_device_flags(unsigned long *device_flags) if (!device_flags) return -EINVAL; - if (g_display_plugin.get_device_flags) - return g_display_plugin.get_device_flags(device_flags); - - *device_flags = NORMAL_MODE; - bool lcd_paneloff_mode = false; - bool stay_touchscreen_off = false; - display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); - display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); - - if (lcd_paneloff_mode) - *device_flags |= LCD_PANEL_OFF_MODE; - - if (stay_touchscreen_off) - *device_flags |= TOUCH_SCREEN_OFF_MODE; + if (!g_display_plugin.get_device_flags) + return -EOPNOTSUPP; - return 0; + return g_display_plugin.get_device_flags(device_flags); } \ No newline at end of file diff --git a/src/display/display-util.c b/src/display/display-util.c index 2cd8c5e..eb9556a 100644 --- a/src/display/display-util.c +++ b/src/display/display-util.c @@ -15,6 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "display-misc.h" +#include "display-plugin.h" #include "display-util.h" int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name) @@ -46,4 +48,28 @@ int display_util_get_device_flags_name(enum device_flags flags, const char **fla *flag_name = UNKNOWN_STR; return 0; -} \ No newline at end of file +} + +int display_util_get_device_flags(unsigned long *device_flags) +{ + bool lcd_paneloff_mode = false; + bool stay_touchscreen_off = false; + + if (!device_flags) + return -EINVAL; + + if (g_display_plugin.get_device_flags) + return display_plugin_get_device_flags(device_flags); + + *device_flags = NORMAL_MODE; + display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); + display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); + + if (lcd_paneloff_mode) + *device_flags |= LCD_PANEL_OFF_MODE; + + if (stay_touchscreen_off) + *device_flags |= TOUCH_SCREEN_OFF_MODE; + + return 0; +} diff --git a/src/display/display-util.h b/src/display/display-util.h index 333e82f..39f7e71 100644 --- a/src/display/display-util.h +++ b/src/display/display-util.h @@ -26,5 +26,6 @@ #define NSEC_TO_SEC(x) ((x)/1000000000.0) int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name); +int display_util_get_device_flags(unsigned long *device_flags); #endif /* __DISPLAY_UTIL_H__ */ \ No newline at end of file -- 2.7.4