From: Yunhee Seo Date: Fri, 26 May 2023 07:20:07 +0000 (+0900) Subject: display: plugin: Add display_plugin_get_device_flags() X-Git-Tag: accepted/tizen/unified/dev/20230726.115933~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6648d64ad3a9eee04bfea33dc691e688a7831746;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: plugin: Add display_plugin_get_device_flags() The reason why the display_plugin_get_device_flags() is added is as follows 1. device flags was being used in the lcd_on/off_procedure() through get_lcd_on/off_flags() 2. There is no need for the function to be divded to get_lcd_on/off_flags() 3. Also, ambient flags is only used in the wearable plugin. Thus, display_plugin_get_device_flgas is a combination of get_lcd_on/off_flags(). It provides device flags value to get_lcd_on/off_flags(). However wearable uses ambient flags, so wearable gets own get_device_flags(). Change-Id: Ibcf4825b7028f045b721e6bfe4e429b77746fe69 Signed-off-by: Yunhee Seo --- diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index d6baafc..d357f6e 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -222,18 +222,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static unsigned long get_lcd_on_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool lcd_paneloff_mode = false; - - display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); - if (lcd_paneloff_mode) - flags |= LCD_PANEL_OFF_MODE; - - return flags; -} - bool touch_event_blocked(void) { return touch_blocked; @@ -241,7 +229,8 @@ bool touch_event_blocked(void) void lcd_on_procedure(int state, enum device_flags flag) { - unsigned long flags = get_lcd_on_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -288,21 +277,10 @@ void lcd_on_procedure(int state, enum device_flags flag) touch_blocked = false; } -static unsigned long get_lcd_off_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool stay_touchscreen_off = false; - - display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); - if (stay_touchscreen_off) - flags |= TOUCH_SCREEN_OFF_MODE; - - return flags; -} - inline void lcd_off_procedure(enum device_flags flag) { - unsigned long flags = get_lcd_off_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -1620,6 +1598,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->delete_state_cond = del_state_cond; dp->set_dim_state = set_dim_state; + dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); /* check display feature */ diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 2aac6cc..ebaa6a8 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -229,18 +229,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static unsigned long get_lcd_on_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool lcd_paneloff_mode = false; - - display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); - if (lcd_paneloff_mode) - flags |= LCD_PANEL_OFF_MODE; - - return flags; -} - bool touch_event_blocked(void) { return touch_blocked; @@ -248,7 +236,8 @@ bool touch_event_blocked(void) void lcd_on_procedure(int state, enum device_flags flag) { - unsigned long flags = get_lcd_on_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -295,21 +284,10 @@ void lcd_on_procedure(int state, enum device_flags flag) touch_blocked = false; } -static unsigned long get_lcd_off_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool stay_touchscreen_off = false; - - display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); - if (stay_touchscreen_off) - flags |= TOUCH_SCREEN_OFF_MODE; - - return flags; -} - inline void lcd_off_procedure(enum device_flags flag) { - unsigned long flags = get_lcd_off_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -1630,6 +1608,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->delete_state_cond = del_state_cond; dp->set_dim_state = set_dim_state; + dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); /** diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 9e298c5..7b5e98a 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -222,18 +222,6 @@ static const char* __device_flags_to_string(enum device_flags flags) return UNKNOWN_STR; } -static unsigned long get_lcd_on_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool lcd_paneloff_mode = false; - - display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); - if (lcd_paneloff_mode) - flags |= LCD_PANEL_OFF_MODE; - - return flags; -} - bool touch_event_blocked(void) { return touch_blocked; @@ -241,7 +229,8 @@ bool touch_event_blocked(void) void lcd_on_procedure(int state, enum device_flags flag) { - unsigned long flags = get_lcd_on_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -288,21 +277,10 @@ void lcd_on_procedure(int state, enum device_flags flag) touch_blocked = false; } -static unsigned long get_lcd_off_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool stay_touchscreen_off = false; - - display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); - if (stay_touchscreen_off) - flags |= TOUCH_SCREEN_OFF_MODE; - - return flags; -} - inline void lcd_off_procedure(enum device_flags flag) { - unsigned long flags = get_lcd_off_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -1621,6 +1599,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->delete_state_cond = del_state_cond; dp->set_dim_state = set_dim_state; + dp->get_device_flags = NULL; setup_display_plugin_backlight_ops(dp); /** diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index b3ba04f..4365feb 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -446,21 +446,31 @@ static void free_killable_daemon_list(void) initialized_killable_daemon_list = false; } -static unsigned long get_lcd_on_flags(void) +static int get_device_flags(unsigned long *device_flags) { - unsigned long flags = NORMAL_MODE; - bool lcd_paneloff_mode = false; + if (!device_flags) + return -EINVAL; + *device_flags = NORMAL_MODE; + bool lcd_paneloff_mode = false; + bool stay_touchscreen_off = false; display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode); - if (lcd_paneloff_mode) - flags |= LCD_PANEL_OFF_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 (ambient_get_state()) { - flags |= AMBIENT_MODE; - flags |= LCD_PHASED_TRANSIT_MODE; + *device_flags |= AMBIENT_MODE; + *device_flags |= LCD_PHASED_TRANSIT_MODE; } - return flags; + return 0; } bool touch_event_blocked(void) @@ -482,7 +492,8 @@ static gboolean late_transit_on(void *data) void lcd_on_procedure(int state, enum device_flags flag) { - unsigned long flags = get_lcd_on_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; int ret; @@ -545,26 +556,10 @@ void lcd_on_procedure(int state, enum device_flags flag) touch_blocked = false; } -static unsigned long get_lcd_off_flags(void) -{ - unsigned long flags = NORMAL_MODE; - bool stay_touchscreen_off = false; - - if (ambient_get_condition() == true) { - flags |= AMBIENT_MODE; - flags |= LCD_PHASED_TRANSIT_MODE; - } - - display_misc_get_stay_touchscreen_off(&stay_touchscreen_off); - if (stay_touchscreen_off) - flags |= TOUCH_SCREEN_OFF_MODE; - - return flags; -} - inline void lcd_off_procedure(enum device_flags flag) { - unsigned long flags = get_lcd_off_flags(); + unsigned long flags = NORMAL_MODE; + display_plugin_get_device_flags(&flags); flags |= flag; /* @@ -1970,6 +1965,7 @@ static int display_probe(void *data) setup_display_plugin_backlight_ops(dp); dp->delete_state_cond = del_state_cond; dp->set_dim_state = set_dim_state; + dp->get_device_flags = get_device_flags; setup_display_plugin_backlight_ops(dp); /** diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index dd5e0fb..4561f79 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -17,6 +17,7 @@ */ #include +#include "display-misc.h" #include "display-plugin.h" #include "shared/log-macro.h" @@ -240,4 +241,27 @@ int display_plugin_set_dim_state(bool on) } return -EOPNOTSUPP; +} + +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; + + return 0; } \ No newline at end of file diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index 54e1240..ff18ecd 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -67,6 +67,7 @@ struct display_plugin { /* FIXME: function names will be redefined */ void (*delete_state_cond) (void *data, enum state_t s_state); void (*set_dim_state) (bool on); + int (*get_device_flags) (unsigned long *device_flags); struct display_config *config; struct display_backlight_ops *backlight; @@ -85,6 +86,7 @@ int display_plugin_set_system_wakeup_flag(bool flag); const char* display_plugin_device_flags_to_string(enum device_flags flags); int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness); int display_plugin_set_dim_state(bool on); +int display_plugin_get_device_flags(unsigned long *device_flags); int display_plugin_backlight_get_lcd_power(void); int display_plugin_backlight_set_brightness(int brightness);