4 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 * @desc Contains API that can help to manage devices/processec for.decrease
25 #ifndef _LOGD_PADVISER_H_
26 #define _LOGD_PADVISER_H_
38 enum { LOGD_ADVISOR_MAX = 32 };
40 struct logd_idle_device {
41 uint64_t idle_time; /** Time when device was swithed on */
42 enum logd_object device; /** Device identifier */
45 struct logd_power_advisor {
46 /** Array of enabled devices */
47 struct logd_idle_device idle_devices[LOGD_ADVISOR_MAX];
48 /** Top <CODE>LOGD_ADVISOR_MAX</CODE> most power cunsuming application */
49 struct logd_proc_stat procs[LOGD_ADVISOR_MAX];
50 /** Count of devices in <CODE>idle_devices</CODE> */
51 int idle_devices_used_num;
52 /** Count of processes in <CODE>procs</CODE> */
53 int proc_stat_used_num;
56 struct logd_power_consumption {
57 enum logd_object device; /** Device identifier */
58 /** Persentage from all devices power consumption */
60 /** Time in sec when device was enabled */
64 struct device_power_consumption {
65 /** Array of all devices with theirs power consumption */
66 struct logd_power_consumption device_cons[LOGD_OBJECT_MAX];
67 /** Sum of all logd_power_consumption::time from device_cons in sec */
71 /* please, not use that function in your application, it isn't public API */
72 int padvisor_init(void);
73 int padvisor_finalize(void);
75 /* next functions are public API */
78 * Return information about devices and processes.
80 * @return On success, pointer to <CODE>logd_power_advisor</CODE> struct.
81 * Returned pointer must be released by <CODE>logd_free_power_advisor</CODE>.
84 struct logd_power_advisor *logd_get_power_advisor(void);
86 * Release <CODE>logd_power_advisor</CODE> struct returned by
87 * <CODE>logd_get_power_advisor</CODE>.
88 * @param lpa pointer that must be free.
90 void logd_free_power_advisor(struct logd_power_advisor *lpa);
93 * Return information about devices power consumption for given period.
95 * @param from Count power consumption from that time in unixtime format.
96 * @param to Count power consumption till that time in unixtime format.
97 * @return On success, pointer to <CODE>device_power_consumption</CODE> struct.
98 * Returned pointer must be released by <CODE>logd_free_device_power_cons</CODE>.
101 struct device_power_consumption *
102 logd_get_device_power_cons(time_t from, time_t to);
104 * Release <CODE>device_power_consumption</CODE> struct returned by
105 * <CODE>logd_get_device_power_cons</CODE>.
106 * @param pcons pointer that must be free.
108 void logd_free_device_power_cons(struct device_power_consumption* pcons);
115 #endif /* _LOGD_PADVISER_H_ */