devices: Remove enum CORE_LOGIC_MODE 62/312862/1
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 10 Jun 2024 07:11:24 +0000 (16:11 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 17 Jun 2024 04:59:35 +0000 (13:59 +0900)
The CORE_LOGIC_MODE is no more than probing and then initializing, or
deinitializing a device. It can be handled by calling probe()/init()
or exit() of device_ops. Therefore, no need to do it within
device_ops->start()/stop() based on the parameter CORE_LOGIC_MODE.
Fix it to directly call probe/init/exit on receiving dbus request
for start/stop device. It is logically same as the previous.

Change-Id: I86285bd5c41a958030d176c32003c61770a72c36
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/wearable/display/core.c
src/display/display-dbus.c
src/display/display.c
src/shared/devices.h

index 011acf458e45d4e84106580f2f6479c6ad4500a5..a28caf7ad5d3065c98ee074532a279b8f7fff544 100644 (file)
@@ -1000,50 +1000,19 @@ static void display_exit(void *data)
 
 static int display_start(enum device_flags flags)
 {
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       display_panel_set_panel_state_by_standby_state(true);
-               else
-                       /* normal lcd on */
-                       display_panel_set_panel_state_by_on_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
+       if (flags & LCD_PANEL_OFF_MODE)
+               /* standby on */
+               display_panel_set_panel_state_by_standby_state(true);
+       else
+               /* normal lcd on */
+               display_panel_set_panel_state_by_on_state(flags);
 
        return 0;
 }
 
 static int display_stop(enum device_flags flags)
 {
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
-               display_panel_set_panel_state_by_off_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       display_get_display_ops_status(&status);
-       if (status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
+       display_panel_set_panel_state_by_off_state(flags);
 
        return 0;
 }
index cb6181e263c1167cf2a977c23f26b47ec30af56b..316a5e71914fc39a43d1b3ed3a68f09d43183894 100644 (file)
@@ -83,13 +83,21 @@ static GVariant *dbus_start(GDBusConnection *conn,
        GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
        static const struct device_ops *display_device_ops = NULL;
+       enum device_ops_status status;
 
        if (!display_device_ops)
                display_device_ops = find_device("display");
        if (NOT_SUPPORT_OPS(display_device_ops))
                goto out;
 
-       display_device_ops->start(CORE_LOGIC_MODE);
+       display_get_display_ops_status(&status);
+       if (status == DEVICE_OPS_STATUS_START)
+               goto out;
+
+       if (display_device_ops->probe(NULL) < 0)
+               goto out;
+
+       display_device_ops->init(NULL);
 out:
        return gdbus_new_g_variant_tuple();
 }
@@ -99,6 +107,7 @@ static GVariant *dbus_stop(GDBusConnection *conn,
        GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
        static const struct device_ops *display_device_ops = NULL;
+       enum device_ops_status status;
 
        if (!display_device_ops)
                display_device_ops = find_device("display");
@@ -107,7 +116,11 @@ static GVariant *dbus_stop(GDBusConnection *conn,
 
        display_state_transition_request_state_transition_with_option(DEVICED_EVENT_DISPLAY, LCD_NORMAL);
 
-       display_device_ops->stop(CORE_LOGIC_MODE);
+       display_get_display_ops_status(&status);
+       if (status == DEVICE_OPS_STATUS_STOP)
+               goto out;
+
+       display_device_ops->exit(NULL);
 out:
        return gdbus_new_g_variant_tuple();
 }
index 6e9c9b97a6246edd6008e67070ed751196cde0c7..cfcfbd67fcd895bef75f9180e110ac1e483ef336 100644 (file)
@@ -724,48 +724,19 @@ static void display_exit(void *data)
 
 static int display_start(enum device_flags flags)
 {
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE) {
-               if (flags & LCD_PANEL_OFF_MODE)
-                       /* standby on */
-                       display_panel_set_panel_state_by_standby_state(true);
-               else
-                       /* normal lcd on */
-                       display_panel_set_panel_state_by_on_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       if (display_ops_status == DEVICE_OPS_STATUS_START)
-               return -EALREADY;
-
-       if (display_probe(NULL) < 0)
-               return -EPERM;
-
-       display_init(NULL);
+       if (flags & LCD_PANEL_OFF_MODE)
+               /* standby on */
+               display_panel_set_panel_state_by_standby_state(true);
+       else
+               /* normal lcd on */
+               display_panel_set_panel_state_by_on_state(flags);
 
        return 0;
 }
 
 static int display_stop(enum device_flags flags)
 {
-       /* NORMAL MODE */
-       if (flags & NORMAL_MODE || flags & FORCE_OFF_MODE) {
-               display_panel_set_panel_state_by_off_state(flags);
-               return 0;
-       }
-
-       /* CORE LOGIC MODE */
-       if (!(flags & CORE_LOGIC_MODE))
-               return 0;
-
-       if (display_ops_status == DEVICE_OPS_STATUS_STOP)
-               return -EALREADY;
-
-       display_exit(NULL);
+       display_panel_set_panel_state_by_off_state(flags);
 
        return 0;
 }
index eb998359fd504a244732313348288f9158a7c771..ac125a0f6370f1d2bdb46bef5899faa12be923b0 100644 (file)
@@ -44,7 +44,6 @@ enum device_flags {
        NORMAL_MODE                   = 0x00000001,
        AMBIENT_MODE                  = 0x00000002,
        FORCE_OFF_MODE                = 0x00000004,
-       CORE_LOGIC_MODE               = 0x00001000,
        TOUCH_SCREEN_OFF_MODE         = 0x00002000,
        LCD_PANEL_OFF_MODE            = 0x00004000,
        LCD_PHASED_TRANSIT_MODE       = 0x00008000,