power: move sleep configuration to power 53/266653/2
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 17 Nov 2021 01:17:14 +0000 (10:17 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 17 Nov 2021 01:43:23 +0000 (10:43 +0900)
Change-Id: I5d6d7054149134bdea68f85802414e7783f8265d
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
conf/power.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.c
src/power/power-control.c
src/power/power-control.h

index 7a753c2..52abf4a 100644 (file)
@@ -4,3 +4,6 @@ Option=download
 Option=wdownload
 Option=debug
 Option=silent
+
+[Sleep]
+TimeoutSleepSupport=yes
index c772d9e..71376ad 100644 (file)
@@ -200,7 +200,6 @@ static struct display_config display_conf = {
        .aod_enter_level        = 40,
        .aod_tsp                = true,
        .touch_wakeup           = false,
-       .sleep_support          = true,
        .display_on_usb_conn_changed = true,
 };
 
@@ -603,7 +602,7 @@ void reset_timeout(int timeout)
                return;
 
        if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || display_conf.sleep_support == false))
+       && (is_emulator() == true || timeout_sleep_support == false))
                return;
 
        _I("Reset timeout(%d ms).", timeout);
@@ -1355,7 +1354,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || display_conf.sleep_support == false))
+                       && (is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
index 6b3aad8..7180885 100644 (file)
@@ -202,7 +202,6 @@ static struct display_config display_conf = {
        .aod_enter_level        = 40,
        .aod_tsp                = true,
        .touch_wakeup           = false,
-       .sleep_support          = true,
        .display_on_usb_conn_changed = true,
 };
 
@@ -610,7 +609,7 @@ void reset_timeout(int timeout)
                return;
 
        if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || display_conf.sleep_support == false))
+       && (is_emulator() == true || timeout_sleep_support == false))
                return;
 
        _I("Reset timeout(%d ms).", timeout);
@@ -1365,7 +1364,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || display_conf.sleep_support == false))
+                       && (is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
index 3f9357d..33b3775 100644 (file)
@@ -200,7 +200,6 @@ static struct display_config display_conf = {
        .aod_enter_level        = 40,
        .aod_tsp                = true,
        .touch_wakeup           = false,
-       .sleep_support          = true,
        .display_on_usb_conn_changed = true,
 };
 
@@ -603,7 +602,7 @@ void reset_timeout(int timeout)
                return;
 
        if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || display_conf.sleep_support == false))
+       && (is_emulator() == true || timeout_sleep_support == false))
                return;
 
        _I("Reset timeout(%d ms) pm_cur_state(%d).", timeout, get_pm_cur_state());
@@ -1355,7 +1354,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || display_conf.sleep_support == false))
+                       && (is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
index 2ff8cf6..bd6349c 100644 (file)
@@ -222,7 +222,6 @@ static struct display_config display_conf = {
        .aod_enter_level        = 40,
        .aod_tsp                = true,
        .touch_wakeup           = false,
-       .sleep_support          = true,
        .display_on_usb_conn_changed = true,
 };
 
@@ -818,7 +817,7 @@ void reset_timeout(int timeout)
                return;
 
        if ((get_pm_cur_state() == S_LCDOFF)
-       && (is_emulator() == true || display_conf.sleep_support == false))
+       && (is_emulator() == true || timeout_sleep_support == false))
                return;
 
        _I("Reset timeout(%d ms).", timeout);
@@ -1619,7 +1618,7 @@ static int default_trans(int evt)
                        states[get_pm_cur_state()].trans(EVENT_TIMEOUT);
                } else {
                        if ((get_pm_cur_state() == S_SLEEP)
-                       && (is_emulator() == true || display_conf.sleep_support == false))
+                       && (is_emulator() == true || timeout_sleep_support == false))
                                return 0;
 
                        st->action(st->timeout);
index e001f65..816e00b 100644 (file)
@@ -138,7 +138,6 @@ struct display_config {
        bool timeout_enable;
        bool input_support;
        bool touch_wakeup;
-       bool sleep_support;
        bool display_on_usb_conn_changed;
 };
 
index 033240e..7eea0ed 100644 (file)
@@ -152,9 +152,6 @@ int display_load_config(struct parse_result *result, void *user_data)
        } else if (MATCH(result->name, "AODTSP")) {
                c->aod_tsp = (MATCH(result->value, "yes") ? true : false);
                _D("TSP control at is %d at aod", c->aod_tsp);
-       } else if (MATCH(result->name, "SleepSupport")) {
-               c->sleep_support = (MATCH(result->value, "yes") ? true : false);
-               _D("SleepSupport is %d", c->sleep_support);
        } else if (MATCH(result->name, "DisplayOnUsbConnChanged")) {
                c->display_on_usb_conn_changed = (MATCH(result->value, "yes") ? true : false);
        }
index 3482a60..c44d2de 100644 (file)
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <dlfcn.h>
 #include <libsyscommon/libgdbus.h>
+#include <libsyscommon/ini-parser.h>
 
 #include "core/log.h"
 #include "shared/devices.h"
@@ -42,6 +43,8 @@
 #include "power/boot.h"
 #include "power-control.h"
 
+#define POWER_CONF_FILE             "/etc/deviced/power.conf"
+
 static int mainlock_status = POWER_UNLOCK;
 static int vital_service;
 static bool vital_sleep;
@@ -64,6 +67,8 @@ static const char history_string[PM_LOG_MAX][15] = {
        "LCD DIM", "LCD DIM FAIL", "LCD OFF", "LCD OFF COMPL", "LCD OFF FAIL",
        "LCD FAIL", "SLEEP"};
 
+bool timeout_sleep_support = false;
+
 void pm_history_init()
 {
        memset(pm_history_log, 0x0, sizeof(pm_history_log));
@@ -325,9 +330,28 @@ static int __pm_power_unlock(void *data)
        return 0;
 }
 
+static int load_sleep_config(struct parse_result *result, void *user_data)
+{
+       if (!MATCH(result->section, "Sleep"))
+               return 0;
+
+       if (MATCH(result->name, "TimeoutSleepSupport") && MATCH(result->value, "yes")) {
+               timeout_sleep_support = true;
+               _D("timeout_sleep_support=%d", timeout_sleep_support);
+       }
+
+       return 0;
+}
+
 static void power_control_init(void *data)
 {
        const struct device_ops *plugin_device_ops;
+       int retval;
+
+       retval = config_parse(POWER_CONF_FILE, load_sleep_config, NULL);
+       if (retval < 0)
+               _E("Failed to load sleep config: %d", retval);
+
 
        plugin_device_ops = find_device("power-control-plugin");
        if (check_default(plugin_device_ops))
index 61d4f53..e4d1a18 100644 (file)
@@ -47,6 +47,8 @@ enum vital_state {
        VITAL_EXIT,
 };
 
+extern bool timeout_sleep_support;
+
 #ifdef ENABLE_PM_LOG
 void pm_history_init(void);
 void pm_history_save(enum pm_log_type log_type, int code);