power: support cpu lock/unlock for headless 70/264470/3 accepted/tizen/unified/20211105.130457 submit/tizen/20211103.072537 submit/tizen/20211104.031932 submit/tizen/20211104.080231
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 23 Sep 2021 00:49:44 +0000 (17:49 -0700)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 30 Sep 2021 06:27:36 +0000 (15:27 +0900)
Change-Id: Ic1ecf15ee3a6f5b5de17f438b094a847ae4e875b
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power.c

index a8fcfaf..971a6ff 100644 (file)
@@ -450,14 +450,16 @@ int device_power_request_lock(power_lock_e type, int timeout_ms)
        _I("power_lock_e = %d", type);
 
        if (!is_feature_display_supported() || !is_feature_display_state_supported()) {
-               if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM))
+               if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM)) {
                        return DEVICE_ERROR_NOT_SUPPORTED;
-               /*
-                * In case of POWER_LOCK_CPU for headless profile, temporary return DEVICE_ERROR_NONE.
-                * It will be implemented later.
-                */
-               else if (type == POWER_LOCK_CPU)
-                       return DEVICE_ERROR_NONE;
+               } else if (type == POWER_LOCK_CPU) {
+                       /* in case of headless, request for cpu lock is handled
+                        * in power module of deviced, not in display module */
+                       ret = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
+                               DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
+                               "LockCpu", g_variant_new("(i)", timeout_ms), NULL);
+                       return errno_to_device_error(ret);
+               }
        }
 
        if (check_async_call_rate(&num_calls) < 0) {
@@ -498,14 +500,16 @@ int device_power_release_lock(power_lock_e type)
        _I("power_lock_e = %d", type);
 
        if (!is_feature_display_supported() || !is_feature_display_state_supported()) {
-               if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM))
+               if ((type == POWER_LOCK_DISPLAY) || (type == POWER_LOCK_DISPLAY_DIM)) {
                        return DEVICE_ERROR_NOT_SUPPORTED;
-               /*
-                * In case of POWER_LOCK_CPU for headless profile, temporary return DEVICE_ERROR_NONE.
-                * It will be implemented later.
-                */
-               else if (type == POWER_LOCK_CPU)
-                       return DEVICE_ERROR_NONE;
+               } else if (type == POWER_LOCK_CPU) {
+                       /* in case of headless, request for cpu unlock is handled
+                        * in power module of deviced, not in display module */
+                       ret_val = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
+                               DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
+                               "UnlockCpu", NULL, NULL);
+                       return errno_to_device_error(ret_val);
+               }
        }
 
        if (type == POWER_LOCK_CPU && power_locked_CPU) {