Add APIs for pmqos cpu request 37/231037/2
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Fri, 17 Apr 2020 01:55:47 +0000 (10:55 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Fri, 17 Apr 2020 07:37:38 +0000 (16:37 +0900)
Change-Id: I151e9941e55d86be7e8d8d89b9153b9e52754f25

include/pmqos-internal.h [new file with mode: 0644]
src/dbus.h
src/pmqos.c [new file with mode: 0644]

diff --git a/include/pmqos-internal.h b/include/pmqos-internal.h
new file mode 100644 (file)
index 0000000..bce7d7b
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SYSTEM_PMQOS_H__
+#define __TIZEN_SYSTEM_PMQOS_H__
+
+
+#include <stdbool.h>
+#include "device-error.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_DEVICE_PMQOS_MODULE
+ * @{
+ */
+
+/**
+ * @brief pmqos cpu request for AppLaunchHome.
+ * @since_tizen 6.0
+ * @param[in] timeout Timeout to change state
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ */
+int device_pmqos_app_launch_home(int timeout);
+
+/**
+ * @brief pmqos cpu request for HomeScreen.
+ * @since_tizen 6.0
+ * @param[in] timeout Timeout to change state
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ */
+int device_pmqos_homescreen(int timeout);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  // __TIZEN_SYSTEM_PMQOS_H__
index c721d3b..1bf4cdf 100644 (file)
 #define DEVICED_OBJECT_PATH            "/Org/Tizen/System/DeviceD"
 #define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
 
+/* PmQos service: operations about pmqos */
+#define DEVICED_PATH_PMQOS                  DEVICED_OBJECT_PATH"/PmQos"
+#define DEVICED_INTERFACE_PMQOS             DEVICED_INTERFACE_NAME".PmQos"
+
 /* Display service: start/stop display(pm), get/set brightness operations about display */
 #define DEVICED_PATH_DISPLAY                DEVICED_OBJECT_PATH"/Display"
 #define DEVICED_INTERFACE_DISPLAY           DEVICED_INTERFACE_NAME".display"
diff --git a/src/pmqos.c b/src/pmqos.c
new file mode 100644 (file)
index 0000000..d73be51
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "pmqos-internal.h"
+#include "common.h"
+#include "dbus.h"
+
+#define METHOD_APP_LAUNCH_HOME "AppLaunchHome"
+#define METHOD_HOMESCREEN              "HomeScreen"
+
+int device_pmqos_app_launch_home(int timeout)
+{
+       int ret;
+
+       if (timeout < 0)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
+       ret = dbus_method_sync_var(DEVICED_BUS_NAME,
+                       DEVICED_PATH_PMQOS,
+                       DEVICED_INTERFACE_PMQOS,
+                       METHOD_APP_LAUNCH_HOME,
+                       g_variant_new("(i)", timeout));;
+       if (ret < 0)
+               return errno_to_device_error(ret);
+
+       return DEVICE_ERROR_NONE;
+}
+
+int device_pmqos_homescreen(int timeout)
+{
+       int ret;
+
+       if (timeout < 0)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
+       ret = dbus_method_sync_var(DEVICED_BUS_NAME,
+                       DEVICED_PATH_PMQOS,
+                       DEVICED_INTERFACE_PMQOS,
+                       METHOD_HOMESCREEN,
+                       g_variant_new("(i)", timeout));;
+       if (ret < 0)
+               return errno_to_device_error(ret);
+
+       return DEVICE_ERROR_NONE;
+}
+