display: Refactor display_plugin_get_device_flags() 34/295634/2
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 11 Jul 2023 09:30:52 +0000 (18:30 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 12 Jul 2023 09:43:46 +0000 (18:43 +0900)
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 <yuni.seo@samsung.com>
src/display/display-panel.c
src/display/display-plugin.c
src/display/display-util.c
src/display/display-util.h

index fbc615e..ec6706c 100644 (file)
@@ -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)
index 1e8171a..1328593 100644 (file)
@@ -17,7 +17,6 @@
  */
 
 #include <errno.h>
-#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
index 2cd8c5e..eb9556a 100644 (file)
@@ -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;
+}
index 333e82f..39f7e71 100644 (file)
@@ -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