From: Youngjae Cho Date: Fri, 13 Oct 2023 09:10:51 +0000 (+0900) Subject: power: Add setter for controlling doze source X-Git-Tag: accepted/tizen/unified/20231115.024830^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f68f02daf74f048b2efef730ebf682b5b6f01d2;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: Add setter for controlling doze source Doze is going to replace the event-lock, that is, short-living power lock. The purpose of doze is for keeping user applications in sleep while the underneath system is awake, doing something for a moment. In other words, it can be utilized for short wakeup without notifying it to the whole applications, especially for jobs related to the real-time clock. The system stays awake when there is at least a doze source. Currently, only two type of doze sources are allowed, power key and bluetooth key. Those key presses should measure their time lapse with real-time clock for testing longkey so the system must be awake at that moment. Change-Id: I91bdf11e34d18c170deb5d2c4a6a67e7e9565371 Signed-off-by: Youngjae Cho --- diff --git a/src/power/resource-power.c b/src/power/resource-power.c index 6b44cd2c..dbecd9f7 100644 --- a/src/power/resource-power.c +++ b/src/power/resource-power.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include "power.h" #include "power-suspend.h" +#include "power-event-lock.h" typedef union { int32_t i32; @@ -163,6 +165,30 @@ static int set_power_attr_data(int resource_id, vital_state_changed(mode); } break; + case DEVICED_POWER_ATTR_INT_ADD_DOZE_SOURCE: + case DEVICED_POWER_ATTR_INT_REMOVE_DOZE_SOURCE: + { + int doze_source_id = *(const int *) data; + enum eventlock_type type; + + /* currently only allow 2 type of source */ + switch (doze_source_id) { + case KEY_POWER: + type = EL_KEY_POWER; + break; + case KEY_BLUETOOTH: + type = EL_KEY_BLUETOOTH; + break; + default: + return -EINVAL; + } + + if (attr->id == DEVICED_POWER_ATTR_INT_ADD_DOZE_SOURCE) + event_wake_lock(type); + else /* DEVICED_POWER_ATTR_INT_REMOVE_DOZE_SOURCE */ + event_wake_unlock(type); + } + break; default: return -EINVAL; } @@ -270,6 +296,24 @@ static const struct syscommon_resman_resource_attribute power_attrs[] = { .set_2_tuple = set_tuple2_power_attr_data, .is_supported = syscommon_resman_resource_attr_supported_always, }, + }, { + .name = "DEVICED_POWER_ATTR_INT_ADD_DOZE_SOURCE", + .id = DEVICED_POWER_ATTR_INT_ADD_DOZE_SOURCE, + .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, + .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC, + .ops = { + .set = set_power_attr_data, + .is_supported = syscommon_resman_resource_attr_supported_always, + }, + }, { + .name = "DEVICED_POWER_ATTR_INT_REMOVE_DOZE_SOURCE", + .id = DEVICED_POWER_ATTR_INT_REMOVE_DOZE_SOURCE, + .type = SYSCOMMON_RESMAN_DATA_TYPE_INT, + .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC, + .ops = { + .set = set_power_attr_data, + .is_supported = syscommon_resman_resource_attr_supported_always, + }, } };