tizen 2.3.1 release
[kernel/api/system-resource.git] / src / powertop-wrapper / powertop-wrapper.h
1 /*
2  * Library for getting power usage statistics
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __POWERTOP_WRAPPER_H__
21 #define __POWERTOP_WRAPPER_H__
22
23 #include <string.h>
24
25 #include <map>
26
27 #define POWERTOP        "powertop"
28 #define LOGFILE         "./powertop-wrapper.log"
29 #define REPORTHEADER    "/usr/share/powertop-wrapper/header.html"
30
31 #ifndef UNUSED
32 #define UNUSED __attribute__((unused))
33 #endif /* UNUSED */
34
35 /* ************************************************************************ */
36
37 typedef enum {
38         S_UNKNOWN,
39         S_SYSTEM_INFORMATION,
40         S_SOFTWARE_POWER_CONSUMERS,
41         S_DEVICE_POWER_REPORT,
42         S_PROCESS_DEVICE_ACTIVITY,
43         S_POWER_CONSUMPTION_SUMMARY,
44         S_SOFTWARE_SETTINGS_TUNING,
45         S_UNTUNABLE_SOFTWARE_ISSUES,
46         S_OPTIMAL_TUNED_SOFTWARE_SETTINGS,
47         S_PROCESSOR_IDLE_STATE_REPORT,
48         S_PROCESSOR_FREQUENCY_REPORT,
49         S_MALI_GPU_POWER_CONSUMERS
50 } sections;
51
52 /* ************************************************************************ */
53
54 typedef struct {
55         /* gpu, harddisk and disk are unneeded now */
56         double usage, wakeups, gpu, harddisk, disk, gfx;
57         char *category, *description;
58 } sw_power_consumer;
59
60 /* ************************************************************************ */
61
62 typedef struct {
63         double usage;
64         char *device;
65         bool network;
66 } hw_power_consumer;
67
68 /* ************************************************************************ */
69
70 typedef struct {
71         double usage;
72         pid_t pid;
73         char *name, *description;
74 } mali_power_consumer;
75
76 /* ************************************************************************ */
77
78 class power_consumer_cmp
79 {
80 public:
81         bool
82         operator()(const char *a, const char *b) const
83         {
84                 return (strcmp(a, b) < 0);
85         }
86 };
87
88 /* ************************************************************************ */
89
90 typedef std::map<const char *, sw_power_consumer, power_consumer_cmp>
91                                                         sw_power_consumer_map;
92 typedef std::map<const char *, hw_power_consumer, power_consumer_cmp>
93                                                         hw_power_consumer_map;
94 typedef std::map<pid_t, mali_power_consumer> mali_power_consumer_map;
95
96 /* ************************************************************************ */
97
98 typedef struct {
99         sw_power_consumer_map swpc;
100         hw_power_consumer_map hwpc;
101         mali_power_consumer_map malipc;
102         int iterations;
103         const char *report_file;
104 } work_ctx;
105
106 #endif /* __POWERTOP_WRAPPER_H__ */