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 9d90031be03dcc16f7ea265462025452b8525daf..123ba509ba9da0e142db28f886a9818790af1c64 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 b4141c51204d5d106ac2a9acd19bc3c2a1892189..a807a16f66ee307827ae619a0c06a63d602bea8c 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 4e14b86fd6bf425ff9c55a5c20a82a1b8879686c..3859a02e1f39df22993580c70f9738d5797d7507 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 f4c1e22a75cfc031e79c936ed987deba8e1e1390..c8daba43c252dcf4976902a7170a86bfd0a7cbf9 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 6952ccc9838194e96ff1ba5cf681209508036e39..660ea0e54102a0e969010ffda369707b0b3d5e23 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 61e5d41dcfcf8343518f37d0463af0d714eee39e..a511760530a8b9c4d20105d8f84616796a77912c 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 e6d22a3984d5c96b383b8d8022e053b9353dbf45..e784dab2cf61227d65ceece938e08695d8b9df14 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 406c2dccfb30491ecb9c2b48516fe75f02ad6b87..abc7680ae061ff7332c1b925e572a2bbc8f720a9 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 34b6c94d74e5e5436af3f5355e1dbabad8741c03..c51461922632ebc9372bb8783e0d4cc96376a8f3 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 e995905437cf26706a43f32241d7fce875205894..37b0ff2dae386daeb5f53941e31799872044ec58 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 f1bbe2f17875f6fb3d843667a80db4cbfea3f127..f1a970e899d9919b55ee70b0e0905abcc0274b74 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 7885ea6cea92eeb8d261871dd6039e7cb523c915..36b1320bff1956395adc8c4451e9030900eca69c 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;