display: Add support to select the DPMS type 85/288485/1 accepted/tizen/7.0/unified/20230220.064529
authorTaeminYeom <taemin.yeom@samsung.com>
Tue, 14 Feb 2023 03:18:58 +0000 (12:18 +0900)
committerTaeminYeom <taemin.yeom@samsung.com>
Fri, 17 Feb 2023 06:31:02 +0000 (15:31 +0900)
DPMS (Display Power Management Signaling) is typically done by
requesting window manager. But some devices don't support window manager
and previous DPMS code was written assuming exiting window manager.
So, to support none window manager devices, dpms_ops struct is added.
According to DPMS type configuration, DPMS function can be bypassed.
If a new DPMS function is created later, it can be supported by connecting to dpms_ops.

[New added configuration]
- DisplayDPMSType
  : Indicates the type of DPMS. (window_manager or none)
    Default value is window_manager

Change-Id: I8a9f254102086b3e22c9498c1604e45c5053b60e
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
12 files changed:
conf/display-profile-iot-headed.conf
conf/display-profile-mobile.conf
conf/display-profile-tv.conf
conf/display-profile-wearable.conf
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/core.h
src/display/display-dpms.c
src/display/display-dpms.h
src/display/display.c

index 9d90031..123ba50 100644 (file)
 # Default: horizontal
 # DisplayInitDirection=(horizontal or vertical)
 
+# This is the type of DPMS.
+# If DPMS type is window_manager, turning display on or off, it uses window manager DPMS.
+# If DPMS type is none, when the DPMS function is called, it does nothing just returns true.
+# Default value is window_manager.
+# DisplayDPMSType=(window_manager or none)
+
 LCDAlwaysOn=no
 TimeoutEnable=yes
 SleepSupport=no
index b4141c5..a807a16 100644 (file)
 # If this value is no, LCD is turned off just by external requests.
 # TimeoutEnable=(yes or no)
 
+# This is the type of DPMS.
+# If DPMS type is window_manager, turning display on or off, it uses window manager DPMS.
+# If DPMS type is none, when the DPMS function is called, it does nothing just returns true.
+# Default value is window_manager.
+# DisplayDPMSType=(window_manager or none)
+
 LCDAlwaysOn=no
 TimeoutEnable=yes
index 4e14b86..3859a02 100644 (file)
 # If this value is no, LCD is turned off just by external requests.
 # TimeoutEnable=(yes or no)
 
+# This is the type of DPMS.
+# If DPMS type is window_manager, turning display on or off, it uses window manager DPMS.
+# If DPMS type is none, when the DPMS function is called, it does nothing just returns true.
+# Default value is window_manager.
+# DisplayDPMSType=(window_manager or none)
+
 LCDAlwaysOn=yes
 TimeoutEnable=no
 SleepSupport=no
index f4c1e22..c8daba4 100644 (file)
 # If this value is no, LCD is turned off just by external requests.
 # TimeoutEnable=(yes or no)
 
+# This is the type of DPMS.
+# If DPMS type is window_manager, turning display on or off, it uses window manager DPMS.
+# If DPMS type is none, when the DPMS function is called, it does nothing just returns true.
+# Default value is window_manager.
+# DisplayDPMSType=(window_manager or none)
+
 LCDAlwaysOn=no
 TimeoutEnable=yes
 ControlDisplay=no
index 6952ccc..660ea0e 100644 (file)
@@ -201,6 +201,7 @@ static struct display_config display_conf = {
        .aod_tsp                = true,
        .touch_wakeup           = false,
        .display_on_usb_conn_changed = true,
+       .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
 struct display_function_info display_info = {
index 61e5d41..a511760 100644 (file)
@@ -203,6 +203,7 @@ static struct display_config display_conf = {
        .aod_tsp                = true,
        .touch_wakeup           = false,
        .display_on_usb_conn_changed = true,
+       .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
 struct display_function_info display_info = {
index e6d22a3..e784dab 100644 (file)
@@ -201,6 +201,7 @@ static struct display_config display_conf = {
        .aod_tsp                = true,
        .touch_wakeup           = false,
        .display_on_usb_conn_changed = true,
+       .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
 struct display_function_info display_info = {
index 406c2dc..abc7680 100644 (file)
@@ -226,6 +226,7 @@ static struct display_config display_conf = {
        .aod_tsp                = true,
        .touch_wakeup           = false,
        .display_on_usb_conn_changed = true,
+       .display_dpms_type      = DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
 };
 
 struct display_function_info display_info = {
index 34b6c94..c514619 100644 (file)
@@ -27,6 +27,7 @@
 #include "poll.h"
 #include "device-interface.h"
 #include "setting.h"
+#include "display-dpms.h"
 
 #define WITHOUT_STARTNOTI      0x1
 #define MASK_BIT    0x7                /* 111 */
@@ -121,6 +122,7 @@ struct display_config {
        bool input_support;
        bool touch_wakeup;
        bool display_on_usb_conn_changed;
+       enum display_dpms_type display_dpms_type;
 };
 
 /*
index e995905..37b0ff2 100644 (file)
@@ -32,6 +32,7 @@
 #include "display/util.h"
 #include "display/display-dpms.h"
 #include "display/device-interface.h"
+#include "core.h"
 
 #define DPMS_RESPONSE_TIMEOUT  10  /* second */
 
@@ -49,10 +50,20 @@ typedef struct {
        bool connected;
 } wl_glib_info;
 
+struct dpms_ops {
+       void (*set_state)(int on);
+       int (*get_state)(void);
+       int (*get_cached_state)(void);
+       bool (*init)(void);
+       void (*exit)(void);
+};
+
 static wl_glib_info *dpms_client = NULL;
 
 static bool wm_is_ready;
 
+static struct dpms_ops g_dpms_ops;
+
 static GMainLoop *dpms_loop;
 static GMainContext *dpms_context;
 static bool dpms_get_state_done;
@@ -491,7 +502,7 @@ static void wait_response(int timeout)
        g_source_unref(timeout_source);
 }
 
-void dpms_set_state(int on)
+static void wm_dpms_set_state(int on)
 {
        uint32_t mode;
 
@@ -524,7 +535,7 @@ void dpms_set_state(int on)
        }
 }
 
-int dpms_get_state(void)
+static int wm_dpms_get_state(void)
 {
        if (!dpms_is_available()) {
                _E("Dpms is not available.");
@@ -552,7 +563,7 @@ int dpms_get_state(void)
        }
 }
 
-int dpms_get_cached_state(void)
+static int wm_dpms_get_cached_state(void)
 {
        if (!dpms_is_available()) {
                _E("Dpms is not available.");
@@ -562,7 +573,7 @@ int dpms_get_cached_state(void)
        return dpms_cache;
 }
 
-bool dpms_init(void)
+static bool wm_dpms_init(void)
 {
        if (dpms_client)
                return true;
@@ -570,7 +581,7 @@ bool dpms_init(void)
        if (!check_wm_ready())
                return false;
 
-       _I("Init dpms.");
+       _I("Init dpms window manager.");
        dpms_context = g_main_context_new();
 
        /* Initialize client */
@@ -590,9 +601,9 @@ bool dpms_init(void)
        return true;
 }
 
-void dpms_exit(void)
+static void wm_dpms_exit(void)
 {
-       _I("Exit dpms.");
+       _I("Exit dpms window manager.");
        if (dpms_loop) {
                g_main_loop_unref(dpms_loop);
                dpms_loop = NULL;
@@ -606,3 +617,69 @@ void dpms_exit(void)
        if (dpms_client && !g_source_is_destroyed((GSource *)dpms_client))
                g_source_destroy((GSource *)dpms_client);
 }
+
+static void none_dpms_set_state(int on) { dpms_cache = on; }
+static int none_dpms_get_state(void) { return dpms_cache; }
+static int none_dpms_get_cached_state(void) { return dpms_cache; }
+static bool none_dpms_init(void) { return true; }
+static void none_dpms_exit(void) {}
+
+void dpms_set_state(int on)
+{
+       if (g_dpms_ops.set_state)
+               g_dpms_ops.set_state(on);
+}
+
+int dpms_get_state(void)
+{
+       if (g_dpms_ops.get_state)
+               return g_dpms_ops.get_state();
+       return -EINVAL;
+}
+
+int dpms_get_cached_state(void)
+{
+       if (g_dpms_ops.get_cached_state)
+               return g_dpms_ops.get_cached_state();
+       return -EINVAL;
+}
+
+bool dpms_init(void)
+{
+       const struct display_config *display_conf = get_var_display_config();
+       if (!display_conf) {
+               _E("Failed to get display configuration");
+               return false;
+       }
+
+       switch (display_conf->display_dpms_type) {
+       case DISPLAY_DPMS_TYPE_WINDOW_MANAGER:
+               g_dpms_ops.set_state = wm_dpms_set_state;
+               g_dpms_ops.get_state = wm_dpms_get_state;
+               g_dpms_ops.get_cached_state = wm_dpms_get_cached_state;
+               g_dpms_ops.init = wm_dpms_init;
+               g_dpms_ops.exit = wm_dpms_exit;
+               break;
+       case DISPLAY_DPMS_TYPE_NONE:
+               g_dpms_ops.set_state = none_dpms_set_state;
+               g_dpms_ops.get_state = none_dpms_get_state;
+               g_dpms_ops.get_cached_state = none_dpms_get_cached_state;
+               g_dpms_ops.init = none_dpms_init;
+               g_dpms_ops.exit = none_dpms_exit;
+               break;
+       default:
+               _E("Invalid dpms type");
+               return false;
+       }
+
+       if (g_dpms_ops.init)
+               return g_dpms_ops.init();
+
+       return false;
+}
+
+void dpms_exit(void)
+{
+       if (g_dpms_ops.exit)
+               g_dpms_ops.exit();
+}
index f1bbe2f..f1a970e 100644 (file)
@@ -26,4 +26,10 @@ bool dpms_init(void);
 void dpms_exit(void);
 void __register_dpms_checklist(int mode, void (*checker)(void), const char *caller);
 #define register_dpms_checklist(mode, checker) __register_dpms_checklist(mode, checker, __func__)
+
+enum display_dpms_type {
+       DISPLAY_DPMS_TYPE_NONE,
+       DISPLAY_DPMS_TYPE_WINDOW_MANAGER,
+};
+
 #endif /* __DISPLAY_DPMS_H__ */
index 7885ea6..36b1320 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "util.h"
 #include "core.h"
+#include "display-dpms.h"
 #include "display-ops.h"
 #include "dd-display.h"
 #include "shared/common.h"
@@ -169,6 +170,9 @@ int display_load_config(struct parse_result *result, void *user_data)
        } else if (MATCH(result->name, "DisplayInitDirection")) {
                c->display_init_direction = (MATCH(result->value, "vertical") ? \
                DISPLAY_INIT_DIRECTION_VERTICAL : DISPLAY_INIT_DIRECTION_HORIZONTAL);
+       } else if (MATCH(result->name, "DisplayDPMSType")) {
+               c->display_dpms_type = (MATCH(result->value, "none") ? \
+               DISPLAY_DPMS_TYPE_NONE : DISPLAY_DPMS_TYPE_WINDOW_MANAGER);
        }
 
        return 0;