build fix
[cpufrequi] / cpufreq.h
1 /*
2  *  cpufreq.h - definitions for libcpufreq
3  *
4  *  Copyright (C) 2004-2009  Dominik Brodowski <linux@dominikbrodowski.de>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, version 2 of the License.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef _CPUFREQ_H
21 #define _CPUFREQ_H 1
22
23 struct cpufreq_policy {
24         unsigned long min;
25         unsigned long max;
26         char *governor;
27 };
28
29 struct cpufreq_available_governors {
30         char *governor;
31         struct cpufreq_available_governors *next;
32         struct cpufreq_available_governors *first;
33 };
34
35 struct cpufreq_available_frequencies {
36         unsigned long frequency;
37         struct cpufreq_available_frequencies *next;
38         struct cpufreq_available_frequencies *first;
39 };
40
41
42 struct cpufreq_affected_cpus {
43         unsigned int cpu;
44         struct cpufreq_affected_cpus *next;
45         struct cpufreq_affected_cpus *first;
46 };
47
48 struct cpufreq_stats {
49         unsigned long frequency;
50         unsigned long long time_in_state;
51         struct cpufreq_stats *next;
52         struct cpufreq_stats *first;
53 };
54
55
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /*
62  * returns 0 if the specified CPU is present (it doesn't say
63  * whether it is online!), and an error value if not.
64  */
65
66 int cpufreq_cpu_exists(unsigned int cpu);
67
68 /* determine current CPU frequency
69  * - _kernel variant means kernel's opinion of CPU frequency
70  * - _hardware variant means actual hardware CPU frequency,
71  *    which is only available to root.
72  *
73  * returns 0 on failure, else frequency in kHz.
74  */
75
76 unsigned long cpufreq_get_freq_kernel(unsigned int cpu);
77
78 unsigned long cpufreq_get_freq_hardware(unsigned int cpu);
79
80 #define cpufreq_get(cpu) cpufreq_get_freq_kernel(cpu);
81
82
83 /* determine CPU transition latency
84  *
85  * returns 0 on failure, else transition latency in 10^(-9) s = nanoseconds
86  */
87 unsigned long cpufreq_get_transition_latency(unsigned int cpu);
88
89
90 /* determine hardware CPU frequency limits
91  *
92  * These may be limited further by thermal, energy or other
93  * considerations by cpufreq policy notifiers in the kernel.
94  */
95
96 int cpufreq_get_hardware_limits(unsigned int cpu,
97                                        unsigned long *min, 
98                                        unsigned long *max);
99
100
101 /* determine CPUfreq driver used
102  *
103  * Remember to call cpufreq_put_driver when no longer needed
104  * to avoid memory leakage, please.
105  */
106
107 char * cpufreq_get_driver(unsigned int cpu);
108
109 void   cpufreq_put_driver(char * ptr);
110
111
112 /* determine CPUfreq policy currently used
113  *
114  * Remember to call cpufreq_put_policy when no longer needed
115  * to avoid memory leakage, please.
116  */
117
118
119 struct cpufreq_policy * cpufreq_get_policy(unsigned int cpu);
120
121 void cpufreq_put_policy(struct cpufreq_policy *policy);
122
123
124 /* determine CPUfreq governors currently available
125  *
126  * may be modified by modprobe'ing or rmmod'ing other governors. Please
127  * free allocated memory by calling cpufreq_put_available_governors
128  * after use.
129  */
130
131
132 struct cpufreq_available_governors * cpufreq_get_available_governors(unsigned int cpu);
133
134 void cpufreq_put_available_governors(struct cpufreq_available_governors *first);
135
136
137 /* determine CPU frequency states available
138  *
139  * only present on _some_ ->target() cpufreq drivers. For information purposes
140  * only. Please free allocated memory by calling cpufreq_put_available_frequencies
141  * after use.
142  */
143
144 struct cpufreq_available_frequencies * cpufreq_get_available_frequencies(unsigned int cpu);
145
146 void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *first);
147
148
149 /* determine affected CPUs 
150  *
151  * Remember to call cpufreq_put_affected_cpus when no longer needed
152  * to avoid memory leakage, please.
153  */
154
155 struct cpufreq_affected_cpus * cpufreq_get_affected_cpus(unsigned int cpu);
156
157 void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *first);
158
159
160 /* determine related CPUs 
161  *
162  * Remember to call cpufreq_put_related_cpus when no longer needed
163  * to avoid memory leakage, please.
164  */
165
166 struct cpufreq_affected_cpus * cpufreq_get_related_cpus(unsigned int cpu);
167
168 void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *first);
169
170
171 /* determine stats for cpufreq subsystem
172  *
173  * This is not available in all kernel versions or configurations.
174  */
175
176 struct cpufreq_stats * cpufreq_get_stats(unsigned int cpu, unsigned long long *total_time);
177
178 void cpufreq_put_stats(struct cpufreq_stats *stats);
179
180 unsigned long cpufreq_get_transitions(unsigned int cpu);
181
182
183 /* set new cpufreq policy 
184  * 
185  * Tries to set the passed policy as new policy as close as possible,
186  * but results may differ depending e.g. on governors being available.
187  */
188
189 int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy);
190
191
192 /* modify a policy by only changing min/max freq or governor 
193  *
194  * Does not check whether result is what was intended.
195  */
196
197 int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq);
198 int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq);
199 int cpufreq_modify_policy_governor(unsigned int cpu, char *governor);
200
201
202 /* set a specific frequency
203  *
204  * Does only work if userspace governor can be used and no external
205  * interference (other calls to this function or to set/modify_policy) 
206  * occurs. Also does not work on ->range() cpufreq drivers.
207  */
208
209 int cpufreq_set_frequency(unsigned int cpu, unsigned long target_frequency);
210
211 /* functions added by SR */
212
213 /*
214  * Get number of cpu's
215  */
216 unsigned int count_cpus(void);
217
218 /*
219  * Get up_threshold value for ondemand governor
220  */
221 unsigned long cpufreq_get_up_threshold(unsigned int cpu);
222
223 /*
224  * Get sampling_rate value for ondemand governor
225  */
226 unsigned long cpufreq_get_sampling_rate(unsigned int cpu);
227
228 /*
229  * Set up_threshold value for ondemand governor
230  */
231 int cpufreq_set_up_threshold(unsigned int cpu, unsigned long target_up_threshold);
232
233 /*
234  * Set sampling_rate value for ondemand governor
235  */
236 int cpufreq_set_sampling_rate(unsigned int cpu, unsigned long target_sampling_rate);
237
238 /*
239  * Get ignore_nice_load value for ondemand governor
240  * Returns -1 if it is not avaliable
241  */
242 int cpufreq_get_ignore_nice_load(unsigned int cpu);
243
244 /*
245  * Set ignore_nice_load value for ondemand governor
246  * Returns -1 if it is not avaliable
247  */
248 //int cpufreq_set_ignore_nice_load(unsigned int cpu, bool target_ignore_nice_load);
249 int cpufreq_set_ignore_nice_load(unsigned int cpu, int target_ignore_nice_load);
250
251 /*
252  * Get SmartReflex value for ondemand governor
253  * Returns -1 if it is not avaliable
254  */
255 int cpufreq_get_SmartReflex();
256 int cpufreq_set_SmartReflex(int target_ignore_nice_load);
257
258 #ifdef __cplusplus
259 }
260 #endif
261
262 #endif /* _CPUFREQ_H */