From ed9d4998dd05c4ccfa2756d2d743683d21ec3f63 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Fri, 17 Apr 2020 10:55:47 +0900 Subject: [PATCH] Add APIs for pmqos cpu request Change-Id: I151e9941e55d86be7e8d8d89b9153b9e52754f25 --- include/pmqos-internal.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ src/dbus.h | 4 +++ src/pmqos.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 include/pmqos-internal.h create mode 100644 src/pmqos.c diff --git a/include/pmqos-internal.h b/include/pmqos-internal.h new file mode 100644 index 0000000..bce7d7b --- /dev/null +++ b/include/pmqos-internal.h @@ -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 +#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__ diff --git a/src/dbus.h b/src/dbus.h index c721d3b..1bf4cdf 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -26,6 +26,10 @@ #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 index 0000000..d73be51 --- /dev/null +++ b/src/pmqos.c @@ -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; +} + -- 2.7.4